qiskit 1.4.0__cp39-abi3-macosx_11_0_arm64.whl → 2.0.0rc1__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 +2 -5
- qiskit/_accelerate.abi3.so +0 -0
- qiskit/circuit/__init__.py +24 -5
- 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 +248 -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 +7 -140
- qiskit/circuit/instructionset.py +7 -54
- qiskit/circuit/library/__init__.py +34 -5
- 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/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 +2 -6
- 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 +13 -60
- 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 +4 -0
- qiskit/circuit/quantumcircuit.py +881 -555
- 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 +4 -2
- 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 +5 -5
- 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 +2 -80
- 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 +141 -19
- qiskit/qpy/binary_io/__init__.py +0 -1
- qiskit/qpy/binary_io/circuits.py +91 -116
- qiskit/qpy/binary_io/schedules.py +61 -388
- qiskit/qpy/binary_io/value.py +168 -28
- qiskit/qpy/common.py +10 -7
- qiskit/qpy/formats.py +41 -0
- qiskit/qpy/interface.py +29 -62
- 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 -10
- qiskit/result/result.py +28 -126
- 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/discrete_basis/generate_basis_approximations.py +2 -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 +2 -40
- qiskit/transpiler/passes/basis/basis_translator.py +4 -3
- 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 +5 -0
- qiskit/transpiler/passes/layout/dense_layout.py +2 -39
- qiskit/transpiler/passes/layout/full_ancilla_allocation.py +4 -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 +1 -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 +30 -2
- qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +20 -58
- qiskit/transpiler/passes/scheduling/padding/pad_delay.py +11 -3
- 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 +127 -59
- 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 +101 -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 +67 -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/dag_visualization.py +2 -1
- qiskit/visualization/gate_map.py +39 -154
- qiskit/visualization/pass_manager_visualization.py +6 -2
- qiskit/visualization/state_visualization.py +6 -0
- qiskit/visualization/timeline/core.py +27 -12
- qiskit/visualization/timeline/interface.py +23 -18
- {qiskit-1.4.0.dist-info → qiskit-2.0.0rc1.dist-info}/METADATA +2 -2
- {qiskit-1.4.0.dist-info → qiskit-2.0.0rc1.dist-info}/RECORD +297 -444
- {qiskit-1.4.0.dist-info → qiskit-2.0.0rc1.dist-info}/WHEEL +2 -1
- {qiskit-1.4.0.dist-info → qiskit-2.0.0rc1.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.0.dist-info → qiskit-2.0.0rc1.dist-info}/LICENSE.txt +0 -0
- {qiskit-1.4.0.dist-info → qiskit-2.0.0rc1.dist-info}/top_level.txt +0 -0
@@ -1,498 +0,0 @@
|
|
1
|
-
# This code is part of Qiskit.
|
2
|
-
#
|
3
|
-
# (C) Copyright IBM 2021.
|
4
|
-
#
|
5
|
-
# This code is licensed under the Apache License, Version 2.0. You may
|
6
|
-
# obtain a copy of this license in the LICENSE.txt file in the root directory
|
7
|
-
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
|
8
|
-
#
|
9
|
-
# Any modifications or derivative works of this code must retain this
|
10
|
-
# copyright notice, and modified files need to carry a notice indicating
|
11
|
-
# that they have been altered from the originals.
|
12
|
-
"""Basic rescheduling functions which take schedule or instructions and return new schedules."""
|
13
|
-
from __future__ import annotations
|
14
|
-
import typing
|
15
|
-
import warnings
|
16
|
-
from collections import defaultdict
|
17
|
-
from collections.abc import Iterable
|
18
|
-
from typing import Type
|
19
|
-
|
20
|
-
import numpy as np
|
21
|
-
|
22
|
-
from qiskit.pulse import channels as chans, exceptions, instructions
|
23
|
-
from qiskit.pulse.channels import ClassicalIOChannel
|
24
|
-
from qiskit.pulse.exceptions import PulseError
|
25
|
-
from qiskit.pulse.exceptions import UnassignedDurationError
|
26
|
-
from qiskit.pulse.instruction_schedule_map import InstructionScheduleMap
|
27
|
-
from qiskit.pulse.instructions import directives
|
28
|
-
from qiskit.pulse.schedule import Schedule, ScheduleBlock, ScheduleComponent
|
29
|
-
|
30
|
-
if typing.TYPE_CHECKING:
|
31
|
-
from qiskit.pulse.library import Pulse # pylint: disable=cyclic-import
|
32
|
-
|
33
|
-
|
34
|
-
def block_to_schedule(block: ScheduleBlock) -> Schedule:
|
35
|
-
"""Convert ``ScheduleBlock`` to ``Schedule``.
|
36
|
-
|
37
|
-
Args:
|
38
|
-
block: A ``ScheduleBlock`` to convert.
|
39
|
-
|
40
|
-
Returns:
|
41
|
-
Scheduled pulse program.
|
42
|
-
|
43
|
-
Raises:
|
44
|
-
UnassignedDurationError: When any instruction duration is not assigned.
|
45
|
-
PulseError: When the alignment context duration is shorter than the schedule duration.
|
46
|
-
|
47
|
-
.. note:: This transform may insert barriers in between contexts.
|
48
|
-
"""
|
49
|
-
if not block.is_schedulable():
|
50
|
-
raise UnassignedDurationError(
|
51
|
-
"All instruction durations should be assigned before creating `Schedule`."
|
52
|
-
"Please check `.parameters` to find unassigned parameter objects."
|
53
|
-
)
|
54
|
-
|
55
|
-
schedule = Schedule.initialize_from(block)
|
56
|
-
|
57
|
-
for op_data in block.blocks:
|
58
|
-
if isinstance(op_data, ScheduleBlock):
|
59
|
-
context_schedule = block_to_schedule(op_data)
|
60
|
-
if hasattr(op_data.alignment_context, "duration"):
|
61
|
-
# context may have local scope duration, e.g. EquispacedAlignment for 1000 dt
|
62
|
-
post_buffer = op_data.alignment_context.duration - context_schedule.duration
|
63
|
-
if post_buffer < 0:
|
64
|
-
raise PulseError(
|
65
|
-
f"ScheduleBlock {op_data.name} has longer duration than "
|
66
|
-
"the specified context duration "
|
67
|
-
f"{context_schedule.duration} > {op_data.duration}."
|
68
|
-
)
|
69
|
-
else:
|
70
|
-
post_buffer = 0
|
71
|
-
schedule.append(context_schedule, inplace=True)
|
72
|
-
|
73
|
-
# prevent interruption by following instructions.
|
74
|
-
# padding with delay instructions is no longer necessary, thanks to alignment context.
|
75
|
-
if post_buffer > 0:
|
76
|
-
context_boundary = instructions.RelativeBarrier(*op_data.channels)
|
77
|
-
schedule.append(context_boundary.shift(post_buffer), inplace=True)
|
78
|
-
else:
|
79
|
-
schedule.append(op_data, inplace=True)
|
80
|
-
|
81
|
-
# transform with defined policy
|
82
|
-
return block.alignment_context.align(schedule)
|
83
|
-
|
84
|
-
|
85
|
-
def compress_pulses(schedules: list[Schedule]) -> list[Schedule]:
|
86
|
-
"""Optimization pass to replace identical pulses.
|
87
|
-
|
88
|
-
Args:
|
89
|
-
schedules: Schedules to compress.
|
90
|
-
|
91
|
-
Returns:
|
92
|
-
Compressed schedules.
|
93
|
-
"""
|
94
|
-
existing_pulses: list[Pulse] = []
|
95
|
-
new_schedules = []
|
96
|
-
|
97
|
-
for schedule in schedules:
|
98
|
-
new_schedule = Schedule.initialize_from(schedule)
|
99
|
-
|
100
|
-
for time, inst in schedule.instructions:
|
101
|
-
if isinstance(inst, instructions.Play):
|
102
|
-
if inst.pulse in existing_pulses:
|
103
|
-
idx = existing_pulses.index(inst.pulse)
|
104
|
-
identical_pulse = existing_pulses[idx]
|
105
|
-
new_schedule.insert(
|
106
|
-
time,
|
107
|
-
instructions.Play(identical_pulse, inst.channel, inst.name),
|
108
|
-
inplace=True,
|
109
|
-
)
|
110
|
-
else:
|
111
|
-
existing_pulses.append(inst.pulse)
|
112
|
-
new_schedule.insert(time, inst, inplace=True)
|
113
|
-
else:
|
114
|
-
new_schedule.insert(time, inst, inplace=True)
|
115
|
-
|
116
|
-
new_schedules.append(new_schedule)
|
117
|
-
|
118
|
-
return new_schedules
|
119
|
-
|
120
|
-
|
121
|
-
def flatten(program: Schedule) -> Schedule:
|
122
|
-
"""Flatten (inline) any called nodes into a Schedule tree with no nested children.
|
123
|
-
|
124
|
-
Args:
|
125
|
-
program: Pulse program to remove nested structure.
|
126
|
-
|
127
|
-
Returns:
|
128
|
-
Flatten pulse program.
|
129
|
-
|
130
|
-
Raises:
|
131
|
-
PulseError: When invalid data format is given.
|
132
|
-
"""
|
133
|
-
if isinstance(program, Schedule):
|
134
|
-
flat_sched = Schedule.initialize_from(program)
|
135
|
-
for time, inst in program.instructions:
|
136
|
-
flat_sched.insert(time, inst, inplace=True)
|
137
|
-
return flat_sched
|
138
|
-
else:
|
139
|
-
raise PulseError(f"Invalid input program {program.__class__.__name__} is specified.")
|
140
|
-
|
141
|
-
|
142
|
-
def inline_subroutines(program: Schedule | ScheduleBlock) -> Schedule | ScheduleBlock:
|
143
|
-
"""Recursively remove call instructions and inline the respective subroutine instructions.
|
144
|
-
|
145
|
-
Assigned parameter values, which are stored in the parameter table, are also applied.
|
146
|
-
The subroutine is copied before the parameter assignment to avoid mutation problem.
|
147
|
-
|
148
|
-
Args:
|
149
|
-
program: A program which may contain the subroutine, i.e. ``Call`` instruction.
|
150
|
-
|
151
|
-
Returns:
|
152
|
-
A schedule without subroutine.
|
153
|
-
|
154
|
-
Raises:
|
155
|
-
PulseError: When input program is not valid data format.
|
156
|
-
"""
|
157
|
-
if isinstance(program, Schedule):
|
158
|
-
return _inline_schedule(program)
|
159
|
-
elif isinstance(program, ScheduleBlock):
|
160
|
-
return _inline_block(program)
|
161
|
-
else:
|
162
|
-
raise PulseError(f"Invalid program {program.__class__.__name__} is specified.")
|
163
|
-
|
164
|
-
|
165
|
-
def _inline_schedule(schedule: Schedule) -> Schedule:
|
166
|
-
"""A helper function to inline subroutine of schedule.
|
167
|
-
|
168
|
-
.. note:: If subroutine is ``ScheduleBlock`` it is converted into Schedule to get ``t0``.
|
169
|
-
"""
|
170
|
-
ret_schedule = Schedule.initialize_from(schedule)
|
171
|
-
for t0, inst in schedule.children:
|
172
|
-
# note that schedule.instructions unintentionally flatten the nested schedule.
|
173
|
-
# this should be performed by another transformer node.
|
174
|
-
if isinstance(inst, Schedule):
|
175
|
-
# recursively inline the program
|
176
|
-
inline_schedule = _inline_schedule(inst)
|
177
|
-
ret_schedule.insert(t0, inline_schedule, inplace=True)
|
178
|
-
else:
|
179
|
-
ret_schedule.insert(t0, inst, inplace=True)
|
180
|
-
return ret_schedule
|
181
|
-
|
182
|
-
|
183
|
-
def _inline_block(block: ScheduleBlock) -> ScheduleBlock:
|
184
|
-
"""A helper function to inline subroutine of schedule block.
|
185
|
-
|
186
|
-
.. note:: If subroutine is ``Schedule`` the function raises an error.
|
187
|
-
"""
|
188
|
-
ret_block = ScheduleBlock.initialize_from(block)
|
189
|
-
for inst in block.blocks:
|
190
|
-
if isinstance(inst, ScheduleBlock):
|
191
|
-
# recursively inline the program
|
192
|
-
inline_block = _inline_block(inst)
|
193
|
-
ret_block.append(inline_block, inplace=True)
|
194
|
-
else:
|
195
|
-
ret_block.append(inst, inplace=True)
|
196
|
-
return ret_block
|
197
|
-
|
198
|
-
|
199
|
-
def remove_directives(schedule: Schedule) -> Schedule:
|
200
|
-
"""Remove directives.
|
201
|
-
|
202
|
-
Args:
|
203
|
-
schedule: A schedule to remove compiler directives.
|
204
|
-
|
205
|
-
Returns:
|
206
|
-
A schedule without directives.
|
207
|
-
"""
|
208
|
-
return schedule.exclude(instruction_types=[directives.Directive])
|
209
|
-
|
210
|
-
|
211
|
-
def remove_trivial_barriers(schedule: Schedule) -> Schedule:
|
212
|
-
"""Remove trivial barriers with 0 or 1 channels.
|
213
|
-
|
214
|
-
Args:
|
215
|
-
schedule: A schedule to remove trivial barriers.
|
216
|
-
|
217
|
-
Returns:
|
218
|
-
schedule: A schedule without trivial barriers
|
219
|
-
"""
|
220
|
-
|
221
|
-
def filter_func(inst):
|
222
|
-
return isinstance(inst[1], directives.RelativeBarrier) and len(inst[1].channels) < 2
|
223
|
-
|
224
|
-
return schedule.exclude(filter_func)
|
225
|
-
|
226
|
-
|
227
|
-
def align_measures(
|
228
|
-
schedules: Iterable[ScheduleComponent],
|
229
|
-
inst_map: InstructionScheduleMap | None = None,
|
230
|
-
cal_gate: str = "u3",
|
231
|
-
max_calibration_duration: int | None = None,
|
232
|
-
align_time: int | None = None,
|
233
|
-
align_all: bool | None = True,
|
234
|
-
) -> list[Schedule]:
|
235
|
-
"""Return new schedules where measurements occur at the same physical time.
|
236
|
-
|
237
|
-
This transformation will align the first :class:`.Acquire` on
|
238
|
-
every channel to occur at the same time.
|
239
|
-
|
240
|
-
Minimum measurement wait time (to allow for calibration pulses) is enforced
|
241
|
-
and may be set with ``max_calibration_duration``.
|
242
|
-
|
243
|
-
By default only instructions containing a :class:`.AcquireChannel` or :class:`.MeasureChannel`
|
244
|
-
will be shifted. If you wish to keep the relative timing of all instructions in the schedule set
|
245
|
-
``align_all=True``.
|
246
|
-
|
247
|
-
This method assumes that ``MeasureChannel(i)`` and ``AcquireChannel(i)``
|
248
|
-
correspond to the same qubit and the acquire/play instructions
|
249
|
-
should be shifted together on these channels.
|
250
|
-
|
251
|
-
.. code-block::
|
252
|
-
|
253
|
-
from qiskit import pulse
|
254
|
-
from qiskit.pulse import transforms
|
255
|
-
|
256
|
-
d0 = pulse.DriveChannel(0)
|
257
|
-
m0 = pulse.MeasureChannel(0)
|
258
|
-
a0 = pulse.AcquireChannel(0)
|
259
|
-
mem0 = pulse.MemorySlot(0)
|
260
|
-
|
261
|
-
sched = pulse.Schedule()
|
262
|
-
sched.append(pulse.Play(pulse.Constant(10, 0.5), d0), inplace=True)
|
263
|
-
sched.append(pulse.Play(pulse.Constant(10, 1.), m0).shift(sched.duration), inplace=True)
|
264
|
-
sched.append(pulse.Acquire(20, a0, mem0).shift(sched.duration), inplace=True)
|
265
|
-
|
266
|
-
sched_shifted = sched << 20
|
267
|
-
|
268
|
-
aligned_sched, aligned_sched_shifted = transforms.align_measures([sched, sched_shifted])
|
269
|
-
|
270
|
-
assert aligned_sched == aligned_sched_shifted
|
271
|
-
|
272
|
-
If it is desired to only shift acquisition and measurement stimulus instructions
|
273
|
-
set the flag ``align_all=False``:
|
274
|
-
|
275
|
-
.. code-block::
|
276
|
-
|
277
|
-
aligned_sched, aligned_sched_shifted = transforms.align_measures(
|
278
|
-
[sched, sched_shifted],
|
279
|
-
align_all=False,
|
280
|
-
)
|
281
|
-
|
282
|
-
assert aligned_sched != aligned_sched_shifted
|
283
|
-
|
284
|
-
|
285
|
-
Args:
|
286
|
-
schedules: Collection of schedules to be aligned together
|
287
|
-
inst_map: Mapping of circuit operations to pulse schedules
|
288
|
-
cal_gate: The name of the gate to inspect for the calibration time
|
289
|
-
max_calibration_duration: If provided, inst_map and cal_gate will be ignored
|
290
|
-
align_time: If provided, this will be used as final align time.
|
291
|
-
align_all: Shift all instructions in the schedule such that they maintain
|
292
|
-
their relative alignment with the shifted acquisition instruction.
|
293
|
-
If ``False`` only the acquisition and measurement pulse instructions
|
294
|
-
will be shifted.
|
295
|
-
Returns:
|
296
|
-
The input list of schedules transformed to have their measurements aligned.
|
297
|
-
|
298
|
-
Raises:
|
299
|
-
PulseError: If the provided alignment time is negative.
|
300
|
-
"""
|
301
|
-
|
302
|
-
def get_first_acquire_times(schedules):
|
303
|
-
"""Return a list of first acquire times for each schedule."""
|
304
|
-
acquire_times = []
|
305
|
-
for schedule in schedules:
|
306
|
-
visited_channels = set()
|
307
|
-
qubit_first_acquire_times: dict[int, int] = defaultdict(lambda: None)
|
308
|
-
|
309
|
-
for time, inst in schedule.instructions:
|
310
|
-
if isinstance(inst, instructions.Acquire) and inst.channel not in visited_channels:
|
311
|
-
visited_channels.add(inst.channel)
|
312
|
-
qubit_first_acquire_times[inst.channel.index] = time
|
313
|
-
|
314
|
-
acquire_times.append(qubit_first_acquire_times)
|
315
|
-
return acquire_times
|
316
|
-
|
317
|
-
def get_max_calibration_duration(inst_map, cal_gate):
|
318
|
-
"""Return the time needed to allow for readout discrimination calibration pulses."""
|
319
|
-
# TODO (qiskit-terra #5472): fix behavior of this.
|
320
|
-
max_calibration_duration = 0
|
321
|
-
for qubits in inst_map.qubits_with_instruction(cal_gate):
|
322
|
-
cmd = inst_map.get(cal_gate, qubits, np.pi, 0, np.pi)
|
323
|
-
max_calibration_duration = max(cmd.duration, max_calibration_duration)
|
324
|
-
return max_calibration_duration
|
325
|
-
|
326
|
-
if align_time is not None and align_time < 0:
|
327
|
-
raise exceptions.PulseError("Align time cannot be negative.")
|
328
|
-
|
329
|
-
first_acquire_times = get_first_acquire_times(schedules)
|
330
|
-
# Extract the maximum acquire in every schedule across all acquires in the schedule.
|
331
|
-
# If there are no acquires in the schedule default to 0.
|
332
|
-
max_acquire_times = [max(0, *times.values()) for times in first_acquire_times]
|
333
|
-
if align_time is None:
|
334
|
-
if max_calibration_duration is None:
|
335
|
-
if inst_map:
|
336
|
-
max_calibration_duration = get_max_calibration_duration(inst_map, cal_gate)
|
337
|
-
else:
|
338
|
-
max_calibration_duration = 0
|
339
|
-
align_time = max(max_calibration_duration, *max_acquire_times)
|
340
|
-
|
341
|
-
# Shift acquires according to the new scheduled time
|
342
|
-
new_schedules = []
|
343
|
-
for sched_idx, schedule in enumerate(schedules):
|
344
|
-
new_schedule = Schedule.initialize_from(schedule)
|
345
|
-
stop_time = schedule.stop_time
|
346
|
-
|
347
|
-
if align_all:
|
348
|
-
if first_acquire_times[sched_idx]:
|
349
|
-
shift = align_time - max_acquire_times[sched_idx]
|
350
|
-
else:
|
351
|
-
shift = align_time - stop_time
|
352
|
-
else:
|
353
|
-
shift = 0
|
354
|
-
|
355
|
-
for time, inst in schedule.instructions:
|
356
|
-
measurement_channels = {
|
357
|
-
chan.index
|
358
|
-
for chan in inst.channels
|
359
|
-
if isinstance(chan, (chans.MeasureChannel, chans.AcquireChannel))
|
360
|
-
}
|
361
|
-
if measurement_channels:
|
362
|
-
sched_first_acquire_times = first_acquire_times[sched_idx]
|
363
|
-
max_start_time = max(
|
364
|
-
sched_first_acquire_times[chan]
|
365
|
-
for chan in measurement_channels
|
366
|
-
if chan in sched_first_acquire_times
|
367
|
-
)
|
368
|
-
shift = align_time - max_start_time
|
369
|
-
|
370
|
-
if shift < 0:
|
371
|
-
warnings.warn(
|
372
|
-
"The provided alignment time is scheduling an acquire instruction "
|
373
|
-
"earlier than it was scheduled for in the original Schedule. "
|
374
|
-
"This may result in an instruction being scheduled before t=0 and "
|
375
|
-
"an error being raised."
|
376
|
-
)
|
377
|
-
new_schedule.insert(time + shift, inst, inplace=True)
|
378
|
-
|
379
|
-
new_schedules.append(new_schedule)
|
380
|
-
|
381
|
-
return new_schedules
|
382
|
-
|
383
|
-
|
384
|
-
def add_implicit_acquires(schedule: ScheduleComponent, meas_map: list[list[int]]) -> Schedule:
|
385
|
-
"""Return a new schedule with implicit acquires from the measurement mapping replaced by
|
386
|
-
explicit ones.
|
387
|
-
|
388
|
-
.. warning:: Since new acquires are being added, Memory Slots will be set to match the
|
389
|
-
qubit index. This may overwrite your specification.
|
390
|
-
|
391
|
-
Args:
|
392
|
-
schedule: Schedule to be aligned.
|
393
|
-
meas_map: List of lists of qubits that are measured together.
|
394
|
-
|
395
|
-
Returns:
|
396
|
-
A ``Schedule`` with the additional acquisition instructions.
|
397
|
-
"""
|
398
|
-
new_schedule = Schedule.initialize_from(schedule)
|
399
|
-
acquire_map = {}
|
400
|
-
|
401
|
-
for time, inst in schedule.instructions:
|
402
|
-
if isinstance(inst, instructions.Acquire):
|
403
|
-
if inst.mem_slot and inst.mem_slot.index != inst.channel.index:
|
404
|
-
warnings.warn(
|
405
|
-
"One of your acquires was mapped to a memory slot which didn't match"
|
406
|
-
" the qubit index. I'm relabeling them to match."
|
407
|
-
)
|
408
|
-
|
409
|
-
# Get the label of all qubits that are measured with the qubit(s) in this instruction
|
410
|
-
all_qubits = []
|
411
|
-
for sublist in meas_map:
|
412
|
-
if inst.channel.index in sublist:
|
413
|
-
all_qubits.extend(sublist)
|
414
|
-
# Replace the old acquire instruction by a new one explicitly acquiring all qubits in
|
415
|
-
# the measurement group.
|
416
|
-
for i in all_qubits:
|
417
|
-
explicit_inst = instructions.Acquire(
|
418
|
-
inst.duration,
|
419
|
-
chans.AcquireChannel(i),
|
420
|
-
mem_slot=chans.MemorySlot(i),
|
421
|
-
kernel=inst.kernel,
|
422
|
-
discriminator=inst.discriminator,
|
423
|
-
)
|
424
|
-
if time not in acquire_map:
|
425
|
-
new_schedule.insert(time, explicit_inst, inplace=True)
|
426
|
-
acquire_map = {time: {i}}
|
427
|
-
elif i not in acquire_map[time]:
|
428
|
-
new_schedule.insert(time, explicit_inst, inplace=True)
|
429
|
-
acquire_map[time].add(i)
|
430
|
-
else:
|
431
|
-
new_schedule.insert(time, inst, inplace=True)
|
432
|
-
|
433
|
-
return new_schedule
|
434
|
-
|
435
|
-
|
436
|
-
def pad(
|
437
|
-
schedule: Schedule,
|
438
|
-
channels: Iterable[chans.Channel] | None = None,
|
439
|
-
until: int | None = None,
|
440
|
-
inplace: bool = False,
|
441
|
-
pad_with: Type[instructions.Instruction] | None = None,
|
442
|
-
) -> Schedule:
|
443
|
-
"""Pad the input Schedule with ``Delay``s on all unoccupied timeslots until
|
444
|
-
``schedule.duration`` or ``until`` if not ``None``.
|
445
|
-
|
446
|
-
Args:
|
447
|
-
schedule: Schedule to pad.
|
448
|
-
channels: Channels to pad. Defaults to all channels in
|
449
|
-
``schedule`` if not provided. If the supplied channel is not a member
|
450
|
-
of ``schedule`` it will be added.
|
451
|
-
until: Time to pad until. Defaults to ``schedule.duration`` if not provided.
|
452
|
-
inplace: Pad this schedule by mutating rather than returning a new schedule.
|
453
|
-
pad_with: Pulse ``Instruction`` subclass to be used for padding.
|
454
|
-
Default to :class:`~qiskit.pulse.instructions.Delay` instruction.
|
455
|
-
|
456
|
-
Returns:
|
457
|
-
The padded schedule.
|
458
|
-
|
459
|
-
Raises:
|
460
|
-
PulseError: When non pulse instruction is set to `pad_with`.
|
461
|
-
"""
|
462
|
-
until = until or schedule.duration
|
463
|
-
channels = channels or schedule.channels
|
464
|
-
|
465
|
-
if pad_with:
|
466
|
-
if issubclass(pad_with, instructions.Instruction):
|
467
|
-
pad_cls = pad_with
|
468
|
-
else:
|
469
|
-
raise PulseError(
|
470
|
-
f"'{pad_with.__class__.__name__}' is not valid pulse instruction to pad with."
|
471
|
-
)
|
472
|
-
else:
|
473
|
-
pad_cls = instructions.Delay
|
474
|
-
|
475
|
-
for channel in channels:
|
476
|
-
if isinstance(channel, ClassicalIOChannel):
|
477
|
-
continue
|
478
|
-
|
479
|
-
if channel not in schedule.channels:
|
480
|
-
schedule = schedule.insert(0, instructions.Delay(until, channel), inplace=inplace)
|
481
|
-
continue
|
482
|
-
|
483
|
-
prev_time = 0
|
484
|
-
timeslots = iter(schedule.timeslots[channel])
|
485
|
-
to_pad = []
|
486
|
-
while prev_time < until:
|
487
|
-
try:
|
488
|
-
t0, t1 = next(timeslots)
|
489
|
-
except StopIteration:
|
490
|
-
to_pad.append((prev_time, until - prev_time))
|
491
|
-
break
|
492
|
-
if prev_time < t0:
|
493
|
-
to_pad.append((prev_time, min(t0, until) - prev_time))
|
494
|
-
prev_time = t1
|
495
|
-
for t0, duration in to_pad:
|
496
|
-
schedule = schedule.insert(t0, pad_cls(duration, channel), inplace=inplace)
|
497
|
-
|
498
|
-
return schedule
|
qiskit/pulse/transforms/dag.py
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
# This code is part of Qiskit.
|
2
|
-
#
|
3
|
-
# (C) Copyright IBM 2021.
|
4
|
-
#
|
5
|
-
# This code is licensed under the Apache License, Version 2.0. You may
|
6
|
-
# obtain a copy of this license in the LICENSE.txt file in the root directory
|
7
|
-
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
|
8
|
-
#
|
9
|
-
# Any modifications or derivative works of this code must retain this
|
10
|
-
# copyright notice, and modified files need to carry a notice indicating
|
11
|
-
# that they have been altered from the originals.
|
12
|
-
"""A collection of functions to convert ScheduleBlock to DAG representation."""
|
13
|
-
from __future__ import annotations
|
14
|
-
|
15
|
-
import typing
|
16
|
-
|
17
|
-
import rustworkx as rx
|
18
|
-
|
19
|
-
|
20
|
-
from qiskit.pulse.channels import Channel
|
21
|
-
from qiskit.pulse.exceptions import UnassignedReferenceError
|
22
|
-
|
23
|
-
if typing.TYPE_CHECKING:
|
24
|
-
from qiskit.pulse import ScheduleBlock # pylint: disable=cyclic-import
|
25
|
-
|
26
|
-
|
27
|
-
def block_to_dag(block: ScheduleBlock) -> rx.PyDAG:
|
28
|
-
"""Convert schedule block instruction into DAG.
|
29
|
-
|
30
|
-
``ScheduleBlock`` can be represented as a DAG as needed.
|
31
|
-
For example, equality of two programs are efficiently checked on DAG representation.
|
32
|
-
|
33
|
-
.. code-block:: python
|
34
|
-
|
35
|
-
from qiskit import pulse
|
36
|
-
|
37
|
-
my_gaussian0 = pulse.Gaussian(100, 0.5, 20)
|
38
|
-
my_gaussian1 = pulse.Gaussian(100, 0.3, 10)
|
39
|
-
|
40
|
-
with pulse.build() as sched1:
|
41
|
-
with pulse.align_left():
|
42
|
-
pulse.play(my_gaussian0, pulse.DriveChannel(0))
|
43
|
-
pulse.shift_phase(1.57, pulse.DriveChannel(2))
|
44
|
-
pulse.play(my_gaussian1, pulse.DriveChannel(1))
|
45
|
-
|
46
|
-
with pulse.build() as sched2:
|
47
|
-
with pulse.align_left():
|
48
|
-
pulse.shift_phase(1.57, pulse.DriveChannel(2))
|
49
|
-
pulse.play(my_gaussian1, pulse.DriveChannel(1))
|
50
|
-
pulse.play(my_gaussian0, pulse.DriveChannel(0))
|
51
|
-
|
52
|
-
Here the ``sched1 `` and ``sched2`` are different implementations of the same program,
|
53
|
-
but it is difficult to confirm on the list representation.
|
54
|
-
|
55
|
-
Another example is instruction optimization.
|
56
|
-
|
57
|
-
.. code-block:: python
|
58
|
-
|
59
|
-
from qiskit import pulse
|
60
|
-
|
61
|
-
with pulse.build() as sched:
|
62
|
-
with pulse.align_left():
|
63
|
-
pulse.shift_phase(1.57, pulse.DriveChannel(1))
|
64
|
-
pulse.play(my_gaussian0, pulse.DriveChannel(0))
|
65
|
-
pulse.shift_phase(-1.57, pulse.DriveChannel(1))
|
66
|
-
|
67
|
-
In above program two ``shift_phase`` instructions can be cancelled out because
|
68
|
-
they are consecutive on the same drive channel.
|
69
|
-
This can be easily found on the DAG representation.
|
70
|
-
|
71
|
-
Args:
|
72
|
-
block ("ScheduleBlock"): A schedule block to be converted.
|
73
|
-
|
74
|
-
Returns:
|
75
|
-
Instructions in DAG representation.
|
76
|
-
|
77
|
-
Raises:
|
78
|
-
PulseError: When the context is invalid subclass.
|
79
|
-
"""
|
80
|
-
if block.alignment_context.is_sequential:
|
81
|
-
return _sequential_allocation(block)
|
82
|
-
return _parallel_allocation(block)
|
83
|
-
|
84
|
-
|
85
|
-
def _sequential_allocation(block) -> rx.PyDAG:
|
86
|
-
"""A helper function to create a DAG of a sequential alignment context."""
|
87
|
-
dag = rx.PyDAG()
|
88
|
-
|
89
|
-
edges: list[tuple[int, int]] = []
|
90
|
-
prev_id = None
|
91
|
-
for elm in block.blocks:
|
92
|
-
node_id = dag.add_node(elm)
|
93
|
-
if dag.num_nodes() > 1:
|
94
|
-
edges.append((prev_id, node_id))
|
95
|
-
prev_id = node_id
|
96
|
-
dag.add_edges_from_no_data(edges)
|
97
|
-
return dag
|
98
|
-
|
99
|
-
|
100
|
-
def _parallel_allocation(block) -> rx.PyDAG:
|
101
|
-
"""A helper function to create a DAG of a parallel alignment context."""
|
102
|
-
dag = rx.PyDAG()
|
103
|
-
|
104
|
-
slots: dict[Channel, int] = {}
|
105
|
-
edges: set[tuple[int, int]] = set()
|
106
|
-
prev_reference = None
|
107
|
-
for elm in block.blocks:
|
108
|
-
node_id = dag.add_node(elm)
|
109
|
-
try:
|
110
|
-
for chan in elm.channels:
|
111
|
-
prev_id = slots.pop(chan, prev_reference)
|
112
|
-
if prev_id is not None:
|
113
|
-
edges.add((prev_id, node_id))
|
114
|
-
slots[chan] = node_id
|
115
|
-
except UnassignedReferenceError:
|
116
|
-
# Broadcasting channels because the reference's channels are unknown.
|
117
|
-
for chan, prev_id in slots.copy().items():
|
118
|
-
edges.add((prev_id, node_id))
|
119
|
-
slots[chan] = node_id
|
120
|
-
prev_reference = node_id
|
121
|
-
dag.add_edges_from_no_data(list(edges))
|
122
|
-
return dag
|