qiskit 1.4.2__cp39-abi3-macosx_11_0_arm64.whl → 2.0.0__cp39-abi3-macosx_11_0_arm64.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 +3 -9
- qiskit/_accelerate.abi3.so +0 -0
- qiskit/circuit/__init__.py +35 -10
- qiskit/circuit/{add_control.py → _add_control.py} +32 -12
- qiskit/circuit/_classical_resource_map.py +5 -3
- qiskit/circuit/barrier.py +3 -7
- qiskit/circuit/classical/expr/__init__.py +31 -3
- qiskit/circuit/classical/expr/constructors.py +236 -28
- qiskit/circuit/classical/expr/expr.py +104 -3
- qiskit/circuit/classical/expr/visitors.py +75 -0
- qiskit/circuit/classical/types/__init__.py +12 -8
- qiskit/circuit/classical/types/ordering.py +14 -7
- qiskit/circuit/classical/types/types.py +36 -0
- qiskit/circuit/commutation_checker.py +34 -7
- qiskit/circuit/controlflow/__init__.py +32 -1
- qiskit/circuit/controlflow/_builder_utils.py +9 -5
- qiskit/circuit/controlflow/box.py +163 -0
- qiskit/circuit/controlflow/break_loop.py +1 -1
- qiskit/circuit/controlflow/builder.py +139 -39
- qiskit/circuit/controlflow/continue_loop.py +1 -3
- qiskit/circuit/controlflow/control_flow.py +10 -0
- qiskit/circuit/controlflow/for_loop.py +2 -1
- qiskit/circuit/controlflow/if_else.py +3 -16
- qiskit/circuit/controlflow/switch_case.py +2 -8
- qiskit/circuit/controlflow/while_loop.py +2 -7
- qiskit/circuit/controlledgate.py +2 -4
- qiskit/circuit/delay.py +40 -11
- qiskit/circuit/duration.py +0 -15
- qiskit/circuit/gate.py +2 -4
- qiskit/circuit/instruction.py +2 -141
- qiskit/circuit/instructionset.py +7 -54
- qiskit/circuit/library/__init__.py +469 -154
- qiskit/circuit/library/arithmetic/__init__.py +16 -10
- qiskit/circuit/library/arithmetic/adders/cdkm_ripple_carry_adder.py +1 -1
- qiskit/circuit/library/arithmetic/adders/draper_qft_adder.py +2 -2
- qiskit/circuit/library/arithmetic/adders/vbe_ripple_carry_adder.py +1 -1
- qiskit/circuit/library/arithmetic/exact_reciprocal.py +64 -21
- qiskit/circuit/library/arithmetic/integer_comparator.py +37 -80
- qiskit/circuit/library/arithmetic/linear_amplitude_function.py +169 -2
- qiskit/circuit/library/arithmetic/linear_pauli_rotations.py +59 -5
- qiskit/circuit/library/arithmetic/piecewise_chebyshev.py +154 -6
- qiskit/circuit/library/arithmetic/piecewise_linear_pauli_rotations.py +114 -4
- qiskit/circuit/library/arithmetic/piecewise_polynomial_pauli_rotations.py +191 -15
- qiskit/circuit/library/arithmetic/polynomial_pauli_rotations.py +93 -39
- qiskit/circuit/library/arithmetic/quadratic_form.py +168 -2
- qiskit/circuit/library/arithmetic/weighted_adder.py +73 -1
- qiskit/circuit/library/bit_flip_oracle.py +130 -0
- qiskit/circuit/library/blueprintcircuit.py +52 -16
- qiskit/circuit/library/data_preparation/initializer.py +1 -1
- qiskit/circuit/library/data_preparation/pauli_feature_map.py +4 -4
- qiskit/circuit/library/data_preparation/state_preparation.py +1 -1
- qiskit/circuit/library/generalized_gates/gms.py +1 -1
- qiskit/circuit/library/generalized_gates/isometry.py +1 -1
- qiskit/circuit/library/generalized_gates/pauli.py +1 -2
- qiskit/circuit/library/generalized_gates/uc.py +97 -7
- qiskit/circuit/library/generalized_gates/uc_pauli_rot.py +1 -1
- qiskit/circuit/library/generalized_gates/unitary.py +4 -2
- qiskit/circuit/library/graph_state.py +1 -0
- qiskit/circuit/library/hamiltonian_gate.py +1 -1
- qiskit/circuit/library/n_local/evolved_operator_ansatz.py +1 -1
- qiskit/circuit/library/n_local/n_local.py +1 -1
- qiskit/circuit/library/n_local/qaoa_ansatz.py +1 -1
- qiskit/circuit/library/overlap.py +2 -2
- qiskit/circuit/library/pauli_evolution.py +39 -24
- qiskit/circuit/library/phase_oracle.py +130 -51
- qiskit/circuit/library/standard_gates/__init__.py +0 -1
- qiskit/circuit/library/standard_gates/dcx.py +3 -4
- qiskit/circuit/library/standard_gates/ecr.py +3 -4
- qiskit/circuit/library/standard_gates/global_phase.py +5 -6
- qiskit/circuit/library/standard_gates/h.py +4 -9
- qiskit/circuit/library/standard_gates/i.py +2 -2
- qiskit/circuit/library/standard_gates/iswap.py +3 -4
- qiskit/circuit/library/standard_gates/p.py +15 -34
- qiskit/circuit/library/standard_gates/r.py +7 -10
- qiskit/circuit/library/standard_gates/rx.py +5 -15
- qiskit/circuit/library/standard_gates/rxx.py +3 -6
- qiskit/circuit/library/standard_gates/ry.py +5 -17
- qiskit/circuit/library/standard_gates/ryy.py +3 -6
- qiskit/circuit/library/standard_gates/rz.py +5 -17
- qiskit/circuit/library/standard_gates/rzx.py +3 -6
- qiskit/circuit/library/standard_gates/rzz.py +3 -6
- qiskit/circuit/library/standard_gates/s.py +6 -15
- qiskit/circuit/library/standard_gates/swap.py +4 -11
- qiskit/circuit/library/standard_gates/sx.py +7 -12
- qiskit/circuit/library/standard_gates/t.py +6 -7
- qiskit/circuit/library/standard_gates/u.py +2 -10
- qiskit/circuit/library/standard_gates/u1.py +5 -16
- qiskit/circuit/library/standard_gates/u2.py +2 -6
- qiskit/circuit/library/standard_gates/u3.py +3 -11
- qiskit/circuit/library/standard_gates/x.py +14 -62
- qiskit/circuit/library/standard_gates/xx_minus_yy.py +2 -5
- qiskit/circuit/library/standard_gates/xx_plus_yy.py +2 -5
- qiskit/circuit/library/standard_gates/y.py +4 -9
- qiskit/circuit/library/standard_gates/z.py +5 -15
- qiskit/circuit/measure.py +11 -2
- qiskit/circuit/parameterexpression.py +7 -1
- qiskit/circuit/quantumcircuit.py +890 -564
- qiskit/circuit/random/utils.py +12 -6
- qiskit/circuit/reset.py +5 -2
- qiskit/circuit/singleton.py +5 -11
- qiskit/circuit/store.py +0 -8
- qiskit/compiler/__init__.py +1 -7
- qiskit/compiler/transpiler.py +38 -196
- qiskit/converters/circuit_to_dag.py +6 -4
- qiskit/converters/circuit_to_dagdependency.py +0 -2
- qiskit/converters/circuit_to_dagdependency_v2.py +0 -1
- qiskit/converters/circuit_to_gate.py +1 -1
- qiskit/converters/circuit_to_instruction.py +16 -29
- qiskit/converters/dag_to_circuit.py +7 -8
- qiskit/converters/dag_to_dagdependency.py +0 -1
- qiskit/converters/dag_to_dagdependency_v2.py +0 -1
- qiskit/converters/dagdependency_to_circuit.py +0 -6
- qiskit/converters/dagdependency_to_dag.py +0 -6
- qiskit/dagcircuit/collect_blocks.py +32 -20
- qiskit/dagcircuit/dagdependency.py +3 -37
- qiskit/dagcircuit/dagdependency_v2.py +5 -82
- qiskit/dagcircuit/dagnode.py +14 -2
- qiskit/passmanager/__init__.py +24 -6
- qiskit/passmanager/passmanager.py +26 -24
- qiskit/primitives/__init__.py +44 -35
- qiskit/primitives/backend_estimator_v2.py +102 -23
- qiskit/primitives/backend_sampler_v2.py +5 -20
- qiskit/primitives/base/__init__.py +4 -4
- qiskit/primitives/base/base_estimator.py +77 -82
- qiskit/primitives/base/base_primitive_job.py +2 -2
- qiskit/primitives/base/{base_primitive.py → base_primitive_v1.py} +1 -1
- qiskit/primitives/base/{base_result.py → base_result_v1.py} +1 -1
- qiskit/primitives/base/base_sampler.py +52 -60
- qiskit/primitives/base/{estimator_result.py → estimator_result_v1.py} +2 -2
- qiskit/primitives/base/{sampler_result.py → sampler_result_v1.py} +2 -2
- qiskit/primitives/base/{validation.py → validation_v1.py} +34 -15
- qiskit/primitives/containers/bindings_array.py +3 -1
- qiskit/primitives/containers/bit_array.py +23 -0
- qiskit/primitives/containers/data_bin.py +3 -1
- qiskit/primitives/containers/observables_array.py +19 -2
- qiskit/primitives/statevector_sampler.py +6 -8
- qiskit/primitives/utils.py +14 -189
- qiskit/providers/__init__.py +4 -130
- qiskit/providers/backend.py +11 -314
- qiskit/providers/basic_provider/__init__.py +3 -1
- qiskit/providers/basic_provider/basic_provider.py +29 -9
- qiskit/providers/basic_provider/basic_simulator.py +158 -298
- qiskit/providers/exceptions.py +0 -33
- qiskit/providers/fake_provider/__init__.py +0 -37
- qiskit/providers/fake_provider/generic_backend_v2.py +32 -693
- qiskit/qasm2/__init__.py +21 -6
- qiskit/qasm2/export.py +2 -10
- qiskit/qasm2/parse.py +11 -25
- qiskit/qasm3/__init__.py +5 -1
- qiskit/qasm3/ast.py +44 -0
- qiskit/qasm3/exporter.py +65 -27
- qiskit/qasm3/printer.py +35 -4
- qiskit/qpy/__init__.py +162 -19
- qiskit/qpy/binary_io/__init__.py +0 -1
- qiskit/qpy/binary_io/circuits.py +98 -130
- qiskit/qpy/binary_io/schedules.py +69 -439
- qiskit/qpy/binary_io/value.py +154 -31
- qiskit/qpy/common.py +10 -7
- qiskit/qpy/formats.py +41 -0
- qiskit/qpy/interface.py +34 -81
- qiskit/qpy/type_keys.py +58 -221
- qiskit/quantum_info/analysis/distance.py +3 -1
- qiskit/quantum_info/operators/dihedral/dihedral.py +3 -1
- qiskit/quantum_info/operators/operator.py +6 -2
- qiskit/quantum_info/operators/symplectic/clifford.py +3 -1
- qiskit/quantum_info/operators/symplectic/pauli.py +4 -2
- qiskit/quantum_info/operators/symplectic/pauli_list.py +17 -5
- qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +40 -6
- qiskit/quantum_info/states/densitymatrix.py +16 -6
- qiskit/quantum_info/states/stabilizerstate.py +35 -4
- qiskit/quantum_info/states/statevector.py +16 -6
- qiskit/result/__init__.py +5 -17
- qiskit/result/models.py +18 -11
- qiskit/result/result.py +38 -134
- qiskit/result/sampled_expval.py +1 -2
- qiskit/result/utils.py +3 -4
- qiskit/synthesis/__init__.py +21 -1
- qiskit/synthesis/arithmetic/__init__.py +3 -1
- qiskit/synthesis/arithmetic/adders/cdkm_ripple_carry_adder.py +1 -1
- qiskit/synthesis/arithmetic/adders/draper_qft_adder.py +1 -1
- qiskit/synthesis/arithmetic/adders/vbe_ripple_carry_adder.py +2 -2
- qiskit/{providers/fake_provider/backends_v1/fake_20q → synthesis/arithmetic/comparators}/__init__.py +4 -6
- qiskit/synthesis/arithmetic/comparators/compare_2s.py +112 -0
- qiskit/synthesis/arithmetic/comparators/compare_greedy.py +66 -0
- qiskit/synthesis/arithmetic/multipliers/hrs_cumulative_multiplier.py +1 -1
- qiskit/synthesis/arithmetic/multipliers/rg_qft_multiplier.py +1 -1
- qiskit/synthesis/arithmetic/weighted_sum.py +155 -0
- qiskit/{result/mitigation → synthesis/boolean}/__init__.py +2 -2
- qiskit/synthesis/boolean/boolean_expression.py +231 -0
- qiskit/synthesis/boolean/boolean_expression_synth.py +124 -0
- qiskit/synthesis/boolean/boolean_expression_visitor.py +96 -0
- qiskit/synthesis/evolution/lie_trotter.py +10 -7
- qiskit/synthesis/evolution/product_formula.py +44 -35
- qiskit/synthesis/evolution/qdrift.py +17 -24
- qiskit/synthesis/evolution/suzuki_trotter.py +20 -27
- qiskit/synthesis/linear/linear_depth_lnn.py +6 -221
- qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py +4 -205
- qiskit/synthesis/multi_controlled/__init__.py +1 -0
- qiskit/synthesis/multi_controlled/mcx_synthesis.py +5 -2
- qiskit/synthesis/multi_controlled/multi_control_rotation_gates.py +206 -0
- qiskit/synthesis/one_qubit/one_qubit_decompose.py +1 -1
- qiskit/synthesis/two_qubit/__init__.py +1 -0
- qiskit/synthesis/two_qubit/two_qubit_decompose.py +28 -145
- qiskit/transpiler/__init__.py +32 -232
- qiskit/transpiler/basepasses.py +20 -51
- qiskit/transpiler/layout.py +1 -1
- qiskit/transpiler/passes/__init__.py +4 -40
- qiskit/transpiler/passes/basis/basis_translator.py +5 -4
- qiskit/transpiler/passes/basis/decompose.py +1 -15
- qiskit/transpiler/passes/basis/unroll_3q_or_more.py +1 -5
- qiskit/transpiler/passes/basis/unroll_custom_definitions.py +3 -2
- qiskit/transpiler/passes/layout/apply_layout.py +4 -0
- qiskit/transpiler/passes/layout/dense_layout.py +2 -39
- qiskit/transpiler/passes/layout/full_ancilla_allocation.py +3 -4
- qiskit/transpiler/passes/layout/sabre_layout.py +7 -3
- qiskit/transpiler/passes/layout/vf2_layout.py +2 -20
- qiskit/transpiler/passes/layout/vf2_post_layout.py +60 -125
- qiskit/transpiler/passes/layout/vf2_utils.py +2 -26
- qiskit/transpiler/passes/optimization/__init__.py +2 -3
- qiskit/transpiler/passes/optimization/collect_and_collapse.py +2 -0
- qiskit/transpiler/passes/optimization/collect_cliffords.py +5 -0
- qiskit/transpiler/passes/optimization/collect_linear_functions.py +5 -0
- qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py +16 -1
- qiskit/transpiler/passes/optimization/commutation_analysis.py +3 -3
- qiskit/transpiler/passes/optimization/consolidate_blocks.py +41 -19
- qiskit/transpiler/passes/optimization/contract_idle_wires_in_control_flow.py +104 -0
- qiskit/transpiler/passes/optimization/light_cone.py +135 -0
- qiskit/transpiler/passes/optimization/optimize_1q_commutation.py +0 -1
- qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +18 -22
- qiskit/transpiler/passes/optimization/optimize_annotated.py +3 -2
- qiskit/transpiler/passes/optimization/remove_identity_equiv.py +6 -4
- qiskit/transpiler/passes/optimization/reset_after_measure_simplification.py +5 -2
- qiskit/transpiler/passes/optimization/split_2q_unitaries.py +26 -3
- qiskit/transpiler/passes/optimization/template_matching/template_substitution.py +1 -0
- qiskit/transpiler/passes/routing/__init__.py +0 -1
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py +3 -1
- qiskit/transpiler/passes/routing/sabre_swap.py +14 -6
- qiskit/transpiler/passes/routing/star_prerouting.py +1 -1
- qiskit/transpiler/passes/scheduling/__init__.py +1 -7
- qiskit/transpiler/passes/scheduling/alignments/__init__.py +2 -4
- qiskit/transpiler/passes/scheduling/alignments/check_durations.py +1 -9
- qiskit/transpiler/passes/scheduling/alignments/reschedule.py +17 -16
- qiskit/transpiler/passes/scheduling/padding/base_padding.py +32 -4
- qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +25 -63
- qiskit/transpiler/passes/scheduling/padding/pad_delay.py +12 -4
- qiskit/transpiler/passes/scheduling/scheduling/alap.py +5 -39
- qiskit/transpiler/passes/scheduling/scheduling/asap.py +4 -35
- qiskit/transpiler/passes/scheduling/scheduling/base_scheduler.py +10 -16
- qiskit/transpiler/passes/scheduling/time_unit_conversion.py +134 -62
- qiskit/transpiler/passes/synthesis/default_unitary_synth_plugin.py +653 -0
- qiskit/transpiler/passes/synthesis/high_level_synthesis.py +176 -601
- qiskit/transpiler/passes/synthesis/hls_plugins.py +294 -1
- qiskit/transpiler/passes/synthesis/plugin.py +4 -0
- qiskit/transpiler/passes/synthesis/solovay_kitaev_synthesis.py +16 -10
- qiskit/transpiler/passes/synthesis/unitary_synthesis.py +34 -697
- qiskit/transpiler/passes/utils/__init__.py +0 -1
- qiskit/transpiler/passes/utils/check_gate_direction.py +13 -5
- qiskit/transpiler/passes/utils/control_flow.py +2 -6
- qiskit/transpiler/passes/utils/gate_direction.py +7 -0
- qiskit/transpiler/passes/utils/remove_final_measurements.py +40 -33
- qiskit/transpiler/passmanager.py +13 -0
- qiskit/transpiler/passmanager_config.py +5 -81
- qiskit/transpiler/preset_passmanagers/builtin_plugins.py +225 -344
- qiskit/transpiler/preset_passmanagers/common.py +140 -167
- qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py +107 -322
- qiskit/transpiler/preset_passmanagers/level0.py +2 -11
- qiskit/transpiler/preset_passmanagers/level1.py +2 -14
- qiskit/transpiler/preset_passmanagers/level2.py +2 -12
- qiskit/transpiler/preset_passmanagers/level3.py +2 -11
- qiskit/transpiler/preset_passmanagers/plugin.py +5 -3
- qiskit/transpiler/target.py +78 -524
- qiskit/user_config.py +8 -4
- qiskit/utils/__init__.py +13 -12
- qiskit/utils/deprecation.py +4 -112
- qiskit/utils/optionals.py +11 -4
- qiskit/utils/parallel.py +214 -87
- qiskit/utils/units.py +4 -1
- qiskit/visualization/__init__.py +3 -7
- qiskit/visualization/array.py +4 -1
- qiskit/visualization/bloch.py +1 -1
- qiskit/visualization/circuit/_utils.py +19 -19
- qiskit/visualization/circuit/circuit_visualization.py +11 -4
- qiskit/visualization/circuit/matplotlib.py +13 -23
- qiskit/visualization/circuit/text.py +7 -3
- qiskit/visualization/counts_visualization.py +4 -0
- qiskit/visualization/dag_visualization.py +2 -1
- qiskit/visualization/gate_map.py +39 -154
- qiskit/visualization/library.py +4 -1
- qiskit/visualization/pass_manager_visualization.py +6 -2
- qiskit/visualization/state_visualization.py +19 -2
- qiskit/visualization/timeline/core.py +19 -13
- qiskit/visualization/timeline/interface.py +19 -18
- qiskit/visualization/timeline/plotters/matplotlib.py +4 -1
- {qiskit-1.4.2.dist-info → qiskit-2.0.0.dist-info}/METADATA +4 -3
- {qiskit-1.4.2.dist-info → qiskit-2.0.0.dist-info}/RECORD +300 -447
- {qiskit-1.4.2.dist-info → qiskit-2.0.0.dist-info}/WHEEL +2 -1
- {qiskit-1.4.2.dist-info → qiskit-2.0.0.dist-info}/entry_points.txt +8 -2
- qiskit/assembler/__init__.py +0 -42
- qiskit/assembler/assemble_circuits.py +0 -451
- qiskit/assembler/assemble_schedules.py +0 -367
- qiskit/assembler/disassemble.py +0 -310
- qiskit/assembler/run_config.py +0 -77
- qiskit/circuit/bit.py +0 -106
- qiskit/circuit/classicalfunction/__init__.py +0 -152
- qiskit/circuit/classicalfunction/boolean_expression.py +0 -138
- qiskit/circuit/classicalfunction/classical_element.py +0 -54
- qiskit/circuit/classicalfunction/classical_function_visitor.py +0 -155
- qiskit/circuit/classicalfunction/classicalfunction.py +0 -182
- qiskit/circuit/classicalfunction/exceptions.py +0 -41
- qiskit/circuit/classicalfunction/types.py +0 -18
- qiskit/circuit/classicalfunction/utils.py +0 -91
- qiskit/circuit/classicalregister.py +0 -57
- qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py +0 -405
- qiskit/circuit/quantumregister.py +0 -75
- qiskit/circuit/register.py +0 -246
- qiskit/compiler/assembler.py +0 -689
- qiskit/compiler/scheduler.py +0 -109
- qiskit/compiler/sequencer.py +0 -71
- qiskit/primitives/backend_estimator.py +0 -486
- qiskit/primitives/backend_sampler.py +0 -222
- qiskit/primitives/estimator.py +0 -172
- qiskit/primitives/sampler.py +0 -162
- qiskit/providers/backend_compat.py +0 -507
- qiskit/providers/fake_provider/backends_v1/__init__.py +0 -22
- qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/__init__.py +0 -18
- qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/conf_washington.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/defs_washington.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/fake_127q_pulse_v1.py +0 -37
- qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/props_washington.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_20q/conf_singapore.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_20q/fake_20q.py +0 -43
- qiskit/providers/fake_provider/backends_v1/fake_20q/props_singapore.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/__init__.py +0 -18
- qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/conf_hanoi.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/defs_hanoi.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/fake_27q_pulse_v1.py +0 -50
- qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/props_hanoi.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_5q/__init__.py +0 -18
- qiskit/providers/fake_provider/backends_v1/fake_5q/conf_yorktown.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_5q/fake_5q_v1.py +0 -41
- qiskit/providers/fake_provider/backends_v1/fake_5q/props_yorktown.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/__init__.py +0 -18
- qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/conf_nairobi.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/defs_nairobi.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/fake_7q_pulse_v1.py +0 -44
- qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/props_nairobi.json +0 -1
- qiskit/providers/fake_provider/fake_1q.py +0 -91
- qiskit/providers/fake_provider/fake_backend.py +0 -165
- qiskit/providers/fake_provider/fake_openpulse_2q.py +0 -391
- qiskit/providers/fake_provider/fake_openpulse_3q.py +0 -340
- qiskit/providers/fake_provider/fake_pulse_backend.py +0 -49
- qiskit/providers/fake_provider/fake_qasm_backend.py +0 -77
- qiskit/providers/fake_provider/utils/backend_converter.py +0 -150
- qiskit/providers/fake_provider/utils/json_decoder.py +0 -109
- qiskit/providers/models/__init__.py +0 -89
- qiskit/providers/models/backendconfiguration.py +0 -1040
- qiskit/providers/models/backendproperties.py +0 -535
- qiskit/providers/models/backendstatus.py +0 -104
- qiskit/providers/models/jobstatus.py +0 -77
- qiskit/providers/models/pulsedefaults.py +0 -305
- qiskit/providers/provider.py +0 -95
- qiskit/pulse/__init__.py +0 -158
- qiskit/pulse/builder.py +0 -2262
- qiskit/pulse/calibration_entries.py +0 -381
- qiskit/pulse/channels.py +0 -227
- qiskit/pulse/configuration.py +0 -245
- qiskit/pulse/exceptions.py +0 -45
- qiskit/pulse/filters.py +0 -309
- qiskit/pulse/instruction_schedule_map.py +0 -424
- qiskit/pulse/instructions/__init__.py +0 -67
- qiskit/pulse/instructions/acquire.py +0 -150
- qiskit/pulse/instructions/delay.py +0 -71
- qiskit/pulse/instructions/directives.py +0 -154
- qiskit/pulse/instructions/frequency.py +0 -135
- qiskit/pulse/instructions/instruction.py +0 -270
- qiskit/pulse/instructions/phase.py +0 -152
- qiskit/pulse/instructions/play.py +0 -99
- qiskit/pulse/instructions/reference.py +0 -100
- qiskit/pulse/instructions/snapshot.py +0 -82
- qiskit/pulse/library/__init__.py +0 -97
- qiskit/pulse/library/continuous.py +0 -430
- qiskit/pulse/library/pulse.py +0 -148
- qiskit/pulse/library/samplers/__init__.py +0 -15
- qiskit/pulse/library/samplers/decorators.py +0 -295
- qiskit/pulse/library/samplers/strategies.py +0 -71
- qiskit/pulse/library/symbolic_pulses.py +0 -1989
- qiskit/pulse/library/waveform.py +0 -136
- qiskit/pulse/macros.py +0 -262
- qiskit/pulse/parameter_manager.py +0 -445
- qiskit/pulse/parser.py +0 -314
- qiskit/pulse/reference_manager.py +0 -58
- qiskit/pulse/schedule.py +0 -1854
- qiskit/pulse/transforms/__init__.py +0 -106
- qiskit/pulse/transforms/alignments.py +0 -406
- qiskit/pulse/transforms/base_transforms.py +0 -71
- qiskit/pulse/transforms/canonicalization.py +0 -498
- qiskit/pulse/transforms/dag.py +0 -122
- qiskit/pulse/utils.py +0 -149
- qiskit/qobj/__init__.py +0 -75
- qiskit/qobj/common.py +0 -81
- qiskit/qobj/converters/__init__.py +0 -18
- qiskit/qobj/converters/lo_config.py +0 -177
- qiskit/qobj/converters/pulse_instruction.py +0 -897
- qiskit/qobj/pulse_qobj.py +0 -709
- qiskit/qobj/qasm_qobj.py +0 -708
- qiskit/qobj/utils.py +0 -46
- qiskit/result/mitigation/base_readout_mitigator.py +0 -79
- qiskit/result/mitigation/correlated_readout_mitigator.py +0 -277
- qiskit/result/mitigation/local_readout_mitigator.py +0 -328
- qiskit/result/mitigation/utils.py +0 -217
- qiskit/scheduler/__init__.py +0 -40
- qiskit/scheduler/config.py +0 -37
- qiskit/scheduler/lowering.py +0 -187
- qiskit/scheduler/methods/__init__.py +0 -15
- qiskit/scheduler/methods/basic.py +0 -140
- qiskit/scheduler/schedule_circuit.py +0 -69
- qiskit/scheduler/sequence.py +0 -104
- qiskit/transpiler/passes/calibration/__init__.py +0 -17
- qiskit/transpiler/passes/calibration/base_builder.py +0 -79
- qiskit/transpiler/passes/calibration/builders.py +0 -20
- qiskit/transpiler/passes/calibration/exceptions.py +0 -22
- qiskit/transpiler/passes/calibration/pulse_gate.py +0 -100
- qiskit/transpiler/passes/calibration/rx_builder.py +0 -164
- qiskit/transpiler/passes/calibration/rzx_builder.py +0 -411
- qiskit/transpiler/passes/calibration/rzx_templates.py +0 -58
- qiskit/transpiler/passes/optimization/cx_cancellation.py +0 -65
- qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposition.py +0 -162
- qiskit/transpiler/passes/optimization/normalize_rx_angle.py +0 -157
- qiskit/transpiler/passes/routing/stochastic_swap.py +0 -532
- qiskit/transpiler/passes/scheduling/alap.py +0 -153
- qiskit/transpiler/passes/scheduling/alignments/align_measures.py +0 -255
- qiskit/transpiler/passes/scheduling/alignments/pulse_gate_validation.py +0 -107
- qiskit/transpiler/passes/scheduling/asap.py +0 -175
- qiskit/transpiler/passes/scheduling/base_scheduler.py +0 -310
- qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +0 -313
- qiskit/transpiler/passes/utils/convert_conditions_to_if_ops.py +0 -93
- qiskit/utils/deprecate_pulse.py +0 -119
- qiskit/utils/multiprocessing.py +0 -56
- qiskit/visualization/pulse_v2/__init__.py +0 -21
- qiskit/visualization/pulse_v2/core.py +0 -901
- qiskit/visualization/pulse_v2/device_info.py +0 -173
- qiskit/visualization/pulse_v2/drawings.py +0 -253
- qiskit/visualization/pulse_v2/events.py +0 -254
- qiskit/visualization/pulse_v2/generators/__init__.py +0 -40
- qiskit/visualization/pulse_v2/generators/barrier.py +0 -76
- qiskit/visualization/pulse_v2/generators/chart.py +0 -208
- qiskit/visualization/pulse_v2/generators/frame.py +0 -436
- qiskit/visualization/pulse_v2/generators/snapshot.py +0 -133
- qiskit/visualization/pulse_v2/generators/waveform.py +0 -645
- qiskit/visualization/pulse_v2/interface.py +0 -459
- qiskit/visualization/pulse_v2/layouts.py +0 -387
- qiskit/visualization/pulse_v2/plotters/__init__.py +0 -17
- qiskit/visualization/pulse_v2/plotters/base_plotter.py +0 -53
- qiskit/visualization/pulse_v2/plotters/matplotlib.py +0 -201
- qiskit/visualization/pulse_v2/stylesheet.py +0 -312
- qiskit/visualization/pulse_v2/types.py +0 -242
- {qiskit-1.4.2.dist-info → qiskit-2.0.0.dist-info/licenses}/LICENSE.txt +0 -0
- {qiskit-1.4.2.dist-info → qiskit-2.0.0.dist-info}/top_level.txt +0 -0
@@ -19,7 +19,7 @@ import numpy as np
|
|
19
19
|
|
20
20
|
from qiskit._accelerate import euler_one_qubit_decomposer
|
21
21
|
from qiskit.circuit.quantumcircuit import QuantumCircuit
|
22
|
-
from qiskit.circuit
|
22
|
+
from qiskit.circuit import Qubit
|
23
23
|
from qiskit.circuit.library.standard_gates import (
|
24
24
|
UGate,
|
25
25
|
PhaseGate,
|
@@ -51,7 +51,6 @@ from qiskit.circuit.library.standard_gates import (
|
|
51
51
|
from qiskit.exceptions import QiskitError
|
52
52
|
from qiskit.quantum_info.operators import Operator
|
53
53
|
from qiskit.synthesis.one_qubit.one_qubit_decompose import (
|
54
|
-
OneQubitEulerDecomposer,
|
55
54
|
DEFAULT_ATOL,
|
56
55
|
)
|
57
56
|
from qiskit.utils.deprecation import deprecate_func
|
@@ -271,168 +270,51 @@ class TwoQubitControlledUDecomposer:
|
|
271
270
|
:math:`U \sim U_d(\alpha, 0, 0) \sim \text{Ctrl-U}`
|
272
271
|
gate that is locally equivalent to an :class:`.RXXGate`."""
|
273
272
|
|
274
|
-
def __init__(self, rxx_equivalent_gate: Type[Gate]):
|
273
|
+
def __init__(self, rxx_equivalent_gate: Type[Gate], euler_basis: str = "ZXZ"):
|
275
274
|
r"""Initialize the KAK decomposition.
|
276
275
|
|
277
276
|
Args:
|
278
277
|
rxx_equivalent_gate: Gate that is locally equivalent to an :class:`.RXXGate`:
|
279
|
-
|
278
|
+
:math:`U \sim U_d(\alpha, 0, 0) \sim \text{Ctrl-U}` gate.
|
279
|
+
Valid options are [:class:`.RZZGate`, :class:`.RXXGate`, :class:`.RYYGate`,
|
280
|
+
:class:`.RZXGate`, :class:`.CPhaseGate`, :class:`.CRXGate`, :class:`.CRYGate`,
|
281
|
+
:class:`.CRZGate`].
|
282
|
+
euler_basis: Basis string to be provided to :class:`.OneQubitEulerDecomposer`
|
283
|
+
for 1Q synthesis.
|
284
|
+
Valid options are [``'ZXZ'``, ``'ZYZ'``, ``'XYX'``, ``'XZX'``, ``'U'``, ``'U3'``,
|
285
|
+
``'U321'``, ``'U1X'``, ``'PSX'``, ``'ZSX'``, ``'ZSXX'``, ``'RR'``].
|
286
|
+
|
280
287
|
Raises:
|
281
288
|
QiskitError: If the gate is not locally equivalent to an :class:`.RXXGate`.
|
282
289
|
"""
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
for test_angle in test_angles:
|
288
|
-
# Check that gate takes a single angle parameter
|
289
|
-
try:
|
290
|
-
rxx_equivalent_gate(test_angle, label="foo")
|
291
|
-
except TypeError as _:
|
292
|
-
raise QiskitError("Equivalent gate needs to take exactly 1 angle parameter.") from _
|
293
|
-
decomp = TwoQubitWeylDecomposition(rxx_equivalent_gate(test_angle))
|
294
|
-
|
295
|
-
circ = QuantumCircuit(2)
|
296
|
-
circ.rxx(test_angle, 0, 1)
|
297
|
-
decomposer_rxx = TwoQubitWeylDecomposition(
|
298
|
-
Operator(circ).data,
|
299
|
-
fidelity=None,
|
300
|
-
_specialization=two_qubit_decompose.Specialization.ControlledEquiv,
|
301
|
-
)
|
302
|
-
|
303
|
-
circ = QuantumCircuit(2)
|
304
|
-
circ.append(rxx_equivalent_gate(test_angle), qargs=[0, 1])
|
305
|
-
decomposer_equiv = TwoQubitWeylDecomposition(
|
306
|
-
Operator(circ).data,
|
307
|
-
fidelity=None,
|
308
|
-
_specialization=two_qubit_decompose.Specialization.ControlledEquiv,
|
290
|
+
if rxx_equivalent_gate._standard_gate is not None:
|
291
|
+
self._inner_decomposer = two_qubit_decompose.TwoQubitControlledUDecomposer(
|
292
|
+
rxx_equivalent_gate._standard_gate, euler_basis
|
309
293
|
)
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
raise QiskitError(
|
315
|
-
f"{rxx_equivalent_gate.__name__} is not equivalent to an RXXGate."
|
316
|
-
)
|
317
|
-
|
318
|
-
scales.append(scale)
|
319
|
-
|
320
|
-
# Check that all three tested angles give the same scale
|
321
|
-
if not np.allclose(scales, [scale] * len(test_angles)):
|
322
|
-
raise QiskitError(
|
323
|
-
f"Cannot initialize {self.__class__.__name__}: with gate {rxx_equivalent_gate}. "
|
324
|
-
"Inconsistent scaling parameters in checks."
|
294
|
+
self.gate_name = rxx_equivalent_gate._standard_gate.name
|
295
|
+
else:
|
296
|
+
self._inner_decomposer = two_qubit_decompose.TwoQubitControlledUDecomposer(
|
297
|
+
rxx_equivalent_gate, euler_basis
|
325
298
|
)
|
326
|
-
|
327
|
-
self.scale = scales[0]
|
328
|
-
|
329
299
|
self.rxx_equivalent_gate = rxx_equivalent_gate
|
300
|
+
self.scale = self._inner_decomposer.scale
|
301
|
+
self.euler_basis = euler_basis
|
330
302
|
|
331
|
-
def __call__(
|
303
|
+
def __call__(
|
304
|
+
self, unitary: Operator | np.ndarray, approximate=False, use_dag=False, *, atol=DEFAULT_ATOL
|
305
|
+
) -> QuantumCircuit:
|
332
306
|
"""Returns the Weyl decomposition in circuit form.
|
333
307
|
|
334
|
-
Note: atol ist passed to OneQubitEulerDecomposer.
|
335
|
-
"""
|
336
|
-
|
337
|
-
# pylint: disable=attribute-defined-outside-init
|
338
|
-
self.decomposer = TwoQubitWeylDecomposition(unitary)
|
339
|
-
|
340
|
-
oneq_decompose = OneQubitEulerDecomposer("ZYZ")
|
341
|
-
c1l, c1r, c2l, c2r = (
|
342
|
-
oneq_decompose(k, atol=atol)
|
343
|
-
for k in (
|
344
|
-
self.decomposer.K1l,
|
345
|
-
self.decomposer.K1r,
|
346
|
-
self.decomposer.K2l,
|
347
|
-
self.decomposer.K2r,
|
348
|
-
)
|
349
|
-
)
|
350
|
-
circ = QuantumCircuit(2, global_phase=self.decomposer.global_phase)
|
351
|
-
circ.compose(c2r, [0], inplace=True)
|
352
|
-
circ.compose(c2l, [1], inplace=True)
|
353
|
-
self._weyl_gate(circ)
|
354
|
-
circ.compose(c1r, [0], inplace=True)
|
355
|
-
circ.compose(c1l, [1], inplace=True)
|
356
|
-
return circ
|
357
|
-
|
358
|
-
def _to_rxx_gate(self, angle: float) -> QuantumCircuit:
|
359
|
-
"""
|
360
|
-
Takes an angle and returns the circuit equivalent to an RXXGate with the
|
361
|
-
RXX equivalent gate as the two-qubit unitary.
|
362
|
-
|
363
308
|
Args:
|
364
|
-
|
309
|
+
unitary (Operator or ndarray): :math:`4 \times 4` unitary to synthesize.
|
365
310
|
|
366
311
|
Returns:
|
367
|
-
|
312
|
+
QuantumCircuit: Synthesized quantum circuit.
|
368
313
|
|
369
|
-
|
370
|
-
QiskitError: If the circuit is not equivalent to an RXXGate.
|
314
|
+
Note: atol is passed to OneQubitEulerDecomposer.
|
371
315
|
"""
|
372
|
-
|
373
|
-
|
374
|
-
# but with some scaling in the rotation angle. For example, RXXGate(angle) has Weyl
|
375
|
-
# parameters (angle, 0, 0) for angle in [0, pi/2] but the user provided gate, i.e.
|
376
|
-
# :code:`self.rxx_equivalent_gate(angle)` might produce the Weyl parameters
|
377
|
-
# (scale * angle, 0, 0) where scale != 1. This is the case for the CPhaseGate.
|
378
|
-
|
379
|
-
circ = QuantumCircuit(2)
|
380
|
-
circ.append(self.rxx_equivalent_gate(self.scale * angle), qargs=[0, 1])
|
381
|
-
decomposer_inv = TwoQubitWeylDecomposition(Operator(circ).data)
|
382
|
-
|
383
|
-
oneq_decompose = OneQubitEulerDecomposer("ZYZ")
|
384
|
-
|
385
|
-
# Express the RXXGate in terms of the user-provided RXXGate equivalent gate.
|
386
|
-
rxx_circ = QuantumCircuit(2, global_phase=-decomposer_inv.global_phase)
|
387
|
-
rxx_circ.compose(oneq_decompose(decomposer_inv.K2r).inverse(), inplace=True, qubits=[0])
|
388
|
-
rxx_circ.compose(oneq_decompose(decomposer_inv.K2l).inverse(), inplace=True, qubits=[1])
|
389
|
-
rxx_circ.compose(circ, inplace=True)
|
390
|
-
rxx_circ.compose(oneq_decompose(decomposer_inv.K1r).inverse(), inplace=True, qubits=[0])
|
391
|
-
rxx_circ.compose(oneq_decompose(decomposer_inv.K1l).inverse(), inplace=True, qubits=[1])
|
392
|
-
|
393
|
-
return rxx_circ
|
394
|
-
|
395
|
-
def _weyl_gate(self, circ: QuantumCircuit, atol=1.0e-13):
|
396
|
-
"""Appends U_d(a, b, c) to the circuit."""
|
397
|
-
|
398
|
-
circ_rxx = self._to_rxx_gate(-2 * self.decomposer.a)
|
399
|
-
circ.compose(circ_rxx, inplace=True)
|
400
|
-
|
401
|
-
# translate the RYYGate(b) into a circuit based on the desired Ctrl-U gate.
|
402
|
-
if abs(self.decomposer.b) > atol:
|
403
|
-
circ_ryy = QuantumCircuit(2)
|
404
|
-
circ_ryy.sdg(0)
|
405
|
-
circ_ryy.sdg(1)
|
406
|
-
circ_ryy.compose(self._to_rxx_gate(-2 * self.decomposer.b), inplace=True)
|
407
|
-
circ_ryy.s(0)
|
408
|
-
circ_ryy.s(1)
|
409
|
-
circ.compose(circ_ryy, inplace=True)
|
410
|
-
|
411
|
-
# translate the RZZGate(c) into a circuit based on the desired Ctrl-U gate.
|
412
|
-
if abs(self.decomposer.c) > atol:
|
413
|
-
# Since the Weyl chamber is here defined as a > b > |c| we may have
|
414
|
-
# negative c. This will cause issues in _to_rxx_gate
|
415
|
-
# as TwoQubitWeylControlledEquiv will map (c, 0, 0) to (|c|, 0, 0).
|
416
|
-
# We therefore produce RZZGate(|c|) and append its inverse to the
|
417
|
-
# circuit if c < 0.
|
418
|
-
gamma, invert = -2 * self.decomposer.c, False
|
419
|
-
if gamma > 0:
|
420
|
-
gamma *= -1
|
421
|
-
invert = True
|
422
|
-
|
423
|
-
circ_rzz = QuantumCircuit(2)
|
424
|
-
circ_rzz.h(0)
|
425
|
-
circ_rzz.h(1)
|
426
|
-
circ_rzz.compose(self._to_rxx_gate(gamma), inplace=True)
|
427
|
-
circ_rzz.h(0)
|
428
|
-
circ_rzz.h(1)
|
429
|
-
|
430
|
-
if invert:
|
431
|
-
circ.compose(circ_rzz.inverse(), inplace=True)
|
432
|
-
else:
|
433
|
-
circ.compose(circ_rzz, inplace=True)
|
434
|
-
|
435
|
-
return circ
|
316
|
+
circ_data = self._inner_decomposer(np.asarray(unitary, dtype=complex), atol)
|
317
|
+
return QuantumCircuit._from_circuit_data(circ_data, add_regs=True)
|
436
318
|
|
437
319
|
|
438
320
|
class TwoQubitBasisDecomposer:
|
@@ -472,6 +354,7 @@ class TwoQubitBasisDecomposer:
|
|
472
354
|
gate_name = "cx"
|
473
355
|
else:
|
474
356
|
gate_name = "USER_GATE"
|
357
|
+
self.gate_name = gate_name
|
475
358
|
|
476
359
|
self._inner_decomposer = two_qubit_decompose.TwoQubitBasisDecomposer(
|
477
360
|
gate_name,
|
qiskit/transpiler/__init__.py
CHANGED
@@ -187,7 +187,9 @@ For example, if you wanted to run a custom scheduling stage using dynamical deco
|
|
187
187
|
:class:`~.PadDynamicalDecoupling` pass) and also add initial logical optimization prior to routing,
|
188
188
|
you would do something like the following (building off the previous example):
|
189
189
|
|
190
|
-
..
|
190
|
+
.. plot::
|
191
|
+
:include-source:
|
192
|
+
:nofigs:
|
191
193
|
|
192
194
|
import numpy as np
|
193
195
|
from qiskit.providers.fake_provider import GenericBackendV2
|
@@ -195,7 +197,6 @@ you would do something like the following (building off the previous example):
|
|
195
197
|
from qiskit.transpiler import PassManager, generate_preset_pass_manager
|
196
198
|
from qiskit.transpiler.passes import (
|
197
199
|
ALAPScheduleAnalysis,
|
198
|
-
CXCancellation,
|
199
200
|
InverseCancellation,
|
200
201
|
PadDynamicalDecoupling,
|
201
202
|
)
|
@@ -504,6 +505,9 @@ is ``qiskit.transpiler.routing``. The built-in plugins are:
|
|
504
505
|
* - Method
|
505
506
|
- Summary
|
506
507
|
|
508
|
+
* - :ref:`default <transpiler-preset-stage-routing-default>`
|
509
|
+
- Use a Qiskit-chosen default routing method.
|
510
|
+
|
507
511
|
* - :ref:`sabre <transpiler-preset-stage-routing-sabre>`
|
508
512
|
- Default. Uses `Qiskit's modified Sabre routing algorithm <sabre-lightsabre-paper_>`_ to
|
509
513
|
swap map.
|
@@ -514,13 +518,19 @@ is ``qiskit.transpiler.routing``. The built-in plugins are:
|
|
514
518
|
* - :ref:`basic <transpiler-preset-stage-routing-basic>`
|
515
519
|
- Greedy swap insertion to route a single operation at a time.
|
516
520
|
|
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
521
|
* - :ref:`lookahead <transpiler-preset-stage-routing-lookahead>`
|
522
522
|
- Breadth-first search with heuristic pruning to find swaps that make gates executable.
|
523
523
|
|
524
|
+
.. _transpiler-preset-stage-routing-default:
|
525
|
+
|
526
|
+
Built-in ``default`` plugin
|
527
|
+
...........................
|
528
|
+
|
529
|
+
Use a Qiskit-chosen default method for routing. As of Qiskit 2.0, the chosen algorithm is the same
|
530
|
+
as :ref:`transpiler-preset-stage-routing-sabre`, though in practice, usually the :ref:`built-in
|
531
|
+
default layout-stage plugin <transpiler-preset-stage-layout-default>` will run the Sabre-based
|
532
|
+
routing algorithm, and the routing stage will only be used to run :class:`.VF2PostLayout`.
|
533
|
+
|
524
534
|
.. _transpiler-preset-stage-routing-none:
|
525
535
|
|
526
536
|
Built-in ``none`` plugin
|
@@ -543,25 +553,6 @@ attempt to improve the initial layout after routing.
|
|
543
553
|
|
544
554
|
This method typically has poor output quality.
|
545
555
|
|
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
556
|
.. _transpiler-preset-stage-routing-lookahead:
|
566
557
|
|
567
558
|
Built-in ``lookahead`` plugin
|
@@ -614,15 +605,6 @@ supported by the target ISA. For example, if a ``cx`` is requested on hardware
|
|
614
605
|
the ISA only contains a ``cz`` operation on those qubits, the translation stage must find a way of
|
615
606
|
representing the ``cx`` gate using the ``cz`` and available one-qubit gates.
|
616
607
|
|
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
608
|
The translation stage is called before entering the optimization stage. Optimization plugins
|
627
609
|
(including Qiskit's built-in plugins) may also use the translation stage as a "fixup" stage after
|
628
610
|
the optimization loop, if the optimization loop returns a circuit that includes non-ISA gates. This
|
@@ -642,6 +624,9 @@ When writing :ref:`stage plugins <transpiler-preset-stage-plugins>`, the entry p
|
|
642
624
|
* - Method
|
643
625
|
- Summary
|
644
626
|
|
627
|
+
* - :ref:`default <transpiler-preset-stage-translation-translator>`
|
628
|
+
- Use a Qiskit-chosen default translation method.
|
629
|
+
|
645
630
|
* - :ref:`translator <transpiler-preset-stage-translation-translator>`
|
646
631
|
- Symbolic translation of gates to the target basis using known equivalences.
|
647
632
|
|
@@ -649,6 +634,15 @@ When writing :ref:`stage plugins <transpiler-preset-stage-plugins>`, the entry p
|
|
649
634
|
- Collect each run of one- and two-qubit gates into a matrix representation, and resynthesize
|
650
635
|
from there.
|
651
636
|
|
637
|
+
.. _transpiler-preset-stage-translation-default:
|
638
|
+
|
639
|
+
Built-in ``default`` plugin
|
640
|
+
...........................
|
641
|
+
|
642
|
+
Use a Qiskit-chosen default method for translation. As of Qiskit 2.0, this is the same as
|
643
|
+
:ref:`transpiler-preset-stage-translation-translator`, but the chosen algorithm might change during
|
644
|
+
the 2.x series, either for all targets, or only for certain classes of target.
|
645
|
+
|
652
646
|
.. _transpiler-preset-stage-translation-synthesis:
|
653
647
|
|
654
648
|
Built-in ``synthesis`` plugin
|
@@ -873,7 +867,9 @@ The specific information needed by the transpiler is described by the
|
|
873
867
|
For example, to construct a simple :class:`~.Target` object, one can iteratively add
|
874
868
|
descriptions of the instructions it supports:
|
875
869
|
|
876
|
-
..
|
870
|
+
.. plot::
|
871
|
+
:include-source:
|
872
|
+
:nofigs:
|
877
873
|
|
878
874
|
from qiskit.circuit import Parameter, Measure
|
879
875
|
from qiskit.transpiler import Target, InstructionProperties
|
@@ -1238,7 +1234,7 @@ also look at it with the :func:`.timeline.draw` function:
|
|
1238
1234
|
|
1239
1235
|
circ = transpile(ghz, backend, scheduling_method="asap")
|
1240
1236
|
|
1241
|
-
timeline_draw(circ)
|
1237
|
+
timeline_draw(circ, target=backend.target)
|
1242
1238
|
|
1243
1239
|
The scheduling of a circuit involves two parts: analysis and constraint mapping, followed by a
|
1244
1240
|
padding pass. The first part requires running a scheduling analysis pass such as
|
@@ -1254,202 +1250,6 @@ the scheduling and adjustments/rescheduling are finished, a padding pass,
|
|
1254
1250
|
such as :class:`~.PadDelay` or :class:`~.PadDynamicalDecoupling` is run
|
1255
1251
|
to insert the instructions into the circuit, which completes the scheduling.
|
1256
1252
|
|
1257
|
-
Scheduling analysis with control-flow instructions
|
1258
|
-
--------------------------------------------------
|
1259
|
-
|
1260
|
-
When running scheduling analysis passes on a circuit, you must keep in mind that there
|
1261
|
-
are additional constraints on classical conditions and control flow instructions. This section
|
1262
|
-
covers the details of these additional
|
1263
|
-
constraints that any scheduling pass will need to account for.
|
1264
|
-
|
1265
|
-
Topological node ordering in scheduling
|
1266
|
-
.......................................
|
1267
|
-
|
1268
|
-
The DAG representation of ``QuantumCircuit`` respects the node ordering in the
|
1269
|
-
classical register wires, though theoretically two conditional instructions
|
1270
|
-
conditioned on the same register could commute, i.e. read-access to the
|
1271
|
-
classical register doesn't change its state.
|
1272
|
-
|
1273
|
-
.. code-block:: text
|
1274
|
-
|
1275
|
-
qc = QuantumCircuit(2, 1)
|
1276
|
-
qc.delay(100, 0)
|
1277
|
-
qc.x(0).c_if(0, True)
|
1278
|
-
qc.x(1).c_if(0, True)
|
1279
|
-
|
1280
|
-
The scheduler SHOULD comply with the above topological ordering policy of the
|
1281
|
-
DAG circuit.
|
1282
|
-
Accordingly, the `asap`-scheduled circuit will become
|
1283
|
-
|
1284
|
-
.. code-block:: text
|
1285
|
-
|
1286
|
-
┌────────────────┐ ┌───┐
|
1287
|
-
q_0: ┤ Delay(100[dt]) ├───┤ X ├──────────────
|
1288
|
-
├────────────────┤ └─╥─┘ ┌───┐
|
1289
|
-
q_1: ┤ Delay(100[dt]) ├─────╫────────┤ X ├───
|
1290
|
-
└────────────────┘ ║ └─╥─┘
|
1291
|
-
┌────╨────┐┌────╨────┐
|
1292
|
-
c: 1/══════════════════╡ c_0=0x1 ╞╡ c_0=0x1 ╞
|
1293
|
-
└─────────┘└─────────┘
|
1294
|
-
|
1295
|
-
Note that this scheduling might be inefficient in some cases,
|
1296
|
-
because the second conditional operation could start without waiting
|
1297
|
-
for the 100 dt delay.
|
1298
|
-
However, any additional optimization should be done in a different pass,
|
1299
|
-
not to break the topological ordering of the original circuit.
|
1300
|
-
|
1301
|
-
Realistic control flow scheduling (respecting microarchitecture)
|
1302
|
-
................................................................
|
1303
|
-
|
1304
|
-
In the dispersive QND readout scheme, the qubit (Q) is measured by sending
|
1305
|
-
a microwave stimulus, followed by a resonator ring-down (depopulation). This
|
1306
|
-
microwave signal is recorded in the buffer memory (B) with the hardware kernel,
|
1307
|
-
then a discriminated (D) binary value is moved to the classical register (C).
|
1308
|
-
A sequence from t0 to t1 of the measure instruction interval could be
|
1309
|
-
modeled as follows:
|
1310
|
-
|
1311
|
-
.. code-block:: text
|
1312
|
-
|
1313
|
-
Q ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░
|
1314
|
-
B ░░▒▒▒▒▒▒▒▒░░░░░░░░░
|
1315
|
-
D ░░░░░░░░░░▒▒▒▒▒▒░░░
|
1316
|
-
C ░░░░░░░░░░░░░░░░▒▒░
|
1317
|
-
|
1318
|
-
However, the :class:`.QuantumCircuit` representation is not accurate enough to represent
|
1319
|
-
this model. In the circuit representation, the corresponding :class:`.circuit.Qubit` is occupied
|
1320
|
-
by the stimulus microwave signal during the first half of the interval,
|
1321
|
-
and the :class:`.Clbit` is only occupied at the very end of the interval.
|
1322
|
-
|
1323
|
-
The lack of precision representing the physical model may induce
|
1324
|
-
edge cases in the scheduling:
|
1325
|
-
|
1326
|
-
.. code-block:: text
|
1327
|
-
|
1328
|
-
┌───┐
|
1329
|
-
q_0: ───┤ X ├──────
|
1330
|
-
└─╥─┘ ┌─┐
|
1331
|
-
q_1: ─────╫─────┤M├
|
1332
|
-
┌────╨────┐└╥┘
|
1333
|
-
c: 1/╡ c_0=0x1 ╞═╩═
|
1334
|
-
└─────────┘ 0
|
1335
|
-
|
1336
|
-
In this example, a user may intend to measure the state of ``q_1`` after the
|
1337
|
-
:class:`.XGate` is applied to ``q_0``. This is the correct interpretation from
|
1338
|
-
the viewpoint of topological node ordering, i.e. The :class:`.XGate` node comes in
|
1339
|
-
front of the :class:`.Measure` node.
|
1340
|
-
However, according to the measurement model above, the data in the register
|
1341
|
-
is unchanged during the application of the stimulus, so two nodes are
|
1342
|
-
simultaneously operated.
|
1343
|
-
If one tries to `alap`-schedule this circuit, it may return following circuit:
|
1344
|
-
|
1345
|
-
.. code-block:: text
|
1346
|
-
|
1347
|
-
┌────────────────┐ ┌───┐
|
1348
|
-
q_0: ┤ Delay(500[dt]) ├───┤ X ├──────
|
1349
|
-
└────────────────┘ └─╥─┘ ┌─┐
|
1350
|
-
q_1: ───────────────────────╫─────┤M├
|
1351
|
-
┌────╨────┐└╥┘
|
1352
|
-
c: 1/══════════════════╡ c_0=0x1 ╞═╩═
|
1353
|
-
└─────────┘ 0
|
1354
|
-
|
1355
|
-
Note that there is no delay on the ``q_1`` wire, and the measure instruction
|
1356
|
-
immediately starts after t=0, while the conditional gate starts after the delay.
|
1357
|
-
It looks like the topological ordering between the nodes is flipped in the
|
1358
|
-
scheduled view.
|
1359
|
-
This behavior can be understood by considering the control flow model described above,
|
1360
|
-
|
1361
|
-
.. code-block:: text
|
1362
|
-
|
1363
|
-
: Quantum Circuit, first-measure
|
1364
|
-
0 ░░░░░░░░░░░░▒▒▒▒▒▒░
|
1365
|
-
1 ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░
|
1366
|
-
|
1367
|
-
: In wire q0
|
1368
|
-
Q ░░░░░░░░░░░░░░░▒▒▒░
|
1369
|
-
C ░░░░░░░░░░░░▒▒░░░░░
|
1370
|
-
|
1371
|
-
: In wire q1
|
1372
|
-
Q ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░
|
1373
|
-
B ░░▒▒▒▒▒▒▒▒░░░░░░░░░
|
1374
|
-
D ░░░░░░░░░░▒▒▒▒▒▒░░░
|
1375
|
-
C ░░░░░░░░░░░░░░░░▒▒░
|
1376
|
-
|
1377
|
-
Since there is no qubit register overlap between Q0 and Q1, the node ordering is
|
1378
|
-
determined by the shared classical register C. As you can see, the execution order is still
|
1379
|
-
preserved on C, i.e. read C then apply ``XGate``, finally store the measured outcome in C.
|
1380
|
-
But because ``DAGOpNode`` cannot define different durations for the associated registers,
|
1381
|
-
the time ordering of the two nodes is inverted.
|
1382
|
-
|
1383
|
-
This behavior can be controlled by ``clbit_write_latency`` and ``conditional_latency``.
|
1384
|
-
``clbit_write_latency`` determines the delay of the register write-access from
|
1385
|
-
the beginning of the measure instruction (t0), while ``conditional_latency`` determines
|
1386
|
-
the delay of conditional gate operations with respect to t0, which is determined
|
1387
|
-
by the register read-access.
|
1388
|
-
This information is accessible in the backend configuration and should
|
1389
|
-
be copied to the pass manager property set before the pass is called.
|
1390
|
-
|
1391
|
-
Due to default latencies, the `alap`-scheduled circuit of above example may become
|
1392
|
-
|
1393
|
-
.. code-block:: text
|
1394
|
-
|
1395
|
-
┌───┐
|
1396
|
-
q_0: ───┤ X ├──────
|
1397
|
-
└─╥─┘ ┌─┐
|
1398
|
-
q_1: ─────╫─────┤M├
|
1399
|
-
┌────╨────┐└╥┘
|
1400
|
-
c: 1/╡ c_0=0x1 ╞═╩═
|
1401
|
-
└─────────┘ 0
|
1402
|
-
|
1403
|
-
If the backend microarchitecture supports smart scheduling of the control flow
|
1404
|
-
instructions, such as separately scheduling qubits and classical registers,
|
1405
|
-
the insertion of the delay yields an unnecessarily longer total execution time.
|
1406
|
-
|
1407
|
-
.. code-block:: text
|
1408
|
-
|
1409
|
-
: Quantum Circuit, first-XGate
|
1410
|
-
0 ░▒▒▒░░░░░░░░░░░░░░░
|
1411
|
-
1 ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░
|
1412
|
-
|
1413
|
-
: In wire q0
|
1414
|
-
Q ░▒▒▒░░░░░░░░░░░░░░░
|
1415
|
-
C ░░░░░░░░░░░░░░░░░░░ (zero latency)
|
1416
|
-
|
1417
|
-
: In wire q1
|
1418
|
-
Q ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░
|
1419
|
-
C ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ (zero latency, scheduled after C0 read-access)
|
1420
|
-
|
1421
|
-
However, this result is much more intuitive in the topological ordering view.
|
1422
|
-
If a finite conditional latency value is provided, for example, 30 dt, the circuit
|
1423
|
-
is scheduled as follows:
|
1424
|
-
|
1425
|
-
.. code-block:: text
|
1426
|
-
|
1427
|
-
┌───────────────┐ ┌───┐
|
1428
|
-
q_0: ┤ Delay(30[dt]) ├───┤ X ├──────
|
1429
|
-
├───────────────┤ └─╥─┘ ┌─┐
|
1430
|
-
q_1: ┤ Delay(30[dt]) ├─────╫─────┤M├
|
1431
|
-
└───────────────┘┌────╨────┐└╥┘
|
1432
|
-
c: 1/═════════════════╡ c_0=0x1 ╞═╩═
|
1433
|
-
└─────────┘ 0
|
1434
|
-
|
1435
|
-
with the timing model:
|
1436
|
-
|
1437
|
-
.. code-block:: text
|
1438
|
-
|
1439
|
-
: Quantum Circuit, first-xgate
|
1440
|
-
0 ░░▒▒▒░░░░░░░░░░░░░░░
|
1441
|
-
1 ░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░
|
1442
|
-
|
1443
|
-
: In wire q0
|
1444
|
-
Q ░░▒▒▒░░░░░░░░░░░░░░░
|
1445
|
-
C ░▒░░░░░░░░░░░░░░░░░░ (30dt latency)
|
1446
|
-
|
1447
|
-
: In wire q1
|
1448
|
-
Q ░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░
|
1449
|
-
C ░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░
|
1450
|
-
|
1451
|
-
See https://arxiv.org/abs/2102.01682 for more details.
|
1452
|
-
|
1453
1253
|
Transpiler API
|
1454
1254
|
==============
|
1455
1255
|
|
qiskit/transpiler/basepasses.py
CHANGED
@@ -19,13 +19,11 @@ from collections.abc import Callable, Hashable, Iterable
|
|
19
19
|
from inspect import signature
|
20
20
|
|
21
21
|
from qiskit.circuit import QuantumCircuit
|
22
|
-
from qiskit.converters import circuit_to_dag, dag_to_circuit
|
23
22
|
from qiskit.dagcircuit import DAGCircuit
|
24
23
|
from qiskit.passmanager.base_tasks import GenericPass, PassManagerIR
|
25
24
|
from qiskit.passmanager.compilation_status import PropertySet, RunState, PassManagerState
|
26
25
|
|
27
26
|
from .exceptions import TranspilerError
|
28
|
-
from .layout import TranspileLayout
|
29
27
|
|
30
28
|
|
31
29
|
class MetaPass(abc.ABCMeta):
|
@@ -126,57 +124,31 @@ class BasePass(GenericPass, metaclass=MetaPass):
|
|
126
124
|
|
127
125
|
Args:
|
128
126
|
circuit: The dag on which the pass is run.
|
129
|
-
property_set: Input/output property set. An analysis pass
|
130
|
-
|
127
|
+
property_set: Input/output property set. An analysis pass might change the property set
|
128
|
+
in-place. If not given, the existing ``property_set`` attribute of the pass will
|
129
|
+
be used (if set).
|
131
130
|
|
132
131
|
Returns:
|
133
132
|
If on transformation pass, the resulting QuantumCircuit.
|
134
133
|
If analysis pass, the input circuit.
|
135
134
|
"""
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
135
|
+
from qiskit.transpiler import PassManager # pylint: disable=cyclic-import
|
136
|
+
|
137
|
+
pm = PassManager([self])
|
138
|
+
# Previous versions of the `__call__` function would not construct a `PassManager`, but just
|
139
|
+
# call `self.run` directly (this caused issues with `requires`). It only overrode
|
140
|
+
# `self.property_set` if the input was not `None`, which some users might have been relying
|
141
|
+
# on (as our test suite was).
|
142
|
+
if property_set is None:
|
143
|
+
property_set = self.property_set
|
144
|
+
out = pm.run(circuit, property_set=property_set)
|
145
|
+
if property_set is not None and property_set is not pm.property_set:
|
146
|
+
# When this `__call__` was first added, it contained this behaviour of mutating the
|
147
|
+
# input `property_set` in-place, but didn't use the `PassManager` infrastructure. This
|
148
|
+
# preserves the output-variable nature of the `property_set` parameter.
|
149
149
|
property_set.clear()
|
150
|
-
property_set.update(
|
151
|
-
|
152
|
-
if isinstance(result, DAGCircuit):
|
153
|
-
result_circuit = dag_to_circuit(result, copy_operations=False)
|
154
|
-
elif result is None:
|
155
|
-
result_circuit = circuit.copy()
|
156
|
-
|
157
|
-
if self.property_set["layout"]:
|
158
|
-
result_circuit._layout = TranspileLayout(
|
159
|
-
initial_layout=self.property_set["layout"],
|
160
|
-
input_qubit_mapping=self.property_set["original_qubit_indices"],
|
161
|
-
final_layout=self.property_set["final_layout"],
|
162
|
-
_input_qubit_count=len(circuit.qubits),
|
163
|
-
_output_qubit_list=result_circuit.qubits,
|
164
|
-
)
|
165
|
-
if self.property_set["clbit_write_latency"] is not None:
|
166
|
-
result_circuit._clbit_write_latency = self.property_set["clbit_write_latency"]
|
167
|
-
if self.property_set["conditional_latency"] is not None:
|
168
|
-
result_circuit._conditional_latency = self.property_set["conditional_latency"]
|
169
|
-
if self.property_set["node_start_time"]:
|
170
|
-
# This is dictionary keyed on the DAGOpNode, which is invalidated once
|
171
|
-
# dag is converted into circuit. So this schedule information is
|
172
|
-
# also converted into list with the same ordering with circuit.data.
|
173
|
-
topological_start_times = []
|
174
|
-
start_times = self.property_set["node_start_time"]
|
175
|
-
for dag_node in result.topological_op_nodes():
|
176
|
-
topological_start_times.append(start_times[dag_node])
|
177
|
-
result_circuit._op_start_times = topological_start_times
|
178
|
-
|
179
|
-
return result_circuit
|
150
|
+
property_set.update(pm.property_set)
|
151
|
+
return out
|
180
152
|
|
181
153
|
|
182
154
|
class AnalysisPass(BasePass): # pylint: disable=abstract-method
|
@@ -199,10 +171,7 @@ class TransformationPass(BasePass): # pylint: disable=abstract-method
|
|
199
171
|
)
|
200
172
|
|
201
173
|
if state.workflow_status.previous_run == RunState.SUCCESS:
|
202
|
-
if isinstance(new_dag, DAGCircuit):
|
203
|
-
# Copy calibration data from the original program
|
204
|
-
new_dag._calibrations_prop = passmanager_ir._calibrations_prop
|
205
|
-
else:
|
174
|
+
if not isinstance(new_dag, DAGCircuit):
|
206
175
|
raise TranspilerError(
|
207
176
|
"Transformation passes should return a transformed dag."
|
208
177
|
f"The pass {self.__class__.__name__} is returning a {type(new_dag)}"
|