117 lines
19 KiB
Plaintext
117 lines
19 KiB
Plaintext
---
|
||
title: passes (v0.29)
|
||
description: API reference for qiskit.transpiler.passes in qiskit v0.29
|
||
in_page_toc_min_heading_level: 2
|
||
python_api_type: module
|
||
python_api_name: qiskit.transpiler.passes
|
||
---
|
||
|
||
<span id="module-qiskit.transpiler.passes" />
|
||
|
||
<span id="qiskit-transpiler-passes" />
|
||
|
||
<span id="transpiler-passes-qiskit-transpiler-passes" />
|
||
|
||
# Transpiler Passes
|
||
|
||
`qiskit.transpiler.passes`
|
||
|
||
## Layout Selection (Placement)
|
||
|
||
| | |
|
||
| ---------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
|
||
| [`SetLayout`](qiskit.transpiler.passes.SetLayout "qiskit.transpiler.passes.SetLayout")(\*args, \*\*kwargs) | Set the `layout` property to the given layout. |
|
||
| [`TrivialLayout`](qiskit.transpiler.passes.TrivialLayout "qiskit.transpiler.passes.TrivialLayout")(\*args, \*\*kwargs) | Choose a Layout by assigning `n` circuit qubits to device qubits `0, .., n-1`. |
|
||
| [`DenseLayout`](qiskit.transpiler.passes.DenseLayout "qiskit.transpiler.passes.DenseLayout")(\*args, \*\*kwargs) | Choose a Layout by finding the most connected subset of qubits. |
|
||
| [`NoiseAdaptiveLayout`](qiskit.transpiler.passes.NoiseAdaptiveLayout "qiskit.transpiler.passes.NoiseAdaptiveLayout")(\*args, \*\*kwargs) | Choose a noise-adaptive Layout based on current calibration data for the backend. |
|
||
| [`SabreLayout`](qiskit.transpiler.passes.SabreLayout "qiskit.transpiler.passes.SabreLayout")(\*args, \*\*kwargs) | Choose a Layout via iterative bidirectional routing of the input circuit. |
|
||
| [`CSPLayout`](qiskit.transpiler.passes.CSPLayout "qiskit.transpiler.passes.CSPLayout")(\*args, \*\*kwargs) | If possible, chooses a Layout as a CSP, using backtracking. |
|
||
| [`ApplyLayout`](qiskit.transpiler.passes.ApplyLayout "qiskit.transpiler.passes.ApplyLayout")(\*args, \*\*kwargs) | Transform a circuit with virtual qubits into a circuit with physical qubits. |
|
||
| [`Layout2qDistance`](qiskit.transpiler.passes.Layout2qDistance "qiskit.transpiler.passes.Layout2qDistance")(\*args, \*\*kwargs) | Evaluate how good the layout selection was. |
|
||
| [`EnlargeWithAncilla`](qiskit.transpiler.passes.EnlargeWithAncilla "qiskit.transpiler.passes.EnlargeWithAncilla")(\*args, \*\*kwargs) | Extend the dag with virtual qubits that are in layout but not in the circuit yet. |
|
||
| [`FullAncillaAllocation`](qiskit.transpiler.passes.FullAncillaAllocation "qiskit.transpiler.passes.FullAncillaAllocation")(\*args, \*\*kwargs) | Allocate all idle nodes from the coupling map as ancilla on the layout. |
|
||
|
||
## Routing
|
||
|
||
| | |
|
||
| ------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
||
| [`BasicSwap`](qiskit.transpiler.passes.BasicSwap "qiskit.transpiler.passes.BasicSwap")(\*args, \*\*kwargs) | Map (with minimum effort) a DAGCircuit onto a coupling\_map adding swap gates. |
|
||
| [`LookaheadSwap`](qiskit.transpiler.passes.LookaheadSwap "qiskit.transpiler.passes.LookaheadSwap")(\*args, \*\*kwargs) | Map input circuit onto a backend topology via insertion of SWAPs. |
|
||
| [`StochasticSwap`](qiskit.transpiler.passes.StochasticSwap "qiskit.transpiler.passes.StochasticSwap")(\*args, \*\*kwargs) | Map a DAGCircuit onto a coupling\_map adding swap gates. |
|
||
| [`SabreSwap`](qiskit.transpiler.passes.SabreSwap "qiskit.transpiler.passes.SabreSwap")(\*args, \*\*kwargs) | Map input circuit onto a backend topology via insertion of SWAPs. |
|
||
| [`BIPMapping`](qiskit.transpiler.passes.BIPMapping "qiskit.transpiler.passes.BIPMapping")(\*args, \*\*kwargs) | Map a DAGCircuit onto a given `coupling_map`, allocating qubits and adding swap gates. |
|
||
|
||
## Basis Change
|
||
|
||
| | |
|
||
| ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
||
| [`Unroller`](qiskit.transpiler.passes.Unroller "qiskit.transpiler.passes.Unroller")(\*args, \*\*kwargs) | Unroll a circuit to a given basis. |
|
||
| [`Unroll3qOrMore`](qiskit.transpiler.passes.Unroll3qOrMore "qiskit.transpiler.passes.Unroll3qOrMore")(\*args, \*\*kwargs) | Recursively expands 3q+ gates until the circuit only contains 2q or 1q gates. |
|
||
| [`Decompose`](qiskit.transpiler.passes.Decompose "qiskit.transpiler.passes.Decompose")(\[gate]) | Expand a gate in a circuit using its decomposition rules. |
|
||
| [`UnrollCustomDefinitions`](qiskit.transpiler.passes.UnrollCustomDefinitions "qiskit.transpiler.passes.UnrollCustomDefinitions")(\*args, \*\*kwargs) | Unrolls instructions with custom definitions. |
|
||
| [`BasisTranslator`](qiskit.transpiler.passes.BasisTranslator "qiskit.transpiler.passes.BasisTranslator")(\*args, \*\*kwargs) | Translates gates to a target basis by searching for a set of translations from a given EquivalenceLibrary. |
|
||
|
||
## Optimizations
|
||
|
||
| | |
|
||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
||
| [`Optimize1qGates`](qiskit.transpiler.passes.Optimize1qGates "qiskit.transpiler.passes.Optimize1qGates")(\*args, \*\*kwargs) | Optimize chains of single-qubit u1, u2, u3 gates by combining them into a single gate. |
|
||
| [`Optimize1qGatesDecomposition`](qiskit.transpiler.passes.Optimize1qGatesDecomposition "qiskit.transpiler.passes.Optimize1qGatesDecomposition")(\*args, \*\*kwargs) | Optimize chains of single-qubit gates by combining them into a single gate. |
|
||
| [`Collect2qBlocks`](qiskit.transpiler.passes.Collect2qBlocks "qiskit.transpiler.passes.Collect2qBlocks")(\*args, \*\*kwargs) | Collect sequences of uninterrupted gates acting on 2 qubits. |
|
||
| [`ConsolidateBlocks`](qiskit.transpiler.passes.ConsolidateBlocks "qiskit.transpiler.passes.ConsolidateBlocks")(\*args, \*\*kwargs) | Replace each block of consecutive gates by a single Unitary node. |
|
||
| [`CXCancellation`](qiskit.transpiler.passes.CXCancellation "qiskit.transpiler.passes.CXCancellation")(\*args, \*\*kwargs) | Cancel back-to-back cx gates in dag. |
|
||
| [`CommutationAnalysis`](qiskit.transpiler.passes.CommutationAnalysis "qiskit.transpiler.passes.CommutationAnalysis")(\*args, \*\*kwargs) | Analysis pass to find commutation relations between DAG nodes. |
|
||
| [`CommutativeCancellation`](qiskit.transpiler.passes.CommutativeCancellation "qiskit.transpiler.passes.CommutativeCancellation")(\*args, \*\*kwargs) | Cancel the redundant (self-adjoint) gates through commutation relations. |
|
||
| [`RemoveDiagonalGatesBeforeMeasure`](qiskit.transpiler.passes.RemoveDiagonalGatesBeforeMeasure "qiskit.transpiler.passes.RemoveDiagonalGatesBeforeMeasure")(\*args, \*\*kwargs) | Remove diagonal gates (including diagonal 2Q gates) before a measurement. |
|
||
| [`RemoveResetInZeroState`](qiskit.transpiler.passes.RemoveResetInZeroState "qiskit.transpiler.passes.RemoveResetInZeroState")(\*args, \*\*kwargs) | Remove reset gate when the qubit is in zero state. |
|
||
| [`CrosstalkAdaptiveSchedule`](qiskit.transpiler.passes.CrosstalkAdaptiveSchedule "qiskit.transpiler.passes.CrosstalkAdaptiveSchedule")(\*args, \*\*kwargs) | Crosstalk mitigation through adaptive instruction scheduling. |
|
||
| [`TemplateOptimization`](qiskit.transpiler.passes.TemplateOptimization "qiskit.transpiler.passes.TemplateOptimization")(\*args, \*\*kwargs) | Class for the template optimization pass. |
|
||
|
||
## Scheduling
|
||
|
||
| | |
|
||
| ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
||
| [`TimeUnitConversion`](qiskit.transpiler.passes.TimeUnitConversion "qiskit.transpiler.passes.TimeUnitConversion")(inst\_durations) | Choose a time unit to be used in the following time-aware passes, and make all circuit time units consistent with that. |
|
||
| [`ALAPSchedule`](qiskit.transpiler.passes.ALAPSchedule "qiskit.transpiler.passes.ALAPSchedule")(\*args, \*\*kwargs) | ALAP Scheduling. |
|
||
| [`ASAPSchedule`](qiskit.transpiler.passes.ASAPSchedule "qiskit.transpiler.passes.ASAPSchedule")(\*args, \*\*kwargs) | ASAP Scheduling. |
|
||
| [`DynamicalDecoupling`](qiskit.transpiler.passes.DynamicalDecoupling "qiskit.transpiler.passes.DynamicalDecoupling")(\*args, \*\*kwargs) | Dynamical decoupling insertion pass. |
|
||
| [`AlignMeasures`](qiskit.transpiler.passes.AlignMeasures "qiskit.transpiler.passes.AlignMeasures")(\[alignment]) | Measurement alignment. |
|
||
| [`ValidatePulseGates`](qiskit.transpiler.passes.ValidatePulseGates "qiskit.transpiler.passes.ValidatePulseGates")(\[granularity, min\_length]) | Check custom gate length. |
|
||
| [`RZXCalibrationBuilder`](qiskit.transpiler.passes.RZXCalibrationBuilder "qiskit.transpiler.passes.RZXCalibrationBuilder")(backend) | Creates calibrations for RZXGate(theta) by stretching and compressing Gaussian square pulses in the CX gate. |
|
||
| [`RZXCalibrationBuilderNoEcho`](qiskit.transpiler.passes.RZXCalibrationBuilderNoEcho "qiskit.transpiler.passes.RZXCalibrationBuilderNoEcho")(backend) | Creates calibrations for RZXGate(theta) by stretching and compressing Gaussian square pulses in the CX gate. |
|
||
|
||
## Circuit Analysis
|
||
|
||
| | |
|
||
| ---------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
|
||
| [`Width`](qiskit.transpiler.passes.Width "qiskit.transpiler.passes.Width")(\*args, \*\*kwargs) | Calculate the width of a DAG circuit. |
|
||
| [`Depth`](qiskit.transpiler.passes.Depth "qiskit.transpiler.passes.Depth")(\*args, \*\*kwargs) | Calculate the depth of a DAG circuit. |
|
||
| [`Size`](qiskit.transpiler.passes.Size "qiskit.transpiler.passes.Size")(\*args, \*\*kwargs) | Calculate the size of a DAG circuit. |
|
||
| [`CountOps`](qiskit.transpiler.passes.CountOps "qiskit.transpiler.passes.CountOps")(\*args, \*\*kwargs) | Count the operations in a DAG circuit. |
|
||
| [`CountOpsLongestPath`](qiskit.transpiler.passes.CountOpsLongestPath "qiskit.transpiler.passes.CountOpsLongestPath")(\*args, \*\*kwargs) | Count the operations on the longest path in a DAGcircuit. |
|
||
| [`NumTensorFactors`](qiskit.transpiler.passes.NumTensorFactors "qiskit.transpiler.passes.NumTensorFactors")(\*args, \*\*kwargs) | Calculate the number of tensor factors of a DAG circuit. |
|
||
| [`DAGLongestPath`](qiskit.transpiler.passes.DAGLongestPath "qiskit.transpiler.passes.DAGLongestPath")(\*args, \*\*kwargs) | Return the longest path in a DAGcircuit as a list of DAGNodes. |
|
||
|
||
## Synthesis
|
||
|
||
| | |
|
||
| ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
|
||
| [`UnitarySynthesis`](qiskit.transpiler.passes.UnitarySynthesis "qiskit.transpiler.passes.UnitarySynthesis")(basis\_gates\[, …]) | Synthesize gates according to their basis gates. |
|
||
|
||
## Additional Passes
|
||
|
||
| | |
|
||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||
| [`CheckMap`](qiskit.transpiler.passes.CheckMap "qiskit.transpiler.passes.CheckMap")(\*args, \*\*kwargs) | Check if a DAG circuit is already mapped to a coupling map. |
|
||
| [`CheckCXDirection`](qiskit.transpiler.passes.CheckCXDirection "qiskit.transpiler.passes.CheckCXDirection")(\*args, \*\*kwargs) | Deprecated: use [`qiskit.transpiler.passes.CheckGateDirection`](qiskit.transpiler.passes.CheckGateDirection "qiskit.transpiler.passes.CheckGateDirection") pass instead. |
|
||
| [`CheckGateDirection`](qiskit.transpiler.passes.CheckGateDirection "qiskit.transpiler.passes.CheckGateDirection")(\*args, \*\*kwargs) | Check if the two-qubit gates follow the right direction with respect to the coupling map. |
|
||
| [`CXDirection`](qiskit.transpiler.passes.CXDirection "qiskit.transpiler.passes.CXDirection")(\*args, \*\*kwargs) | Deprecated: use [`qiskit.transpiler.passes.GateDirection`](qiskit.transpiler.passes.GateDirection "qiskit.transpiler.passes.GateDirection") pass instead. |
|
||
| [`GateDirection`](qiskit.transpiler.passes.GateDirection "qiskit.transpiler.passes.GateDirection")(\*args, \*\*kwargs) | Modify asymmetric gates to match the hardware coupling direction. |
|
||
| [`MergeAdjacentBarriers`](qiskit.transpiler.passes.MergeAdjacentBarriers "qiskit.transpiler.passes.MergeAdjacentBarriers")(\*args, \*\*kwargs) | Return a circuit with any adjacent barriers merged together. |
|
||
| [`RemoveBarriers`](qiskit.transpiler.passes.RemoveBarriers "qiskit.transpiler.passes.RemoveBarriers")(\*args, \*\*kwargs) | Return a circuit with any barrier removed. |
|
||
| [`BarrierBeforeFinalMeasurements`](qiskit.transpiler.passes.BarrierBeforeFinalMeasurements "qiskit.transpiler.passes.BarrierBeforeFinalMeasurements")(\*args, \*\*kwargs) | Add a barrier before final measurements. |
|
||
| [`RemoveFinalMeasurements`](qiskit.transpiler.passes.RemoveFinalMeasurements "qiskit.transpiler.passes.RemoveFinalMeasurements")(\*args, \*\*kwargs) | Remove final measurements and barriers at the end of a circuit. |
|
||
| [`DAGFixedPoint`](qiskit.transpiler.passes.DAGFixedPoint "qiskit.transpiler.passes.DAGFixedPoint")(\*args, \*\*kwargs) | Check if the DAG has reached a fixed point. |
|
||
| [`FixedPoint`](qiskit.transpiler.passes.FixedPoint "qiskit.transpiler.passes.FixedPoint")(\*args, \*\*kwargs) | Check if a property reached a fixed point. |
|
||
|