qiskit 1.3.1__cp39-abi3-win32.whl → 1.3.3__cp39-abi3-win32.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. qiskit/VERSION.txt +1 -1
  2. qiskit/_accelerate.pyd +0 -0
  3. qiskit/circuit/__init__.py +7 -2
  4. qiskit/circuit/controlledgate.py +2 -0
  5. qiskit/circuit/delay.py +5 -0
  6. qiskit/circuit/library/__init__.py +1 -0
  7. qiskit/circuit/library/arithmetic/piecewise_chebyshev.py +1 -0
  8. qiskit/circuit/library/basis_change/qft.py +3 -0
  9. qiskit/circuit/library/boolean_logic/inner_product.py +2 -0
  10. qiskit/circuit/library/boolean_logic/quantum_and.py +4 -0
  11. qiskit/circuit/library/boolean_logic/quantum_or.py +4 -0
  12. qiskit/circuit/library/boolean_logic/quantum_xor.py +2 -0
  13. qiskit/circuit/library/fourier_checking.py +2 -0
  14. qiskit/circuit/library/generalized_gates/gms.py +1 -0
  15. qiskit/circuit/library/generalized_gates/gr.py +4 -0
  16. qiskit/circuit/library/generalized_gates/mcmt.py +1 -0
  17. qiskit/circuit/library/generalized_gates/permutation.py +5 -1
  18. qiskit/circuit/library/generalized_gates/unitary.py +1 -1
  19. qiskit/circuit/library/graph_state.py +2 -0
  20. qiskit/circuit/library/grover_operator.py +7 -3
  21. qiskit/circuit/library/hidden_linear_function.py +2 -0
  22. qiskit/circuit/library/iqp.py +5 -0
  23. qiskit/circuit/library/n_local/efficient_su2.py +7 -2
  24. qiskit/circuit/library/n_local/evolved_operator_ansatz.py +3 -0
  25. qiskit/circuit/library/n_local/excitation_preserving.py +14 -8
  26. qiskit/circuit/library/n_local/n_local.py +10 -5
  27. qiskit/circuit/library/n_local/pauli_two_design.py +5 -2
  28. qiskit/circuit/library/n_local/qaoa_ansatz.py +1 -0
  29. qiskit/circuit/library/n_local/real_amplitudes.py +10 -4
  30. qiskit/circuit/library/overlap.py +1 -0
  31. qiskit/circuit/library/phase_estimation.py +2 -0
  32. qiskit/circuit/library/quantum_volume.py +3 -0
  33. qiskit/circuit/library/standard_gates/rz.py +7 -7
  34. qiskit/circuit/library/standard_gates/xx_minus_yy.py +0 -30
  35. qiskit/circuit/operation.py +1 -0
  36. qiskit/circuit/parameter.py +1 -0
  37. qiskit/circuit/parameterexpression.py +1 -1
  38. qiskit/circuit/parametervector.py +25 -5
  39. qiskit/circuit/quantumcircuit.py +17 -20
  40. qiskit/circuit/random/utils.py +2 -0
  41. qiskit/compiler/transpiler.py +1 -1
  42. qiskit/converters/dag_to_circuit.py +1 -0
  43. qiskit/primitives/statevector_estimator.py +1 -0
  44. qiskit/providers/fake_provider/__init__.py +1 -0
  45. qiskit/pulse/builder.py +8 -0
  46. qiskit/pulse/library/symbolic_pulses.py +1 -0
  47. qiskit/qasm2/export.py +2 -2
  48. qiskit/qasm3/__init__.py +1 -0
  49. qiskit/qasm3/exporter.py +6 -3
  50. qiskit/quantum_info/operators/channel/transformations.py +15 -0
  51. qiskit/quantum_info/operators/symplectic/pauli_list.py +8 -8
  52. qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +10 -1
  53. qiskit/quantum_info/states/statevector.py +1 -0
  54. qiskit/synthesis/arithmetic/multipliers/hrs_cumulative_multiplier.py +1 -0
  55. qiskit/synthesis/arithmetic/multipliers/rg_qft_multiplier.py +1 -0
  56. qiskit/synthesis/evolution/product_formula.py +0 -6
  57. qiskit/synthesis/evolution/suzuki_trotter.py +22 -5
  58. qiskit/transpiler/__init__.py +780 -529
  59. qiskit/transpiler/layout.py +9 -6
  60. qiskit/transpiler/passes/layout/sabre_layout.py +13 -0
  61. qiskit/transpiler/passes/optimization/remove_identity_equiv.py +2 -3
  62. qiskit/transpiler/passes/routing/star_prerouting.py +1 -0
  63. qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +1 -0
  64. qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +1 -0
  65. qiskit/transpiler/passes/scheduling/scheduling/alap.py +1 -1
  66. qiskit/transpiler/passes/scheduling/scheduling/asap.py +1 -1
  67. qiskit/transpiler/passes/synthesis/hls_plugins.py +48 -9
  68. qiskit/transpiler/passes/utils/filter_op_nodes.py +2 -1
  69. qiskit/transpiler/passes/utils/remove_barriers.py +1 -0
  70. qiskit/transpiler/preset_passmanagers/__init__.py +31 -11
  71. qiskit/transpiler/preset_passmanagers/builtin_plugins.py +19 -22
  72. qiskit/transpiler/preset_passmanagers/plugin.py +33 -42
  73. qiskit/transpiler/target.py +1 -1
  74. qiskit/visualization/__init__.py +6 -0
  75. qiskit/visualization/circuit/circuit_visualization.py +1 -0
  76. qiskit/visualization/circuit/text.py +3 -2
  77. qiskit/visualization/counts_visualization.py +2 -0
  78. qiskit/visualization/dag_visualization.py +1 -0
  79. qiskit/visualization/gate_map.py +7 -3
  80. qiskit/visualization/pulse_v2/interface.py +4 -1
  81. qiskit/visualization/state_visualization.py +13 -2
  82. qiskit/visualization/timeline/interface.py +6 -3
  83. {qiskit-1.3.1.dist-info → qiskit-1.3.3.dist-info}/METADATA +20 -23
  84. {qiskit-1.3.1.dist-info → qiskit-1.3.3.dist-info}/RECORD +88 -88
  85. {qiskit-1.3.1.dist-info → qiskit-1.3.3.dist-info}/WHEEL +1 -1
  86. {qiskit-1.3.1.dist-info → qiskit-1.3.3.dist-info}/LICENSE.txt +0 -0
  87. {qiskit-1.3.1.dist-info → qiskit-1.3.3.dist-info}/entry_points.txt +0 -0
  88. {qiskit-1.3.1.dist-info → qiskit-1.3.3.dist-info}/top_level.txt +0 -0
@@ -33,81 +33,165 @@ branches, and other complex behaviors. That being said, the standard
33
33
  compilation flow follows the structure given below:
34
34
 
35
35
  .. image:: /source_images/transpiling_core_steps.png
36
+ :alt: The transpilation process takes the input circuit, applies the transpilation \
37
+ passes, then produces the output circuit.
38
+
39
+ Qiskit uses the graph-based :class:`.DAGCircuit` intermediate representation (IR) of a circuit
40
+ throughout the transpiler stack, rather than the tree-based :class:`.QuantumCircuit`. A transpiler
41
+ pipeline is a :class:`.PassManager` object, whose :meth:`.PassManager.run` method takes in a
42
+ :class:`.QuantumCircuit` and converts it to a :class:`.DAGCircuit`, then subjects the IR to a
43
+ sequence of *passes*, finally returning a :class:`.QuantumCircuit` back. A pass is either an
44
+ :class:`.AnalysisPass`, which calculates and stores properties about the circuit in the
45
+ stateful :class:`.PropertySet`, or a :class:`.TransformationPass`, which modifies the IR
46
+ to achieve a particular singular goal. You can think of a pipeline as being split into
47
+ "stages", where each stage is responsible for one high-level transformation.
48
+
49
+ Qiskit exposes a default transpilation pipeline builder using the function
50
+ :func:`.generate_preset_pass_manager`. This returns a properly configured pipeline for complete
51
+ transpilation, at a chosen ``optimization_level`` (between 0 and 3, inclusive). Unless you are
52
+ looking for something highly specialized, this is almost certainly the entry point you want. A
53
+ sample transpilation looks like::
54
+
55
+ from qiskit.circuit import QuantumCircuit
56
+ from qiskit.transpiler import generate_preset_pass_manager
57
+ from qiskit_ibm_runtime import QiskitRuntimeService
58
+
59
+ # Any abstract circuit you want:
60
+ abstract = QuantumCircuit(2)
61
+ abstract.h(0)
62
+ abstract.cx(0, 1)
63
+
64
+ # Any method you like to retrieve the backend you want to run on:
65
+ backend = QiskitRuntimeService().backend("some-backend")
66
+
67
+ # Create the pass manager for the transpilation ...
68
+ pm = generate_preset_pass_manager(backend=backend)
69
+ # ... and use it (as many times as you like).
70
+ physical = pm.run(abstract)
71
+
72
+ For most use cases, this is all you need.
73
+ All of Qiskit's transpiler infrastructure is highly extensible and configurable, however.
74
+ The rest of this page details how to harness the low-level capabilities of the transpiler stack.
75
+
76
+ .. _transpiler-preset:
77
+
78
+ Preset pass managers
79
+ ====================
36
80
 
37
- .. raw:: html
38
-
39
- <br>
40
-
41
- Qiskit has four pre-built transpilation pipelines available here:
42
- :mod:`qiskit.transpiler.preset_passmanagers`. Unless the reader is familiar with
43
- quantum circuit optimization methods and their usage, it is best to use one of
44
- these ready-made routines. By default the preset pass managers are composed
45
- of six stages:
46
-
47
- #. ``init`` - This stage runs any initial passes that are required before we start embedding the
48
- circuit to the backend. This typically involves unrolling custom instructions and converting
49
- the circuit to all 1 and 2 qubit gates.
50
- #. ``layout`` - This stage applies a layout, mapping the virtual qubits in the circuit to the
51
- physical qubits on a backend. See :ref:`layout_stage` for more details.
52
- #. ``routing`` - This stage runs after a layout has been applied and will inject
53
- gates (i.e. swaps) into the original circuit to make it compatible
54
- with the backend's connectivity. See :ref:`routing_stage` for more details.
55
- #. ``translation`` - This stage translates the gates in the circuit to the target backend's basis set.
56
- See :ref:`translation_stage` for more details.
57
- #. ``optimization`` - This stage runs the main optimization loop repeatedly
58
- until a condition (such as fixed depth) is reached. See :ref:`optimization_stage` for more details.
59
- #. ``scheduling`` - This stage is for any hardware-aware scheduling passes. See
60
- :ref:`scheduling_stage` for more details.
61
-
62
- When using :func:`~.transpile`, the implementation of each stage can be modified with the ``*_method``
63
- arguments (e.g. ``layout_method``). These can be set to one of the built-in methods and
64
- can also refer to available external plugins. See
65
- :mod:`qiskit.transpiler.preset_passmanagers.plugin` for details on this plugin interface.
66
-
67
- .. _working_with_preset_pass_managers:
68
-
69
- Working with Preset Pass Managers
70
- =================================
71
-
72
- Qiskit includes functions to build preset :class:`~.PassManager` objects.
73
- These preset passmanagers are used by the :func:`~.transpile` function
74
- for each optimization level. There are 4 optimization levels ranging from 0 to 3, where higher
75
- optimization levels take more time and computational effort but may yield a
76
- more optimal circuit.
77
- Optimization level 0 is intended for device characterization experiments and, as such, only
78
- maps the input circuit to the constraints of the target backend, without
79
- performing any optimizations. Optimization level 3 spends the most effort to optimize the circuit.
80
- However, as many of the optimization techniques in the transpiler are heuristic based, spending more
81
- computational effort does not always result in an improvement in the quality of the output
82
- circuit.
83
-
84
- If you'd like to work directly with a
85
- preset pass manager you can use the :func:`~.generate_preset_pass_manager`
86
- function to easily generate one. For example:
81
+ The function :func:`.generate_preset_pass_manager` creates the "preset pass managers".
82
+ These are all instances of :class:`.PassManager`, so are used by passing a :class:`.QuantumCircuit`
83
+ to the :meth:`.PassManager.run` method. More specifically, the preset pass managers are instances
84
+ of :class:`.StagedPassManager`, which allows greater configuration of the individual stages of a
85
+ transpilation, including pre- and post-stage hooks.
86
+
87
+ A preset pass manager has up to six named stages. These are summarized, in order of execution,
88
+ below, with more in-depth information in the following subsections.
89
+
90
+ ``init``
91
+ Abstract-circuit optimizations, and reduction of multi-qubit operations to one- and two-qubit
92
+ operations. See :ref:`transpiler-preset-stage-init` for more details.
93
+
94
+ ``layout``
95
+ Choose an initial mapping of virtual qubits to physical qubits, including expansion of the
96
+ circuit to contain explicit ancillas. This stage sometimes subsumes ``routing``. See
97
+ :ref:`transpiler-preset-stage-layout` for more details.
98
+
99
+ ``routing``
100
+ Insert gates into the circuit to ensure it matches the connectivity constraints of the
101
+ :class:`.Target`. The inserted gates need not match the target ISA yet, so are often just
102
+ ``swap`` instructions. This stage is sometimes omitted, when the ``layout`` stage handles its
103
+ job. See :ref:`transpiler-preset-stage-routing` for more details.
104
+
105
+ ``translation``
106
+ Convert all gates in the circuit to ones matching the ISA of the :class:`Target`. See
107
+ :ref:`transpiler-preset-stage-translation` for more details.
108
+
109
+ ``optimization``
110
+ Low-level, hardware-aware optimizations. Unlike the abstract optimizations of the ``init``
111
+ stage, this stage acts on a physical circuit. See :ref:`transpiler-preset-stage-optimization`
112
+ for more details.
113
+
114
+ ``scheduling``
115
+ Insert :class:`~.circuit.Delay` instructions to make the wall-clock timing of a circuit
116
+ explicit. This may also include hardware-aware online error reduction techniques such as
117
+ dynamical decoupling, which are dependent on knowing wall-clock timings. See
118
+ :ref:`transpiler-preset-stage-scheduling` for more details.
119
+
120
+ The preset transpiler pipelines can also be configured at a high level by setting an
121
+ ``optimization_level``. This is an integer from 0 to 3, inclusive, indicating the relative effort to
122
+ exert in attempting to optimize the circuit for the hardware. Level 0 disables all unnecessary
123
+ optimizations; only transformations needed to make the circuit runnable are used. On
124
+ the other end, level 3 enables a full range of optimization techniques, some of which can be very
125
+ expensive in compilation time. Similar to classical compilers, optimization level 3 is not always
126
+ guaranteed to produce the best results. Qiskit defaults to optimization level 2, as a trade-off
127
+ between compilation time and the expected amount of optimization.
128
+
129
+ The optimization level affects which implementations are used for a given stage by default, though
130
+ this can be overridden by passing explicit ``<stage>_method="<choice>"`` arguments to
131
+ :func:`.generate_preset_pass_manager`.
132
+
133
+ .. note::
134
+
135
+ The preset pass managers almost always include stochastic, heuristic-based passes. If you need
136
+ to ensure reproducibility of a compilation, pass a known integer to the ``seed_transpiler``
137
+ argument to the generator functions.
138
+
139
+ This stochasticity arises because many of the problems the transpiler must solve are known to be
140
+ non-polynomial in complexity, but transpilation must complete in a workable amount of time.
141
+
142
+ Choosing preset stage implementations
143
+ -------------------------------------
144
+
145
+ Qiskit includes several implementations of the above stages, and more can be installed as
146
+ separate "plugins". To control which implementation of a stage is used, pass its name to the
147
+ ``<stage>_method`` keyword argument of the two functions, such as
148
+ ``translation_method="translator"``. To read more about implementing such external plugins for a
149
+ stage, see :mod:`qiskit.transpiler.preset_passmanagers.plugin`.
150
+
151
+ For example, to generate a preset pass manager at optimization level 1 that explicitly uses the
152
+ ``trivial`` method for layout with the ``sabre`` method for routing, we would do:
87
153
 
88
- .. code-block:: python
154
+ .. plot::
155
+ :include-source:
156
+ :nofigs:
89
157
 
90
- from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
158
+ from qiskit.transpiler import generate_preset_pass_manager
91
159
  from qiskit.providers.fake_provider import GenericBackendV2
92
160
 
161
+ # Whatever backend you like:
93
162
  backend = GenericBackendV2(num_qubits=5)
94
- pass_manager = generate_preset_pass_manager(3, backend)
95
-
96
- which will generate a :class:`~.StagedPassManager` object for optimization level 3
97
- targeting the :class:`~.GenericBackendV2` backend (equivalent to what is used internally
98
- by :func:`~.transpile` with ``backend=GenericBackendV2(5)`` and ``optimization_level=3``).
99
- You can use this just like you would any other :class:`~.PassManager`. However,
100
- because it is a :class:`~.StagedPassManager` it also makes it easy to compose and/or
101
- replace stages of the pipeline. For example, if you wanted to run a custom scheduling
102
- stage using dynamical decoupling (via the :class:`~.PadDynamicalDecoupling` pass) and
103
- also add initial logical optimization prior to routing, you would do something like
104
- (building off the previous example):
163
+
164
+ pass_manager = generate_preset_pass_manager(
165
+ optimization_level=1,
166
+ backend=backend,
167
+ layout_method="trivial",
168
+ routing_method="sabre",
169
+ )
170
+
171
+ .. note::
172
+
173
+ The built-in set of available plugins for each stage is part of Qiskit's public API, and subject
174
+ to all the stability guarantees. This includes the high-level logical effects of that method
175
+ (for example, ``routing_method="sabre"`` will always use a Sabre-derived algorithm). The exact
176
+ internal construction of the :class:`.PassManager` representing the stage is not, however; the
177
+ order of passes might change between minor versions, or new passes might be introduced.
178
+
179
+ For any stage that has one, the method named ``"default"`` is the most subject to change.
180
+ Qiskit typically only makes complete algorithmic changes in the default method across a
181
+ major-version boundary, but it might rebalance heuristics and add new passes to default
182
+ methods between minor versions.
183
+
184
+ Since the output of :func:`.generate_preset_pass_manager` is a :class:`.StagedPassManager`, you can
185
+ also modify the pass manager after its creation to provide an entirely custom stage implementation.
186
+ For example, if you wanted to run a custom scheduling stage using dynamical decoupling (using the
187
+ :class:`~.PadDynamicalDecoupling` pass) and also add initial logical optimization prior to routing,
188
+ you would do something like the following (building off the previous example):
105
189
 
106
190
  .. code-block:: python
107
191
 
108
192
  import numpy as np
109
193
  from qiskit.providers.fake_provider import GenericBackendV2
110
- from qiskit.circuit.library import HGate, PhaseGate, RXGate, TdgGate, TGate, XGate
194
+ from qiskit.circuit import library as lib
111
195
  from qiskit.transpiler import PassManager, generate_preset_pass_manager
112
196
  from qiskit.transpiler.passes import (
113
197
  ALAPScheduleAnalysis,
@@ -117,7 +201,7 @@ also add initial logical optimization prior to routing, you would do something l
117
201
  )
118
202
 
119
203
  backend = GenericBackendV2(num_qubits=5)
120
- dd_sequence = [XGate(), XGate()]
204
+ dd_sequence = [lib.XGate(), lib.XGate()]
121
205
  scheduling_pm = PassManager(
122
206
  [
123
207
  ALAPScheduleAnalysis(target=backend.target),
@@ -125,22 +209,15 @@ also add initial logical optimization prior to routing, you would do something l
125
209
  ]
126
210
  )
127
211
  inverse_gate_list = [
128
- HGate(),
129
- (RXGate(np.pi / 4), RXGate(-np.pi / 4)),
130
- (PhaseGate(np.pi / 4), PhaseGate(-np.pi / 4)),
131
- (TGate(), TdgGate()),
212
+ lib.CXGate(),
213
+ lib.HGate(),
214
+ (lib.RXGate(np.pi / 4), lib.RXGate(-np.pi / 4)),
215
+ (lib.PhaseGate(np.pi / 4), lib.PhaseGate(-np.pi / 4)),
216
+ (lib.TGate(), lib.TdgGate()),
132
217
  ]
133
- logical_opt = PassManager(
134
- [
135
- CXCancellation(),
136
- InverseCancellation(inverse_gate_list),
137
- ]
138
- )
139
-
140
- pass_manager = generate_preset_pass_manager(
141
- optimization_level=0
142
- )
218
+ logical_opt = PassManager([InverseCancellation(inverse_gate_list)])
143
219
 
220
+ pass_manager = generate_preset_pass_manager(optimization_level=0)
144
221
  # Add pre-layout stage to run extra logical optimization
145
222
  pass_manager.pre_layout = logical_opt
146
223
  # Set scheduling stage to custom pass manager
@@ -150,7 +227,593 @@ Now, when the staged pass manager is run via the :meth:`~.StagedPassManager.run`
150
227
  the ``logical_opt`` pass manager will be called before the ``layout`` stage, and the
151
228
  ``scheduling_pm`` pass manager will be used for the ``scheduling`` stage instead of the default.
152
229
 
153
- Custom Pass Managers
230
+ If you are constructing custom stages for the preset pass managers, you may find some of the
231
+ low-level helper functions in :mod:`qiskit.transpiler.preset_passmanagers` useful.
232
+
233
+ .. _transpiler-preset-stage-init:
234
+
235
+ Initialization stage
236
+ --------------------
237
+
238
+ .. seealso::
239
+ `Init stage explanation <https://docs.quantum.ibm.com/guides/transpiler-stages#init-stage>`__
240
+ Higher-level user-facing explanation of the init stage in the IBM Quantum guide.
241
+
242
+ The ``init`` stage is responsible for high-level, logical optimizations on abstract circuits, and
243
+ for lowering multi-qubit (3+) operations down to a series of one- and two-qubit operations. As this is
244
+ the first stage run, its input is a fully abstract circuit. The ``init`` stage must be able to
245
+ handle custom user-defined gates, and all the high-level abstract circuit-description objects, such
246
+ as :class:`.AnnotatedOperation`.
247
+
248
+ The output of the ``init`` stage is an abstract circuit that contains only one- and two-qubit
249
+ operations.
250
+
251
+ When writing :ref:`stage plugins <transpiler-preset-stage-plugins>`, the entry point for ``init`` is
252
+ ``qiskit.transpiler.init``. The built-in plugins are:
253
+
254
+ .. list-table::
255
+ :header-rows: 1
256
+
257
+ * - Method
258
+ - Summary
259
+
260
+ * - :ref:`default <transpiler-preset-stage-init-default>`
261
+ - Built-in unrolling of multi-qubit operations and abstract optimizations.
262
+
263
+
264
+ .. _transpiler-preset-stage-init-default:
265
+
266
+ Built-in ``default`` plugin
267
+ ...........................
268
+
269
+ At optimization level 0, no abstract optimization is done. The default plugin simply "unrolls"
270
+ operations with more than three qubits by accessing their hierarchical
271
+ :class:`~.circuit.Instruction.definition` fields.
272
+
273
+ At optimization levels 1 and above, the default plugin also does simple cancellation of adjacent
274
+ inverse gates, such as two back-to-back ``cx`` gates.
275
+
276
+ At optimization levels 2 and 3, the default plugin enables a much wider range of abstract
277
+ optimizations. This includes:
278
+
279
+ * "Virtual permutation elision" (see :class:`.ElidePermutations`), where explicit
280
+ permutation-inducing operations are removed and instead effected as remapping of virtual qubits.
281
+ * Analysis of the commutation structure of the IR to find pairs of gates that can be canceled out.
282
+ * Numerical splitting of two-qubit operations that can be expressed as a series of separable
283
+ one-qubit operations.
284
+ * Removal of imperceivable operations, such as tiny-angle Pauli rotations and diagonal operations
285
+ immediately preceding measurements.
286
+
287
+ .. _transpiler-preset-stage-layout:
288
+
289
+ Layout stage
290
+ ------------
291
+
292
+ .. seealso::
293
+ `Layout stage explanation <https://docs.quantum.ibm.com/guides/transpiler-stages#layout-stage>`__
294
+ Higher-level user-facing explanation of the layout stage in the IBM Quantum guide.
295
+
296
+ The layout stage is responsible for making an initial mapping between the virtual qubits of the
297
+ input circuit, and the hardware qubits of the target. This includes expanding the input circuit
298
+ with explicit ancillas so it has as many qubits as the target has, and rewriting all operations in
299
+ terms of hardware qubits. You may also see this problem called the "placement" problem in other
300
+ toolkits or literature.
301
+
302
+ The layout stage must set the properties ``layout`` and ``original_qubit_indices`` in the pipeline's
303
+ :class:`.PropertySet`.
304
+
305
+ .. note::
306
+
307
+ All built-in plugins for the layout stage will give priority to an explicit layout selected
308
+ using the ``initial_layout`` argument to :func:`.generate_preset_pass_manager` or
309
+ :func:`.transpile`.
310
+
311
+ At any given point in a circuit, we can identify a mapping between currently active "virtual" qubits
312
+ of the input circuit to hardware qubits of the backend. A hardware qubit can only ever represent a
313
+ single virtual qubit at a given point, but the mapping might vary over the course of the circuit.
314
+ In principle, some virtual qubits might not be mapped at all points in the circuit
315
+ execution, if the lifetime of a virtual qubit state can be shortened, though Qiskit's built-in
316
+ pipelines do not use this currently.
317
+
318
+ .. image:: /source_images/mapping.png
319
+ :alt: Illustration of how virtual qubits from an input circuit could be mapped to hardware
320
+ qubits on a backend device's connectivity map.
321
+
322
+ The layout stage is not responsible for ensuring that the connectivity of the target
323
+ is respected all the way through the circuit, nor that all operations are valid for direct execution
324
+ on the target; these are the responsibilities of the :ref:`routing
325
+ <transpiler-preset-stage-routing>` and :ref:`translation <transpiler-preset-stage-translation>`
326
+ stages, respectively.
327
+
328
+ The choice of initial layout is one of the most important factors that affects the quality of the
329
+ output circuit. The layout stage is often the most computationally expensive stage in the default
330
+ pipelines; the default plugin for layout even tries several different algorithms (described in more
331
+ detail in :ref:`transpiler-preset-stage-layout-default`).
332
+
333
+ The ideal situation for the layout stage is to find a "perfect" layout, where all operations
334
+ respect the connectivity constraints of the :class:`.Target` such that the routing stage
335
+ is not required. This is typically not possible for arbitrary input circuits, but when it is, the
336
+ :class:`.VF2Layout` pass can be used to find a valid initial layout. If multiple perfect layouts
337
+ are found, a scoring heuristic based on estimated error rates is used to decide which one to use.
338
+
339
+ In all built-in plugins, passing the :func:`.generate_preset_pass_manager` argument
340
+ ``initial_layout`` causes the given layout to be used verbatim, skipping the individual "choosing"
341
+ logic. All built-in plugins also handle embedding the circuit into the full width of the device,
342
+ including assigning ancillas.
343
+
344
+ If you write your own layout plugin, you might find :func:`.generate_embed_passmanager` useful for
345
+ automating the "embedding" stage of the layout application.
346
+
347
+ When writing :ref:`stage plugins <transpiler-preset-stage-plugins>`, the entry point for ``layout``
348
+ is ``qiskit.transpiler.layout``. The built-in plugins are:
349
+
350
+ .. list-table::
351
+ :header-rows: 1
352
+
353
+ * - Method
354
+ - Summary
355
+
356
+ * - :ref:`default <transpiler-preset-stage-layout-default>`
357
+ - At the highest optimization levels, attempts to find a perfect layout, then tries a
358
+ Sabre-based layout-and-routing combined pass.
359
+
360
+ * - :ref:`dense <transpiler-preset-stage-layout-dense>`
361
+ - Finds the densest subgraph (in terms of qubit link degrees) of the backend to use as the
362
+ initial qubits.
363
+
364
+ * - :ref:`trivial <transpiler-preset-stage-layout-trivial>`
365
+ - Maps virtual qubit 0 to physical qubit 0, and so on.
366
+
367
+ * - :ref:`sabre <transpiler-preset-stage-layout-sabre>`
368
+ - Uses `Qiskit's enhanced Sabre layout algorithm <sabre-lightsabre-paper_>`_.
369
+
370
+ At all optimization levels, the default layout method is ``default``, though the structure of this
371
+ stage changes dramatically based on the level.
372
+
373
+ .. _transpiler-preset-stage-layout-default:
374
+
375
+ Built-in ``default`` plugin
376
+ ...........................
377
+
378
+ An amalgamation of several different layout techniques.
379
+
380
+ At optimization level 0, the trivial layout is chosen.
381
+
382
+ At optimization levels above 0, there is a two-step process:
383
+
384
+ #. First, use :class:`.VF2Layout` to attempt to find a "perfect" layout. The maximum number of
385
+ calls to the isomorphism evaluator increases with the optimization level. For huge, complex
386
+ targets, we are not guaranteed to find perfect layouts even if they exist, but the chance
387
+ increases with the optimization level.
388
+
389
+ #. If no perfect layout can be found, use :class:`.SabreLayout` to choose an initial layout, with
390
+ the numbers of initial layout trials, swap-map trials, and forwards–backwards iterations
391
+ increasing with the optimization level.
392
+
393
+ In addition, optimization level 1 also tries the trivial layout before the VF2-based version,
394
+ for historical backwards compatibility.
395
+
396
+
397
+ .. _transpiler-preset-stage-layout-dense:
398
+
399
+ Built-in ``dense`` plugin
400
+ .........................
401
+
402
+ Uses the :class:`.DenseLayout` pass to choose the layout. This pass finds the densest connected
403
+ subgraph of the complete target connectivity graph, where "densest" means that hardware qubits with
404
+ the greatest number of available connections are preferred. The virtual-to-hardware mapping is
405
+ completed by assigning the highest-degree virtual qubits to the highest-degree hardware qubits.
406
+
407
+ This is a relatively cheap heuristic for choosing an initial layout, but typically has far worse
408
+ output quality than Sabre-based methods. The :ref:`default layout plugin
409
+ <transpiler-preset-stage-layout-default>` uses the initial mapping selected by :class:`.DenseLayout`
410
+ as one of its initial layouts to seed the Sabre algorithm.
411
+
412
+ .. _transpiler-preset-stage-layout-trivial:
413
+
414
+ Built-in ``trivial`` plugin
415
+ ...........................
416
+
417
+ Uses the :class:`.TrivialLayout` pass to choose the layout. This is the simplest assignment, where
418
+ each virtual qubit is assigned to the hardware qubit with the same index, so virtual qubit 0 is
419
+ mapped to hardware qubit 0, and so on.
420
+
421
+ This method is most useful for hardware-characterization experiments, where the incoming "abstract"
422
+ circuit is already full-width on the device, its operations correspond to physical operations, and
423
+ the transpiler is just being invoked to formalize the creation of a physical
424
+ :class:`.QuantumCircuit`.
425
+
426
+
427
+ .. _transpiler-preset-stage-layout-sabre:
428
+
429
+ Built-in ``sabre`` plugin
430
+ .........................
431
+
432
+ Uses the :class:`.SabreLayout` to choose an initial layout, using Qiskit's modified :ref:`Sabre
433
+ routing algorithm <transpiler-preset-stage-routing-sabre>` as the subroutine to swap-map the
434
+ candidate circuit both forwards and backwards.
435
+
436
+ Summarily, the layout component of `the original Sabre algorithm <sabre-original-paper_>`_
437
+ chooses an initial layout arbitrarily, then tries to "improve" it by running routing on the circuit,
438
+ reversing the circuit, and running routing on the reversed circuit with the previous "final"
439
+ virtual-to-hardware assignment as the initial state. The configured optimization level decides how
440
+ many iterations of this to-and-fro to do, and how many different random initial layouts to try.
441
+
442
+ The principal difference to the :ref:`default stage <transpiler-preset-stage-layout-default>` at
443
+ optimization levels other than 0 is that this plugin *only* runs the Sabre-based algorithm. It
444
+ does not attempt to find a perfect layout, nor attempt the trivial layout.
445
+
446
+
447
+
448
+ .. _transpiler-preset-stage-routing:
449
+
450
+ Routing stage
451
+ -------------
452
+
453
+ .. seealso::
454
+ `Routing stage explanation <https://docs.quantum.ibm.com/guides/transpiler-stages#routing-stage>`__
455
+ Higher-level user-facing explanation of the routing stage in the IBM Quantum guide.
456
+
457
+ The routing stage ensures that the virtual connectivity graph of the circuit is compatible with the
458
+ hardware connectivity graph of the target. In simpler terms, the routing stage makes sure that all
459
+ two-qubit gates in the circuit are mapped to hardware qubits that have a defined two-qubit operation
460
+ in the target ISA. You may also see this problem referred to as the "mapping" or "swap-mapping"
461
+ problem in other toolkits or literature.
462
+
463
+ Routing algorithms typically do this by inserting ``swap`` gates into the circuit, and modifying the
464
+ virtual-to-hardware mapping of qubits over the course of the circuit execution.
465
+
466
+ The routing stage does not need to ensure that all the gates in the circuit are valid for the target
467
+ ISA. For example, a routing plugin can leave literal ``swap`` gates in the circuit, even if the
468
+ :class:`.Target` does not contain :class:`.SwapGate`. However, there must be at least one two-qubit
469
+ gate defined in the :class:`.Target` for any pair of hardware qubits that has a gate applied in the
470
+ circuit.
471
+
472
+ The routing stage must set the ``final_layout`` and ``virtual_permutation_layout`` properties in
473
+ the :class:`.PropertySet` if routing has taken place.
474
+
475
+ All of Qiskit's built-in routing stages will additionally run the :class:`.VF2PostLayout` pass after
476
+ routing. This might reassign the initial layout, if lower-error qubits can be found. This
477
+ pass is very similar to the :class:`.VF2Layout` class that :ref:`the default layout plugin
478
+ <transpiler-preset-stage-layout-default>` uses, except in :class:`.VF2PostLayout` we can guarantee
479
+ that there is at least one isomorphic induced subgraph of the target topology that matches the
480
+ circuit topology.
481
+
482
+ .. note::
483
+
484
+ Qiskit's built-in routing plugins all generally assume that all pairs of qubits with a
485
+ defined two-qubit link have a *universal* set of gates defined for those two qubits. Hardware
486
+ does not necessarily need to respect this (for example, if the only defined two-qubit gate is
487
+ ``swap``, then entangling operations like ``cx`` cannot be realized), but Qiskit does not yet
488
+ consider this possibility.
489
+
490
+ .. note::
491
+
492
+ Finding the minimal number of swaps to insert is known to be a non-polynomial problem. This
493
+ means it is prohibitively expensive to attempt, so many of Qiskit's built-in algorithms are
494
+ stochastic, and you may see large variations between different compilations. If you need
495
+ reproducibility, be sure to set the ``seed_transpiler`` argument of
496
+ :func:`.generate_preset_pass_manager` or :func:`.transpile`.
497
+
498
+ When writing :ref:`stage plugins <transpiler-preset-stage-plugins>`, the entry point for ``routing``
499
+ is ``qiskit.transpiler.routing``. The built-in plugins are:
500
+
501
+ .. list-table::
502
+ :header-rows: 1
503
+
504
+ * - Method
505
+ - Summary
506
+
507
+ * - :ref:`sabre <transpiler-preset-stage-routing-sabre>`
508
+ - Default. Uses `Qiskit's modified Sabre routing algorithm <sabre-lightsabre-paper_>`_ to
509
+ swap map.
510
+
511
+ * - :ref:`none <transpiler-preset-stage-routing-none>`
512
+ - Disable routing. Raises an error if routing is required.
513
+
514
+ * - :ref:`basic <transpiler-preset-stage-routing-basic>`
515
+ - Greedy swap insertion to route a single operation at a time.
516
+
517
+ * - :ref:`stochastic <transpiler-preset-stage-routing-stochastic>`
518
+ - Consider operations layer-by-layer, using a stochastic algorithm to find swap networks that
519
+ implement a suitable permutation to make the layer executable.
520
+
521
+ * - :ref:`lookahead <transpiler-preset-stage-routing-lookahead>`
522
+ - Breadth-first search with heuristic pruning to find swaps that make gates executable.
523
+
524
+ .. _transpiler-preset-stage-routing-none:
525
+
526
+ Built-in ``none`` plugin
527
+ ........................
528
+
529
+ A dummy plugin used to disable routing entirely. This can occasionally be useful for
530
+ hardware-configuration experiments, or in certain special cases of partial compilation.
531
+
532
+ .. _transpiler-preset-stage-routing-basic:
533
+
534
+ Built-in ``basic`` plugin
535
+ .........................
536
+
537
+ Uses the :class:`.BasisSwap` greedy swap-insertion algorithm. This is conceptually very simple; for
538
+ each operation in topological order, insert the shortest-path swaps needed to make the connection
539
+ executable on the device.
540
+
541
+ The optimization level only affects the amount of work the :class:`.VF2PostLayout` step does to
542
+ attempt to improve the initial layout after routing.
543
+
544
+ This method typically has poor output quality.
545
+
546
+ .. _transpiler-preset-stage-routing-stochastic:
547
+
548
+ Built-in ``stochastic`` plugin
549
+ ..............................
550
+
551
+ .. deprecated:: 1.3
552
+ Use :ref:`transpiler-preset-stage-routing-sabre` instead.
553
+
554
+ Uses the :class:`.StochasticSwap` algorithm to route. In short, this stratifies the circuit into
555
+ layers, then uses a stochastic algorithm to find a permutation that will allow the layer to execute,
556
+ and a series of swaps that will implement that permutation in a hardware-valid way.
557
+
558
+ The optimization level affects the number of stochastic trials used for each layer, and the amount
559
+ of work spent in :class:`.VF2PostLayout` to optimize the initial layout.
560
+
561
+ This was Qiskit's primary routing algorithm for several years, until approximately 2021. Now, it
562
+ is reliably beaten in runtime and output quality by :ref:`Qiskit's custom Sabre-based routing
563
+ algorithm <transpiler-preset-stage-routing-sabre>`.
564
+
565
+ .. _transpiler-preset-stage-routing-lookahead:
566
+
567
+ Built-in ``lookahead`` plugin
568
+ .............................
569
+
570
+ Uses the :class:`.LookaheadSwap` algorithm to route. This is essentially a breadth-first search
571
+ at producing a swap network, where the tree being explored is pruned down to a small number of
572
+ candidate swaps at each depth.
573
+
574
+ This algorithm is similar to the ``basic`` heuristic of :ref:`the "sabre" plugin
575
+ <transpiler-preset-stage-routing-sabre>`, except it considers the following effects of each swap to
576
+ a small depth as well.
577
+
578
+ The optimization level affects the search depth, the amount of per-depth pruning, and amount of work
579
+ done by :class:`.VF2PostLayout` to post-optimize the initial layout.
580
+
581
+ In practice, :ref:`the "sabre" plugin <transpiler-preset-stage-routing-sabre>` runs several orders
582
+ of magnitude faster, and produces better output.
583
+
584
+ .. _transpiler-preset-stage-routing-sabre:
585
+
586
+ Built-in ``sabre`` plugin
587
+ .........................
588
+
589
+ Uses the :class:`.SabreSwap` algorithm to route. This uses `Qiskit's enhanced version
590
+ <sabre-lightsabre-paper_>`_ of `the original Sabre routing algorithm <sabre-original-paper_>`_.
591
+
592
+ This routing algorithm runs with threaded parallelism to consider several different possibilities
593
+ for routing, choosing the one that minimizes the number of inserted swaps.
594
+
595
+ The optimization level affects how many different stochastic seeds are attempted for the full
596
+ routing, and the amount of work done by :class:`.VF2PostLayout` to post-optimize the initial layout.
597
+
598
+ This is almost invariably the best-performing built-in plugin, and the one Qiskit uses by default in
599
+ all cases where routing is necessary.
600
+
601
+ .. _transpiler-preset-stage-translation:
602
+
603
+ Translation stage
604
+ -----------------
605
+
606
+ .. seealso::
607
+ `Translation stage explanation`__
608
+ Higher-level user-facing explanation of the translation stage in the IBM Quantum guide.
609
+
610
+ .. __: https://docs.quantum.ibm.com/guides/transpiler-stages#translation-stage
611
+
612
+ The translation stage is responsible for rewriting all gates in the circuit into ones that are
613
+ supported by the target ISA. For example, if a ``cx`` is requested on hardware qubits 0 and 1, but
614
+ the ISA only contains a ``cz`` operation on those qubits, the translation stage must find a way of
615
+ representing the ``cx`` gate using the ``cz`` and available one-qubit gates.
616
+
617
+ .. note::
618
+
619
+ In Qiskit 1.x, translation plugins need not output gates with the correct
620
+ directionality, provided the gate exists with opposite directionality on the given qubit pair.
621
+ For example, if ``cx(0, 1)`` is ISA-supported, the translation stage can output
622
+ ``cx(1, 0)``.
623
+
624
+ This is likely to change in later versions of Qiskit.
625
+
626
+ The translation stage is called before entering the optimization stage. Optimization plugins
627
+ (including Qiskit's built-in plugins) may also use the translation stage as a "fixup" stage after
628
+ the optimization loop, if the optimization loop returns a circuit that includes non-ISA gates. This
629
+ latter situation is fairly common; the optimization loop may only be concerned with minimizing
630
+ properties like "number of two-qubit gates", and will leave its output in terms of locally
631
+ equivalent gates, which the translation stage can easily rewrite without affecting the target
632
+ optimization properties. This allows easier separation of concerns between the two stages. Some
633
+ optimization plugins may be stricter in their output, and so this follow-up to the translation stage
634
+ may no longer be necessary.
635
+
636
+ When writing :ref:`stage plugins <transpiler-preset-stage-plugins>`, the entry point for
637
+ ``translation`` is ``qiskit.transpiler.translation``. The built-in plugins are:
638
+
639
+ .. list-table::
640
+ :header-rows: 1
641
+
642
+ * - Method
643
+ - Summary
644
+
645
+ * - :ref:`translator <transpiler-preset-stage-translation-translator>`
646
+ - Symbolic translation of gates to the target basis using known equivalences.
647
+
648
+ * - :ref:`synthesis <transpiler-preset-stage-translation-synthesis>`
649
+ - Collect each run of one- and two-qubit gates into a matrix representation, and resynthesize
650
+ from there.
651
+
652
+ .. _transpiler-preset-stage-translation-synthesis:
653
+
654
+ Built-in ``synthesis`` plugin
655
+ .............................
656
+
657
+ Collect runs of gates on the same qubits into matrix form, and then resynthesize using the
658
+ :class:`.UnitarySynthesis` pass (with the configured ``unitary_synthesis_method``). This is, in
659
+ large part, similar to the optimization loop itself at high optimization levels.
660
+
661
+ The collection into matrices is typically more expensive than matrix-free translations, but in
662
+ principle the quality of the translations can be better. In practice, this requires a synthesis
663
+ algorithm tailored to the target ISA, which makes this method less general than other methods. It
664
+ can produce higher-quality results when targeting simple ISAs that match the synthesis routines
665
+ already in Qiskit.
666
+
667
+ If this method is used, you might not need the optimization loop.
668
+
669
+ The optimization level has no effect on this plugin.
670
+
671
+
672
+ .. _transpiler-preset-stage-translation-translator:
673
+
674
+ Built-in ``translator`` plugin
675
+ ..............................
676
+
677
+ Uses the :class:`.BasisTranslator` algorithm to symbolically translate gates into the target basis.
678
+ At a high level, this starts from the set of gates requested by the circuit, and uses rules from a
679
+ given :class:`.EquivalenceLibrary` (typically the :data:`.SessionEquivalenceLibrary`) to move
680
+ towards the ISA.
681
+
682
+ This is the default translation method.
683
+
684
+ The optimization level has no effect on this plugin.
685
+
686
+
687
+ .. _transpiler-preset-stage-optimization:
688
+
689
+ Optimization stage
690
+ ------------------
691
+
692
+ .. seealso::
693
+ `Optimization stage explanation`__
694
+ Higher-level user-facing explanation of the optimization stage in the IBM Quantum guide.
695
+
696
+ .. __: https://docs.quantum.ibm.com/guides/transpiler-stages#optimization-stage
697
+
698
+ The optimization stage is for low-level hardware-aware optimizations. Unlike :ref:`the init stage
699
+ <transpiler-preset-stage-init>`, the input to this stage is a circuit that is already
700
+ ISA-compatible, so a low-level optimization plugin can be tailored for a particular ISA.
701
+
702
+ There are very few requirements on an optimization plugin, other than it takes in ISA-supported
703
+ circuits, and returns ISA-supported circuits. An optimization plugin will often contain a loop,
704
+ such as the :class:`.DoWhileController`, and might include the configured translation stage
705
+ as a fix-up pipeline.
706
+
707
+ Qiskit's built-in optimization plugins are general, and apply well to most real-world ISAs for
708
+ non-error-corrected devices. The built-in plugins are less well-suited to ISAs that have no
709
+ continuously parametrized single-qubit gate, such as a Clifford+T basis set.
710
+
711
+ When writing :ref:`stage plugins <transpiler-preset-stage-plugins>`, the entry point for
712
+ ``optimization`` is ``qiskit.transpiler.optimization``. The built-in plugins are:
713
+
714
+ .. list-table::
715
+ :header-rows: 1
716
+
717
+ * - Method
718
+ - Summary
719
+
720
+ * - :ref:`default <transpiler-preset-stage-optimization-default>`
721
+ - A default set of optimization passes. This varies significantly between optimization
722
+ levels.
723
+
724
+ .. _transpiler-preset-stage-optimization-default:
725
+
726
+ Built-in ``default`` plugin
727
+ ...........................
728
+
729
+ This varies significantly between optimization levels.
730
+
731
+ The specifics of this pipeline are subject to change between Qiskit versions. The broad principles
732
+ are described below.
733
+
734
+ At optimization level 0, the stage is empty.
735
+
736
+ At optimization level 1, the stage does matrix-based resynthesis of runs of single-qubit gates, and
737
+ very simple symbolic inverse cancellation of two-qubit gates, if they appear consecutively. This
738
+ runs in a loop until the size and depth of the circuit are fixed.
739
+
740
+ At optimization level 2, in addition the optimizations of level 1, the loop contains commutation
741
+ analysis of sets of gates to widen the range of gates that can be considered for cancellation.
742
+ Before the loop, runs of both one- and two-qubit gates undergo a single matrix-based resynthesis.
743
+
744
+ At optimization level 3, the two-qubit matrix-based resynthesis runs inside the optimization loop.
745
+ The optimization loop condition also tries multiple runs and chooses the minimum point in the case
746
+ of fluctuating output; this is necessary because matrix-based resynthesis is relatively unstable in
747
+ terms of concrete gates.
748
+
749
+ Optimization level 3 is typically very expensive for large circuits.
750
+
751
+
752
+ .. _transpiler-preset-stage-scheduling:
753
+
754
+ Scheduling stage
755
+ ----------------
756
+
757
+ .. seealso::
758
+ :ref:`transpiler-scheduling-description`
759
+ A guide-level explanation of scheduling concepts.
760
+
761
+ The scheduling stage, if requested, is responsible for inserting explicit :class:`~.circuit.Delay`
762
+ instructions to make idle periods of qubits explicit. Plugins may optionally choose to do
763
+ walltime-sensitive transformations, such as inserting dynamical decoupling sequences.
764
+
765
+ The input to the scheduling stage is an ISA-compatible circuit. The output of the scheduling stage
766
+ must also be an ISA-compatible circuit, with explicit :class:`~.circuit.Delay` instructions that
767
+ satisfy the hardware's timing information, if appropriate.
768
+
769
+ The scheduling stage should set the ``node_start_time`` property in the pipeline's
770
+ :class:`.PropertySet`.
771
+
772
+ When writing :ref:`stage plugins <transpiler-preset-stage-plugins>`, the entry point for
773
+ ``scheduling`` is ``qiskit.transpiler.scheduling``. The built-in plugins are:
774
+
775
+ .. list-table::
776
+ :header-rows: 1
777
+
778
+ * - Method
779
+ - Summary
780
+
781
+ * - :ref:`default <transpiler-preset-stage-scheduling-default>`
782
+ - Attempt to satisfy timing alignment constraints without otherwise scheduling.
783
+
784
+ * - :ref:`alap <transpiler-preset-stage-scheduling-alap>`
785
+ - Schedule the circuit, preferring operations to be as late as possible.
786
+
787
+ * - :ref:`asap <transpiler-preset-stage-scheduling-asap>`
788
+ - Schedule the circuit, preferring operations to be as soon as possible.
789
+
790
+ .. _transpiler-preset-stage-scheduling-default:
791
+
792
+ Built-in ``default`` plugin
793
+ ...........................
794
+
795
+ Do nothing, unless the circuit already contains instructions with explicit timings. If there are
796
+ explicitly timed operations in the circuit, insert additional padding to ensure that these timings
797
+ satisfy the alignment and other hardware constraints.
798
+
799
+ .. _transpiler-preset-stage-scheduling-alap:
800
+
801
+ Builtin ``alap`` plugin
802
+ .......................
803
+
804
+ Explicitly schedule all operations using an "as late as possible" strategy. This uses the
805
+ :class:`.ALAPScheduleAnalysis` algorithm to decide where to place gates.
806
+
807
+ .. _transpiler-preset-stage-scheduling-asap:
808
+
809
+ Builtin ``asap`` plugin
810
+ .......................
811
+
812
+ Explicitly schedule all operations using an "as soon as possible" strategy. This uses the
813
+ :class:`.ASAPScheduleAnalysis` algorithm to decide where to place gates.
814
+
815
+
816
+ Custom pass managers
154
817
  ====================
155
818
 
156
819
  In addition to modifying preset pass managers, it is also possible to construct a pass
@@ -158,7 +821,11 @@ manager to build an entirely custom pipeline for transforming input
158
821
  circuits. You can use the :class:`~.StagedPassManager` class directly to do
159
822
  this. You can define arbitrary stage names and populate them with a :class:`~.PassManager`
160
823
  instance. For example, the following code creates a new :class:`~.StagedPassManager`
161
- that has 2 stages, ``init`` and ``translation``.::
824
+ that has two stages, ``init`` and ``translation``.
825
+
826
+ .. plot::
827
+ :include-source:
828
+ :nofigs:
162
829
 
163
830
  from qiskit.transpiler.passes import (
164
831
  UnitarySynthesis,
@@ -183,12 +850,13 @@ that has 2 stages, ``init`` and ``translation``.::
183
850
  stages=["init", "translation"], init=init, translation=translate
184
851
  )
185
852
 
186
- There is no limit on the number of stages you can put in a :class:`~.StagedPassManager`.
853
+ There is no limit on the number of stages you can put in a :class:`~.StagedPassManager`. The stages
854
+ do not need to correspond to the stages used by Qiskit's preset pipelines.
187
855
 
188
- The :ref:`stage_generators` may be useful for the construction of custom :class:`~.StagedPassManager`s.
189
- They generate pass managers which provide common functionality used in many stages.
190
- For example, :func:`~.generate_embed_passmanager` generates a :class:`~.PassManager`
191
- to "embed" a selected initial :class:`~.Layout` from a layout pass to the specified target device.
856
+ The :ref:`stage_generators` may be useful for the construction of custom :class:`~.StagedPassManager`
857
+ instances. They generate pass managers which provide common functionality used in many stages. For
858
+ example, :func:`~.generate_embed_passmanager` generates a :class:`~.PassManager` to "embed" a
859
+ selected initial :class:`~.Layout` from a layout pass to the specified target device.
192
860
 
193
861
  Representing Quantum Computers
194
862
  ==============================
@@ -331,6 +999,7 @@ example 3 qubit :class:`~.Target` above:
331
999
 
332
1000
  .. plot::
333
1001
  :include-source:
1002
+ :alt: Output from the previous code.
334
1003
 
335
1004
  from qiskit.circuit import Parameter, Measure
336
1005
  from qiskit.transpiler import Target, InstructionProperties
@@ -390,6 +1059,7 @@ see the individual connectivity, you can pass the operation name to
390
1059
  :meth:`.CouplingMap.build_coupling_map`:
391
1060
 
392
1061
  .. plot::
1062
+ :alt: Output from the previous code.
393
1063
  :include-source:
394
1064
 
395
1065
  from qiskit.circuit import Parameter, Measure
@@ -445,6 +1115,7 @@ see the individual connectivity, you can pass the operation name to
445
1115
  target.build_coupling_map('cx').draw()
446
1116
 
447
1117
  .. plot::
1118
+ :alt: Output from the previous code.
448
1119
  :include-source:
449
1120
 
450
1121
  from qiskit.circuit import Parameter, Measure
@@ -499,445 +1170,19 @@ see the individual connectivity, you can pass the operation name to
499
1170
 
500
1171
  target.build_coupling_map('cz').draw()
501
1172
 
502
- .. _transpiler_stage_descriptions:
503
-
504
- Transpiler Stage Details
505
- ========================
506
-
507
- Below are a description of the default transpiler stages and the problems
508
- they solve. The default passes used for each stage are described, but
509
- the specifics are configurable via the ``*_method`` keyword arguments for
510
- the :func:`~.transpile` and :func:`~.generate_preset_pass_manager` functions
511
- which can be used to override the methods described in this section.
512
-
513
- .. _translation_stage:
514
-
515
- Translation Stage
516
- -----------------
517
-
518
- When writing a quantum circuit you are free to use any quantum gate (unitary operator) that
519
- you like, along with a collection of non-gate operations such as qubit measurements and
520
- reset operations. However, most quantum devices only natively support a handful of quantum gates
521
- and non-gate operations. The allowed instructions for a given backend can be found by querying the
522
- :class:`~.Target` for the devices:
523
-
524
- .. code-block::
525
-
526
- from qiskit.providers.fake_provider import GenericBackendV2
527
- backend = GenericBackendV2(5)
528
-
529
- print(backend.target)
530
-
531
- Every quantum circuit run on the target device must be expressed using only these instructions.
532
- For example, to run a simple phase estimation circuit:
533
-
534
- .. plot::
535
- :include-source:
536
-
537
- import numpy as np
538
- from qiskit import QuantumCircuit
539
- from qiskit.providers.fake_provider import GenericBackendV2
540
-
541
- backend = GenericBackendV2(5)
542
-
543
- qc = QuantumCircuit(2, 1)
544
-
545
- qc.h(0)
546
- qc.x(1)
547
- qc.cp(np.pi/4, 0, 1)
548
- qc.h(0)
549
- qc.measure([0], [0])
550
- qc.draw(output='mpl')
551
-
552
- We have :math:`H`, :math:`X`, and controlled-:math:`P` gates, none of which are
553
- in our device's basis gate set, and thus must be translated.
554
- We can
555
- transpile the circuit to show what it will look like in the native gate set of
556
- the target IBM Quantum device (the :class:`~.GenericBackendV2` class generates
557
- a fake backend with a specified number of qubits for test purposes):
558
-
559
- .. plot::
560
- :include-source:
561
-
562
- from qiskit import transpile
563
- from qiskit import QuantumCircuit
564
- from qiskit.providers.fake_provider import GenericBackendV2
565
-
566
- backend = GenericBackendV2(5)
567
-
568
- qc = QuantumCircuit(2, 1)
569
-
570
- qc.h(0)
571
- qc.x(1)
572
- qc.cp(np.pi/4, 0, 1)
573
- qc.h(0)
574
- qc.measure([0], [0])
575
-
576
- qc_basis = transpile(qc, backend)
577
- qc_basis.draw(output='mpl')
578
-
579
- A few things to highlight. First, the circuit has gotten longer with respect to the
580
- original. This can be verified by checking the depth of both circuits:
581
-
582
- .. code-block::
583
-
584
- print('Original depth:', qc.depth(), 'Decomposed Depth:', qc_basis.depth())
585
-
586
- .. code-block:: text
587
-
588
- Original depth: 4 Decomposed Depth: 10
589
-
590
- Second, although we had a single controlled gate, the fact that it was not in the basis
591
- set means that, when expanded, it requires more than a single :class:`~.CXGate` to implement.
592
- All said, unrolling to the basis set of gates leads to an increase in the depth of a
593
- quantum circuit and the number of gates.
594
-
595
- It is important to highlight two special cases:
596
-
597
- 1. If A swap gate is not a native gate and must be decomposed this requires three CNOT gates:
598
-
599
- .. code-block::
600
-
601
- from qiskit.providers.fake_provider import GenericBackendV2
602
- backend = GenericBackendV2(5)
603
-
604
- print(backend.operation_names)
605
-
606
- .. code-block:: text
607
-
608
- ['id', 'rz', 'sx', 'x', 'cx', 'measure', 'delay']
609
-
610
- .. plot:
611
- :include-source:
612
-
613
- from qiskit.circuit import QuantumCircuit
614
1173
 
615
- swap_circ = QuantumCircuit(2)
616
- swap_circ.swap(0, 1)
617
- swap_circ.decompose().draw(output='mpl')
1174
+ .. _transpiler-scheduling-description:
618
1175
 
619
- As a product of three CNOT gates, swap gates are expensive operations to perform on
620
- noisy quantum devices. However, such operations are usually necessary for embedding a
621
- circuit into the limited gate connectivities of many devices. Thus,
622
- minimizing the number of swap gates in a circuit is a primary goal in the
623
- transpilation process.
1176
+ Scheduling of circuits
1177
+ ======================
624
1178
 
1179
+ ..
1180
+ This section is still here because the content hasn't fully migrated to other places yet, unlike
1181
+ other discussions of the components of quantum compilation.
625
1182
 
626
- 2. A Toffoli, or controlled-controlled-not gate (``ccx``), is a three-qubit gate. Given
627
- that our basis gate set includes only single- and two-qubit gates, it is obvious that
628
- this gate must be decomposed. This decomposition is quite costly:
629
-
630
- .. plot::
631
- :include-source:
632
-
633
- from qiskit.circuit import QuantumCircuit
634
-
635
- ccx_circ = QuantumCircuit(3)
636
- ccx_circ.ccx(0, 1, 2)
637
- ccx_circ.decompose().draw(output='mpl')
638
-
639
- For every Toffoli gate in a quantum circuit, the hardware may execute up to six CNOT
640
- gates, and a handful of single-qubit gates. From this example, it should be
641
- clear that any algorithm that makes use of multiple Toffoli gates will end up as a
642
- circuit with large depth and will therefore be appreciably affected by noise and gate
643
- errors.
644
-
645
-
646
- .. _layout_stage:
647
-
648
- Layout Stage
649
- ------------
650
-
651
- Quantum circuits are abstract entities whose qubits are "virtual" representations of actual
652
- qubits used in computations. We need to be able to map these virtual qubits in a one-to-one
653
- manner to the "physical" qubits in an actual quantum device.
654
-
655
- .. image:: /source_images/mapping.png
656
-
657
-
658
- By default, qiskit will do this mapping for you. The choice of mapping depends on the
659
- properties of the circuit, the particular device you are targeting, and the optimization
660
- level that is chosen. The choice of initial layout is extremely important for minimizing the
661
- number of swap operations needed to map the input circuit onto the device topology and
662
- for minimizing the loss due to non-uniform noise properties across a device. Due to the
663
- importance of this stage, the preset pass managers
664
- try a few different methods to find the best layout. Typically this involves 2 steps: first,
665
- trying to find a "perfect" layout (a layout which does not require any swap operations), and then,
666
- a heuristic pass that tries to find the best layout to use if a perfect layout cannot be found.
667
- There are 2 passes typically used for the first stage:
668
-
669
- - :class:`~.VF2Layout`: Models layout selection as a subgraph isomorphism problem and tries
670
- to find a subgraph of the connectivity graph that is isomorphic to the
671
- graph of 2 qubit interactions in the circuit. If more than one isomorphic mapping is found a
672
- scoring heuristic is run to select the mapping which would result in the lowest average error
673
- when executing the circuit.
674
-
675
- - :class:`~.TrivialLayout`: Maps each virtual qubit to the same numbered physical qubit on the device,
676
- i.e. ``[0,1,2,3,4]`` -> ``[0,1,2,3,4]``. This is historical behavior used only in
677
- ``optimization_level=1`` to try to find a perfect layout. If it fails to do so, :class:`~.VF2Layout`
678
- is tried next.
679
-
680
- Next, for the heuristic stage, 2 passes are used by default:
681
-
682
- - :class:`~.SabreLayout`: Selects a layout by starting from an initial random layout and then
683
- repeatedly running a routing algorithm (by default :class:`~.SabreSwap`) both forward and
684
- backward over the circuit, using the permutation caused by swap insertions to adjust that
685
- initial random layout. For more details you can refer to the paper describing the algorithm:
686
- `arXiv:1809.02573 <https://arxiv.org/abs/1809.02573>`__
687
- :class:`~.SabreLayout` is used to select a layout if a perfect layout isn't found for
688
- optimization levels 1, 2, and 3.
689
- - :class:`~.TrivialLayout`: Always used for the layout at optimization level 0.
690
-
691
- There are other passes than can be used for the heuristic stage, but are not included in the default
692
- pipeline, such as:
693
-
694
- - :class:`~.DenseLayout`: Finds the sub-graph of the device with greatest connectivity
695
- that has the same number of qubits as the circuit.
696
-
697
- Let's see what layouts are automatically picked at various optimization levels. The circuits
698
- returned by :func:`qiskit.compiler.transpile` are annotated with this initial layout information,
699
- and we can view this layout selection graphically using
700
- :func:`qiskit.visualization.plot_circuit_layout`:
701
-
702
- .. plot::
703
- :include-source:
704
-
705
- from qiskit import QuantumCircuit, transpile
706
- from qiskit.visualization import plot_circuit_layout
707
- from qiskit.providers.fake_provider import Fake5QV1
708
- backend = Fake5QV1()
709
-
710
- ghz = QuantumCircuit(3, 3)
711
- ghz.h(0)
712
- ghz.cx(0,range(1,3))
713
- ghz.barrier()
714
- ghz.measure(range(3), range(3))
715
- ghz.draw(output='mpl')
716
-
717
-
718
- - **Layout Using Optimization Level 0**
719
-
720
- .. plot::
721
- :include-source:
722
-
723
- from qiskit import QuantumCircuit, transpile
724
- from qiskit.visualization import plot_circuit_layout
725
- from qiskit.providers.fake_provider import Fake5QV1
726
- backend = Fake5QV1()
727
-
728
- ghz = QuantumCircuit(3, 3)
729
- ghz.h(0)
730
- ghz.cx(0,range(1,3))
731
- ghz.barrier()
732
- ghz.measure(range(3), range(3))
733
-
734
- new_circ_lv0 = transpile(ghz, backend=backend, optimization_level=0)
735
- plot_circuit_layout(new_circ_lv0, backend)
736
-
737
- - **Layout Using Optimization Level 3**
738
-
739
- .. plot::
740
- :include-source:
741
-
742
- from qiskit import QuantumCircuit, transpile
743
- from qiskit.visualization import plot_circuit_layout
744
- from qiskit.providers.fake_provider import Fake5QV1
745
- backend = Fake5QV1()
746
-
747
- ghz = QuantumCircuit(3, 3)
748
- ghz.h(0)
749
- ghz.cx(0,range(1,3))
750
- ghz.barrier()
751
- ghz.measure(range(3), range(3))
752
-
753
- new_circ_lv3 = transpile(ghz, backend=backend, optimization_level=3)
754
- plot_circuit_layout(new_circ_lv3, backend)
755
-
756
-
757
- It is possible to override automatic layout selection by specifying an initial layout. To do so we can
758
- pass a list of integers to :func:`qiskit.compiler.transpile` via the `initial_layout`
759
- keyword argument, where the index labels the virtual qubit in the circuit and the
760
- corresponding value is the label for the physical qubit to map onto:
761
-
762
- .. plot::
763
- :include-source:
764
-
765
- from qiskit import QuantumCircuit, transpile
766
- from qiskit.visualization import plot_circuit_layout
767
- from qiskit.providers.fake_provider import Fake5QV1
768
- backend = Fake5QV1()
769
-
770
- ghz = QuantumCircuit(3, 3)
771
- ghz.h(0)
772
- ghz.cx(0,range(1,3))
773
- ghz.barrier()
774
- ghz.measure(range(3), range(3))
775
-
776
- # Virtual -> physical
777
- # 0 -> 3
778
- # 1 -> 4
779
- # 2 -> 2
780
-
781
- my_ghz = transpile(ghz, backend, initial_layout=[3, 4, 2])
782
- plot_circuit_layout(my_ghz, backend)
783
-
784
- .. _routing_stage:
785
-
786
- Routing Stage
787
- -------------
788
-
789
- In order to implement a 2-qubit gate between qubits in a quantum circuit that are not directly
790
- connected on a quantum device, one or more swap gates must be inserted into the circuit to
791
- move the qubit states around until they are adjacent on the device gate map. Each swap
792
- gate typically represents an expensive and noisy operation to perform. Thus, finding the
793
- minimum number of swap gates needed to map a circuit onto a given device, is an important
794
- step (if not the most important) in the whole execution process.
795
-
796
- However, as with many important things in life, finding the optimal swap mapping is hard.
797
- In fact it is in a class of problems called NP-hard, and is thus prohibitively expensive
798
- to compute for all but the smallest quantum devices and input circuits. To get around this,
799
- by default Qiskit uses a stochastic heuristic algorithm called :class:`~.SabreSwap` to compute
800
- a good, but not necessarily optimal swap mapping. The use of a stochastic method means the
801
- circuits generated by :func:`~.transpile`
802
- are not guaranteed to be the same over repeated runs. Indeed, running the same
803
- circuit repeatedly will in general result in a distribution of circuit depths and gate counts
804
- at the output.
805
-
806
- In order to highlight this, we run a GHZ circuit 100 times, using a "bad" (disconnected)
807
- ``initial_layout`` in a heavy hex coupling map:
808
-
809
- .. plot::
810
-
811
- from qiskit import QuantumCircuit, transpile
812
-
813
- ghz = QuantumCircuit(15)
814
- ghz.h(0)
815
- ghz.cx(0, range(1, 15))
816
- ghz.draw(output='mpl')
817
-
818
- .. plot::
819
- :include-source:
820
-
821
- import matplotlib.pyplot as plt
822
- from qiskit import QuantumCircuit, transpile
823
- from qiskit.providers.fake_provider import GenericBackendV2
824
- from qiskit.transpiler import CouplingMap
825
-
826
- coupling_map = CouplingMap.from_heavy_hex(3)
827
- backend = GenericBackendV2(coupling_map.size(), coupling_map=coupling_map)
828
-
829
- ghz = QuantumCircuit(15)
830
- ghz.h(0)
831
- ghz.cx(0, range(1, 15))
832
-
833
- depths = []
834
- for i in range(100):
835
- depths.append(
836
- transpile(
837
- ghz,
838
- backend,
839
- seed_transpiler=i,
840
- layout_method='trivial' # Fixed layout mapped in circuit order
841
- ).depth()
842
- )
843
-
844
- plt.figure(figsize=(8, 6))
845
- plt.hist(depths, align='left', color='#AC557C')
846
- plt.xlabel('Depth', fontsize=14)
847
- plt.ylabel('Counts', fontsize=14);
848
-
849
-
850
- This distribution is quite wide, signaling the difficulty the swap mapper is having
851
- in computing the best mapping. Most circuits will have a distribution of depths,
852
- perhaps not as wide as this one, due to the stochastic nature of the default swap
853
- mapper. Of course, we want the best circuit we can get, especially in cases where
854
- the depth is critical to success or failure. The :class:`~.SabreSwap` pass will by default by run its
855
- algorithm in parallel with multiple seed values and select the output which
856
- uses the fewest swaps. If you would like to increase the number of trials
857
- :class:`~.SabreSwap` runs you can refer to :ref:`working_with_preset_pass_managers`
858
- and modify the ``routing`` stage with a custom instance of :class:`~.SabreSwap`
859
- with a larger value for the ``trials`` argument.
860
-
861
- Typically, following the swap mapper, the routing stage in the preset pass managers
862
- also includes running the :class:`~.VF2PostLayout` pass. As its name implies,
863
- :class:`~.VF2PostLayout` uses the same basic algorithm as :class:`~.VF2Layout`,
864
- but instead of using it to find a perfect initial layout, it is designed to run after
865
- mapping and try to find a layout on qubits with lower error rates which will
866
- result in better output fidelity when running the circuit. The details of this
867
- algorithm are described in `arXiv:2209.15512 <https://arxiv.org/abs/2209.15512>`__.
868
-
869
- .. _optimization_stage:
870
-
871
- Optimization Stage
872
- ------------------
873
-
874
- Decomposing quantum circuits into the basis gate set of the target device,
875
- and the addition of swap gates needed to match hardware topology, conspire to
876
- increase the depth and gate count of quantum circuits. Fortunately many routines
877
- for optimizing circuits by combining or eliminating gates exist. In some cases
878
- these methods are so effective the output circuits have lower depth than the inputs.
879
- In other cases, not much can be done, and the computation may be difficult to
880
- perform on noisy devices. Different gate optimizations are turned on with
881
- different ``optimization_level`` values. Below we show the benefits gained from
882
- setting the optimization level higher:
883
-
884
- .. important::
885
-
886
- The output from :func:`.transpile` varies due to the stochastic swap mapper.
887
- So the numbers below will likely change each time you run the code.
888
-
889
-
890
- .. plot::
891
-
892
- import matplotlib.pyplot as plt
893
- from qiskit import QuantumCircuit, transpile
894
- from qiskit.providers.fake_provider import GenericBackendV2
895
- backend = GenericBackendV2(16)
896
-
897
- ghz = QuantumCircuit(15)
898
- ghz.h(0)
899
- ghz.cx(0, range(1, 15))
900
- ghz.draw(output='mpl')
901
-
902
- .. plot::
903
- :include-source:
904
-
905
- import matplotlib.pyplot as plt
906
- from qiskit import QuantumCircuit, transpile
907
- from qiskit.providers.fake_provider import GenericBackendV2
908
- backend = GenericBackendV2(16)
909
-
910
- ghz = QuantumCircuit(15)
911
- ghz.h(0)
912
- ghz.cx(0, range(1, 15))
913
-
914
- depths = []
915
- gate_counts = []
916
- non_local_gate_counts = []
917
- levels = [str(x) for x in range(4)]
918
- for level in range(4):
919
- circ = transpile(ghz, backend, optimization_level=level)
920
- depths.append(circ.depth())
921
- gate_counts.append(sum(circ.count_ops().values()))
922
- non_local_gate_counts.append(circ.num_nonlocal_gates())
923
- fig, (ax1, ax2) = plt.subplots(2, 1)
924
- ax1.bar(levels, depths, label='Depth')
925
- ax1.set_xlabel("Optimization Level")
926
- ax1.set_ylabel("Depth")
927
- ax1.set_title("Output Circuit Depth")
928
- ax2.bar(levels, gate_counts, label='Number of Circuit Operations')
929
- ax2.bar(levels, non_local_gate_counts, label='Number of non-local gates')
930
- ax2.set_xlabel("Optimization Level")
931
- ax2.set_ylabel("Number of gates")
932
- ax2.legend()
933
- ax2.set_title("Number of output circuit gates")
934
- fig.tight_layout()
935
- plt.show()
936
-
937
- .. _scheduling_stage:
938
-
939
- Scheduling Stage
940
- ----------------
1183
+ .. seealso::
1184
+ :ref:`transpiler-preset-stage-scheduling`
1185
+ How to configure the scheduling stages of the preset pass managers.
941
1186
 
942
1187
  After the circuit has been translated to the target basis, mapped to the device, and optimized,
943
1188
  a scheduling phase can be applied to optionally account for all the idle time in the circuit.
@@ -946,6 +1191,7 @@ for idle time on the qubits between the execution of instructions. For example,
946
1191
  circuit such as:
947
1192
 
948
1193
  .. plot::
1194
+ :alt: Diagram illustrating the previously described circuit.
949
1195
 
950
1196
  from qiskit import QuantumCircuit
951
1197
 
@@ -957,6 +1203,7 @@ circuit such as:
957
1203
  we can then call :func:`~.transpile` on it with ``scheduling_method`` set:
958
1204
 
959
1205
  .. plot::
1206
+ :alt: Circuit diagram output by the previous code.
960
1207
  :include-source:
961
1208
 
962
1209
  from qiskit import QuantumCircuit, transpile
@@ -976,6 +1223,7 @@ account for idle time on each qubit. To get a better idea of the timing of the c
976
1223
  also look at it with the :func:`.timeline.draw` function:
977
1224
 
978
1225
  .. plot::
1226
+ :alt: Output from circuit timeline drawer.
979
1227
 
980
1228
  from qiskit.visualization.timeline import draw as timeline_draw
981
1229
 
@@ -1006,8 +1254,8 @@ the scheduling and adjustments/rescheduling are finished, a padding pass,
1006
1254
  such as :class:`~.PadDelay` or :class:`~.PadDynamicalDecoupling` is run
1007
1255
  to insert the instructions into the circuit, which completes the scheduling.
1008
1256
 
1009
- Scheduling Analysis with control flow instructions
1010
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1257
+ Scheduling analysis with control-flow instructions
1258
+ --------------------------------------------------
1011
1259
 
1012
1260
  When running scheduling analysis passes on a circuit, you must keep in mind that there
1013
1261
  are additional constraints on classical conditions and control flow instructions. This section
@@ -1015,7 +1263,7 @@ covers the details of these additional
1015
1263
  constraints that any scheduling pass will need to account for.
1016
1264
 
1017
1265
  Topological node ordering in scheduling
1018
- ''''''''''''''''''''''''''''''''''''''''
1266
+ .......................................
1019
1267
 
1020
1268
  The DAG representation of ``QuantumCircuit`` respects the node ordering in the
1021
1269
  classical register wires, though theoretically two conditional instructions
@@ -1051,7 +1299,7 @@ However, any additional optimization should be done in a different pass,
1051
1299
  not to break the topological ordering of the original circuit.
1052
1300
 
1053
1301
  Realistic control flow scheduling (respecting microarchitecture)
1054
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
1302
+ ................................................................
1055
1303
 
1056
1304
  In the dispersive QND readout scheme, the qubit (Q) is measured by sending
1057
1305
  a microwave stimulus, followed by a resonator ring-down (depopulation). This
@@ -1205,8 +1453,8 @@ See https://arxiv.org/abs/2102.01682 for more details.
1205
1453
  Transpiler API
1206
1454
  ==============
1207
1455
 
1208
- Transpiler Target
1209
- -----------------
1456
+ Hardware description
1457
+ --------------------
1210
1458
 
1211
1459
  .. autosummary::
1212
1460
  :toctree: ../stubs/
@@ -1214,8 +1462,8 @@ Transpiler Target
1214
1462
  Target
1215
1463
  InstructionProperties
1216
1464
 
1217
- Pass Manager Construction
1218
- -------------------------
1465
+ Pass Manager Definition
1466
+ -----------------------
1219
1467
 
1220
1468
  .. autosummary::
1221
1469
  :toctree: ../stubs/
@@ -1223,6 +1471,7 @@ Pass Manager Construction
1223
1471
  StagedPassManager
1224
1472
  PassManager
1225
1473
  PassManagerConfig
1474
+ generate_preset_pass_manager
1226
1475
 
1227
1476
  Layout and Topology
1228
1477
  -------------------
@@ -1261,6 +1510,8 @@ Exceptions
1261
1510
  .. autoexception:: CircuitTooWideForTarget
1262
1511
  .. autoexception:: InvalidLayoutError
1263
1512
 
1513
+ .. _sabre-original-paper: https://arxiv.org/abs/1809.02573
1514
+ .. _sabre-lightsabre-paper: https://arxiv.org/abs/2409.08368
1264
1515
  """
1265
1516
 
1266
1517
  # For backward compatibility