qiskit 1.1.2__cp38-abi3-win32.whl → 1.2.0__cp38-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.
- qiskit/VERSION.txt +1 -1
- qiskit/__init__.py +27 -24
- qiskit/_accelerate.pyd +0 -0
- qiskit/_numpy_compat.py +1 -1
- qiskit/assembler/assemble_circuits.py +107 -64
- qiskit/assembler/assemble_schedules.py +5 -12
- qiskit/assembler/disassemble.py +10 -1
- qiskit/circuit/__init__.py +6 -3
- qiskit/circuit/_classical_resource_map.py +5 -5
- qiskit/circuit/_utils.py +0 -13
- qiskit/circuit/add_control.py +1 -1
- qiskit/circuit/annotated_operation.py +23 -1
- qiskit/circuit/classical/expr/expr.py +4 -4
- qiskit/circuit/classical/expr/visitors.py +1 -1
- qiskit/circuit/classical/types/__init__.py +1 -1
- qiskit/circuit/classical/types/types.py +2 -2
- qiskit/circuit/classicalfunction/boolean_expression.py +1 -1
- qiskit/circuit/classicalfunction/classical_function_visitor.py +5 -5
- qiskit/circuit/classicalfunction/utils.py +1 -1
- qiskit/circuit/classicalregister.py +1 -1
- qiskit/circuit/commutation_checker.py +83 -35
- qiskit/circuit/controlflow/_builder_utils.py +1 -1
- qiskit/circuit/controlflow/builder.py +10 -6
- qiskit/circuit/controlflow/if_else.py +2 -2
- qiskit/circuit/controlflow/switch_case.py +1 -1
- qiskit/circuit/delay.py +1 -1
- qiskit/circuit/duration.py +2 -2
- qiskit/circuit/equivalence.py +5 -7
- qiskit/circuit/gate.py +11 -8
- qiskit/circuit/instruction.py +31 -13
- qiskit/circuit/instructionset.py +2 -5
- qiskit/circuit/library/__init__.py +2 -1
- qiskit/circuit/library/arithmetic/linear_amplitude_function.py +1 -1
- qiskit/circuit/library/arithmetic/linear_pauli_rotations.py +1 -1
- qiskit/circuit/library/arithmetic/piecewise_chebyshev.py +1 -1
- qiskit/circuit/library/arithmetic/piecewise_linear_pauli_rotations.py +1 -1
- qiskit/circuit/library/arithmetic/piecewise_polynomial_pauli_rotations.py +3 -3
- qiskit/circuit/library/arithmetic/polynomial_pauli_rotations.py +1 -1
- qiskit/circuit/library/basis_change/__init__.py +1 -1
- qiskit/circuit/library/basis_change/qft.py +40 -6
- qiskit/circuit/library/blueprintcircuit.py +3 -5
- qiskit/circuit/library/data_preparation/__init__.py +9 -2
- qiskit/circuit/library/data_preparation/initializer.py +8 -0
- qiskit/circuit/library/data_preparation/state_preparation.py +98 -178
- qiskit/circuit/library/generalized_gates/isometry.py +8 -8
- qiskit/circuit/library/generalized_gates/linear_function.py +3 -2
- qiskit/circuit/library/generalized_gates/mcg_up_to_diagonal.py +4 -4
- qiskit/circuit/library/generalized_gates/permutation.py +8 -9
- qiskit/circuit/library/generalized_gates/uc.py +3 -3
- qiskit/circuit/library/generalized_gates/uc_pauli_rot.py +2 -2
- qiskit/circuit/library/generalized_gates/unitary.py +13 -11
- qiskit/circuit/library/graph_state.py +1 -1
- qiskit/circuit/library/hamiltonian_gate.py +1 -2
- qiskit/circuit/library/hidden_linear_function.py +1 -1
- qiskit/circuit/library/n_local/evolved_operator_ansatz.py +3 -2
- qiskit/circuit/library/n_local/n_local.py +4 -5
- qiskit/circuit/library/n_local/pauli_two_design.py +1 -1
- qiskit/circuit/library/n_local/qaoa_ansatz.py +6 -8
- qiskit/circuit/library/n_local/two_local.py +1 -1
- qiskit/circuit/library/overlap.py +11 -5
- qiskit/circuit/library/pauli_evolution.py +7 -3
- qiskit/circuit/library/standard_gates/dcx.py +3 -0
- qiskit/circuit/library/standard_gates/ecr.py +3 -0
- qiskit/circuit/library/standard_gates/global_phase.py +3 -0
- qiskit/circuit/library/standard_gates/h.py +13 -5
- qiskit/circuit/library/standard_gates/i.py +3 -0
- qiskit/circuit/library/standard_gates/iswap.py +3 -0
- qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py +19 -10
- qiskit/circuit/library/standard_gates/p.py +14 -9
- qiskit/circuit/library/standard_gates/r.py +3 -0
- qiskit/circuit/library/standard_gates/rx.py +21 -6
- qiskit/circuit/library/standard_gates/rxx.py +40 -1
- qiskit/circuit/library/standard_gates/ry.py +21 -6
- qiskit/circuit/library/standard_gates/ryy.py +40 -1
- qiskit/circuit/library/standard_gates/rz.py +22 -6
- qiskit/circuit/library/standard_gates/rzx.py +40 -1
- qiskit/circuit/library/standard_gates/rzz.py +41 -2
- qiskit/circuit/library/standard_gates/s.py +77 -0
- qiskit/circuit/library/standard_gates/swap.py +12 -5
- qiskit/circuit/library/standard_gates/sx.py +14 -5
- qiskit/circuit/library/standard_gates/t.py +5 -0
- qiskit/circuit/library/standard_gates/u.py +22 -7
- qiskit/circuit/library/standard_gates/u1.py +8 -3
- qiskit/circuit/library/standard_gates/u2.py +3 -0
- qiskit/circuit/library/standard_gates/u3.py +22 -7
- qiskit/circuit/library/standard_gates/x.py +156 -92
- qiskit/circuit/library/standard_gates/xx_minus_yy.py +40 -1
- qiskit/circuit/library/standard_gates/xx_plus_yy.py +52 -11
- qiskit/circuit/library/standard_gates/y.py +6 -1
- qiskit/circuit/library/standard_gates/z.py +8 -1
- qiskit/circuit/operation.py +1 -1
- qiskit/circuit/parameter.py +9 -10
- qiskit/circuit/parameterexpression.py +16 -13
- qiskit/circuit/parametertable.py +1 -190
- qiskit/circuit/parametervector.py +1 -1
- qiskit/circuit/quantumcircuit.py +395 -387
- qiskit/circuit/quantumcircuitdata.py +3 -5
- qiskit/circuit/quantumregister.py +1 -1
- qiskit/circuit/random/__init__.py +1 -1
- qiskit/circuit/random/utils.py +175 -26
- qiskit/circuit/register.py +5 -7
- qiskit/circuit/singleton.py +3 -3
- qiskit/circuit/tools/pi_check.py +4 -4
- qiskit/compiler/assembler.py +95 -24
- qiskit/compiler/scheduler.py +2 -2
- qiskit/compiler/transpiler.py +42 -128
- qiskit/converters/circuit_to_dag.py +4 -6
- qiskit/converters/circuit_to_gate.py +4 -8
- qiskit/converters/circuit_to_instruction.py +5 -17
- qiskit/converters/dag_to_circuit.py +2 -6
- qiskit/dagcircuit/collect_blocks.py +2 -2
- qiskit/dagcircuit/dagcircuit.py +190 -187
- qiskit/dagcircuit/dagdependency.py +4 -4
- qiskit/dagcircuit/dagdependency_v2.py +4 -4
- qiskit/dagcircuit/dagdepnode.py +1 -1
- qiskit/dagcircuit/dagnode.py +66 -157
- qiskit/passmanager/flow_controllers.py +1 -1
- qiskit/passmanager/passmanager.py +3 -3
- qiskit/primitives/__init__.py +1 -5
- qiskit/primitives/backend_estimator.py +25 -15
- qiskit/primitives/backend_estimator_v2.py +31 -7
- qiskit/primitives/backend_sampler.py +21 -12
- qiskit/primitives/backend_sampler_v2.py +12 -3
- qiskit/primitives/base/base_estimator.py +31 -4
- qiskit/primitives/base/base_primitive.py +2 -2
- qiskit/primitives/base/base_result.py +2 -2
- qiskit/primitives/base/base_sampler.py +26 -2
- qiskit/primitives/base/estimator_result.py +2 -2
- qiskit/primitives/base/sampler_result.py +2 -2
- qiskit/primitives/containers/__init__.py +0 -1
- qiskit/primitives/containers/bindings_array.py +2 -2
- qiskit/primitives/containers/bit_array.py +108 -10
- qiskit/primitives/containers/shape.py +3 -3
- qiskit/primitives/estimator.py +9 -2
- qiskit/primitives/primitive_job.py +1 -1
- qiskit/primitives/sampler.py +10 -3
- qiskit/primitives/statevector_estimator.py +5 -3
- qiskit/primitives/statevector_sampler.py +11 -5
- qiskit/primitives/utils.py +16 -0
- qiskit/providers/backend.py +15 -6
- qiskit/providers/backend_compat.py +7 -4
- qiskit/providers/basic_provider/basic_provider_tools.py +1 -1
- qiskit/providers/basic_provider/basic_simulator.py +33 -25
- qiskit/providers/fake_provider/fake_backend.py +10 -3
- qiskit/providers/fake_provider/fake_openpulse_2q.py +157 -149
- qiskit/providers/fake_provider/fake_openpulse_3q.py +228 -220
- qiskit/providers/fake_provider/fake_pulse_backend.py +2 -1
- qiskit/providers/fake_provider/fake_qasm_backend.py +7 -2
- qiskit/providers/fake_provider/generic_backend_v2.py +514 -68
- qiskit/providers/models/__init__.py +48 -11
- qiskit/providers/models/backendconfiguration.py +50 -4
- qiskit/providers/models/backendproperties.py +13 -2
- qiskit/providers/models/pulsedefaults.py +10 -11
- qiskit/providers/options.py +13 -13
- qiskit/providers/providerutils.py +3 -1
- qiskit/pulse/configuration.py +8 -12
- qiskit/pulse/instruction_schedule_map.py +3 -5
- qiskit/pulse/instructions/acquire.py +7 -8
- qiskit/pulse/instructions/instruction.py +2 -3
- qiskit/pulse/library/samplers/decorators.py +5 -9
- qiskit/pulse/library/symbolic_pulses.py +4 -7
- qiskit/pulse/library/waveform.py +2 -5
- qiskit/pulse/macros.py +11 -6
- qiskit/pulse/parser.py +8 -10
- qiskit/pulse/schedule.py +9 -17
- qiskit/pulse/transforms/alignments.py +1 -3
- qiskit/pulse/utils.py +1 -2
- qiskit/qasm/libs/stdgates.inc +35 -28
- qiskit/qasm2/__init__.py +7 -7
- qiskit/qasm2/export.py +5 -9
- qiskit/qasm2/parse.py +1 -1
- qiskit/qasm3/ast.py +9 -25
- qiskit/qasm3/exporter.py +582 -479
- qiskit/qasm3/printer.py +7 -16
- qiskit/qobj/common.py +10 -0
- qiskit/qobj/converters/lo_config.py +9 -0
- qiskit/qobj/converters/pulse_instruction.py +13 -6
- qiskit/qobj/pulse_qobj.py +69 -15
- qiskit/qobj/qasm_qobj.py +72 -20
- qiskit/qobj/utils.py +9 -0
- qiskit/qpy/__init__.py +1 -1
- qiskit/qpy/binary_io/circuits.py +8 -5
- qiskit/qpy/binary_io/schedules.py +1 -1
- qiskit/qpy/binary_io/value.py +3 -3
- qiskit/qpy/interface.py +3 -2
- qiskit/qpy/type_keys.py +2 -2
- qiskit/quantum_info/operators/channel/quantum_channel.py +3 -6
- qiskit/quantum_info/operators/channel/superop.py +2 -2
- qiskit/quantum_info/operators/channel/transformations.py +1 -1
- qiskit/quantum_info/operators/dihedral/dihedral.py +3 -4
- qiskit/quantum_info/operators/dihedral/dihedral_circuits.py +1 -3
- qiskit/quantum_info/operators/dihedral/random.py +6 -3
- qiskit/quantum_info/operators/measures.py +2 -2
- qiskit/quantum_info/operators/op_shape.py +12 -20
- qiskit/quantum_info/operators/operator.py +14 -21
- qiskit/quantum_info/operators/predicates.py +1 -0
- qiskit/quantum_info/operators/symplectic/base_pauli.py +7 -11
- qiskit/quantum_info/operators/symplectic/clifford.py +1 -1
- qiskit/quantum_info/operators/symplectic/pauli.py +3 -3
- qiskit/quantum_info/operators/symplectic/pauli_list.py +9 -10
- qiskit/quantum_info/operators/symplectic/random.py +1 -1
- qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +15 -17
- qiskit/quantum_info/quaternion.py +1 -1
- qiskit/quantum_info/states/densitymatrix.py +5 -8
- qiskit/quantum_info/states/stabilizerstate.py +128 -37
- qiskit/quantum_info/states/statevector.py +4 -8
- qiskit/result/counts.py +2 -2
- qiskit/result/mitigation/correlated_readout_mitigator.py +2 -2
- qiskit/result/mitigation/local_readout_mitigator.py +2 -2
- qiskit/result/mitigation/utils.py +1 -3
- qiskit/result/models.py +17 -16
- qiskit/result/result.py +15 -20
- qiskit/scheduler/lowering.py +2 -2
- qiskit/synthesis/__init__.py +2 -1
- qiskit/synthesis/clifford/__init__.py +1 -1
- qiskit/synthesis/clifford/clifford_decompose_ag.py +2 -2
- qiskit/synthesis/clifford/clifford_decompose_bm.py +10 -240
- qiskit/synthesis/clifford/clifford_decompose_greedy.py +9 -303
- qiskit/synthesis/clifford/clifford_decompose_layers.py +25 -23
- qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_full.py +1 -1
- qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_general.py +1 -1
- qiskit/synthesis/discrete_basis/generate_basis_approximations.py +1 -1
- qiskit/synthesis/discrete_basis/solovay_kitaev.py +2 -2
- qiskit/synthesis/evolution/evolution_synthesis.py +4 -2
- qiskit/synthesis/evolution/lie_trotter.py +46 -19
- qiskit/synthesis/evolution/product_formula.py +111 -55
- qiskit/synthesis/evolution/qdrift.py +40 -10
- qiskit/synthesis/evolution/suzuki_trotter.py +43 -33
- qiskit/synthesis/linear/__init__.py +1 -0
- qiskit/synthesis/linear/cnot_synth.py +22 -96
- qiskit/synthesis/linear/linear_depth_lnn.py +8 -8
- qiskit/synthesis/linear/linear_matrix_utils.py +13 -161
- qiskit/synthesis/linear_phase/cnot_phase_synth.py +1 -1
- qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py +3 -3
- qiskit/synthesis/linear_phase/cz_depth_lnn.py +1 -1
- qiskit/synthesis/one_qubit/one_qubit_decompose.py +29 -29
- qiskit/synthesis/permutation/permutation_full.py +5 -29
- qiskit/synthesis/permutation/permutation_lnn.py +2 -24
- qiskit/synthesis/permutation/permutation_utils.py +2 -59
- qiskit/synthesis/qft/__init__.py +1 -0
- qiskit/synthesis/qft/qft_decompose_full.py +79 -0
- qiskit/synthesis/qft/qft_decompose_lnn.py +17 -9
- qiskit/synthesis/stabilizer/stabilizer_circuit.py +6 -6
- qiskit/synthesis/stabilizer/stabilizer_decompose.py +2 -2
- qiskit/synthesis/two_qubit/local_invariance.py +8 -38
- qiskit/synthesis/two_qubit/two_qubit_decompose.py +48 -129
- qiskit/synthesis/unitary/aqc/cnot_structures.py +1 -1
- qiskit/synthesis/unitary/qsd.py +5 -3
- qiskit/transpiler/__init__.py +1 -0
- qiskit/transpiler/basepasses.py +1 -1
- qiskit/transpiler/coupling.py +3 -3
- qiskit/transpiler/instruction_durations.py +1 -2
- qiskit/transpiler/layout.py +3 -3
- qiskit/transpiler/passes/__init__.py +2 -0
- qiskit/transpiler/passes/basis/basis_translator.py +84 -64
- qiskit/transpiler/passes/basis/translate_parameterized.py +3 -5
- qiskit/transpiler/passes/basis/unroll_3q_or_more.py +1 -1
- qiskit/transpiler/passes/basis/unroll_custom_definitions.py +10 -10
- qiskit/transpiler/passes/calibration/rx_builder.py +3 -3
- qiskit/transpiler/passes/calibration/rzx_builder.py +3 -3
- qiskit/transpiler/passes/layout/apply_layout.py +13 -3
- qiskit/transpiler/passes/layout/sabre_layout.py +10 -8
- qiskit/transpiler/passes/layout/sabre_pre_layout.py +4 -1
- qiskit/transpiler/passes/layout/set_layout.py +2 -2
- qiskit/transpiler/passes/layout/vf2_layout.py +1 -1
- qiskit/transpiler/passes/layout/vf2_utils.py +3 -3
- qiskit/transpiler/passes/optimization/__init__.py +1 -0
- qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py +2 -2
- qiskit/transpiler/passes/optimization/commutation_analysis.py +7 -10
- qiskit/transpiler/passes/optimization/commutative_cancellation.py +35 -19
- qiskit/transpiler/passes/optimization/consolidate_blocks.py +17 -8
- qiskit/transpiler/passes/optimization/inverse_cancellation.py +6 -6
- qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +64 -41
- qiskit/transpiler/passes/optimization/optimize_1q_gates.py +1 -1
- qiskit/transpiler/passes/optimization/split_2q_unitaries.py +83 -0
- qiskit/transpiler/passes/optimization/template_matching/backward_match.py +1 -1
- qiskit/transpiler/passes/optimization/template_matching/forward_match.py +2 -2
- qiskit/transpiler/passes/optimization/template_matching/template_substitution.py +1 -1
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py +3 -2
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/swap_strategy.py +1 -1
- qiskit/transpiler/passes/routing/layout_transformation.py +2 -1
- qiskit/transpiler/passes/routing/sabre_swap.py +35 -26
- qiskit/transpiler/passes/routing/star_prerouting.py +80 -105
- qiskit/transpiler/passes/routing/stochastic_swap.py +1 -3
- qiskit/transpiler/passes/scheduling/alap.py +1 -2
- qiskit/transpiler/passes/scheduling/alignments/__init__.py +2 -2
- qiskit/transpiler/passes/scheduling/alignments/check_durations.py +1 -1
- qiskit/transpiler/passes/scheduling/alignments/pulse_gate_validation.py +2 -2
- qiskit/transpiler/passes/scheduling/alignments/reschedule.py +1 -1
- qiskit/transpiler/passes/scheduling/asap.py +1 -2
- qiskit/transpiler/passes/scheduling/base_scheduler.py +5 -5
- qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +3 -3
- qiskit/transpiler/passes/scheduling/padding/base_padding.py +1 -1
- qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +20 -14
- qiskit/transpiler/passes/scheduling/scheduling/base_scheduler.py +7 -6
- qiskit/transpiler/passes/scheduling/time_unit_conversion.py +4 -3
- qiskit/transpiler/passes/synthesis/high_level_synthesis.py +211 -36
- qiskit/transpiler/passes/synthesis/plugin.py +2 -2
- qiskit/transpiler/passes/synthesis/unitary_synthesis.py +80 -40
- qiskit/transpiler/passes/utils/__init__.py +0 -1
- qiskit/transpiler/passes/utils/check_gate_direction.py +4 -4
- qiskit/transpiler/passes/utils/check_map.py +3 -6
- qiskit/transpiler/passes/utils/convert_conditions_to_if_ops.py +3 -4
- qiskit/transpiler/passes/utils/error.py +2 -2
- qiskit/transpiler/passes/utils/fixed_point.py +3 -3
- qiskit/transpiler/passes/utils/gate_direction.py +1 -1
- qiskit/transpiler/passes/utils/gates_basis.py +1 -2
- qiskit/transpiler/passmanager.py +7 -6
- qiskit/transpiler/preset_passmanagers/__init__.py +4 -228
- qiskit/transpiler/preset_passmanagers/builtin_plugins.py +73 -18
- qiskit/transpiler/preset_passmanagers/common.py +3 -6
- qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py +518 -0
- qiskit/transpiler/preset_passmanagers/level0.py +1 -1
- qiskit/transpiler/target.py +27 -8
- qiskit/user_config.py +29 -6
- qiskit/utils/classtools.py +3 -3
- qiskit/utils/deprecation.py +3 -2
- qiskit/utils/lazy_tester.py +2 -2
- qiskit/utils/optionals.py +8 -8
- qiskit/visualization/bloch.py +18 -23
- qiskit/visualization/circuit/_utils.py +34 -10
- qiskit/visualization/circuit/circuit_visualization.py +23 -16
- qiskit/visualization/circuit/latex.py +29 -27
- qiskit/visualization/circuit/matplotlib.py +4 -2
- qiskit/visualization/circuit/qcstyle.py +2 -2
- qiskit/visualization/circuit/text.py +9 -15
- qiskit/visualization/dag_visualization.py +2 -2
- qiskit/visualization/pulse_v2/core.py +1 -1
- qiskit/visualization/pulse_v2/events.py +1 -1
- qiskit/visualization/pulse_v2/generators/frame.py +3 -4
- qiskit/visualization/pulse_v2/generators/waveform.py +5 -9
- qiskit/visualization/pulse_v2/layouts.py +1 -5
- qiskit/visualization/pulse_v2/plotters/matplotlib.py +1 -2
- qiskit/visualization/state_visualization.py +5 -6
- qiskit/visualization/timeline/plotters/matplotlib.py +1 -2
- qiskit/visualization/transition_visualization.py +7 -2
- {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/METADATA +12 -12
- {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/RECORD +342 -340
- {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/entry_points.txt +3 -0
- qiskit/transpiler/passes/utils/block_to_matrix.py +0 -47
- {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/LICENSE.txt +0 -0
- {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/WHEEL +0 -0
- {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/top_level.txt +0 -0
@@ -17,12 +17,11 @@ from qiskit.circuit import (
|
|
17
17
|
CircuitInstruction,
|
18
18
|
ClassicalRegister,
|
19
19
|
Clbit,
|
20
|
-
ControlFlowOp,
|
21
20
|
IfElseOp,
|
22
21
|
QuantumCircuit,
|
23
22
|
)
|
24
23
|
from qiskit.dagcircuit import DAGCircuit
|
25
|
-
from qiskit.transpiler import TransformationPass
|
24
|
+
from qiskit.transpiler.basepasses import TransformationPass
|
26
25
|
|
27
26
|
|
28
27
|
class ConvertConditionsToIfOps(TransformationPass):
|
@@ -37,7 +36,7 @@ class ConvertConditionsToIfOps(TransformationPass):
|
|
37
36
|
was modified and ``False`` if not."""
|
38
37
|
modified = False
|
39
38
|
for node in dag.op_nodes():
|
40
|
-
if
|
39
|
+
if node.is_control_flow():
|
41
40
|
modified_blocks = False
|
42
41
|
new_dags = []
|
43
42
|
for block in node.op.blocks:
|
@@ -51,7 +50,7 @@ class ConvertConditionsToIfOps(TransformationPass):
|
|
51
50
|
node.op.replace_blocks(dag_to_circuit(block) for block in new_dags),
|
52
51
|
inplace=True,
|
53
52
|
)
|
54
|
-
elif
|
53
|
+
elif node.condition is None:
|
55
54
|
continue
|
56
55
|
else:
|
57
56
|
target, value = node.op.condition
|
@@ -43,7 +43,7 @@ class Error(AnalysisPass):
|
|
43
43
|
if action in ["raise", "warn", "log"]:
|
44
44
|
self.action = action
|
45
45
|
else:
|
46
|
-
raise TranspilerError("Unknown action:
|
46
|
+
raise TranspilerError(f"Unknown action: {action}")
|
47
47
|
|
48
48
|
def run(self, _):
|
49
49
|
"""Run the Error pass on `dag`."""
|
@@ -66,4 +66,4 @@ class Error(AnalysisPass):
|
|
66
66
|
logger = logging.getLogger(__name__)
|
67
67
|
logger.info(msg)
|
68
68
|
else:
|
69
|
-
raise TranspilerError("Unknown action:
|
69
|
+
raise TranspilerError(f"Unknown action: {self.action}")
|
@@ -37,12 +37,12 @@ class FixedPoint(AnalysisPass):
|
|
37
37
|
def run(self, dag):
|
38
38
|
"""Run the FixedPoint pass on `dag`."""
|
39
39
|
current_value = self.property_set[self._property]
|
40
|
-
fixed_point_previous_property = "_fixed_point_previous_
|
40
|
+
fixed_point_previous_property = f"_fixed_point_previous_{self._property}"
|
41
41
|
|
42
42
|
if self.property_set[fixed_point_previous_property] is None:
|
43
|
-
self.property_set["
|
43
|
+
self.property_set[f"{self._property}_fixed_point"] = False
|
44
44
|
else:
|
45
45
|
fixed_point_reached = self.property_set[fixed_point_previous_property] == current_value
|
46
|
-
self.property_set["
|
46
|
+
self.property_set[f"{self._property}_fixed_point"] = fixed_point_reached
|
47
47
|
|
48
48
|
self.property_set[fixed_point_previous_property] = deepcopy(current_value)
|
@@ -67,7 +67,7 @@ class GateDirection(TransformationPass):
|
|
67
67
|
└──────┘ └───┘└──────┘└───┘
|
68
68
|
|
69
69
|
This pass assumes that the positions of the qubits in the :attr:`.DAGCircuit.qubits` attribute
|
70
|
-
are the physical qubit
|
70
|
+
are the physical qubit indices. For example if ``dag.qubits[0]`` is qubit 0 in the
|
71
71
|
:class:`.CouplingMap` or :class:`.Target`.
|
72
72
|
"""
|
73
73
|
|
@@ -12,7 +12,6 @@
|
|
12
12
|
|
13
13
|
"""Check if all gates in the DAGCircuit are in the specified basis gates."""
|
14
14
|
|
15
|
-
from qiskit.circuit import ControlFlowOp
|
16
15
|
from qiskit.converters import circuit_to_dag
|
17
16
|
from qiskit.transpiler.basepasses import AnalysisPass
|
18
17
|
|
@@ -55,7 +54,7 @@ class GatesInBasis(AnalysisPass):
|
|
55
54
|
return True
|
56
55
|
# Control-flow ops still need to be supported, so don't skip them in the
|
57
56
|
# previous checks.
|
58
|
-
if
|
57
|
+
if gate.is_control_flow():
|
59
58
|
for block in gate.op.blocks:
|
60
59
|
inner_wire_map = {
|
61
60
|
inner: wire_map[outer]
|
qiskit/transpiler/passmanager.py
CHANGED
@@ -18,7 +18,7 @@ import io
|
|
18
18
|
import re
|
19
19
|
from collections.abc import Iterator, Iterable, Callable
|
20
20
|
from functools import wraps
|
21
|
-
from typing import Union, List, Any
|
21
|
+
from typing import Union, List, Any, TypeVar
|
22
22
|
|
23
23
|
from qiskit.circuit import QuantumCircuit
|
24
24
|
from qiskit.converters import circuit_to_dag, dag_to_circuit
|
@@ -31,7 +31,7 @@ from .basepasses import BasePass
|
|
31
31
|
from .exceptions import TranspilerError
|
32
32
|
from .layout import TranspileLayout, Layout
|
33
33
|
|
34
|
-
_CircuitsT = Union[List[QuantumCircuit], QuantumCircuit]
|
34
|
+
_CircuitsT = TypeVar("_CircuitsT", bound=Union[List[QuantumCircuit], QuantumCircuit])
|
35
35
|
|
36
36
|
|
37
37
|
class PassManager(BasePassManager):
|
@@ -121,6 +121,7 @@ class PassManager(BasePassManager):
|
|
121
121
|
# Ordered list of original qubits
|
122
122
|
original_qubits_reverse = {v: k for k, v in original_qubit_indices.items()}
|
123
123
|
original_qubits = []
|
124
|
+
# pylint: disable-next=consider-using-enumerate
|
124
125
|
for i in range(len(original_qubits_reverse)):
|
125
126
|
original_qubits.append(original_qubits_reverse[i])
|
126
127
|
|
@@ -139,7 +140,7 @@ class PassManager(BasePassManager):
|
|
139
140
|
self.property_set["layout"] = t_initial_layout
|
140
141
|
self.property_set["final_layout"] = new_final_layout
|
141
142
|
|
142
|
-
def append(
|
143
|
+
def append( # pylint:disable=arguments-renamed
|
143
144
|
self,
|
144
145
|
passes: Task | list[Task],
|
145
146
|
) -> None:
|
@@ -153,7 +154,7 @@ class PassManager(BasePassManager):
|
|
153
154
|
"""
|
154
155
|
super().append(tasks=passes)
|
155
156
|
|
156
|
-
def replace(
|
157
|
+
def replace( # pylint:disable=arguments-renamed
|
157
158
|
self,
|
158
159
|
index: int,
|
159
160
|
passes: Task | list[Task],
|
@@ -167,7 +168,7 @@ class PassManager(BasePassManager):
|
|
167
168
|
super().replace(index, tasks=passes)
|
168
169
|
|
169
170
|
# pylint: disable=arguments-differ
|
170
|
-
def run(
|
171
|
+
def run( # pylint:disable=arguments-renamed
|
171
172
|
self,
|
172
173
|
circuits: _CircuitsT,
|
173
174
|
output_name: str | None = None,
|
@@ -337,7 +338,7 @@ class StagedPassManager(PassManager):
|
|
337
338
|
"scheduling",
|
338
339
|
]
|
339
340
|
self._validate_stages(stages)
|
340
|
-
# Set through parent class since `__setattr__`
|
341
|
+
# Set through parent class since `__setattr__` requires `expanded_stages` to be defined
|
341
342
|
super().__setattr__("_stages", tuple(stages))
|
342
343
|
super().__setattr__("_expanded_stages", tuple(self._generate_expanded_stages()))
|
343
344
|
super().__init__()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# This code is part of Qiskit.
|
2
2
|
#
|
3
|
-
# (C) Copyright IBM 2017,
|
3
|
+
# (C) Copyright IBM 2017, 2024.
|
4
4
|
#
|
5
5
|
# This code is licensed under the Apache License, Version 2.0. You may
|
6
6
|
# obtain a copy of this license in the LICENSE.txt file in the root directory
|
@@ -21,7 +21,8 @@ This module contains functions for generating the preset pass managers
|
|
21
21
|
for the transpiler. The preset pass managers are instances of
|
22
22
|
:class:`~.StagedPassManager` which are used to execute the circuit
|
23
23
|
transformations as part of Qiskit's compiler inside the
|
24
|
-
:func:`~.transpile` function at the different optimization levels
|
24
|
+
:func:`~.transpile` function at the different optimization levels, but
|
25
|
+
can also be used in a standalone manner.
|
25
26
|
The functionality here is divided into two parts, the first includes the
|
26
27
|
functions used generate the entire pass manager which is used by
|
27
28
|
:func:`~.transpile` (:ref:`preset_pass_manager_generators`) and the
|
@@ -56,238 +57,13 @@ Stage Generator Functions
|
|
56
57
|
.. autofunction:: generate_scheduling
|
57
58
|
.. currentmodule:: qiskit.transpiler.preset_passmanagers
|
58
59
|
"""
|
59
|
-
|
60
|
-
import warnings
|
61
|
-
|
62
|
-
from qiskit.transpiler.passmanager_config import PassManagerConfig
|
63
|
-
from qiskit.transpiler.target import target_to_backend_properties
|
64
|
-
from qiskit.transpiler import CouplingMap
|
65
|
-
|
60
|
+
from .generate_preset_pass_manager import generate_preset_pass_manager
|
66
61
|
from .level0 import level_0_pass_manager
|
67
62
|
from .level1 import level_1_pass_manager
|
68
63
|
from .level2 import level_2_pass_manager
|
69
64
|
from .level3 import level_3_pass_manager
|
70
65
|
|
71
66
|
|
72
|
-
def generate_preset_pass_manager(
|
73
|
-
optimization_level,
|
74
|
-
backend=None,
|
75
|
-
target=None,
|
76
|
-
basis_gates=None,
|
77
|
-
inst_map=None,
|
78
|
-
coupling_map=None,
|
79
|
-
instruction_durations=None,
|
80
|
-
backend_properties=None,
|
81
|
-
timing_constraints=None,
|
82
|
-
initial_layout=None,
|
83
|
-
layout_method=None,
|
84
|
-
routing_method=None,
|
85
|
-
translation_method=None,
|
86
|
-
scheduling_method=None,
|
87
|
-
approximation_degree=1.0,
|
88
|
-
seed_transpiler=None,
|
89
|
-
unitary_synthesis_method="default",
|
90
|
-
unitary_synthesis_plugin_config=None,
|
91
|
-
hls_config=None,
|
92
|
-
init_method=None,
|
93
|
-
optimization_method=None,
|
94
|
-
*,
|
95
|
-
_skip_target=False,
|
96
|
-
):
|
97
|
-
"""Generate a preset :class:`~.PassManager`
|
98
|
-
|
99
|
-
This function is used to quickly generate a preset pass manager. Preset pass
|
100
|
-
managers are the default pass managers used by the :func:`~.transpile`
|
101
|
-
function. This function provides a convenient and simple method to construct
|
102
|
-
a standalone :class:`~.PassManager` object that mirrors what the :func:`~.transpile`
|
103
|
-
function internally builds and uses.
|
104
|
-
|
105
|
-
The target constraints for the pass manager construction can be specified through a :class:`.Target`
|
106
|
-
instance, a :class:`.BackendV1` or :class:`.BackendV2` instance, or via loose constraints
|
107
|
-
(``basis_gates``, ``inst_map``, ``coupling_map``, ``backend_properties``, ``instruction_durations``,
|
108
|
-
``dt`` or ``timing_constraints``).
|
109
|
-
The order of priorities for target constraints works as follows: if a ``target``
|
110
|
-
input is provided, it will take priority over any ``backend`` input or loose constraints.
|
111
|
-
If a ``backend`` is provided together with any loose constraint
|
112
|
-
from the list above, the loose constraint will take priority over the corresponding backend
|
113
|
-
constraint. This behavior is independent of whether the ``backend`` instance is of type
|
114
|
-
:class:`.BackendV1` or :class:`.BackendV2`, as summarized in the table below. The first column
|
115
|
-
in the table summarizes the potential user-provided constraints, and each cell shows whether
|
116
|
-
the priority is assigned to that specific constraint input or another input
|
117
|
-
(`target`/`backend(V1)`/`backend(V2)`).
|
118
|
-
|
119
|
-
============================ ========= ======================== =======================
|
120
|
-
User Provided target backend(V1) backend(V2)
|
121
|
-
============================ ========= ======================== =======================
|
122
|
-
**basis_gates** target basis_gates basis_gates
|
123
|
-
**coupling_map** target coupling_map coupling_map
|
124
|
-
**instruction_durations** target instruction_durations instruction_durations
|
125
|
-
**inst_map** target inst_map inst_map
|
126
|
-
**dt** target dt dt
|
127
|
-
**timing_constraints** target timing_constraints timing_constraints
|
128
|
-
**backend_properties** target backend_properties backend_properties
|
129
|
-
============================ ========= ======================== =======================
|
130
|
-
|
131
|
-
Args:
|
132
|
-
optimization_level (int): The optimization level to generate a
|
133
|
-
:class:`~.PassManager` for. This can be 0, 1, 2, or 3. Higher
|
134
|
-
levels generate more optimized circuits, at the expense of
|
135
|
-
longer transpilation time:
|
136
|
-
|
137
|
-
* 0: no optimization
|
138
|
-
* 1: light optimization
|
139
|
-
* 2: heavy optimization
|
140
|
-
* 3: even heavier optimization
|
141
|
-
|
142
|
-
backend (Backend): An optional backend object which can be used as the
|
143
|
-
source of the default values for the ``basis_gates``, ``inst_map``,
|
144
|
-
``coupling_map``, ``backend_properties``, ``instruction_durations``,
|
145
|
-
``timing_constraints``, and ``target``. If any of those other arguments
|
146
|
-
are specified in addition to ``backend`` they will take precedence
|
147
|
-
over the value contained in the backend.
|
148
|
-
target (Target): The :class:`~.Target` representing a backend compilation
|
149
|
-
target. The following attributes will be inferred from this
|
150
|
-
argument if they are not set: ``coupling_map``, ``basis_gates``,
|
151
|
-
``instruction_durations``, ``inst_map``, ``timing_constraints``
|
152
|
-
and ``backend_properties``.
|
153
|
-
basis_gates (list): List of basis gate names to unroll to
|
154
|
-
(e.g: ``['u1', 'u2', 'u3', 'cx']``).
|
155
|
-
inst_map (InstructionScheduleMap): Mapping object that maps gate to schedules.
|
156
|
-
If any user defined calibration is found in the map and this is used in a
|
157
|
-
circuit, transpiler attaches the custom gate definition to the circuit.
|
158
|
-
This enables one to flexibly override the low-level instruction
|
159
|
-
implementation.
|
160
|
-
coupling_map (CouplingMap or list): Directed graph represented a coupling
|
161
|
-
map.
|
162
|
-
instruction_durations (InstructionDurations): Dictionary of duration
|
163
|
-
(in dt) for each instruction.
|
164
|
-
timing_constraints (TimingConstraints): Hardware time alignment restrictions.
|
165
|
-
initial_layout (Layout | List[int]): Initial position of virtual qubits on
|
166
|
-
physical qubits.
|
167
|
-
layout_method (str): The :class:`~.Pass` to use for choosing initial qubit
|
168
|
-
placement. Valid choices are ``'trivial'``, ``'dense'``,
|
169
|
-
and ``'sabre'``, representing :class:`~.TrivialLayout`, :class:`~.DenseLayout` and
|
170
|
-
:class:`~.SabreLayout` respectively. This can also
|
171
|
-
be the external plugin name to use for the ``layout`` stage of the output
|
172
|
-
:class:`~.StagedPassManager`. You can see a list of installed plugins by using
|
173
|
-
:func:`~.list_stage_plugins` with ``"layout"`` for the ``stage_name`` argument.
|
174
|
-
routing_method (str): The pass to use for routing qubits on the
|
175
|
-
architecture. Valid choices are ``'basic'``, ``'lookahead'``, ``'stochastic'``,
|
176
|
-
``'sabre'``, and ``'none'`` representing :class:`~.BasicSwap`,
|
177
|
-
:class:`~.LookaheadSwap`, :class:`~.StochasticSwap`, :class:`~.SabreSwap`, and
|
178
|
-
erroring if routing is required respectively. This can also be the external plugin
|
179
|
-
name to use for the ``routing`` stage of the output :class:`~.StagedPassManager`.
|
180
|
-
You can see a list of installed plugins by using :func:`~.list_stage_plugins` with
|
181
|
-
``"routing"`` for the ``stage_name`` argument.
|
182
|
-
translation_method (str): The method to use for translating gates to
|
183
|
-
basis gates. Valid choices ``'translator'``, ``'synthesis'`` representing
|
184
|
-
:class:`~.BasisTranslator`, and :class:`~.UnitarySynthesis` respectively. This can
|
185
|
-
also be the external plugin name to use for the ``translation`` stage of the output
|
186
|
-
:class:`~.StagedPassManager`. You can see a list of installed plugins by using
|
187
|
-
:func:`~.list_stage_plugins` with ``"translation"`` for the ``stage_name`` argument.
|
188
|
-
scheduling_method (str): The pass to use for scheduling instructions. Valid choices
|
189
|
-
are ``'alap'`` and ``'asap'``. This can also be the external plugin name to use
|
190
|
-
for the ``scheduling`` stage of the output :class:`~.StagedPassManager`. You can
|
191
|
-
see a list of installed plugins by using :func:`~.list_stage_plugins` with
|
192
|
-
``"scheduling"`` for the ``stage_name`` argument.
|
193
|
-
backend_properties (BackendProperties): Properties returned by a
|
194
|
-
backend, including information on gate errors, readout errors,
|
195
|
-
qubit coherence times, etc.
|
196
|
-
approximation_degree (float): Heuristic dial used for circuit approximation
|
197
|
-
(1.0=no approximation, 0.0=maximal approximation).
|
198
|
-
seed_transpiler (int): Sets random seed for the stochastic parts of
|
199
|
-
the transpiler.
|
200
|
-
unitary_synthesis_method (str): The name of the unitary synthesis
|
201
|
-
method to use. By default ``'default'`` is used. You can see a list of
|
202
|
-
installed plugins with :func:`.unitary_synthesis_plugin_names`.
|
203
|
-
unitary_synthesis_plugin_config (dict): An optional configuration dictionary
|
204
|
-
that will be passed directly to the unitary synthesis plugin. By
|
205
|
-
default this setting will have no effect as the default unitary
|
206
|
-
synthesis method does not take custom configuration. This should
|
207
|
-
only be necessary when a unitary synthesis plugin is specified with
|
208
|
-
the ``unitary_synthesis_method`` argument. As this is custom for each
|
209
|
-
unitary synthesis plugin refer to the plugin documentation for how
|
210
|
-
to use this option.
|
211
|
-
hls_config (HLSConfig): An optional configuration class :class:`~.HLSConfig`
|
212
|
-
that will be passed directly to :class:`~.HighLevelSynthesis` transformation pass.
|
213
|
-
This configuration class allows to specify for various high-level objects
|
214
|
-
the lists of synthesis algorithms and their parameters.
|
215
|
-
init_method (str): The plugin name to use for the ``init`` stage of
|
216
|
-
the output :class:`~.StagedPassManager`. By default an external
|
217
|
-
plugin is not used. You can see a list of installed plugins by
|
218
|
-
using :func:`~.list_stage_plugins` with ``"init"`` for the stage
|
219
|
-
name argument.
|
220
|
-
optimization_method (str): The plugin name to use for the
|
221
|
-
``optimization`` stage of the output
|
222
|
-
:class:`~.StagedPassManager`. By default an external
|
223
|
-
plugin is not used. You can see a list of installed plugins by
|
224
|
-
using :func:`~.list_stage_plugins` with ``"optimization"`` for the
|
225
|
-
``stage_name`` argument.
|
226
|
-
|
227
|
-
Returns:
|
228
|
-
StagedPassManager: The preset pass manager for the given options
|
229
|
-
|
230
|
-
Raises:
|
231
|
-
ValueError: if an invalid value for ``optimization_level`` is passed in.
|
232
|
-
"""
|
233
|
-
|
234
|
-
if coupling_map is not None and not isinstance(coupling_map, CouplingMap):
|
235
|
-
coupling_map = CouplingMap(coupling_map)
|
236
|
-
|
237
|
-
if target is not None:
|
238
|
-
if coupling_map is None:
|
239
|
-
coupling_map = target.build_coupling_map()
|
240
|
-
if basis_gates is None:
|
241
|
-
basis_gates = target.operation_names
|
242
|
-
if instruction_durations is None:
|
243
|
-
instruction_durations = target.durations()
|
244
|
-
if inst_map is None:
|
245
|
-
inst_map = target.instruction_schedule_map()
|
246
|
-
if timing_constraints is None:
|
247
|
-
timing_constraints = target.timing_constraints()
|
248
|
-
if backend_properties is None:
|
249
|
-
backend_properties = target_to_backend_properties(target)
|
250
|
-
|
251
|
-
pm_options = {
|
252
|
-
"target": target,
|
253
|
-
"basis_gates": basis_gates,
|
254
|
-
"inst_map": inst_map,
|
255
|
-
"coupling_map": coupling_map,
|
256
|
-
"instruction_durations": instruction_durations,
|
257
|
-
"backend_properties": backend_properties,
|
258
|
-
"timing_constraints": timing_constraints,
|
259
|
-
"layout_method": layout_method,
|
260
|
-
"routing_method": routing_method,
|
261
|
-
"translation_method": translation_method,
|
262
|
-
"scheduling_method": scheduling_method,
|
263
|
-
"approximation_degree": approximation_degree,
|
264
|
-
"seed_transpiler": seed_transpiler,
|
265
|
-
"unitary_synthesis_method": unitary_synthesis_method,
|
266
|
-
"unitary_synthesis_plugin_config": unitary_synthesis_plugin_config,
|
267
|
-
"initial_layout": initial_layout,
|
268
|
-
"hls_config": hls_config,
|
269
|
-
"init_method": init_method,
|
270
|
-
"optimization_method": optimization_method,
|
271
|
-
}
|
272
|
-
|
273
|
-
if backend is not None:
|
274
|
-
pm_options["_skip_target"] = _skip_target
|
275
|
-
pm_config = PassManagerConfig.from_backend(backend, **pm_options)
|
276
|
-
else:
|
277
|
-
pm_config = PassManagerConfig(**pm_options)
|
278
|
-
if optimization_level == 0:
|
279
|
-
pm = level_0_pass_manager(pm_config)
|
280
|
-
elif optimization_level == 1:
|
281
|
-
pm = level_1_pass_manager(pm_config)
|
282
|
-
elif optimization_level == 2:
|
283
|
-
pm = level_2_pass_manager(pm_config)
|
284
|
-
elif optimization_level == 3:
|
285
|
-
pm = level_3_pass_manager(pm_config)
|
286
|
-
else:
|
287
|
-
raise ValueError(f"Invalid optimization level {optimization_level}")
|
288
|
-
return pm
|
289
|
-
|
290
|
-
|
291
67
|
__all__ = [
|
292
68
|
"level_0_pass_manager",
|
293
69
|
"level_1_pass_manager",
|
@@ -12,6 +12,9 @@
|
|
12
12
|
|
13
13
|
"""Built-in transpiler stage plugins for preset pass managers."""
|
14
14
|
|
15
|
+
import os
|
16
|
+
|
17
|
+
from qiskit.transpiler.passes.optimization.split_2q_unitaries import Split2QUnitaries
|
15
18
|
from qiskit.transpiler.passmanager import PassManager
|
16
19
|
from qiskit.transpiler.exceptions import TranspilerError
|
17
20
|
from qiskit.transpiler.passes import BasicSwap
|
@@ -63,6 +66,20 @@ from qiskit.circuit.library.standard_gates import (
|
|
63
66
|
SXGate,
|
64
67
|
SXdgGate,
|
65
68
|
)
|
69
|
+
from qiskit.utils.parallel import CPU_COUNT
|
70
|
+
from qiskit import user_config
|
71
|
+
|
72
|
+
CONFIG = user_config.get_config()
|
73
|
+
|
74
|
+
_discrete_skipped_ops = {
|
75
|
+
"delay",
|
76
|
+
"reset",
|
77
|
+
"measure",
|
78
|
+
"switch_case",
|
79
|
+
"if_else",
|
80
|
+
"for_loop",
|
81
|
+
"while_loop",
|
82
|
+
}
|
66
83
|
|
67
84
|
|
68
85
|
class DefaultInitPassManager(PassManagerStagePlugin):
|
@@ -154,6 +171,16 @@ class DefaultInitPassManager(PassManagerStagePlugin):
|
|
154
171
|
)
|
155
172
|
)
|
156
173
|
init.append(CommutativeCancellation())
|
174
|
+
init.append(Collect2qBlocks())
|
175
|
+
init.append(ConsolidateBlocks())
|
176
|
+
# If approximation degree is None that indicates a request to approximate up to the
|
177
|
+
# error rates in the target. However, in the init stage we don't yet know the target
|
178
|
+
# qubits being used to figure out the fidelity so just use the default fidelity parameter
|
179
|
+
# in this case.
|
180
|
+
if pass_manager_config.approximation_degree is not None:
|
181
|
+
init.append(Split2QUnitaries(pass_manager_config.approximation_degree))
|
182
|
+
else:
|
183
|
+
init.append(Split2QUnitaries())
|
157
184
|
else:
|
158
185
|
raise TranspilerError(f"Invalid optimization level {optimization_level}")
|
159
186
|
return init
|
@@ -397,11 +424,12 @@ class SabreSwapPassManager(PassManagerStagePlugin):
|
|
397
424
|
pass_manager_config.initial_layout,
|
398
425
|
)
|
399
426
|
if optimization_level == 0:
|
427
|
+
trial_count = _get_trial_count(5)
|
400
428
|
routing_pass = SabreSwap(
|
401
429
|
coupling_map_routing,
|
402
430
|
heuristic="basic",
|
403
431
|
seed=seed_transpiler,
|
404
|
-
trials=
|
432
|
+
trials=trial_count,
|
405
433
|
)
|
406
434
|
return common.generate_routing_passmanager(
|
407
435
|
routing_pass,
|
@@ -411,11 +439,12 @@ class SabreSwapPassManager(PassManagerStagePlugin):
|
|
411
439
|
use_barrier_before_measurement=True,
|
412
440
|
)
|
413
441
|
if optimization_level == 1:
|
442
|
+
trial_count = _get_trial_count(5)
|
414
443
|
routing_pass = SabreSwap(
|
415
444
|
coupling_map_routing,
|
416
445
|
heuristic="decay",
|
417
446
|
seed=seed_transpiler,
|
418
|
-
trials=
|
447
|
+
trials=trial_count,
|
419
448
|
)
|
420
449
|
return common.generate_routing_passmanager(
|
421
450
|
routing_pass,
|
@@ -429,11 +458,13 @@ class SabreSwapPassManager(PassManagerStagePlugin):
|
|
429
458
|
use_barrier_before_measurement=True,
|
430
459
|
)
|
431
460
|
if optimization_level == 2:
|
461
|
+
trial_count = _get_trial_count(20)
|
462
|
+
|
432
463
|
routing_pass = SabreSwap(
|
433
464
|
coupling_map_routing,
|
434
465
|
heuristic="decay",
|
435
466
|
seed=seed_transpiler,
|
436
|
-
trials=
|
467
|
+
trials=trial_count,
|
437
468
|
)
|
438
469
|
return common.generate_routing_passmanager(
|
439
470
|
routing_pass,
|
@@ -446,11 +477,12 @@ class SabreSwapPassManager(PassManagerStagePlugin):
|
|
446
477
|
use_barrier_before_measurement=True,
|
447
478
|
)
|
448
479
|
if optimization_level == 3:
|
480
|
+
trial_count = _get_trial_count(20)
|
449
481
|
routing_pass = SabreSwap(
|
450
482
|
coupling_map_routing,
|
451
483
|
heuristic="decay",
|
452
484
|
seed=seed_transpiler,
|
453
|
-
trials=
|
485
|
+
trials=trial_count,
|
454
486
|
)
|
455
487
|
return common.generate_routing_passmanager(
|
456
488
|
routing_pass,
|
@@ -737,12 +769,15 @@ class DefaultLayoutPassManager(PassManagerStagePlugin):
|
|
737
769
|
max_trials=2500, # Limits layout scoring to < 600ms on ~400 qubit devices
|
738
770
|
)
|
739
771
|
layout.append(ConditionalController(choose_layout_1, condition=_layout_not_perfect))
|
772
|
+
|
773
|
+
trial_count = _get_trial_count(5)
|
774
|
+
|
740
775
|
choose_layout_2 = SabreLayout(
|
741
776
|
coupling_map,
|
742
777
|
max_iterations=2,
|
743
778
|
seed=pass_manager_config.seed_transpiler,
|
744
|
-
swap_trials=
|
745
|
-
layout_trials=
|
779
|
+
swap_trials=trial_count,
|
780
|
+
layout_trials=trial_count,
|
746
781
|
skip_routing=pass_manager_config.routing_method is not None
|
747
782
|
and pass_manager_config.routing_method != "sabre",
|
748
783
|
)
|
@@ -769,12 +804,15 @@ class DefaultLayoutPassManager(PassManagerStagePlugin):
|
|
769
804
|
layout.append(
|
770
805
|
ConditionalController(choose_layout_0, condition=_choose_layout_condition)
|
771
806
|
)
|
807
|
+
|
808
|
+
trial_count = _get_trial_count(20)
|
809
|
+
|
772
810
|
choose_layout_1 = SabreLayout(
|
773
811
|
coupling_map,
|
774
812
|
max_iterations=2,
|
775
813
|
seed=pass_manager_config.seed_transpiler,
|
776
|
-
swap_trials=
|
777
|
-
layout_trials=
|
814
|
+
swap_trials=trial_count,
|
815
|
+
layout_trials=trial_count,
|
778
816
|
skip_routing=pass_manager_config.routing_method is not None
|
779
817
|
and pass_manager_config.routing_method != "sabre",
|
780
818
|
)
|
@@ -801,12 +839,15 @@ class DefaultLayoutPassManager(PassManagerStagePlugin):
|
|
801
839
|
layout.append(
|
802
840
|
ConditionalController(choose_layout_0, condition=_choose_layout_condition)
|
803
841
|
)
|
842
|
+
|
843
|
+
trial_count = _get_trial_count(20)
|
844
|
+
|
804
845
|
choose_layout_1 = SabreLayout(
|
805
846
|
coupling_map,
|
806
847
|
max_iterations=4,
|
807
848
|
seed=pass_manager_config.seed_transpiler,
|
808
|
-
swap_trials=
|
809
|
-
layout_trials=
|
849
|
+
swap_trials=trial_count,
|
850
|
+
layout_trials=trial_count,
|
810
851
|
skip_routing=pass_manager_config.routing_method is not None
|
811
852
|
and pass_manager_config.routing_method != "sabre",
|
812
853
|
)
|
@@ -902,42 +943,50 @@ class SabreLayoutPassManager(PassManagerStagePlugin):
|
|
902
943
|
layout = PassManager()
|
903
944
|
layout.append(_given_layout)
|
904
945
|
if optimization_level == 0:
|
946
|
+
trial_count = _get_trial_count(5)
|
947
|
+
|
905
948
|
layout_pass = SabreLayout(
|
906
949
|
coupling_map,
|
907
950
|
max_iterations=1,
|
908
951
|
seed=pass_manager_config.seed_transpiler,
|
909
|
-
swap_trials=
|
910
|
-
layout_trials=
|
952
|
+
swap_trials=trial_count,
|
953
|
+
layout_trials=trial_count,
|
911
954
|
skip_routing=pass_manager_config.routing_method is not None
|
912
955
|
and pass_manager_config.routing_method != "sabre",
|
913
956
|
)
|
914
957
|
elif optimization_level == 1:
|
958
|
+
trial_count = _get_trial_count(5)
|
959
|
+
|
915
960
|
layout_pass = SabreLayout(
|
916
961
|
coupling_map,
|
917
962
|
max_iterations=2,
|
918
963
|
seed=pass_manager_config.seed_transpiler,
|
919
|
-
swap_trials=
|
920
|
-
layout_trials=
|
964
|
+
swap_trials=trial_count,
|
965
|
+
layout_trials=trial_count,
|
921
966
|
skip_routing=pass_manager_config.routing_method is not None
|
922
967
|
and pass_manager_config.routing_method != "sabre",
|
923
968
|
)
|
924
969
|
elif optimization_level == 2:
|
970
|
+
trial_count = _get_trial_count(20)
|
971
|
+
|
925
972
|
layout_pass = SabreLayout(
|
926
973
|
coupling_map,
|
927
974
|
max_iterations=2,
|
928
975
|
seed=pass_manager_config.seed_transpiler,
|
929
|
-
swap_trials=
|
930
|
-
layout_trials=
|
976
|
+
swap_trials=trial_count,
|
977
|
+
layout_trials=trial_count,
|
931
978
|
skip_routing=pass_manager_config.routing_method is not None
|
932
979
|
and pass_manager_config.routing_method != "sabre",
|
933
980
|
)
|
934
981
|
elif optimization_level == 3:
|
982
|
+
trial_count = _get_trial_count(20)
|
983
|
+
|
935
984
|
layout_pass = SabreLayout(
|
936
985
|
coupling_map,
|
937
986
|
max_iterations=4,
|
938
987
|
seed=pass_manager_config.seed_transpiler,
|
939
|
-
swap_trials=
|
940
|
-
layout_trials=
|
988
|
+
swap_trials=trial_count,
|
989
|
+
layout_trials=trial_count,
|
941
990
|
skip_routing=pass_manager_config.routing_method is not None
|
942
991
|
and pass_manager_config.routing_method != "sabre",
|
943
992
|
)
|
@@ -957,3 +1006,9 @@ class SabreLayoutPassManager(PassManagerStagePlugin):
|
|
957
1006
|
embed = common.generate_embed_passmanager(coupling_map)
|
958
1007
|
layout.append(ConditionalController(embed.to_flow_controller(), condition=_swap_mapped))
|
959
1008
|
return layout
|
1009
|
+
|
1010
|
+
|
1011
|
+
def _get_trial_count(default_trials=5):
|
1012
|
+
if CONFIG.get("sabre_all_threads", None) or os.getenv("QISKIT_SABRE_ALL_THREADS"):
|
1013
|
+
return max(CPU_COUNT, default_trials)
|
1014
|
+
return default_trials
|
@@ -364,10 +364,7 @@ def generate_routing_passmanager(
|
|
364
364
|
routing.append(ConditionalController(ApplyLayout(), condition=_apply_post_layout_condition))
|
365
365
|
|
366
366
|
def filter_fn(node):
|
367
|
-
return
|
368
|
-
getattr(node.op, "label", None)
|
369
|
-
!= "qiskit.transpiler.internal.routing.protection.barrier"
|
370
|
-
)
|
367
|
+
return node.label != "qiskit.transpiler.internal.routing.protection.barrier"
|
371
368
|
|
372
369
|
routing.append([FilterOpNodes(filter_fn)])
|
373
370
|
|
@@ -518,7 +515,7 @@ def generate_translation_passmanager(
|
|
518
515
|
),
|
519
516
|
]
|
520
517
|
else:
|
521
|
-
raise TranspilerError("Invalid translation method
|
518
|
+
raise TranspilerError(f"Invalid translation method {method}.")
|
522
519
|
return PassManager(unroll)
|
523
520
|
|
524
521
|
|
@@ -557,7 +554,7 @@ def generate_scheduling(
|
|
557
554
|
try:
|
558
555
|
scheduling.append(scheduler[scheduling_method](instruction_durations, target=target))
|
559
556
|
except KeyError as ex:
|
560
|
-
raise TranspilerError("Invalid scheduling method
|
557
|
+
raise TranspilerError(f"Invalid scheduling method {scheduling_method}.") from ex
|
561
558
|
elif instruction_durations:
|
562
559
|
# No scheduling. But do unit conversion for delays.
|
563
560
|
def _contains_delay(property_set):
|