qiskit/releasenotes/notes/0.22/transpiler-control-flow-708...

91 lines
3.1 KiB
YAML

---
features:
- |
Control-flow operations are now supported through the transpiler at
optimization levels 0 and 1 (e.g. calling :func:`.transpile` or
:func:`.generate_preset_pass_manager` with keyword argument
``optimization_level=1``). One can now construct a circuit such as
.. code-block:: python
from qiskit import QuantumCircuit
qc = QuantumCircuit(2, 1)
qc.h(0)
qc.measure(0, 0)
with qc.if_test((0, True)) as else_:
qc.x(1)
with else_:
qc.y(1)
and successfully transpile this, such as by::
from qiskit import transpile
from qiskit_aer import AerSimulator
backend = AerSimulator(method="statevector")
transpiled = transpile(qc, backend)
The available values for the keyword argument ``layout_method`` are
"trivial" and "dense". For ``routing_method``, "stochastic" and "none" are
available. Translation (``translation_method``) can be done using
"translator" or "unroller". Optimization levels 2 and 3 are not yet
supported with control flow, nor is circuit scheduling (i.e. providing a
value to ``scheduling_method``), though we intend to expand support for
these, and the other layout, routing and translation methods in subsequent
releases of Qiskit Terra.
In order for transpilation with control-flow operations to succeed with a
backend, the backend must have the requisite control-flow operations in its
stated basis. Qiskit Aer, for example, does this. If you simply want to try
out such transpilations, consider overriding the ``basis_gates`` argument
to :func:`.transpile`.
- |
The following transpiler passes have all been taught to understand
control-flow constructs in the form of :class:`.ControlFlowOp` instructions
in a circuit:
.. rubric:: Layout-related
- :class:`.ApplyLayout`
- :class:`.DenseLayout`
- :class:`.EnlargeWithAncilla`
- :class:`.FullAncillaAllocation`
- :class:`.SetLayout`
- :class:`.TrivialLayout`
- :class:`.VF2Layout`
- :class:`.VF2PostLayout`
.. rubric:: Routing-related
- :class:`.CheckGateDirection`
- :class:`.CheckMap`
- :class:`.GateDirection`
- :class:`.StochasticSwap`
.. rubric:: Translation-related
- :class:`.BasisTranslator`
- :class:`.ContainsInstruction`
- :class:`.GatesInBasis`
- :class:`.UnitarySynthesis`
- :class:`.Unroll3qOrMore`
- :class:`.UnrollCustomDefinitions`
- :class:`.Unroller`
.. rubric:: Optimization-related
- :class:`.BarrierBeforeFinalMeasurements`
- :class:`.Depth`
- :class:`.FixedPoint`
- :class:`.Size`
- :class:`.Optimize1qGatesDecomposition`
- :class:`.CXCancellation`
- :class:`.RemoveResetInZeroState`
These passes are most commonly used via the preset pass managers (those used
internally by :func:`.transpile` and :func:`.generate_preset_pass_manager`),
but are also available for other uses. These passes will now recurse into
control-flow operations where appropriate, updating or analysing the
internal blocks.