405 lines
37 KiB
Plaintext
405 lines
37 KiB
Plaintext
---
|
||
title: preset_passmanagers (v1.2)
|
||
description: API reference for qiskit.transpiler.preset_passmanagers in qiskit v1.2
|
||
in_page_toc_min_heading_level: 2
|
||
python_api_type: module
|
||
python_api_name: qiskit.transpiler.preset_passmanagers
|
||
---
|
||
|
||
<span id="module-qiskit.transpiler.preset_passmanagers" />
|
||
|
||
<span id="qiskit-transpiler-preset-passmanagers" />
|
||
|
||
<span id="preset-passmanagers-qiskit-transpiler-preset-passmanagers" />
|
||
|
||
# Preset Passmanagers
|
||
|
||
`qiskit.transpiler.preset_passmanagers`
|
||
|
||
This module contains functions for generating the preset pass managers for the transpiler. The preset pass managers are instances of [`StagedPassManager`](qiskit.transpiler.StagedPassManager "qiskit.transpiler.StagedPassManager") which are used to execute the circuit transformations as part of Qiskit’s compiler inside the [`transpile()`](compiler#qiskit.compiler.transpile "qiskit.compiler.transpile") function at the different optimization levels, but can also be used in a standalone manner. The functionality here is divided into two parts, the first includes the functions used generate the entire pass manager which is used by [`transpile()`](compiler#qiskit.compiler.transpile "qiskit.compiler.transpile") ([Preset Pass Manager Generation](#preset-pass-manager-generators)) and the second includes functions which are used to build (either entirely or in part) the stages which the preset pass managers are composed of ([Stage Generator Functions](#stage-generators)).
|
||
|
||
<span id="preset-pass-manager-generators" />
|
||
|
||
## Preset Pass Manager Generation
|
||
|
||
### generate\_preset\_pass\_manager
|
||
|
||
<Function id="qiskit.transpiler.preset_passmanagers.generate_preset_pass_manager" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py#L38-L385" signature="qiskit.transpiler.preset_passmanagers.generate_preset_pass_manager(optimization_level, backend=None, target=None, basis_gates=None, inst_map=None, coupling_map=None, instruction_durations=None, backend_properties=None, timing_constraints=None, initial_layout=None, layout_method=None, routing_method=None, translation_method=None, scheduling_method=None, approximation_degree=1.0, seed_transpiler=None, unitary_synthesis_method='default', unitary_synthesis_plugin_config=None, hls_config=None, init_method=None, optimization_method=None, dt=None, *, _skip_target=False)">
|
||
Generate a preset [`PassManager`](qiskit.transpiler.PassManager "qiskit.transpiler.PassManager")
|
||
|
||
This function is used to quickly generate a preset pass manager. Preset pass managers are the default pass managers used by the [`transpile()`](compiler#qiskit.compiler.transpile "qiskit.compiler.transpile") function. This function provides a convenient and simple method to construct a standalone [`PassManager`](qiskit.transpiler.PassManager "qiskit.transpiler.PassManager") object that mirrors what the [`transpile()`](compiler#qiskit.compiler.transpile "qiskit.compiler.transpile") function internally builds and uses.
|
||
|
||
The target constraints for the pass manager construction can be specified through a [`Target`](qiskit.transpiler.Target "qiskit.transpiler.Target") instance, a [`BackendV1`](qiskit.providers.BackendV1 "qiskit.providers.BackendV1") or [`BackendV2`](qiskit.providers.BackendV2 "qiskit.providers.BackendV2") instance, or via loose constraints (`basis_gates`, `inst_map`, `coupling_map`, `backend_properties`, `instruction_durations`, `dt` or `timing_constraints`). The order of priorities for target constraints works as follows: if a `target` input is provided, it will take priority over any `backend` input or loose constraints. If a `backend` is provided together with any loose constraint from the list above, the loose constraint will take priority over the corresponding backend constraint. This behavior is independent of whether the `backend` instance is of type [`BackendV1`](qiskit.providers.BackendV1 "qiskit.providers.BackendV1") or [`BackendV2`](qiskit.providers.BackendV2 "qiskit.providers.BackendV2"), as summarized in the table below. The first column in the table summarizes the potential user-provided constraints, and each cell shows whether the priority is assigned to that specific constraint input or another input (target/backend(V1)/backend(V2)).
|
||
|
||
| User Provided | target | backend(V1) | backend(V2) |
|
||
| -------------------------- | ------ | ---------------------- | ---------------------- |
|
||
| **basis\_gates** | target | basis\_gates | basis\_gates |
|
||
| **coupling\_map** | target | coupling\_map | coupling\_map |
|
||
| **instruction\_durations** | target | instruction\_durations | instruction\_durations |
|
||
| **inst\_map** | target | inst\_map | inst\_map |
|
||
| **dt** | target | dt | dt |
|
||
| **timing\_constraints** | target | timing\_constraints | timing\_constraints |
|
||
| **backend\_properties** | target | backend\_properties | backend\_properties |
|
||
|
||
**Parameters**
|
||
|
||
* **optimization\_level** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) –
|
||
|
||
The optimization level to generate a [`PassManager`](qiskit.transpiler.PassManager "qiskit.transpiler.PassManager") for. This can be 0, 1, 2, or 3. Higher levels generate more optimized circuits, at the expense of longer transpilation time:
|
||
|
||
> * 0: no optimization
|
||
> * 1: light optimization
|
||
> * 2: heavy optimization
|
||
> * 3: even heavier optimization
|
||
|
||
* **backend** ([*Backend*](qiskit.providers.Backend "qiskit.providers.Backend")) – An optional backend object which can be used as the source of the default values for the `basis_gates`, `inst_map`, `coupling_map`, `backend_properties`, `instruction_durations`, `timing_constraints`, and `target`. If any of those other arguments are specified in addition to `backend` they will take precedence over the value contained in the backend.
|
||
|
||
* **target** ([*Target*](qiskit.transpiler.Target "qiskit.transpiler.Target")) – The [`Target`](qiskit.transpiler.Target "qiskit.transpiler.Target") representing a backend compilation target. The following attributes will be inferred from this argument if they are not set: `coupling_map`, `basis_gates`, `instruction_durations`, `inst_map`, `timing_constraints` and `backend_properties`.
|
||
|
||
* **basis\_gates** ([*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.13)")) – List of basis gate names to unroll to (e.g: `['u1', 'u2', 'u3', 'cx']`).
|
||
|
||
* **inst\_map** ([*InstructionScheduleMap*](qiskit.pulse.InstructionScheduleMap "qiskit.pulse.InstructionScheduleMap")) – Mapping object that maps gates to schedules. If any user defined calibration is found in the map and this is used in a circuit, transpiler attaches the custom gate definition to the circuit. This enables one to flexibly override the low-level instruction implementation.
|
||
|
||
* **coupling\_map** ([*CouplingMap*](qiskit.transpiler.CouplingMap "qiskit.transpiler.CouplingMap") *or*[*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.13)")) –
|
||
|
||
Directed graph represented a coupling map. Multiple formats are supported:
|
||
|
||
1. `CouplingMap` instance
|
||
2. List, must be given as an adjacency matrix, where each entry specifies all directed two-qubit interactions supported by backend, e.g: `[[0, 1], [0, 3], [1, 2], [1, 5], [2, 5], [4, 1], [5, 3]]`
|
||
|
||
* **instruction\_durations** ([*InstructionDurations*](qiskit.transpiler.InstructionDurations "qiskit.transpiler.InstructionDurations") *or*[*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.13)")) –
|
||
|
||
Dictionary of duration (in dt) for each instruction. If specified, these durations overwrite the gate lengths in `backend.properties`. Applicable only if `scheduling_method` is specified. The format of `instruction_durations` must be as follows: They must be given as an [`InstructionDurations`](qiskit.transpiler.InstructionDurations "qiskit.transpiler.InstructionDurations") instance or a list of tuples
|
||
|
||
`` ` [(instruction_name, qubits, duration, unit), ...]. | [('cx', [0, 1], 12.3, 'ns'), ('u3', [0], 4.56, 'ns')] | [('cx', [0, 1], 1000), ('u3', [0], 300)] ` ``
|
||
|
||
If `unit` is omitted, the default is `'dt'`, which is a sample time depending on backend. If the time unit is `'dt'`, the duration must be an integer.
|
||
|
||
* **dt** ([*float*](https://docs.python.org/3/library/functions.html#float "(in Python v3.13)")) – Backend sample time (resolution) in seconds. If provided, this value will overwrite the `dt` value in `instruction_durations`. If `None` (default) and a backend is provided, `backend.dt` is used.
|
||
|
||
* **timing\_constraints** (*TimingConstraints*) –
|
||
|
||
Hardware time alignment restrictions. A quantum computer backend may report a set of restrictions, namely:
|
||
|
||
> * granularity: An integer value representing minimum pulse gate resolution in units of `dt`. A user-defined pulse gate should have duration of a multiple of this granularity value.
|
||
> * min\_length: An integer value representing minimum pulse gate length in units of `dt`. A user-defined pulse gate should be longer than this length.
|
||
> * pulse\_alignment: An integer value representing a time resolution of gate instruction starting time. Gate instruction should start at time which is a multiple of the alignment value.
|
||
> * acquire\_alignment: An integer value representing a time resolution of measure instruction starting time. Measure instruction should start at time which is a multiple of the alignment value.
|
||
>
|
||
> This information will be provided by the backend configuration. If the backend doesn’t have any restriction on the instruction time allocation, then `timing_constraints` is None and no adjustment will be performed.
|
||
|
||
* **initial\_layout** ([*Layout*](qiskit.transpiler.Layout "qiskit.transpiler.Layout") *| List\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*]*) – Initial position of virtual qubits on physical qubits.
|
||
|
||
* **layout\_method** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")) – The `Pass` to use for choosing initial qubit placement. Valid choices are `'trivial'`, `'dense'`, and `'sabre'`, representing [`TrivialLayout`](qiskit.transpiler.passes.TrivialLayout "qiskit.transpiler.passes.TrivialLayout"), [`DenseLayout`](qiskit.transpiler.passes.DenseLayout "qiskit.transpiler.passes.DenseLayout") and [`SabreLayout`](qiskit.transpiler.passes.SabreLayout "qiskit.transpiler.passes.SabreLayout") respectively. This can also be the external plugin name to use for the `layout` stage of the output [`StagedPassManager`](qiskit.transpiler.StagedPassManager "qiskit.transpiler.StagedPassManager"). You can see a list of installed plugins by using [`list_stage_plugins()`](transpiler_plugins#qiskit.transpiler.preset_passmanagers.plugin.list_stage_plugins "qiskit.transpiler.preset_passmanagers.plugin.list_stage_plugins") with `"layout"` for the `stage_name` argument.
|
||
|
||
* **routing\_method** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")) – The pass to use for routing qubits on the architecture. Valid choices are `'basic'`, `'lookahead'`, `'stochastic'`, `'sabre'`, and `'none'` representing [`BasicSwap`](qiskit.transpiler.passes.BasicSwap "qiskit.transpiler.passes.BasicSwap"), [`LookaheadSwap`](qiskit.transpiler.passes.LookaheadSwap "qiskit.transpiler.passes.LookaheadSwap"), [`StochasticSwap`](qiskit.transpiler.passes.StochasticSwap "qiskit.transpiler.passes.StochasticSwap"), [`SabreSwap`](qiskit.transpiler.passes.SabreSwap "qiskit.transpiler.passes.SabreSwap"), and erroring if routing is required respectively. This can also be the external plugin name to use for the `routing` stage of the output [`StagedPassManager`](qiskit.transpiler.StagedPassManager "qiskit.transpiler.StagedPassManager"). You can see a list of installed plugins by using [`list_stage_plugins()`](transpiler_plugins#qiskit.transpiler.preset_passmanagers.plugin.list_stage_plugins "qiskit.transpiler.preset_passmanagers.plugin.list_stage_plugins") with `"routing"` for the `stage_name` argument.
|
||
|
||
* **translation\_method** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")) – The method to use for translating gates to basis gates. Valid choices `'translator'`, `'synthesis'` representing [`BasisTranslator`](qiskit.transpiler.passes.BasisTranslator "qiskit.transpiler.passes.BasisTranslator"), and [`UnitarySynthesis`](qiskit.transpiler.passes.UnitarySynthesis "qiskit.transpiler.passes.UnitarySynthesis") respectively. This can also be the external plugin name to use for the `translation` stage of the output [`StagedPassManager`](qiskit.transpiler.StagedPassManager "qiskit.transpiler.StagedPassManager"). You can see a list of installed plugins by using [`list_stage_plugins()`](transpiler_plugins#qiskit.transpiler.preset_passmanagers.plugin.list_stage_plugins "qiskit.transpiler.preset_passmanagers.plugin.list_stage_plugins") with `"translation"` for the `stage_name` argument.
|
||
|
||
* **scheduling\_method** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")) – The pass to use for scheduling instructions. Valid choices are `'alap'` and `'asap'`. This can also be the external plugin name to use for the `scheduling` stage of the output [`StagedPassManager`](qiskit.transpiler.StagedPassManager "qiskit.transpiler.StagedPassManager"). You can see a list of installed plugins by using [`list_stage_plugins()`](transpiler_plugins#qiskit.transpiler.preset_passmanagers.plugin.list_stage_plugins "qiskit.transpiler.preset_passmanagers.plugin.list_stage_plugins") with `"scheduling"` for the `stage_name` argument.
|
||
|
||
* **backend\_properties** ([*BackendProperties*](qiskit.providers.models.BackendProperties "qiskit.providers.models.BackendProperties")) – Properties returned by a backend, including information on gate errors, readout errors, qubit coherence times, etc.
|
||
|
||
* **approximation\_degree** ([*float*](https://docs.python.org/3/library/functions.html#float "(in Python v3.13)")) – Heuristic dial used for circuit approximation (1.0=no approximation, 0.0=maximal approximation).
|
||
|
||
* **seed\_transpiler** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) – Sets random seed for the stochastic parts of the transpiler.
|
||
|
||
* **unitary\_synthesis\_method** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")) – The name of the unitary synthesis method to use. By default `'default'` is used. You can see a list of installed plugins with [`unitary_synthesis_plugin_names()`](qiskit.transpiler.passes.synthesis.plugin.unitary_synthesis_plugin_names "qiskit.transpiler.passes.synthesis.plugin.unitary_synthesis_plugin_names").
|
||
|
||
* **unitary\_synthesis\_plugin\_config** ([*dict*](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.13)")) – An optional configuration dictionary that will be passed directly to the unitary synthesis plugin. By default this setting will have no effect as the default unitary synthesis method does not take custom configuration. This should only be necessary when a unitary synthesis plugin is specified with the `unitary_synthesis_method` argument. As this is custom for each unitary synthesis plugin refer to the plugin documentation for how to use this option.
|
||
|
||
* **hls\_config** ([*HLSConfig*](qiskit.transpiler.passes.HLSConfig "qiskit.transpiler.passes.HLSConfig")) – An optional configuration class [`HLSConfig`](qiskit.transpiler.passes.HLSConfig "qiskit.transpiler.passes.HLSConfig") that will be passed directly to [`HighLevelSynthesis`](qiskit.transpiler.passes.HighLevelSynthesis "qiskit.transpiler.passes.HighLevelSynthesis") transformation pass. This configuration class allows to specify for various high-level objects the lists of synthesis algorithms and their parameters.
|
||
|
||
* **init\_method** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")) – The plugin name to use for the `init` stage of the output [`StagedPassManager`](qiskit.transpiler.StagedPassManager "qiskit.transpiler.StagedPassManager"). By default an external plugin is not used. You can see a list of installed plugins by using [`list_stage_plugins()`](transpiler_plugins#qiskit.transpiler.preset_passmanagers.plugin.list_stage_plugins "qiskit.transpiler.preset_passmanagers.plugin.list_stage_plugins") with `"init"` for the stage name argument.
|
||
|
||
* **optimization\_method** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")) – The plugin name to use for the `optimization` stage of the output [`StagedPassManager`](qiskit.transpiler.StagedPassManager "qiskit.transpiler.StagedPassManager"). By default an external plugin is not used. You can see a list of installed plugins by using [`list_stage_plugins()`](transpiler_plugins#qiskit.transpiler.preset_passmanagers.plugin.list_stage_plugins "qiskit.transpiler.preset_passmanagers.plugin.list_stage_plugins") with `"optimization"` for the `stage_name` argument.
|
||
|
||
**Returns**
|
||
|
||
The preset pass manager for the given options
|
||
|
||
**Return type**
|
||
|
||
[StagedPassManager](qiskit.transpiler.StagedPassManager "qiskit.transpiler.StagedPassManager")
|
||
|
||
**Raises**
|
||
|
||
[**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.13)") – if an invalid value for `optimization_level` is passed in.
|
||
</Function>
|
||
|
||
### level\_0\_pass\_manager
|
||
|
||
<Function id="qiskit.transpiler.preset_passmanagers.level_0_pass_manager" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/preset_passmanagers/level0.py#L26-L113" signature="qiskit.transpiler.preset_passmanagers.level_0_pass_manager(pass_manager_config)">
|
||
Level 0 pass manager: no explicit optimization other than mapping to backend.
|
||
|
||
This pass manager applies the user-given initial layout. If none is given, a trivial layout consisting of mapping the i-th virtual qubit to the i-th physical qubit is used. Any unused physical qubit is allocated as ancilla space.
|
||
|
||
The pass manager then unrolls the circuit to the desired basis, and transforms the circuit to match the coupling map.
|
||
|
||
**Parameters**
|
||
|
||
**pass\_manager\_config** ([*PassManagerConfig*](qiskit.transpiler.PassManagerConfig "qiskit.transpiler.passmanager_config.PassManagerConfig")) – configuration of the pass manager.
|
||
|
||
**Returns**
|
||
|
||
a level 0 pass manager.
|
||
|
||
**Raises**
|
||
|
||
[**TranspilerError**](transpiler#qiskit.transpiler.TranspilerError "qiskit.transpiler.TranspilerError") – if the passmanager config is invalid.
|
||
|
||
**Return type**
|
||
|
||
[*StagedPassManager*](qiskit.transpiler.StagedPassManager "qiskit.transpiler.passmanager.StagedPassManager")
|
||
</Function>
|
||
|
||
### level\_1\_pass\_manager
|
||
|
||
<Function id="qiskit.transpiler.preset_passmanagers.level_1_pass_manager" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/preset_passmanagers/level1.py#L26-L120" signature="qiskit.transpiler.preset_passmanagers.level_1_pass_manager(pass_manager_config)">
|
||
Level 1 pass manager: light optimization by simple adjacent gate collapsing.
|
||
|
||
This pass manager applies the user-given initial layout. If none is given, and a trivial layout (i-th virtual -> i-th physical) makes the circuit fit the coupling map, that is used. Otherwise, the circuit is mapped to the most densely connected coupling subgraph, and swaps are inserted to map. Any unused physical qubit is allocated as ancilla space. The pass manager then unrolls the circuit to the desired basis, and transforms the circuit to match the coupling map. Finally, optimizations in the form of adjacent gate collapse and redundant reset removal are performed.
|
||
|
||
**Parameters**
|
||
|
||
**pass\_manager\_config** ([*PassManagerConfig*](qiskit.transpiler.PassManagerConfig "qiskit.transpiler.passmanager_config.PassManagerConfig")) – configuration of the pass manager.
|
||
|
||
**Returns**
|
||
|
||
a level 1 pass manager.
|
||
|
||
**Raises**
|
||
|
||
[**TranspilerError**](transpiler#qiskit.transpiler.TranspilerError "qiskit.transpiler.TranspilerError") – if the passmanager config is invalid.
|
||
|
||
**Return type**
|
||
|
||
[*StagedPassManager*](qiskit.transpiler.StagedPassManager "qiskit.transpiler.passmanager.StagedPassManager")
|
||
</Function>
|
||
|
||
### level\_2\_pass\_manager
|
||
|
||
<Function id="qiskit.transpiler.preset_passmanagers.level_2_pass_manager" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/preset_passmanagers/level2.py#L27-L119" signature="qiskit.transpiler.preset_passmanagers.level_2_pass_manager(pass_manager_config)">
|
||
Level 2 pass manager: medium optimization by initial layout selection and gate cancellation using commutativity rules.
|
||
|
||
This pass manager applies the user-given initial layout. If none is given, a search for a perfect layout (i.e. one that satisfies all 2-qubit interactions) is conducted. If no such layout is found, qubits are laid out on the most densely connected subset which also exhibits the best gate fidelities.
|
||
|
||
The pass manager then transforms the circuit to match the coupling constraints. It is then unrolled to the basis, and any flipped cx directions are fixed. Finally, optimizations in the form of commutative gate cancellation and redundant reset removal are performed.
|
||
|
||
**Parameters**
|
||
|
||
**pass\_manager\_config** ([*PassManagerConfig*](qiskit.transpiler.PassManagerConfig "qiskit.transpiler.passmanager_config.PassManagerConfig")) – configuration of the pass manager.
|
||
|
||
**Returns**
|
||
|
||
a level 2 pass manager.
|
||
|
||
**Raises**
|
||
|
||
[**TranspilerError**](transpiler#qiskit.transpiler.TranspilerError "qiskit.transpiler.TranspilerError") – if the passmanager config is invalid.
|
||
|
||
**Return type**
|
||
|
||
[*StagedPassManager*](qiskit.transpiler.StagedPassManager "qiskit.transpiler.passmanager.StagedPassManager")
|
||
</Function>
|
||
|
||
### level\_3\_pass\_manager
|
||
|
||
<Function id="qiskit.transpiler.preset_passmanagers.level_3_pass_manager" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/preset_passmanagers/level3.py#L27-L119" signature="qiskit.transpiler.preset_passmanagers.level_3_pass_manager(pass_manager_config)">
|
||
Level 3 pass manager: heavy optimization by noise adaptive qubit mapping and gate cancellation using commutativity rules and unitary synthesis.
|
||
|
||
This pass manager applies the user-given initial layout. If none is given, a search for a perfect layout (i.e. one that satisfies all 2-qubit interactions) is conducted. If no such layout is found, and device calibration information is available, the circuit is mapped to the qubits with best readouts and to CX gates with highest fidelity.
|
||
|
||
The pass manager then transforms the circuit to match the coupling constraints. It is then unrolled to the basis, and any flipped cx directions are fixed. Finally, optimizations in the form of commutative gate cancellation, resynthesis of two-qubit unitary blocks, and redundant reset removal are performed.
|
||
|
||
**Parameters**
|
||
|
||
**pass\_manager\_config** ([*PassManagerConfig*](qiskit.transpiler.PassManagerConfig "qiskit.transpiler.passmanager_config.PassManagerConfig")) – configuration of the pass manager.
|
||
|
||
**Returns**
|
||
|
||
a level 3 pass manager.
|
||
|
||
**Raises**
|
||
|
||
[**TranspilerError**](transpiler#qiskit.transpiler.TranspilerError "qiskit.transpiler.TranspilerError") – if the passmanager config is invalid.
|
||
|
||
**Return type**
|
||
|
||
[*StagedPassManager*](qiskit.transpiler.StagedPassManager "qiskit.transpiler.passmanager.StagedPassManager")
|
||
</Function>
|
||
|
||
<span id="stage-generators" />
|
||
|
||
## Stage Generator Functions
|
||
|
||
### generate\_control\_flow\_options\_check
|
||
|
||
<Function id="qiskit.transpiler.preset_passmanagers.common.generate_control_flow_options_check" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/preset_passmanagers/common.py#L111-L157" signature="qiskit.transpiler.preset_passmanagers.common.generate_control_flow_options_check(layout_method=None, routing_method=None, translation_method=None, optimization_method=None, scheduling_method=None, basis_gates=(), target=None)">
|
||
Generate a pass manager that, when run on a DAG that contains control flow, fails with an error message explaining the invalid options, and what could be used instead.
|
||
|
||
**Returns**
|
||
|
||
a pass manager that populates the `contains_x` properties for each of the control-flow operations, and raises an error if any of the given options do not support control flow, but a circuit with control flow is given.
|
||
|
||
**Return type**
|
||
|
||
[PassManager](qiskit.transpiler.PassManager "qiskit.transpiler.PassManager")
|
||
</Function>
|
||
|
||
### generate\_error\_on\_control\_flow
|
||
|
||
<Function id="qiskit.transpiler.preset_passmanagers.common.generate_error_on_control_flow" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/preset_passmanagers/common.py#L160-L166" signature="qiskit.transpiler.preset_passmanagers.common.generate_error_on_control_flow(message)">
|
||
Get a pass manager that always raises an error if control flow is present in a given circuit.
|
||
</Function>
|
||
|
||
### generate\_unroll\_3q
|
||
|
||
<Function id="qiskit.transpiler.preset_passmanagers.common.generate_unroll_3q" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/preset_passmanagers/common.py#L183-L239" signature="qiskit.transpiler.preset_passmanagers.common.generate_unroll_3q(target, basis_gates=None, approximation_degree=None, unitary_synthesis_method='default', unitary_synthesis_plugin_config=None, hls_config=None)">
|
||
Generate an unroll >3q [`PassManager`](qiskit.transpiler.PassManager "qiskit.transpiler.PassManager")
|
||
|
||
**Parameters**
|
||
|
||
* **target** ([*Target*](qiskit.transpiler.Target "qiskit.transpiler.Target")) – the [`Target`](qiskit.transpiler.Target "qiskit.transpiler.Target") object representing the backend
|
||
* **basis\_gates** ([*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.13)")) – A list of str gate names that represent the basis gates on the backend target
|
||
* **approximation\_degree** (*Optional\[*[*float*](https://docs.python.org/3/library/functions.html#float "(in Python v3.13)")*]*) – The heuristic approximation degree to use. Can be between 0 and 1.
|
||
* **unitary\_synthesis\_method** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")) – The unitary synthesis method to use. You can see a list of installed plugins with [`unitary_synthesis_plugin_names()`](qiskit.transpiler.passes.synthesis.plugin.unitary_synthesis_plugin_names "qiskit.transpiler.passes.synthesis.plugin.unitary_synthesis_plugin_names").
|
||
* **unitary\_synthesis\_plugin\_config** ([*dict*](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.13)")) – The optional dictionary plugin configuration, this is plugin specific refer to the specified plugin’s documentation for how to use.
|
||
* **hls\_config** ([*HLSConfig*](qiskit.transpiler.passes.HLSConfig "qiskit.transpiler.passes.HLSConfig")) – An optional configuration class to use for [`HighLevelSynthesis`](qiskit.transpiler.passes.HighLevelSynthesis "qiskit.transpiler.passes.HighLevelSynthesis") pass. Specifies how to synthesize various high-level objects.
|
||
|
||
**Returns**
|
||
|
||
The unroll 3q or more pass manager
|
||
|
||
**Return type**
|
||
|
||
[PassManager](qiskit.transpiler.PassManager "qiskit.transpiler.PassManager")
|
||
</Function>
|
||
|
||
### generate\_embed\_passmanager
|
||
|
||
<Function id="qiskit.transpiler.preset_passmanagers.common.generate_embed_passmanager" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/preset_passmanagers/common.py#L242-L255" signature="qiskit.transpiler.preset_passmanagers.common.generate_embed_passmanager(coupling_map)">
|
||
Generate a layout embedding [`PassManager`](qiskit.transpiler.PassManager "qiskit.transpiler.PassManager")
|
||
|
||
This is used to generate a [`PassManager`](qiskit.transpiler.PassManager "qiskit.transpiler.PassManager") object that can be used to expand and apply an initial layout to a circuit
|
||
|
||
**Parameters**
|
||
|
||
**coupling\_map** (*Union\[*[*CouplingMap*](qiskit.transpiler.CouplingMap "qiskit.transpiler.CouplingMap")*,* [*Target*](qiskit.transpiler.Target "qiskit.transpiler.Target")) – The coupling map for the backend to embed the circuit to.
|
||
|
||
**Returns**
|
||
|
||
**The embedding passmanager that assumes the layout property**
|
||
|
||
set has been set in earlier stages
|
||
|
||
**Return type**
|
||
|
||
[PassManager](qiskit.transpiler.PassManager "qiskit.transpiler.PassManager")
|
||
</Function>
|
||
|
||
### generate\_routing\_passmanager
|
||
|
||
<Function id="qiskit.transpiler.preset_passmanagers.common.generate_routing_passmanager" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/preset_passmanagers/common.py#L273-L371" signature="qiskit.transpiler.preset_passmanagers.common.generate_routing_passmanager(routing_pass, target, coupling_map=None, vf2_call_limit=None, backend_properties=None, seed_transpiler=None, check_trivial=False, use_barrier_before_measurement=True, vf2_max_trials=None)">
|
||
Generate a routing [`PassManager`](qiskit.transpiler.PassManager "qiskit.transpiler.PassManager")
|
||
|
||
**Parameters**
|
||
|
||
* **routing\_pass** ([*TransformationPass*](qiskit.transpiler.TransformationPass "qiskit.transpiler.TransformationPass")) – The pass which will perform the routing
|
||
* **target** ([*Target*](qiskit.transpiler.Target "qiskit.transpiler.Target")) – the [`Target`](qiskit.transpiler.Target "qiskit.transpiler.Target") object representing the backend
|
||
* **coupling\_map** ([*CouplingMap*](qiskit.transpiler.CouplingMap "qiskit.transpiler.CouplingMap")) – The coupling map of the backend to route for
|
||
* **vf2\_call\_limit** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) – The internal call limit for the vf2 post layout pass. If this is `None` or `0` the vf2 post layout will not be run.
|
||
* **backend\_properties** ([*BackendProperties*](qiskit.providers.models.BackendProperties "qiskit.providers.models.BackendProperties")) – Properties of a backend to synthesize for (e.g. gate fidelities).
|
||
* **seed\_transpiler** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) – Sets random seed for the stochastic parts of the transpiler.
|
||
* **check\_trivial** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)")) – If set to true this will condition running the [`VF2PostLayout`](qiskit.transpiler.passes.VF2PostLayout "qiskit.transpiler.passes.VF2PostLayout") pass after routing on whether a trivial layout was tried and was found to not be perfect. This is only needed if the constructed pass manager runs [`TrivialLayout`](qiskit.transpiler.passes.TrivialLayout "qiskit.transpiler.passes.TrivialLayout") as a first layout attempt and uses it if it’s a perfect layout (as is the case with preset pass manager level 1).
|
||
* **use\_barrier\_before\_measurement** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)")) – If true (the default) the [`BarrierBeforeFinalMeasurements`](qiskit.transpiler.passes.BarrierBeforeFinalMeasurements "qiskit.transpiler.passes.BarrierBeforeFinalMeasurements") transpiler pass will be run prior to the specified pass in the `routing_pass` argument.
|
||
* **vf2\_max\_trials** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) – The maximum number of trials to run VF2 when evaluating the vf2 post layout pass. If this is `None` or `0` the vf2 post layout will not be run.
|
||
|
||
**Returns**
|
||
|
||
The routing pass manager
|
||
|
||
**Return type**
|
||
|
||
[PassManager](qiskit.transpiler.PassManager "qiskit.transpiler.PassManager")
|
||
</Function>
|
||
|
||
### generate\_pre\_op\_passmanager
|
||
|
||
<Function id="qiskit.transpiler.preset_passmanagers.common.generate_pre_op_passmanager" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/preset_passmanagers/common.py#L374-L404" signature="qiskit.transpiler.preset_passmanagers.common.generate_pre_op_passmanager(target=None, coupling_map=None, remove_reset_in_zero=False)">
|
||
Generate a pre-optimization loop [`PassManager`](qiskit.transpiler.PassManager "qiskit.transpiler.PassManager")
|
||
|
||
This pass manager will check to ensure that directionality from the coupling map is respected
|
||
|
||
**Parameters**
|
||
|
||
* **target** ([*Target*](qiskit.transpiler.Target "qiskit.transpiler.Target")) – the [`Target`](qiskit.transpiler.Target "qiskit.transpiler.Target") object representing the backend
|
||
* **coupling\_map** ([*CouplingMap*](qiskit.transpiler.CouplingMap "qiskit.transpiler.CouplingMap")) – The coupling map to use
|
||
* **remove\_reset\_in\_zero** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)")) – If `True` include the remove reset in zero pass in the generated PassManager
|
||
|
||
**Returns**
|
||
|
||
The pass manager
|
||
|
||
**Return type**
|
||
|
||
[PassManager](qiskit.transpiler.PassManager "qiskit.transpiler.PassManager")
|
||
</Function>
|
||
|
||
### generate\_translation\_passmanager
|
||
|
||
<Function id="qiskit.transpiler.preset_passmanagers.common.generate_translation_passmanager" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/preset_passmanagers/common.py#L407-L519" signature="qiskit.transpiler.preset_passmanagers.common.generate_translation_passmanager(target, basis_gates=None, method='translator', approximation_degree=None, coupling_map=None, backend_props=None, unitary_synthesis_method='default', unitary_synthesis_plugin_config=None, hls_config=None)">
|
||
Generate a basis translation [`PassManager`](qiskit.transpiler.PassManager "qiskit.transpiler.PassManager")
|
||
|
||
**Parameters**
|
||
|
||
* **target** ([*Target*](qiskit.transpiler.Target "qiskit.transpiler.Target")) – the [`Target`](qiskit.transpiler.Target "qiskit.transpiler.Target") object representing the backend
|
||
* **basis\_gates** ([*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.13)")) – A list of str gate names that represent the basis gates on the backend target
|
||
* **method** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")) – The basis translation method to use
|
||
* **approximation\_degree** (*Optional\[*[*float*](https://docs.python.org/3/library/functions.html#float "(in Python v3.13)")*]*) – The heuristic approximation degree to use. Can be between 0 and 1.
|
||
* **coupling\_map** ([*CouplingMap*](qiskit.transpiler.CouplingMap "qiskit.transpiler.CouplingMap")) – the coupling map of the backend in case synthesis is done on a physical circuit. The directionality of the coupling\_map will be taken into account if pulse\_optimize is True/None and natural\_direction is True/None.
|
||
* **unitary\_synthesis\_plugin\_config** ([*dict*](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.13)")) – The optional dictionary plugin configuration, this is plugin specific refer to the specified plugin’s documentation for how to use.
|
||
* **backend\_props** ([*BackendProperties*](qiskit.providers.models.BackendProperties "qiskit.providers.models.BackendProperties")) – Properties of a backend to synthesize for (e.g. gate fidelities).
|
||
* **unitary\_synthesis\_method** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")) – The unitary synthesis method to use. You can see a list of installed plugins with [`unitary_synthesis_plugin_names()`](qiskit.transpiler.passes.synthesis.plugin.unitary_synthesis_plugin_names "qiskit.transpiler.passes.synthesis.plugin.unitary_synthesis_plugin_names").
|
||
* **hls\_config** ([*HLSConfig*](qiskit.transpiler.passes.HLSConfig "qiskit.transpiler.passes.HLSConfig")) – An optional configuration class to use for [`HighLevelSynthesis`](qiskit.transpiler.passes.HighLevelSynthesis "qiskit.transpiler.passes.HighLevelSynthesis") pass. Specifies how to synthesize various high-level objects.
|
||
|
||
**Returns**
|
||
|
||
The basis translation pass manager
|
||
|
||
**Return type**
|
||
|
||
[PassManager](qiskit.transpiler.PassManager "qiskit.transpiler.PassManager")
|
||
|
||
**Raises**
|
||
|
||
[**TranspilerError**](transpiler#qiskit.transpiler.TranspilerError "qiskit.transpiler.TranspilerError") – If the `method` kwarg is not a valid value
|
||
</Function>
|
||
|
||
### generate\_scheduling
|
||
|
||
<Function id="qiskit.transpiler.preset_passmanagers.common.generate_scheduling" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/preset_passmanagers/common.py#L522-L608" signature="qiskit.transpiler.preset_passmanagers.common.generate_scheduling(instruction_durations, scheduling_method, timing_constraints, inst_map, target=None)">
|
||
Generate a post optimization scheduling [`PassManager`](qiskit.transpiler.PassManager "qiskit.transpiler.PassManager")
|
||
|
||
**Parameters**
|
||
|
||
* **instruction\_durations** ([*dict*](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.13)")) – The dictionary of instruction durations
|
||
* **scheduling\_method** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")) – The scheduling method to use, can either be `'asap'`/`'as_soon_as_possible'` or `'alap'`/`'as_late_as_possible'`
|
||
* **timing\_constraints** (*TimingConstraints*) – Hardware time alignment restrictions.
|
||
* **inst\_map** ([*InstructionScheduleMap*](qiskit.pulse.InstructionScheduleMap "qiskit.pulse.InstructionScheduleMap")) – Mapping object that maps gate to schedule.
|
||
* **target** ([*Target*](qiskit.transpiler.Target "qiskit.transpiler.Target")) – The [`Target`](qiskit.transpiler.Target "qiskit.transpiler.Target") object representing the backend
|
||
|
||
**Returns**
|
||
|
||
The scheduling pass manager
|
||
|
||
**Return type**
|
||
|
||
[PassManager](qiskit.transpiler.PassManager "qiskit.transpiler.PassManager")
|
||
|
||
**Raises**
|
||
|
||
[**TranspilerError**](transpiler#qiskit.transpiler.TranspilerError "qiskit.transpiler.TranspilerError") – If the `scheduling_method` kwarg is not a valid value
|
||
</Function>
|
||
|