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
@@ -1,381 +0,0 @@
|
|
1
|
-
# This code is part of Qiskit.
|
2
|
-
#
|
3
|
-
# (C) Copyright IBM 2023.
|
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
|
-
|
13
|
-
"""Internal format of calibration data in target."""
|
14
|
-
from __future__ import annotations
|
15
|
-
import inspect
|
16
|
-
import warnings
|
17
|
-
from abc import ABCMeta, abstractmethod
|
18
|
-
from collections.abc import Sequence, Callable
|
19
|
-
from enum import IntEnum
|
20
|
-
from typing import Any
|
21
|
-
|
22
|
-
from qiskit.pulse.exceptions import PulseError
|
23
|
-
from qiskit.pulse.schedule import Schedule, ScheduleBlock
|
24
|
-
from qiskit.qobj.converters import QobjToInstructionConverter
|
25
|
-
from qiskit.qobj.pulse_qobj import PulseQobjInstruction
|
26
|
-
from qiskit.exceptions import QiskitError
|
27
|
-
|
28
|
-
|
29
|
-
IncompletePulseQobj = object()
|
30
|
-
"""A None-like constant that represents the PulseQobj is incomplete."""
|
31
|
-
|
32
|
-
|
33
|
-
class CalibrationPublisher(IntEnum):
|
34
|
-
"""Defines who defined schedule entry."""
|
35
|
-
|
36
|
-
BACKEND_PROVIDER = 0
|
37
|
-
QISKIT = 1
|
38
|
-
EXPERIMENT_SERVICE = 2
|
39
|
-
|
40
|
-
|
41
|
-
class CalibrationEntry(metaclass=ABCMeta):
|
42
|
-
"""A metaclass of a calibration entry.
|
43
|
-
|
44
|
-
This class defines a standard model of Qiskit pulse program that is
|
45
|
-
agnostic to the underlying in-memory representation.
|
46
|
-
|
47
|
-
This entry distinguishes whether this is provided by end-users or a backend
|
48
|
-
by :attr:`.user_provided` attribute which may be provided when
|
49
|
-
the actual calibration data is provided to the entry with by :meth:`define`.
|
50
|
-
|
51
|
-
Note that a custom entry provided by an end-user may appear in the wire-format
|
52
|
-
as an inline calibration, e.g. :code:`defcal` of the QASM3,
|
53
|
-
that may update the backend instruction set architecture for execution.
|
54
|
-
|
55
|
-
.. note::
|
56
|
-
|
57
|
-
This and built-in subclasses are expected to be private without stable user-facing API.
|
58
|
-
The purpose of this class is to wrap different
|
59
|
-
in-memory pulse program representations in Qiskit, so that it can provide
|
60
|
-
the standard data model and API which are primarily used by the transpiler ecosystem.
|
61
|
-
It is assumed that end-users will never directly instantiate this class,
|
62
|
-
but :class:`.Target` or :class:`.InstructionScheduleMap` internally use this data model
|
63
|
-
to avoid implementing a complicated branching logic to
|
64
|
-
manage different calibration data formats.
|
65
|
-
|
66
|
-
"""
|
67
|
-
|
68
|
-
@abstractmethod
|
69
|
-
def define(self, definition: Any, user_provided: bool):
|
70
|
-
"""Attach definition to the calibration entry.
|
71
|
-
|
72
|
-
Args:
|
73
|
-
definition: Definition of this entry.
|
74
|
-
user_provided: If this entry is defined by user.
|
75
|
-
If the flag is set, this calibration may appear in the wire format
|
76
|
-
as an inline calibration, to override the backend instruction set architecture.
|
77
|
-
"""
|
78
|
-
pass
|
79
|
-
|
80
|
-
@abstractmethod
|
81
|
-
def get_signature(self) -> inspect.Signature:
|
82
|
-
"""Return signature object associated with entry definition.
|
83
|
-
|
84
|
-
Returns:
|
85
|
-
Signature object.
|
86
|
-
"""
|
87
|
-
pass
|
88
|
-
|
89
|
-
@abstractmethod
|
90
|
-
def get_schedule(self, *args, **kwargs) -> Schedule | ScheduleBlock:
|
91
|
-
"""Generate schedule from entry definition.
|
92
|
-
|
93
|
-
If the pulse program is templated with :class:`.Parameter` objects,
|
94
|
-
you can provide corresponding parameter values for this method
|
95
|
-
to get a particular pulse program with assigned parameters.
|
96
|
-
|
97
|
-
Args:
|
98
|
-
args: Command parameters.
|
99
|
-
kwargs: Command keyword parameters.
|
100
|
-
|
101
|
-
Returns:
|
102
|
-
Pulse schedule with assigned parameters.
|
103
|
-
"""
|
104
|
-
pass
|
105
|
-
|
106
|
-
@property
|
107
|
-
@abstractmethod
|
108
|
-
def user_provided(self) -> bool:
|
109
|
-
"""Return if this entry is user defined."""
|
110
|
-
pass
|
111
|
-
|
112
|
-
|
113
|
-
class ScheduleDef(CalibrationEntry):
|
114
|
-
"""In-memory Qiskit Pulse representation.
|
115
|
-
|
116
|
-
A pulse schedule must provide signature with the .parameters attribute.
|
117
|
-
This entry can be parameterized by a Qiskit Parameter object.
|
118
|
-
The .get_schedule method returns a parameter-assigned pulse program.
|
119
|
-
|
120
|
-
.. see_also::
|
121
|
-
:class:`.CalibrationEntry` for the purpose of this class.
|
122
|
-
|
123
|
-
"""
|
124
|
-
|
125
|
-
def __init__(self, arguments: Sequence[str] | None = None):
|
126
|
-
"""Define an empty entry.
|
127
|
-
|
128
|
-
Args:
|
129
|
-
arguments: User provided argument names for this entry, if parameterized.
|
130
|
-
|
131
|
-
Raises:
|
132
|
-
PulseError: When `arguments` is not a sequence of string.
|
133
|
-
"""
|
134
|
-
if arguments and not all(isinstance(arg, str) for arg in arguments):
|
135
|
-
raise PulseError(f"Arguments must be name of parameters. Not {arguments}.")
|
136
|
-
if arguments:
|
137
|
-
arguments = list(arguments)
|
138
|
-
self._user_arguments = arguments
|
139
|
-
|
140
|
-
self._definition: Callable | Schedule | None = None
|
141
|
-
self._signature: inspect.Signature | None = None
|
142
|
-
self._user_provided: bool | None = None
|
143
|
-
|
144
|
-
@property
|
145
|
-
def user_provided(self) -> bool:
|
146
|
-
return self._user_provided
|
147
|
-
|
148
|
-
def _parse_argument(self):
|
149
|
-
"""Generate signature from program and user provided argument names."""
|
150
|
-
# This doesn't assume multiple parameters with the same name
|
151
|
-
# Parameters with the same name are treated identically
|
152
|
-
all_argnames = {x.name for x in self._definition.parameters}
|
153
|
-
|
154
|
-
if self._user_arguments:
|
155
|
-
if set(self._user_arguments) != all_argnames:
|
156
|
-
raise PulseError(
|
157
|
-
"Specified arguments don't match with schedule parameters. "
|
158
|
-
f"{self._user_arguments} != {self._definition.parameters}."
|
159
|
-
)
|
160
|
-
argnames = list(self._user_arguments)
|
161
|
-
else:
|
162
|
-
argnames = sorted(all_argnames)
|
163
|
-
|
164
|
-
params = []
|
165
|
-
for argname in argnames:
|
166
|
-
param = inspect.Parameter(
|
167
|
-
argname,
|
168
|
-
kind=inspect.Parameter.POSITIONAL_OR_KEYWORD,
|
169
|
-
)
|
170
|
-
params.append(param)
|
171
|
-
signature = inspect.Signature(
|
172
|
-
parameters=params,
|
173
|
-
return_annotation=type(self._definition),
|
174
|
-
)
|
175
|
-
self._signature = signature
|
176
|
-
|
177
|
-
def define(
|
178
|
-
self,
|
179
|
-
definition: Schedule | ScheduleBlock,
|
180
|
-
user_provided: bool = True,
|
181
|
-
):
|
182
|
-
self._definition = definition
|
183
|
-
self._parse_argument()
|
184
|
-
self._user_provided = user_provided
|
185
|
-
|
186
|
-
def get_signature(self) -> inspect.Signature:
|
187
|
-
return self._signature
|
188
|
-
|
189
|
-
def get_schedule(self, *args, **kwargs) -> Schedule | ScheduleBlock:
|
190
|
-
if not args and not kwargs:
|
191
|
-
out = self._definition
|
192
|
-
else:
|
193
|
-
try:
|
194
|
-
to_bind = self.get_signature().bind_partial(*args, **kwargs)
|
195
|
-
except TypeError as ex:
|
196
|
-
raise PulseError(
|
197
|
-
"Assigned parameter doesn't match with schedule parameters."
|
198
|
-
) from ex
|
199
|
-
value_dict = {}
|
200
|
-
for param in self._definition.parameters:
|
201
|
-
# Schedule allows partial bind. This results in parameterized Schedule.
|
202
|
-
try:
|
203
|
-
value_dict[param] = to_bind.arguments[param.name]
|
204
|
-
except KeyError:
|
205
|
-
pass
|
206
|
-
out = self._definition.assign_parameters(value_dict, inplace=False)
|
207
|
-
if "publisher" not in out.metadata:
|
208
|
-
if self.user_provided:
|
209
|
-
out.metadata["publisher"] = CalibrationPublisher.QISKIT
|
210
|
-
else:
|
211
|
-
out.metadata["publisher"] = CalibrationPublisher.BACKEND_PROVIDER
|
212
|
-
return out
|
213
|
-
|
214
|
-
def __eq__(self, other):
|
215
|
-
# This delegates equality check to Schedule or ScheduleBlock.
|
216
|
-
if hasattr(other, "_definition"):
|
217
|
-
return self._definition == other._definition
|
218
|
-
return False
|
219
|
-
|
220
|
-
def __str__(self):
|
221
|
-
out = f"Schedule {self._definition.name}"
|
222
|
-
params_str = ", ".join(self.get_signature().parameters.keys())
|
223
|
-
if params_str:
|
224
|
-
out += f"({params_str})"
|
225
|
-
return out
|
226
|
-
|
227
|
-
|
228
|
-
class CallableDef(CalibrationEntry):
|
229
|
-
"""Python callback function that generates Qiskit Pulse program.
|
230
|
-
|
231
|
-
A callable is inspected by the python built-in inspection module and
|
232
|
-
provide the signature. This entry is parameterized by the function signature
|
233
|
-
and .get_schedule method returns a non-parameterized pulse program
|
234
|
-
by consuming the provided arguments and keyword arguments.
|
235
|
-
|
236
|
-
.. see_also::
|
237
|
-
:class:`.CalibrationEntry` for the purpose of this class.
|
238
|
-
|
239
|
-
"""
|
240
|
-
|
241
|
-
def __init__(self):
|
242
|
-
"""Define an empty entry."""
|
243
|
-
self._definition = None
|
244
|
-
self._signature = None
|
245
|
-
self._user_provided = None
|
246
|
-
|
247
|
-
@property
|
248
|
-
def user_provided(self) -> bool:
|
249
|
-
return self._user_provided
|
250
|
-
|
251
|
-
def define(
|
252
|
-
self,
|
253
|
-
definition: Callable,
|
254
|
-
user_provided: bool = True,
|
255
|
-
):
|
256
|
-
self._definition = definition
|
257
|
-
self._signature = inspect.signature(definition)
|
258
|
-
self._user_provided = user_provided
|
259
|
-
|
260
|
-
def get_signature(self) -> inspect.Signature:
|
261
|
-
return self._signature
|
262
|
-
|
263
|
-
def get_schedule(self, *args, **kwargs) -> Schedule | ScheduleBlock:
|
264
|
-
try:
|
265
|
-
# Python function doesn't allow partial bind, but default value can exist.
|
266
|
-
to_bind = self._signature.bind(*args, **kwargs)
|
267
|
-
to_bind.apply_defaults()
|
268
|
-
except TypeError as ex:
|
269
|
-
raise PulseError("Assigned parameter doesn't match with function signature.") from ex
|
270
|
-
out = self._definition(**to_bind.arguments)
|
271
|
-
if "publisher" not in out.metadata:
|
272
|
-
if self.user_provided:
|
273
|
-
out.metadata["publisher"] = CalibrationPublisher.QISKIT
|
274
|
-
else:
|
275
|
-
out.metadata["publisher"] = CalibrationPublisher.BACKEND_PROVIDER
|
276
|
-
return out
|
277
|
-
|
278
|
-
def __eq__(self, other):
|
279
|
-
# We cannot evaluate function equality without parsing python AST.
|
280
|
-
# This simply compares weather they are the same object.
|
281
|
-
if hasattr(other, "_definition"):
|
282
|
-
return self._definition == other._definition
|
283
|
-
return False
|
284
|
-
|
285
|
-
def __str__(self):
|
286
|
-
params_str = ", ".join(self.get_signature().parameters.keys())
|
287
|
-
return f"Callable {self._definition.__name__}({params_str})"
|
288
|
-
|
289
|
-
|
290
|
-
class PulseQobjDef(ScheduleDef):
|
291
|
-
"""Qobj JSON serialized format instruction sequence.
|
292
|
-
|
293
|
-
A JSON serialized program can be converted into Qiskit Pulse program with
|
294
|
-
the provided qobj converter. Because the Qobj JSON doesn't provide signature,
|
295
|
-
conversion process occurs when the signature is requested for the first time
|
296
|
-
and the generated pulse program is cached for performance.
|
297
|
-
|
298
|
-
.. see_also::
|
299
|
-
:class:`.CalibrationEntry` for the purpose of this class.
|
300
|
-
|
301
|
-
"""
|
302
|
-
|
303
|
-
def __init__(
|
304
|
-
self,
|
305
|
-
arguments: Sequence[str] | None = None,
|
306
|
-
converter: QobjToInstructionConverter | None = None,
|
307
|
-
name: str | None = None,
|
308
|
-
):
|
309
|
-
"""Define an empty entry.
|
310
|
-
|
311
|
-
Args:
|
312
|
-
arguments: User provided argument names for this entry, if parameterized.
|
313
|
-
converter: Optional. Qobj to Qiskit converter.
|
314
|
-
name: Name of schedule.
|
315
|
-
"""
|
316
|
-
super().__init__(arguments=arguments)
|
317
|
-
|
318
|
-
self._converter = converter or QobjToInstructionConverter(pulse_library=[])
|
319
|
-
self._name = name
|
320
|
-
self._source: list[PulseQobjInstruction] | None = None
|
321
|
-
|
322
|
-
def _build_schedule(self):
|
323
|
-
"""Build pulse schedule from cmd-def sequence."""
|
324
|
-
with warnings.catch_warnings():
|
325
|
-
warnings.simplefilter(action="ignore", category=DeprecationWarning)
|
326
|
-
# `Schedule` is being deprecated in Qiskit 1.3
|
327
|
-
schedule = Schedule(name=self._name)
|
328
|
-
try:
|
329
|
-
for qobj_inst in self._source:
|
330
|
-
for qiskit_inst in self._converter._get_sequences(qobj_inst):
|
331
|
-
schedule.insert(qobj_inst.t0, qiskit_inst, inplace=True)
|
332
|
-
self._definition = schedule
|
333
|
-
self._parse_argument()
|
334
|
-
except QiskitError as ex:
|
335
|
-
# When the play waveform data is missing in pulse_lib we cannot build schedule.
|
336
|
-
# Instead of raising an error, get_schedule should return None.
|
337
|
-
warnings.warn(
|
338
|
-
f"Pulse calibration cannot be built and the entry is ignored: {ex.message}.",
|
339
|
-
UserWarning,
|
340
|
-
)
|
341
|
-
self._definition = IncompletePulseQobj
|
342
|
-
|
343
|
-
def define(
|
344
|
-
self,
|
345
|
-
definition: list[PulseQobjInstruction],
|
346
|
-
user_provided: bool = False,
|
347
|
-
):
|
348
|
-
# This doesn't generate signature immediately, because of lazy schedule build.
|
349
|
-
self._source = definition
|
350
|
-
self._user_provided = user_provided
|
351
|
-
|
352
|
-
def get_signature(self) -> inspect.Signature:
|
353
|
-
if self._definition is None:
|
354
|
-
self._build_schedule()
|
355
|
-
return super().get_signature()
|
356
|
-
|
357
|
-
def get_schedule(self, *args, **kwargs) -> Schedule | ScheduleBlock | None:
|
358
|
-
if self._definition is None:
|
359
|
-
self._build_schedule()
|
360
|
-
if self._definition is IncompletePulseQobj:
|
361
|
-
return None
|
362
|
-
return super().get_schedule(*args, **kwargs)
|
363
|
-
|
364
|
-
def __eq__(self, other):
|
365
|
-
if isinstance(other, PulseQobjDef):
|
366
|
-
# If both objects are Qobj just check Qobj equality.
|
367
|
-
return self._source == other._source
|
368
|
-
if isinstance(other, ScheduleDef) and self._definition is None:
|
369
|
-
# To compare with other schedule def, this also generates schedule object from qobj.
|
370
|
-
self._build_schedule()
|
371
|
-
if hasattr(other, "_definition"):
|
372
|
-
return self._definition == other._definition
|
373
|
-
return False
|
374
|
-
|
375
|
-
def __str__(self):
|
376
|
-
if self._definition is None:
|
377
|
-
# Avoid parsing schedule for pretty print.
|
378
|
-
return "PulseQobj"
|
379
|
-
if self._definition is IncompletePulseQobj:
|
380
|
-
return "None"
|
381
|
-
return super().__str__()
|
qiskit/pulse/channels.py
DELETED
@@ -1,227 +0,0 @@
|
|
1
|
-
# This code is part of Qiskit.
|
2
|
-
#
|
3
|
-
# (C) Copyright IBM 2017, 2019.
|
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
|
-
|
13
|
-
"""
|
14
|
-
.. _pulse-channels:
|
15
|
-
|
16
|
-
=======================================
|
17
|
-
Channels (:mod:`qiskit.pulse.channels`)
|
18
|
-
=======================================
|
19
|
-
|
20
|
-
Pulse is meant to be agnostic to the underlying hardware implementation, while still allowing
|
21
|
-
low-level control. Therefore, our signal channels are *virtual* hardware channels. The backend
|
22
|
-
which executes our programs is responsible for mapping these virtual channels to the proper
|
23
|
-
physical channel within the quantum control hardware.
|
24
|
-
|
25
|
-
Channels are characterized by their type and their index. Channels include:
|
26
|
-
|
27
|
-
* transmit channels, which should subclass ``PulseChannel``
|
28
|
-
* receive channels, such as :class:`AcquireChannel`
|
29
|
-
* non-signal "channels" such as :class:`SnapshotChannel`, :class:`MemorySlot` and
|
30
|
-
:class:`RegisterChannel`.
|
31
|
-
|
32
|
-
Novel channel types can often utilize the :class:`ControlChannel`, but if this is not sufficient,
|
33
|
-
new channel types can be created. Then, they must be supported in the PulseQobj schema and the
|
34
|
-
assembler. Channels are characterized by their type and their index. See each channel type below to
|
35
|
-
learn more.
|
36
|
-
|
37
|
-
.. autosummary::
|
38
|
-
:toctree: ../stubs/
|
39
|
-
|
40
|
-
DriveChannel
|
41
|
-
MeasureChannel
|
42
|
-
AcquireChannel
|
43
|
-
ControlChannel
|
44
|
-
RegisterSlot
|
45
|
-
MemorySlot
|
46
|
-
SnapshotChannel
|
47
|
-
|
48
|
-
All channels are children of the same abstract base class:
|
49
|
-
|
50
|
-
.. autoclass:: Channel
|
51
|
-
"""
|
52
|
-
from __future__ import annotations
|
53
|
-
from abc import ABCMeta
|
54
|
-
from typing import Any
|
55
|
-
|
56
|
-
import numpy as np
|
57
|
-
|
58
|
-
from qiskit.circuit import Parameter
|
59
|
-
from qiskit.circuit.parameterexpression import ParameterExpression
|
60
|
-
from qiskit.pulse.exceptions import PulseError
|
61
|
-
from qiskit.utils.deprecate_pulse import deprecate_pulse_func
|
62
|
-
|
63
|
-
|
64
|
-
class Channel(metaclass=ABCMeta):
|
65
|
-
"""Base class of channels. Channels provide a Qiskit-side label for typical quantum control
|
66
|
-
hardware signal channels. The final label -> physical channel mapping is the responsibility
|
67
|
-
of the hardware backend. For instance, ``DriveChannel(0)`` holds instructions which the backend
|
68
|
-
should map to the signal line driving gate operations on the qubit labeled (indexed) 0.
|
69
|
-
|
70
|
-
When serialized channels are identified by their serialized name ``<prefix><index>``.
|
71
|
-
The type of the channel is interpreted from the prefix,
|
72
|
-
and the index often (but not always) maps to the qubit index.
|
73
|
-
All concrete channel classes must have a ``prefix`` class attribute
|
74
|
-
(and instances of that class have an index attribute). Base classes which have
|
75
|
-
``prefix`` set to ``None`` are prevented from being instantiated.
|
76
|
-
|
77
|
-
To implement a new channel inherit from :class:`Channel` and provide a unique string identifier
|
78
|
-
for the ``prefix`` class attribute.
|
79
|
-
"""
|
80
|
-
|
81
|
-
prefix: str | None = None
|
82
|
-
"""A shorthand string prefix for characterizing the channel type."""
|
83
|
-
|
84
|
-
# pylint: disable=unused-argument
|
85
|
-
def __new__(cls, *args, **kwargs):
|
86
|
-
if cls.prefix is None:
|
87
|
-
raise NotImplementedError(
|
88
|
-
"Cannot instantiate abstract channel. "
|
89
|
-
"See Channel documentation for more information."
|
90
|
-
)
|
91
|
-
|
92
|
-
return super().__new__(cls)
|
93
|
-
|
94
|
-
@deprecate_pulse_func
|
95
|
-
def __init__(self, index: int):
|
96
|
-
"""Channel class.
|
97
|
-
|
98
|
-
Args:
|
99
|
-
index: Index of channel.
|
100
|
-
"""
|
101
|
-
self._validate_index(index)
|
102
|
-
self._index = index
|
103
|
-
|
104
|
-
@property
|
105
|
-
def index(self) -> int | ParameterExpression:
|
106
|
-
"""Return the index of this channel. The index is a label for a control signal line
|
107
|
-
typically mapped trivially to a qubit index. For instance, ``DriveChannel(0)`` labels
|
108
|
-
the signal line driving the qubit labeled with index 0.
|
109
|
-
"""
|
110
|
-
return self._index
|
111
|
-
|
112
|
-
def _validate_index(self, index: Any) -> None:
|
113
|
-
"""Raise a PulseError if the channel index is invalid, namely, if it's not a positive
|
114
|
-
integer.
|
115
|
-
|
116
|
-
Raises:
|
117
|
-
PulseError: If ``index`` is not a nonnegative integer.
|
118
|
-
"""
|
119
|
-
if isinstance(index, ParameterExpression) and index.parameters:
|
120
|
-
# Parameters are unbound
|
121
|
-
return
|
122
|
-
elif isinstance(index, ParameterExpression):
|
123
|
-
index = float(index)
|
124
|
-
if index.is_integer():
|
125
|
-
index = int(index)
|
126
|
-
|
127
|
-
if not isinstance(index, (int, np.integer)) or index < 0:
|
128
|
-
raise PulseError("Channel index must be a nonnegative integer")
|
129
|
-
|
130
|
-
@property
|
131
|
-
def parameters(self) -> set[Parameter]:
|
132
|
-
"""Parameters which determine the channel index."""
|
133
|
-
if isinstance(self.index, ParameterExpression):
|
134
|
-
return self.index.parameters
|
135
|
-
return set()
|
136
|
-
|
137
|
-
def is_parameterized(self) -> bool:
|
138
|
-
"""Return True iff the channel is parameterized."""
|
139
|
-
return isinstance(self.index, ParameterExpression)
|
140
|
-
|
141
|
-
@property
|
142
|
-
def name(self) -> str:
|
143
|
-
"""Return the shorthand alias for this channel, which is based on its type and index."""
|
144
|
-
return f"{self.__class__.prefix}{self._index}"
|
145
|
-
|
146
|
-
def __repr__(self):
|
147
|
-
return f"{self.__class__.__name__}({self._index})"
|
148
|
-
|
149
|
-
def __eq__(self, other: object) -> bool:
|
150
|
-
"""Return True iff self and other are equal, specifically, iff they have the same type
|
151
|
-
and the same index.
|
152
|
-
|
153
|
-
Args:
|
154
|
-
other: The channel to compare to this channel.
|
155
|
-
|
156
|
-
Returns:
|
157
|
-
True iff equal.
|
158
|
-
"""
|
159
|
-
if not isinstance(other, Channel):
|
160
|
-
return NotImplemented
|
161
|
-
return type(self) is type(other) and self._index == other._index
|
162
|
-
|
163
|
-
def __hash__(self):
|
164
|
-
return hash((type(self), self._index))
|
165
|
-
|
166
|
-
|
167
|
-
class PulseChannel(Channel, metaclass=ABCMeta):
|
168
|
-
"""Base class of transmit Channels. Pulses can be played on these channels."""
|
169
|
-
|
170
|
-
pass
|
171
|
-
|
172
|
-
|
173
|
-
class ClassicalIOChannel(Channel, metaclass=ABCMeta):
|
174
|
-
"""Base class of classical IO channels. These cannot have instructions scheduled on them."""
|
175
|
-
|
176
|
-
pass
|
177
|
-
|
178
|
-
|
179
|
-
class DriveChannel(PulseChannel):
|
180
|
-
"""Drive channels transmit signals to qubits which enact gate operations."""
|
181
|
-
|
182
|
-
prefix = "d"
|
183
|
-
|
184
|
-
|
185
|
-
class MeasureChannel(PulseChannel):
|
186
|
-
"""Measure channels transmit measurement stimulus pulses for readout."""
|
187
|
-
|
188
|
-
prefix = "m"
|
189
|
-
|
190
|
-
|
191
|
-
class ControlChannel(PulseChannel):
|
192
|
-
"""Control channels provide supplementary control over the qubit to the drive channel.
|
193
|
-
These are often associated with multi-qubit gate operations. They may not map trivially
|
194
|
-
to a particular qubit index.
|
195
|
-
"""
|
196
|
-
|
197
|
-
prefix = "u"
|
198
|
-
|
199
|
-
|
200
|
-
class AcquireChannel(Channel):
|
201
|
-
"""Acquire channels are used to collect data."""
|
202
|
-
|
203
|
-
prefix = "a"
|
204
|
-
|
205
|
-
|
206
|
-
class SnapshotChannel(ClassicalIOChannel):
|
207
|
-
"""Snapshot channels are used to specify instructions for simulators."""
|
208
|
-
|
209
|
-
prefix = "s"
|
210
|
-
|
211
|
-
def __init__(self):
|
212
|
-
"""Create new snapshot channel."""
|
213
|
-
super().__init__(0)
|
214
|
-
|
215
|
-
|
216
|
-
class MemorySlot(ClassicalIOChannel):
|
217
|
-
"""Memory slot channels represent classical memory storage."""
|
218
|
-
|
219
|
-
prefix = "m"
|
220
|
-
|
221
|
-
|
222
|
-
class RegisterSlot(ClassicalIOChannel):
|
223
|
-
"""Classical resister slot channels represent classical registers (low-latency classical
|
224
|
-
memory).
|
225
|
-
"""
|
226
|
-
|
227
|
-
prefix = "c"
|