qiskit 1.4.1__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 +11 -0
- 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/circuit/tools/pi_check.py +3 -0
- 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 +96 -116
- qiskit/qpy/binary_io/parse_sympy_repr.py +121 -0
- qiskit/qpy/binary_io/schedules.py +61 -388
- qiskit/qpy/binary_io/value.py +159 -33
- 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 -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/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 +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 +3 -2
- 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.1.dist-info → qiskit-2.0.0.dist-info}/METADATA +4 -3
- {qiskit-1.4.1.dist-info → qiskit-2.0.0.dist-info}/RECORD +303 -449
- {qiskit-1.4.1.dist-info → qiskit-2.0.0.dist-info}/WHEEL +2 -1
- {qiskit-1.4.1.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.1.dist-info → qiskit-2.0.0.dist-info/licenses}/LICENSE.txt +0 -0
- {qiskit-1.4.1.dist-info → qiskit-2.0.0.dist-info}/top_level.txt +0 -0
@@ -1,1040 +0,0 @@
|
|
1
|
-
# This code is part of Qiskit.
|
2
|
-
#
|
3
|
-
# (C) Copyright IBM 2017, 2018.
|
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
|
-
"""Backend Configuration Classes."""
|
14
|
-
import re
|
15
|
-
import copy
|
16
|
-
import numbers
|
17
|
-
from typing import Dict, List, Any, Iterable, Tuple, Union
|
18
|
-
from collections import defaultdict
|
19
|
-
|
20
|
-
from qiskit.exceptions import QiskitError
|
21
|
-
from qiskit.providers.exceptions import BackendConfigurationError
|
22
|
-
from qiskit.pulse.channels import (
|
23
|
-
AcquireChannel,
|
24
|
-
Channel,
|
25
|
-
ControlChannel,
|
26
|
-
DriveChannel,
|
27
|
-
MeasureChannel,
|
28
|
-
)
|
29
|
-
from qiskit.utils import deprecate_func
|
30
|
-
|
31
|
-
|
32
|
-
class GateConfig:
|
33
|
-
"""Class representing a Gate Configuration
|
34
|
-
|
35
|
-
Attributes:
|
36
|
-
name: the gate name as it will be referred to in OpenQASM.
|
37
|
-
parameters: variable names for the gate parameters (if any).
|
38
|
-
qasm_def: definition of this gate in terms of OpenQASM 2 primitives U
|
39
|
-
and CX.
|
40
|
-
"""
|
41
|
-
|
42
|
-
@deprecate_func(
|
43
|
-
since="1.2",
|
44
|
-
removal_timeline="in the 2.0 release",
|
45
|
-
additional_msg="The models in ``qiskit.providers.models`` are part "
|
46
|
-
"of the deprecated `BackendV1` workflow and no longer necessary for `BackendV2`. If a user "
|
47
|
-
"workflow requires these representations it likely relies on deprecated functionality and "
|
48
|
-
"should be updated to use `BackendV2`.",
|
49
|
-
stacklevel=3,
|
50
|
-
)
|
51
|
-
def __init__(
|
52
|
-
self,
|
53
|
-
name,
|
54
|
-
parameters,
|
55
|
-
qasm_def,
|
56
|
-
coupling_map=None,
|
57
|
-
latency_map=None,
|
58
|
-
conditional=None,
|
59
|
-
description=None,
|
60
|
-
):
|
61
|
-
"""Initialize a GateConfig object
|
62
|
-
|
63
|
-
Args:
|
64
|
-
name (str): the gate name as it will be referred to in OpenQASM.
|
65
|
-
parameters (list): variable names for the gate parameters (if any)
|
66
|
-
as a list of strings.
|
67
|
-
qasm_def (str): definition of this gate in terms of OpenQASM 2 primitives U and CX.
|
68
|
-
coupling_map (list): An optional coupling map for the gate. In
|
69
|
-
the form of a list of lists of integers representing the qubit
|
70
|
-
groupings which are coupled by this gate.
|
71
|
-
latency_map (list): An optional map of latency for the gate. In the
|
72
|
-
the form of a list of lists of integers of either 0 or 1
|
73
|
-
representing an array of dimension
|
74
|
-
len(coupling_map) X n_registers that specifies the register
|
75
|
-
latency (1: fast, 0: slow) conditional operations on the gate
|
76
|
-
conditional (bool): Optionally specify whether this gate supports
|
77
|
-
conditional operations (true/false). If this is not specified,
|
78
|
-
then the gate inherits the conditional property of the backend.
|
79
|
-
description (str): Description of the gate operation
|
80
|
-
"""
|
81
|
-
|
82
|
-
self.name = name
|
83
|
-
self.parameters = parameters
|
84
|
-
self.qasm_def = qasm_def
|
85
|
-
# coupling_map with length 0 is invalid
|
86
|
-
if coupling_map:
|
87
|
-
self.coupling_map = coupling_map
|
88
|
-
# latency_map with length 0 is invalid
|
89
|
-
if latency_map:
|
90
|
-
self.latency_map = latency_map
|
91
|
-
if conditional is not None:
|
92
|
-
self.conditional = conditional
|
93
|
-
if description is not None:
|
94
|
-
self.description = description
|
95
|
-
|
96
|
-
@classmethod
|
97
|
-
def from_dict(cls, data):
|
98
|
-
"""Create a new GateConfig object from a dictionary.
|
99
|
-
|
100
|
-
Args:
|
101
|
-
data (dict): A dictionary representing the GateConfig to create.
|
102
|
-
It will be in the same format as output by
|
103
|
-
:func:`to_dict`.
|
104
|
-
|
105
|
-
Returns:
|
106
|
-
GateConfig: The GateConfig from the input dictionary.
|
107
|
-
"""
|
108
|
-
return cls(**data)
|
109
|
-
|
110
|
-
def to_dict(self):
|
111
|
-
"""Return a dictionary format representation of the GateConfig.
|
112
|
-
|
113
|
-
Returns:
|
114
|
-
dict: The dictionary form of the GateConfig.
|
115
|
-
"""
|
116
|
-
out_dict = {
|
117
|
-
"name": self.name,
|
118
|
-
"parameters": self.parameters,
|
119
|
-
"qasm_def": self.qasm_def,
|
120
|
-
}
|
121
|
-
if hasattr(self, "coupling_map"):
|
122
|
-
out_dict["coupling_map"] = self.coupling_map
|
123
|
-
if hasattr(self, "latency_map"):
|
124
|
-
out_dict["latency_map"] = self.latency_map
|
125
|
-
if hasattr(self, "conditional"):
|
126
|
-
out_dict["conditional"] = self.conditional
|
127
|
-
if hasattr(self, "description"):
|
128
|
-
out_dict["description"] = self.description
|
129
|
-
return out_dict
|
130
|
-
|
131
|
-
def __eq__(self, other):
|
132
|
-
if isinstance(other, GateConfig):
|
133
|
-
if self.to_dict() == other.to_dict():
|
134
|
-
return True
|
135
|
-
return False
|
136
|
-
|
137
|
-
def __repr__(self):
|
138
|
-
out_str = f"GateConfig({self.name}, {self.parameters}, {self.qasm_def}"
|
139
|
-
for i in ["coupling_map", "latency_map", "conditional", "description"]:
|
140
|
-
if hasattr(self, i):
|
141
|
-
out_str += ", " + repr(getattr(self, i))
|
142
|
-
out_str += ")"
|
143
|
-
return out_str
|
144
|
-
|
145
|
-
|
146
|
-
class UchannelLO:
|
147
|
-
"""Class representing a U Channel LO
|
148
|
-
|
149
|
-
Attributes:
|
150
|
-
q: Qubit that scale corresponds too.
|
151
|
-
scale: Scale factor for qubit frequency.
|
152
|
-
"""
|
153
|
-
|
154
|
-
@deprecate_func(
|
155
|
-
since="1.2",
|
156
|
-
removal_timeline="in the 2.0 release",
|
157
|
-
additional_msg="The models in ``qiskit.providers.models`` are part "
|
158
|
-
"of the deprecated `BackendV1` workflow and no longer necessary for `BackendV2`. If a user "
|
159
|
-
"workflow requires these representations it likely relies on deprecated functionality and "
|
160
|
-
"should be updated to use `BackendV2`.",
|
161
|
-
)
|
162
|
-
def __init__(self, q, scale):
|
163
|
-
"""Initialize a UchannelLOSchema object
|
164
|
-
|
165
|
-
Args:
|
166
|
-
q (int): Qubit that scale corresponds too. Must be >= 0.
|
167
|
-
scale (complex): Scale factor for qubit frequency.
|
168
|
-
|
169
|
-
Raises:
|
170
|
-
QiskitError: If q is < 0
|
171
|
-
"""
|
172
|
-
if q < 0:
|
173
|
-
raise QiskitError("q must be >=0")
|
174
|
-
self.q = q
|
175
|
-
self.scale = scale
|
176
|
-
|
177
|
-
@classmethod
|
178
|
-
def from_dict(cls, data):
|
179
|
-
"""Create a new UchannelLO object from a dictionary.
|
180
|
-
|
181
|
-
Args:
|
182
|
-
data (dict): A dictionary representing the UChannelLO to
|
183
|
-
create. It will be in the same format as output by
|
184
|
-
:func:`to_dict`.
|
185
|
-
|
186
|
-
Returns:
|
187
|
-
UchannelLO: The UchannelLO from the input dictionary.
|
188
|
-
"""
|
189
|
-
return cls(**data)
|
190
|
-
|
191
|
-
def to_dict(self):
|
192
|
-
"""Return a dictionary format representation of the UChannelLO.
|
193
|
-
|
194
|
-
Returns:
|
195
|
-
dict: The dictionary form of the UChannelLO.
|
196
|
-
"""
|
197
|
-
out_dict = {
|
198
|
-
"q": self.q,
|
199
|
-
"scale": self.scale,
|
200
|
-
}
|
201
|
-
return out_dict
|
202
|
-
|
203
|
-
def __eq__(self, other):
|
204
|
-
if isinstance(other, UchannelLO):
|
205
|
-
if self.to_dict() == other.to_dict():
|
206
|
-
return True
|
207
|
-
return False
|
208
|
-
|
209
|
-
def __repr__(self):
|
210
|
-
return f"UchannelLO({self.q}, {self.scale})"
|
211
|
-
|
212
|
-
|
213
|
-
class QasmBackendConfiguration:
|
214
|
-
"""Class representing an OpenQASM 2.0 Backend Configuration.
|
215
|
-
|
216
|
-
Attributes:
|
217
|
-
backend_name: backend name.
|
218
|
-
backend_version: backend version in the form X.Y.Z.
|
219
|
-
n_qubits: number of qubits.
|
220
|
-
basis_gates: list of basis gates names on the backend.
|
221
|
-
gates: list of basis gates on the backend.
|
222
|
-
local: backend is local or remote.
|
223
|
-
simulator: backend is a simulator.
|
224
|
-
conditional: backend supports conditional operations.
|
225
|
-
open_pulse: backend supports open pulse.
|
226
|
-
memory: backend supports memory.
|
227
|
-
max_shots: maximum number of shots supported.
|
228
|
-
"""
|
229
|
-
|
230
|
-
_data = {}
|
231
|
-
|
232
|
-
@deprecate_func(
|
233
|
-
since="1.2",
|
234
|
-
removal_timeline="in the 2.0 release",
|
235
|
-
additional_msg="The models in ``qiskit.providers.models`` are part "
|
236
|
-
"of the deprecated `BackendV1` workflow and no longer necessary for `BackendV2`. If a user "
|
237
|
-
"workflow requires these representations it likely relies on deprecated functionality and "
|
238
|
-
"should be updated to use `BackendV2`.",
|
239
|
-
stacklevel=3,
|
240
|
-
)
|
241
|
-
def __init__(
|
242
|
-
self,
|
243
|
-
backend_name,
|
244
|
-
backend_version,
|
245
|
-
n_qubits,
|
246
|
-
basis_gates,
|
247
|
-
gates,
|
248
|
-
local,
|
249
|
-
simulator,
|
250
|
-
conditional,
|
251
|
-
open_pulse,
|
252
|
-
memory,
|
253
|
-
max_shots,
|
254
|
-
coupling_map,
|
255
|
-
supported_instructions=None,
|
256
|
-
dynamic_reprate_enabled=False,
|
257
|
-
rep_delay_range=None,
|
258
|
-
default_rep_delay=None,
|
259
|
-
max_experiments=None,
|
260
|
-
sample_name=None,
|
261
|
-
n_registers=None,
|
262
|
-
register_map=None,
|
263
|
-
configurable=None,
|
264
|
-
credits_required=None,
|
265
|
-
online_date=None,
|
266
|
-
display_name=None,
|
267
|
-
description=None,
|
268
|
-
tags=None,
|
269
|
-
dt=None,
|
270
|
-
dtm=None,
|
271
|
-
processor_type=None,
|
272
|
-
parametric_pulses=None,
|
273
|
-
**kwargs,
|
274
|
-
):
|
275
|
-
"""Initialize a QasmBackendConfiguration Object
|
276
|
-
|
277
|
-
Args:
|
278
|
-
backend_name (str): The backend name
|
279
|
-
backend_version (str): The backend version in the form X.Y.Z
|
280
|
-
n_qubits (int): the number of qubits for the backend
|
281
|
-
basis_gates (list): The list of strings for the basis gates of the
|
282
|
-
backends
|
283
|
-
gates (list): The list of GateConfig objects for the basis gates of
|
284
|
-
the backend
|
285
|
-
local (bool): True if the backend is local or False if remote
|
286
|
-
simulator (bool): True if the backend is a simulator
|
287
|
-
conditional (bool): True if the backend supports conditional
|
288
|
-
operations
|
289
|
-
open_pulse (bool): True if the backend supports OpenPulse
|
290
|
-
memory (bool): True if the backend supports memory
|
291
|
-
max_shots (int): The maximum number of shots allowed on the backend
|
292
|
-
coupling_map (list): The coupling map for the device
|
293
|
-
supported_instructions (List[str]): Instructions supported by the backend.
|
294
|
-
dynamic_reprate_enabled (bool): whether delay between programs can be set dynamically
|
295
|
-
(ie via ``rep_delay``). Defaults to False.
|
296
|
-
rep_delay_range (List[float]): 2d list defining supported range of repetition
|
297
|
-
delays for backend in μs. First entry is lower end of the range, second entry is
|
298
|
-
higher end of the range. Optional, but will be specified when
|
299
|
-
``dynamic_reprate_enabled=True``.
|
300
|
-
default_rep_delay (float): Value of ``rep_delay`` if not specified by user and
|
301
|
-
``dynamic_reprate_enabled=True``.
|
302
|
-
max_experiments (int): The maximum number of experiments per job
|
303
|
-
sample_name (str): Sample name for the backend
|
304
|
-
n_registers (int): Number of register slots available for feedback
|
305
|
-
(if conditional is True)
|
306
|
-
register_map (list): An array of dimension n_qubits X
|
307
|
-
n_registers that specifies whether a qubit can store a
|
308
|
-
measurement in a certain register slot.
|
309
|
-
configurable (bool): True if the backend is configurable, if the
|
310
|
-
backend is a simulator
|
311
|
-
credits_required (bool): True if backend requires credits to run a
|
312
|
-
job.
|
313
|
-
online_date (datetime.datetime): The date that the device went online
|
314
|
-
display_name (str): Alternate name field for the backend
|
315
|
-
description (str): A description for the backend
|
316
|
-
tags (list): A list of string tags to describe the backend
|
317
|
-
dt (float): Qubit drive channel timestep in nanoseconds.
|
318
|
-
dtm (float): Measurement drive channel timestep in nanoseconds.
|
319
|
-
processor_type (dict): Processor type for this backend. A dictionary of the
|
320
|
-
form ``{"family": <str>, "revision": <str>, segment: <str>}`` such as
|
321
|
-
``{"family": "Canary", "revision": "1.0", segment: "A"}``.
|
322
|
-
|
323
|
-
- family: Processor family of this backend.
|
324
|
-
- revision: Revision version of this processor.
|
325
|
-
- segment: Segment this processor belongs to within a larger chip.
|
326
|
-
parametric_pulses (list): A list of pulse shapes which are supported on the backend.
|
327
|
-
For example: ``['gaussian', 'constant']``
|
328
|
-
|
329
|
-
**kwargs: optional fields
|
330
|
-
"""
|
331
|
-
self._data = {}
|
332
|
-
|
333
|
-
self.backend_name = backend_name
|
334
|
-
self.backend_version = backend_version
|
335
|
-
self.n_qubits = n_qubits
|
336
|
-
self.basis_gates = basis_gates
|
337
|
-
self.gates = gates
|
338
|
-
self.local = local
|
339
|
-
self.simulator = simulator
|
340
|
-
self.conditional = conditional
|
341
|
-
self.open_pulse = open_pulse
|
342
|
-
self.memory = memory
|
343
|
-
self.max_shots = max_shots
|
344
|
-
self.coupling_map = coupling_map
|
345
|
-
if supported_instructions:
|
346
|
-
self.supported_instructions = supported_instructions
|
347
|
-
|
348
|
-
self.dynamic_reprate_enabled = dynamic_reprate_enabled
|
349
|
-
if rep_delay_range:
|
350
|
-
self.rep_delay_range = [_rd * 1e-6 for _rd in rep_delay_range] # convert to sec
|
351
|
-
if default_rep_delay is not None:
|
352
|
-
self.default_rep_delay = default_rep_delay * 1e-6 # convert to sec
|
353
|
-
|
354
|
-
# max_experiments must be >=1
|
355
|
-
if max_experiments:
|
356
|
-
self.max_experiments = max_experiments
|
357
|
-
if sample_name is not None:
|
358
|
-
self.sample_name = sample_name
|
359
|
-
# n_registers must be >=1
|
360
|
-
if n_registers:
|
361
|
-
self.n_registers = 1
|
362
|
-
# register_map must have at least 1 entry
|
363
|
-
if register_map:
|
364
|
-
self.register_map = register_map
|
365
|
-
if configurable is not None:
|
366
|
-
self.configurable = configurable
|
367
|
-
if credits_required is not None:
|
368
|
-
self.credits_required = credits_required
|
369
|
-
if online_date is not None:
|
370
|
-
self.online_date = online_date
|
371
|
-
if display_name is not None:
|
372
|
-
self.display_name = display_name
|
373
|
-
if description is not None:
|
374
|
-
self.description = description
|
375
|
-
if tags is not None:
|
376
|
-
self.tags = tags
|
377
|
-
# Add pulse properties here because some backends do not
|
378
|
-
# fit within the Qasm / Pulse backend partitioning in Qiskit
|
379
|
-
if dt is not None:
|
380
|
-
self.dt = dt * 1e-9
|
381
|
-
if dtm is not None:
|
382
|
-
self.dtm = dtm * 1e-9
|
383
|
-
if processor_type is not None:
|
384
|
-
self.processor_type = processor_type
|
385
|
-
if parametric_pulses is not None:
|
386
|
-
self.parametric_pulses = parametric_pulses
|
387
|
-
|
388
|
-
# convert lo range from GHz to Hz
|
389
|
-
if "qubit_lo_range" in kwargs:
|
390
|
-
kwargs["qubit_lo_range"] = [
|
391
|
-
[min_range * 1e9, max_range * 1e9]
|
392
|
-
for (min_range, max_range) in kwargs["qubit_lo_range"]
|
393
|
-
]
|
394
|
-
|
395
|
-
if "meas_lo_range" in kwargs:
|
396
|
-
kwargs["meas_lo_range"] = [
|
397
|
-
[min_range * 1e9, max_range * 1e9]
|
398
|
-
for (min_range, max_range) in kwargs["meas_lo_range"]
|
399
|
-
]
|
400
|
-
|
401
|
-
# convert rep_times from μs to sec
|
402
|
-
if "rep_times" in kwargs:
|
403
|
-
kwargs["rep_times"] = [_rt * 1e-6 for _rt in kwargs["rep_times"]]
|
404
|
-
|
405
|
-
self._data.update(kwargs)
|
406
|
-
|
407
|
-
def __getattr__(self, name):
|
408
|
-
try:
|
409
|
-
return self._data[name]
|
410
|
-
except KeyError as ex:
|
411
|
-
raise AttributeError(f"Attribute {name} is not defined") from ex
|
412
|
-
|
413
|
-
@classmethod
|
414
|
-
def from_dict(cls, data):
|
415
|
-
"""Create a new GateConfig object from a dictionary.
|
416
|
-
|
417
|
-
Args:
|
418
|
-
data (dict): A dictionary representing the GateConfig to create.
|
419
|
-
It will be in the same format as output by
|
420
|
-
:func:`to_dict`.
|
421
|
-
Returns:
|
422
|
-
GateConfig: The GateConfig from the input dictionary.
|
423
|
-
"""
|
424
|
-
in_data = copy.copy(data)
|
425
|
-
gates = [GateConfig.from_dict(x) for x in in_data.pop("gates")]
|
426
|
-
in_data["gates"] = gates
|
427
|
-
return cls(**in_data)
|
428
|
-
|
429
|
-
def to_dict(self):
|
430
|
-
"""Return a dictionary format representation of the GateConfig.
|
431
|
-
|
432
|
-
Returns:
|
433
|
-
dict: The dictionary form of the GateConfig.
|
434
|
-
"""
|
435
|
-
out_dict = {
|
436
|
-
"backend_name": self.backend_name,
|
437
|
-
"backend_version": self.backend_version,
|
438
|
-
"n_qubits": self.n_qubits,
|
439
|
-
"basis_gates": self.basis_gates,
|
440
|
-
"gates": [x.to_dict() for x in self.gates],
|
441
|
-
"local": self.local,
|
442
|
-
"simulator": self.simulator,
|
443
|
-
"conditional": self.conditional,
|
444
|
-
"open_pulse": self.open_pulse,
|
445
|
-
"memory": self.memory,
|
446
|
-
"max_shots": self.max_shots,
|
447
|
-
"coupling_map": self.coupling_map,
|
448
|
-
"dynamic_reprate_enabled": self.dynamic_reprate_enabled,
|
449
|
-
}
|
450
|
-
|
451
|
-
if hasattr(self, "supported_instructions"):
|
452
|
-
out_dict["supported_instructions"] = self.supported_instructions
|
453
|
-
|
454
|
-
if hasattr(self, "rep_delay_range"):
|
455
|
-
out_dict["rep_delay_range"] = [_rd * 1e6 for _rd in self.rep_delay_range]
|
456
|
-
if hasattr(self, "default_rep_delay"):
|
457
|
-
out_dict["default_rep_delay"] = self.default_rep_delay * 1e6
|
458
|
-
|
459
|
-
for kwarg in [
|
460
|
-
"max_experiments",
|
461
|
-
"sample_name",
|
462
|
-
"n_registers",
|
463
|
-
"register_map",
|
464
|
-
"configurable",
|
465
|
-
"credits_required",
|
466
|
-
"online_date",
|
467
|
-
"display_name",
|
468
|
-
"description",
|
469
|
-
"tags",
|
470
|
-
"dt",
|
471
|
-
"dtm",
|
472
|
-
"processor_type",
|
473
|
-
"parametric_pulses",
|
474
|
-
]:
|
475
|
-
if hasattr(self, kwarg):
|
476
|
-
out_dict[kwarg] = getattr(self, kwarg)
|
477
|
-
|
478
|
-
out_dict.update(self._data)
|
479
|
-
|
480
|
-
if "dt" in out_dict:
|
481
|
-
out_dict["dt"] *= 1e9
|
482
|
-
if "dtm" in out_dict:
|
483
|
-
out_dict["dtm"] *= 1e9
|
484
|
-
|
485
|
-
# Use GHz in dict
|
486
|
-
if "qubit_lo_range" in out_dict:
|
487
|
-
out_dict["qubit_lo_range"] = [
|
488
|
-
[min_range * 1e-9, max_range * 1e-9]
|
489
|
-
for (min_range, max_range) in out_dict["qubit_lo_range"]
|
490
|
-
]
|
491
|
-
|
492
|
-
if "meas_lo_range" in out_dict:
|
493
|
-
out_dict["meas_lo_range"] = [
|
494
|
-
[min_range * 1e-9, max_range * 1e-9]
|
495
|
-
for (min_range, max_range) in out_dict["meas_lo_range"]
|
496
|
-
]
|
497
|
-
|
498
|
-
return out_dict
|
499
|
-
|
500
|
-
@property
|
501
|
-
def num_qubits(self):
|
502
|
-
"""Returns the number of qubits.
|
503
|
-
|
504
|
-
In future, `n_qubits` should be replaced in favor of `num_qubits` for consistent use
|
505
|
-
throughout Qiskit. Until this is properly refactored, this property serves as intermediate
|
506
|
-
solution.
|
507
|
-
"""
|
508
|
-
return self.n_qubits
|
509
|
-
|
510
|
-
def __eq__(self, other):
|
511
|
-
if isinstance(other, QasmBackendConfiguration):
|
512
|
-
if self.to_dict() == other.to_dict():
|
513
|
-
return True
|
514
|
-
return False
|
515
|
-
|
516
|
-
def __contains__(self, item):
|
517
|
-
return item in self.__dict__
|
518
|
-
|
519
|
-
|
520
|
-
class BackendConfiguration(QasmBackendConfiguration):
|
521
|
-
"""Backwards compatibility shim representing an abstract backend configuration."""
|
522
|
-
|
523
|
-
@deprecate_func(
|
524
|
-
since="1.2",
|
525
|
-
removal_timeline="in the 2.0 release",
|
526
|
-
additional_msg="The models in ``qiskit.providers.models`` are part "
|
527
|
-
"of the deprecated `BackendV1` workflow and no longer necessary for `BackendV2`. If a user "
|
528
|
-
"workflow requires these representations it likely relies on deprecated functionality and "
|
529
|
-
"should be updated to use `BackendV2`.",
|
530
|
-
stacklevel=3,
|
531
|
-
)
|
532
|
-
def __init__(self, *args, **kwargs):
|
533
|
-
super().__init__(*args, **kwargs)
|
534
|
-
|
535
|
-
|
536
|
-
class PulseBackendConfiguration(QasmBackendConfiguration):
|
537
|
-
"""Static configuration state for an OpenPulse enabled backend. This contains information
|
538
|
-
about the set up of the device which can be useful for building Pulse programs.
|
539
|
-
"""
|
540
|
-
|
541
|
-
@deprecate_func(
|
542
|
-
since="1.2",
|
543
|
-
removal_timeline="in the 2.0 release",
|
544
|
-
additional_msg="The models in ``qiskit.providers.models`` are part "
|
545
|
-
"of the deprecated `BackendV1` workflow and no longer necessary for `BackendV2`. If a user "
|
546
|
-
"workflow requires these representations it likely relies on deprecated functionality and "
|
547
|
-
"should be updated to use `BackendV2`.",
|
548
|
-
stacklevel=3,
|
549
|
-
)
|
550
|
-
def __init__(
|
551
|
-
self,
|
552
|
-
backend_name: str,
|
553
|
-
backend_version: str,
|
554
|
-
n_qubits: int,
|
555
|
-
basis_gates: List[str],
|
556
|
-
gates: GateConfig,
|
557
|
-
local: bool,
|
558
|
-
simulator: bool,
|
559
|
-
conditional: bool,
|
560
|
-
open_pulse: bool,
|
561
|
-
memory: bool,
|
562
|
-
max_shots: int,
|
563
|
-
coupling_map,
|
564
|
-
n_uchannels: int,
|
565
|
-
u_channel_lo: List[List[UchannelLO]],
|
566
|
-
meas_levels: List[int],
|
567
|
-
qubit_lo_range: List[List[float]],
|
568
|
-
meas_lo_range: List[List[float]],
|
569
|
-
dt: float,
|
570
|
-
dtm: float,
|
571
|
-
rep_times: List[float],
|
572
|
-
meas_kernels: List[str],
|
573
|
-
discriminators: List[str],
|
574
|
-
hamiltonian: Dict[str, Any] = None,
|
575
|
-
channel_bandwidth=None,
|
576
|
-
acquisition_latency=None,
|
577
|
-
conditional_latency=None,
|
578
|
-
meas_map=None,
|
579
|
-
max_experiments=None,
|
580
|
-
sample_name=None,
|
581
|
-
n_registers=None,
|
582
|
-
register_map=None,
|
583
|
-
configurable=None,
|
584
|
-
credits_required=None,
|
585
|
-
online_date=None,
|
586
|
-
display_name=None,
|
587
|
-
description=None,
|
588
|
-
tags=None,
|
589
|
-
channels: Dict[str, Any] = None,
|
590
|
-
**kwargs,
|
591
|
-
):
|
592
|
-
"""
|
593
|
-
Initialize a backend configuration that contains all the extra configuration that is made
|
594
|
-
available for OpenPulse backends.
|
595
|
-
|
596
|
-
Args:
|
597
|
-
backend_name: backend name.
|
598
|
-
backend_version: backend version in the form X.Y.Z.
|
599
|
-
n_qubits: number of qubits.
|
600
|
-
basis_gates: list of basis gates names on the backend.
|
601
|
-
gates: list of basis gates on the backend.
|
602
|
-
local: backend is local or remote.
|
603
|
-
simulator: backend is a simulator.
|
604
|
-
conditional: backend supports conditional operations.
|
605
|
-
open_pulse: backend supports open pulse.
|
606
|
-
memory: backend supports memory.
|
607
|
-
max_shots: maximum number of shots supported.
|
608
|
-
coupling_map (list): The coupling map for the device
|
609
|
-
n_uchannels: Number of u-channels.
|
610
|
-
u_channel_lo: U-channel relationship on device los.
|
611
|
-
meas_levels: Supported measurement levels.
|
612
|
-
qubit_lo_range: Qubit lo ranges for each qubit with form (min, max) in GHz.
|
613
|
-
meas_lo_range: Measurement lo ranges for each qubit with form (min, max) in GHz.
|
614
|
-
dt: Qubit drive channel timestep in nanoseconds.
|
615
|
-
dtm: Measurement drive channel timestep in nanoseconds.
|
616
|
-
rep_times: Supported repetition times (program execution time) for backend in μs.
|
617
|
-
meas_kernels: Supported measurement kernels.
|
618
|
-
discriminators: Supported discriminators.
|
619
|
-
hamiltonian: An optional dictionary with fields characterizing the system hamiltonian.
|
620
|
-
channel_bandwidth (list): Bandwidth of all channels
|
621
|
-
(qubit, measurement, and U)
|
622
|
-
acquisition_latency (list): Array of dimension
|
623
|
-
n_qubits x n_registers. Latency (in units of dt) to write a
|
624
|
-
measurement result from qubit n into register slot m.
|
625
|
-
conditional_latency (list): Array of dimension n_channels
|
626
|
-
[d->u->m] x n_registers. Latency (in units of dt) to do a
|
627
|
-
conditional operation on channel n from register slot m
|
628
|
-
meas_map (list): Grouping of measurement which are multiplexed
|
629
|
-
max_experiments (int): The maximum number of experiments per job
|
630
|
-
sample_name (str): Sample name for the backend
|
631
|
-
n_registers (int): Number of register slots available for feedback
|
632
|
-
(if conditional is True)
|
633
|
-
register_map (list): An array of dimension n_qubits X
|
634
|
-
n_registers that specifies whether a qubit can store a
|
635
|
-
measurement in a certain register slot.
|
636
|
-
configurable (bool): True if the backend is configurable, if the
|
637
|
-
backend is a simulator
|
638
|
-
credits_required (bool): True if backend requires credits to run a
|
639
|
-
job.
|
640
|
-
online_date (datetime.datetime): The date that the device went online
|
641
|
-
display_name (str): Alternate name field for the backend
|
642
|
-
description (str): A description for the backend
|
643
|
-
tags (list): A list of string tags to describe the backend
|
644
|
-
channels: An optional dictionary containing information of each channel -- their
|
645
|
-
purpose, type, and qubits operated on.
|
646
|
-
**kwargs: Optional fields.
|
647
|
-
"""
|
648
|
-
self.n_uchannels = n_uchannels
|
649
|
-
self.u_channel_lo = u_channel_lo
|
650
|
-
self.meas_levels = meas_levels
|
651
|
-
|
652
|
-
# convert from GHz to Hz
|
653
|
-
self.qubit_lo_range = [
|
654
|
-
[min_range * 1e9, max_range * 1e9] for (min_range, max_range) in qubit_lo_range
|
655
|
-
]
|
656
|
-
self.meas_lo_range = [
|
657
|
-
[min_range * 1e9, max_range * 1e9] for (min_range, max_range) in meas_lo_range
|
658
|
-
]
|
659
|
-
|
660
|
-
self.meas_kernels = meas_kernels
|
661
|
-
self.discriminators = discriminators
|
662
|
-
self.hamiltonian = hamiltonian
|
663
|
-
if hamiltonian is not None:
|
664
|
-
self.hamiltonian = dict(hamiltonian)
|
665
|
-
self.hamiltonian["vars"] = {
|
666
|
-
k: v * 1e9 if isinstance(v, numbers.Number) else v
|
667
|
-
for k, v in self.hamiltonian["vars"].items()
|
668
|
-
}
|
669
|
-
|
670
|
-
self.rep_times = [_rt * 1e-6 for _rt in rep_times] # convert to sec
|
671
|
-
|
672
|
-
self.dt = dt * 1e-9
|
673
|
-
self.dtm = dtm * 1e-9
|
674
|
-
|
675
|
-
if channels is not None:
|
676
|
-
self.channels = channels
|
677
|
-
|
678
|
-
(
|
679
|
-
self._qubit_channel_map,
|
680
|
-
self._channel_qubit_map,
|
681
|
-
self._control_channels,
|
682
|
-
) = self._parse_channels(channels=channels)
|
683
|
-
else:
|
684
|
-
self._control_channels = defaultdict(list)
|
685
|
-
|
686
|
-
if channel_bandwidth is not None:
|
687
|
-
self.channel_bandwidth = [
|
688
|
-
[min_range * 1e9, max_range * 1e9] for (min_range, max_range) in channel_bandwidth
|
689
|
-
]
|
690
|
-
if acquisition_latency is not None:
|
691
|
-
self.acquisition_latency = acquisition_latency
|
692
|
-
if conditional_latency is not None:
|
693
|
-
self.conditional_latency = conditional_latency
|
694
|
-
if meas_map is not None:
|
695
|
-
self.meas_map = meas_map
|
696
|
-
super().__init__(
|
697
|
-
backend_name=backend_name,
|
698
|
-
backend_version=backend_version,
|
699
|
-
n_qubits=n_qubits,
|
700
|
-
basis_gates=basis_gates,
|
701
|
-
gates=gates,
|
702
|
-
local=local,
|
703
|
-
simulator=simulator,
|
704
|
-
conditional=conditional,
|
705
|
-
open_pulse=open_pulse,
|
706
|
-
memory=memory,
|
707
|
-
max_shots=max_shots,
|
708
|
-
coupling_map=coupling_map,
|
709
|
-
max_experiments=max_experiments,
|
710
|
-
sample_name=sample_name,
|
711
|
-
n_registers=n_registers,
|
712
|
-
register_map=register_map,
|
713
|
-
configurable=configurable,
|
714
|
-
credits_required=credits_required,
|
715
|
-
online_date=online_date,
|
716
|
-
display_name=display_name,
|
717
|
-
description=description,
|
718
|
-
tags=tags,
|
719
|
-
**kwargs,
|
720
|
-
)
|
721
|
-
|
722
|
-
@classmethod
|
723
|
-
def from_dict(cls, data):
|
724
|
-
"""Create a new GateConfig object from a dictionary.
|
725
|
-
|
726
|
-
Args:
|
727
|
-
data (dict): A dictionary representing the GateConfig to create.
|
728
|
-
It will be in the same format as output by :func:`to_dict`.
|
729
|
-
|
730
|
-
Returns:
|
731
|
-
GateConfig: The GateConfig from the input dictionary.
|
732
|
-
"""
|
733
|
-
in_data = copy.copy(data)
|
734
|
-
gates = [GateConfig.from_dict(x) for x in in_data.pop("gates")]
|
735
|
-
in_data["gates"] = gates
|
736
|
-
input_uchannels = in_data.pop("u_channel_lo")
|
737
|
-
u_channels = []
|
738
|
-
for channel in input_uchannels:
|
739
|
-
u_channels.append([UchannelLO.from_dict(x) for x in channel])
|
740
|
-
in_data["u_channel_lo"] = u_channels
|
741
|
-
return cls(**in_data)
|
742
|
-
|
743
|
-
def to_dict(self):
|
744
|
-
"""Return a dictionary format representation of the GateConfig.
|
745
|
-
|
746
|
-
Returns:
|
747
|
-
dict: The dictionary form of the GateConfig.
|
748
|
-
"""
|
749
|
-
out_dict = super().to_dict()
|
750
|
-
u_channel_lo = []
|
751
|
-
for x in self.u_channel_lo:
|
752
|
-
channel = []
|
753
|
-
for y in x:
|
754
|
-
channel.append(y.to_dict())
|
755
|
-
u_channel_lo.append(channel)
|
756
|
-
out_dict.update(
|
757
|
-
{
|
758
|
-
"n_uchannels": self.n_uchannels,
|
759
|
-
"u_channel_lo": u_channel_lo,
|
760
|
-
"meas_levels": self.meas_levels,
|
761
|
-
"qubit_lo_range": self.qubit_lo_range,
|
762
|
-
"meas_lo_range": self.meas_lo_range,
|
763
|
-
"meas_kernels": self.meas_kernels,
|
764
|
-
"discriminators": self.discriminators,
|
765
|
-
"rep_times": self.rep_times,
|
766
|
-
"dt": self.dt,
|
767
|
-
"dtm": self.dtm,
|
768
|
-
}
|
769
|
-
)
|
770
|
-
|
771
|
-
if hasattr(self, "channel_bandwidth"):
|
772
|
-
out_dict["channel_bandwidth"] = self.channel_bandwidth
|
773
|
-
if hasattr(self, "meas_map"):
|
774
|
-
out_dict["meas_map"] = self.meas_map
|
775
|
-
if hasattr(self, "acquisition_latency"):
|
776
|
-
out_dict["acquisition_latency"] = self.acquisition_latency
|
777
|
-
if hasattr(self, "conditional_latency"):
|
778
|
-
out_dict["conditional_latency"] = self.conditional_latency
|
779
|
-
if "channels" in out_dict:
|
780
|
-
out_dict.pop("_qubit_channel_map")
|
781
|
-
out_dict.pop("_channel_qubit_map")
|
782
|
-
out_dict.pop("_control_channels")
|
783
|
-
|
784
|
-
# Use GHz in dict
|
785
|
-
if self.qubit_lo_range:
|
786
|
-
out_dict["qubit_lo_range"] = [
|
787
|
-
[min_range * 1e-9, max_range * 1e-9]
|
788
|
-
for (min_range, max_range) in self.qubit_lo_range
|
789
|
-
]
|
790
|
-
|
791
|
-
if self.meas_lo_range:
|
792
|
-
out_dict["meas_lo_range"] = [
|
793
|
-
[min_range * 1e-9, max_range * 1e-9]
|
794
|
-
for (min_range, max_range) in self.meas_lo_range
|
795
|
-
]
|
796
|
-
|
797
|
-
if self.rep_times:
|
798
|
-
out_dict["rep_times"] = [_rt * 1e6 for _rt in self.rep_times]
|
799
|
-
|
800
|
-
out_dict["dt"] *= 1e9
|
801
|
-
out_dict["dtm"] *= 1e9
|
802
|
-
|
803
|
-
if hasattr(self, "channel_bandwidth"):
|
804
|
-
out_dict["channel_bandwidth"] = [
|
805
|
-
[min_range * 1e-9, max_range * 1e-9]
|
806
|
-
for (min_range, max_range) in self.channel_bandwidth
|
807
|
-
]
|
808
|
-
|
809
|
-
if self.hamiltonian:
|
810
|
-
hamiltonian = copy.deepcopy(self.hamiltonian)
|
811
|
-
hamiltonian["vars"] = {
|
812
|
-
k: v * 1e-9 if isinstance(v, numbers.Number) else v
|
813
|
-
for k, v in hamiltonian["vars"].items()
|
814
|
-
}
|
815
|
-
out_dict["hamiltonian"] = hamiltonian
|
816
|
-
|
817
|
-
if hasattr(self, "channels"):
|
818
|
-
out_dict["channels"] = self.channels
|
819
|
-
|
820
|
-
return out_dict
|
821
|
-
|
822
|
-
def __eq__(self, other):
|
823
|
-
if isinstance(other, QasmBackendConfiguration):
|
824
|
-
if self.to_dict() == other.to_dict():
|
825
|
-
return True
|
826
|
-
return False
|
827
|
-
|
828
|
-
@property
|
829
|
-
def sample_rate(self) -> float:
|
830
|
-
"""Sample rate of the signal channels in Hz (1/dt)."""
|
831
|
-
return 1.0 / self.dt
|
832
|
-
|
833
|
-
@property
|
834
|
-
def control_channels(self) -> Dict[Tuple[int, ...], List]:
|
835
|
-
"""Return the control channels"""
|
836
|
-
return self._control_channels
|
837
|
-
|
838
|
-
def drive(self, qubit: int) -> DriveChannel:
|
839
|
-
"""
|
840
|
-
Return the drive channel for the given qubit.
|
841
|
-
|
842
|
-
Raises:
|
843
|
-
BackendConfigurationError: If the qubit is not a part of the system.
|
844
|
-
|
845
|
-
Returns:
|
846
|
-
Qubit drive channel.
|
847
|
-
"""
|
848
|
-
if not 0 <= qubit < self.n_qubits:
|
849
|
-
raise BackendConfigurationError(f"Invalid index for {qubit}-qubit system.")
|
850
|
-
return DriveChannel(qubit)
|
851
|
-
|
852
|
-
def measure(self, qubit: int) -> MeasureChannel:
|
853
|
-
"""
|
854
|
-
Return the measure stimulus channel for the given qubit.
|
855
|
-
|
856
|
-
Raises:
|
857
|
-
BackendConfigurationError: If the qubit is not a part of the system.
|
858
|
-
Returns:
|
859
|
-
Qubit measurement stimulus line.
|
860
|
-
"""
|
861
|
-
if not 0 <= qubit < self.n_qubits:
|
862
|
-
raise BackendConfigurationError(f"Invalid index for {qubit}-qubit system.")
|
863
|
-
return MeasureChannel(qubit)
|
864
|
-
|
865
|
-
def acquire(self, qubit: int) -> AcquireChannel:
|
866
|
-
"""
|
867
|
-
Return the acquisition channel for the given qubit.
|
868
|
-
|
869
|
-
Raises:
|
870
|
-
BackendConfigurationError: If the qubit is not a part of the system.
|
871
|
-
Returns:
|
872
|
-
Qubit measurement acquisition line.
|
873
|
-
"""
|
874
|
-
if not 0 <= qubit < self.n_qubits:
|
875
|
-
raise BackendConfigurationError(f"Invalid index for {qubit}-qubit systems.")
|
876
|
-
return AcquireChannel(qubit)
|
877
|
-
|
878
|
-
def control(self, qubits: Iterable[int] = None) -> List[ControlChannel]:
|
879
|
-
"""
|
880
|
-
Return the secondary drive channel for the given qubit -- typically utilized for
|
881
|
-
controlling multiqubit interactions. This channel is derived from other channels.
|
882
|
-
|
883
|
-
Args:
|
884
|
-
qubits: Tuple or list of qubits of the form `(control_qubit, target_qubit)`.
|
885
|
-
|
886
|
-
Raises:
|
887
|
-
BackendConfigurationError: If the ``qubits`` is not a part of the system or if
|
888
|
-
the backend does not provide `channels` information in its configuration.
|
889
|
-
|
890
|
-
Returns:
|
891
|
-
List of control channels.
|
892
|
-
"""
|
893
|
-
try:
|
894
|
-
if isinstance(qubits, list):
|
895
|
-
qubits = tuple(qubits)
|
896
|
-
return self._control_channels[qubits]
|
897
|
-
except KeyError as ex:
|
898
|
-
raise BackendConfigurationError(
|
899
|
-
f"Couldn't find the ControlChannel operating on qubits {qubits} on "
|
900
|
-
f"{self.n_qubits}-qubit system. The ControlChannel information is retrieved "
|
901
|
-
"from the backend."
|
902
|
-
) from ex
|
903
|
-
except AttributeError as ex:
|
904
|
-
raise BackendConfigurationError(
|
905
|
-
f"This backend - '{self.backend_name}' does not provide channel information."
|
906
|
-
) from ex
|
907
|
-
|
908
|
-
def get_channel_qubits(self, channel: Channel) -> List[int]:
|
909
|
-
"""
|
910
|
-
Return a list of indices for qubits which are operated on directly by the given ``channel``.
|
911
|
-
|
912
|
-
Raises:
|
913
|
-
BackendConfigurationError: If ``channel`` is not a found or if
|
914
|
-
the backend does not provide `channels` information in its configuration.
|
915
|
-
|
916
|
-
Returns:
|
917
|
-
List of qubits operated on my the given ``channel``.
|
918
|
-
"""
|
919
|
-
try:
|
920
|
-
return self._channel_qubit_map[channel]
|
921
|
-
except KeyError as ex:
|
922
|
-
raise BackendConfigurationError(f"Couldn't find the Channel - {channel}") from ex
|
923
|
-
except AttributeError as ex:
|
924
|
-
raise BackendConfigurationError(
|
925
|
-
f"This backend - '{self.backend_name}' does not provide channel information."
|
926
|
-
) from ex
|
927
|
-
|
928
|
-
def get_qubit_channels(self, qubit: Union[int, Iterable[int]]) -> List[Channel]:
|
929
|
-
r"""Return a list of channels which operate on the given ``qubit``.
|
930
|
-
|
931
|
-
Raises:
|
932
|
-
BackendConfigurationError: If ``qubit`` is not a found or if
|
933
|
-
the backend does not provide `channels` information in its configuration.
|
934
|
-
|
935
|
-
Returns:
|
936
|
-
List of ``Channel``\s operated on my the given ``qubit``.
|
937
|
-
"""
|
938
|
-
channels = set()
|
939
|
-
try:
|
940
|
-
if isinstance(qubit, int):
|
941
|
-
for key, value in self._qubit_channel_map.items():
|
942
|
-
if qubit in key:
|
943
|
-
channels.update(value)
|
944
|
-
if len(channels) == 0:
|
945
|
-
raise KeyError
|
946
|
-
elif isinstance(qubit, list):
|
947
|
-
qubit = tuple(qubit)
|
948
|
-
channels.update(self._qubit_channel_map[qubit])
|
949
|
-
elif isinstance(qubit, tuple):
|
950
|
-
channels.update(self._qubit_channel_map[qubit])
|
951
|
-
return list(channels)
|
952
|
-
except KeyError as ex:
|
953
|
-
raise BackendConfigurationError(f"Couldn't find the qubit - {qubit}") from ex
|
954
|
-
except AttributeError as ex:
|
955
|
-
raise BackendConfigurationError(
|
956
|
-
f"This backend - '{self.backend_name}' does not provide channel information."
|
957
|
-
) from ex
|
958
|
-
|
959
|
-
def describe(self, channel: ControlChannel) -> Dict[DriveChannel, complex]:
|
960
|
-
"""
|
961
|
-
Return a basic description of the channel dependency. Derived channels are given weights
|
962
|
-
which describe how their frames are linked to other frames.
|
963
|
-
For instance, the backend could be configured with this setting::
|
964
|
-
|
965
|
-
u_channel_lo = [
|
966
|
-
[UchannelLO(q=0, scale=1. + 0.j)],
|
967
|
-
[UchannelLO(q=0, scale=-1. + 0.j), UchannelLO(q=1, scale=1. + 0.j)]
|
968
|
-
]
|
969
|
-
|
970
|
-
Then, this method can be used as follows::
|
971
|
-
|
972
|
-
backend.configuration().describe(ControlChannel(1))
|
973
|
-
>>> {DriveChannel(0): -1, DriveChannel(1): 1}
|
974
|
-
|
975
|
-
Args:
|
976
|
-
channel: The derived channel to describe.
|
977
|
-
Raises:
|
978
|
-
BackendConfigurationError: If channel is not a ControlChannel.
|
979
|
-
Returns:
|
980
|
-
Control channel derivations.
|
981
|
-
"""
|
982
|
-
if not isinstance(channel, ControlChannel):
|
983
|
-
raise BackendConfigurationError("Can only describe ControlChannels.")
|
984
|
-
result = {}
|
985
|
-
for u_chan_lo in self.u_channel_lo[channel.index]:
|
986
|
-
result[DriveChannel(u_chan_lo.q)] = u_chan_lo.scale
|
987
|
-
return result
|
988
|
-
|
989
|
-
def _parse_channels(self, channels: Dict[set, Any]) -> Dict[Any, Any]:
|
990
|
-
r"""
|
991
|
-
Generates a dictionaries of ``Channel``\s, and tuple of qubit(s) they operate on.
|
992
|
-
|
993
|
-
Args:
|
994
|
-
channels: An optional dictionary containing information of each channel -- their
|
995
|
-
purpose, type, and qubits operated on.
|
996
|
-
|
997
|
-
Returns:
|
998
|
-
qubit_channel_map: Dictionary mapping tuple of qubit(s) to list of ``Channel``\s.
|
999
|
-
channel_qubit_map: Dictionary mapping ``Channel`` to list of qubit(s).
|
1000
|
-
control_channels: Dictionary mapping tuple of qubit(s), to list of
|
1001
|
-
``ControlChannel``\s.
|
1002
|
-
"""
|
1003
|
-
qubit_channel_map = defaultdict(list)
|
1004
|
-
channel_qubit_map = defaultdict(list)
|
1005
|
-
control_channels = defaultdict(list)
|
1006
|
-
channels_dict = {
|
1007
|
-
DriveChannel.prefix: DriveChannel,
|
1008
|
-
ControlChannel.prefix: ControlChannel,
|
1009
|
-
MeasureChannel.prefix: MeasureChannel,
|
1010
|
-
"acquire": AcquireChannel,
|
1011
|
-
}
|
1012
|
-
for channel, config in channels.items():
|
1013
|
-
channel_prefix, index = self._get_channel_prefix_index(channel)
|
1014
|
-
channel_type = channels_dict[channel_prefix]
|
1015
|
-
qubits = tuple(config["operates"]["qubits"])
|
1016
|
-
if channel_prefix in channels_dict:
|
1017
|
-
qubit_channel_map[qubits].append(channel_type(index))
|
1018
|
-
channel_qubit_map[(channel_type(index))].extend(list(qubits))
|
1019
|
-
if channel_prefix == ControlChannel.prefix:
|
1020
|
-
control_channels[qubits].append(channel_type(index))
|
1021
|
-
return dict(qubit_channel_map), dict(channel_qubit_map), dict(control_channels)
|
1022
|
-
|
1023
|
-
def _get_channel_prefix_index(self, channel: str) -> str:
|
1024
|
-
"""Return channel prefix and index from the given ``channel``.
|
1025
|
-
|
1026
|
-
Args:
|
1027
|
-
channel: Name of channel.
|
1028
|
-
|
1029
|
-
Raises:
|
1030
|
-
BackendConfigurationError: If invalid channel name is found.
|
1031
|
-
|
1032
|
-
Return:
|
1033
|
-
Channel name and index. For example, if ``channel=acquire0``, this method
|
1034
|
-
returns ``acquire`` and ``0``.
|
1035
|
-
"""
|
1036
|
-
channel_prefix = re.match(r"(?P<channel>[a-z]+)(?P<index>[0-9]+)", channel)
|
1037
|
-
try:
|
1038
|
-
return channel_prefix.group("channel"), int(channel_prefix.group("index"))
|
1039
|
-
except AttributeError as ex:
|
1040
|
-
raise BackendConfigurationError(f"Invalid channel name - '{channel}' found.") from ex
|