qiskit 1.4.1__cp39-abi3-win_amd64.whl → 2.0.0rc1__cp39-abi3-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qiskit/VERSION.txt +1 -1
- qiskit/__init__.py +2 -5
- qiskit/_accelerate.pyd +0 -0
- qiskit/circuit/__init__.py +24 -5
- qiskit/circuit/{add_control.py → _add_control.py} +32 -12
- qiskit/circuit/_classical_resource_map.py +5 -3
- qiskit/circuit/barrier.py +3 -7
- qiskit/circuit/classical/expr/__init__.py +31 -3
- qiskit/circuit/classical/expr/constructors.py +248 -28
- qiskit/circuit/classical/expr/expr.py +104 -3
- qiskit/circuit/classical/expr/visitors.py +75 -0
- qiskit/circuit/classical/types/__init__.py +12 -8
- qiskit/circuit/classical/types/ordering.py +14 -7
- qiskit/circuit/classical/types/types.py +36 -0
- qiskit/circuit/commutation_checker.py +34 -7
- qiskit/circuit/controlflow/__init__.py +32 -1
- qiskit/circuit/controlflow/_builder_utils.py +9 -5
- qiskit/circuit/controlflow/box.py +163 -0
- qiskit/circuit/controlflow/break_loop.py +1 -1
- qiskit/circuit/controlflow/builder.py +139 -39
- qiskit/circuit/controlflow/continue_loop.py +1 -3
- qiskit/circuit/controlflow/control_flow.py +10 -0
- qiskit/circuit/controlflow/for_loop.py +2 -1
- qiskit/circuit/controlflow/if_else.py +3 -16
- qiskit/circuit/controlflow/switch_case.py +2 -8
- qiskit/circuit/controlflow/while_loop.py +2 -7
- qiskit/circuit/controlledgate.py +2 -4
- qiskit/circuit/delay.py +40 -11
- qiskit/circuit/duration.py +0 -15
- qiskit/circuit/gate.py +2 -4
- qiskit/circuit/instruction.py +2 -141
- qiskit/circuit/instructionset.py +7 -54
- qiskit/circuit/library/__init__.py +34 -5
- qiskit/circuit/library/arithmetic/__init__.py +16 -10
- qiskit/circuit/library/arithmetic/adders/cdkm_ripple_carry_adder.py +1 -1
- qiskit/circuit/library/arithmetic/adders/draper_qft_adder.py +2 -2
- qiskit/circuit/library/arithmetic/adders/vbe_ripple_carry_adder.py +1 -1
- qiskit/circuit/library/arithmetic/exact_reciprocal.py +64 -21
- qiskit/circuit/library/arithmetic/integer_comparator.py +37 -80
- qiskit/circuit/library/arithmetic/linear_amplitude_function.py +169 -2
- qiskit/circuit/library/arithmetic/linear_pauli_rotations.py +59 -5
- qiskit/circuit/library/arithmetic/piecewise_chebyshev.py +154 -6
- qiskit/circuit/library/arithmetic/piecewise_linear_pauli_rotations.py +114 -4
- qiskit/circuit/library/arithmetic/piecewise_polynomial_pauli_rotations.py +191 -15
- qiskit/circuit/library/arithmetic/polynomial_pauli_rotations.py +93 -39
- qiskit/circuit/library/arithmetic/quadratic_form.py +168 -2
- qiskit/circuit/library/arithmetic/weighted_adder.py +73 -1
- qiskit/circuit/library/bit_flip_oracle.py +130 -0
- qiskit/circuit/library/blueprintcircuit.py +52 -16
- qiskit/circuit/library/data_preparation/initializer.py +1 -1
- qiskit/circuit/library/data_preparation/pauli_feature_map.py +4 -4
- qiskit/circuit/library/data_preparation/state_preparation.py +1 -1
- qiskit/circuit/library/generalized_gates/gms.py +1 -1
- qiskit/circuit/library/generalized_gates/isometry.py +1 -1
- qiskit/circuit/library/generalized_gates/pauli.py +1 -2
- qiskit/circuit/library/generalized_gates/uc.py +97 -7
- qiskit/circuit/library/generalized_gates/uc_pauli_rot.py +1 -1
- qiskit/circuit/library/generalized_gates/unitary.py +4 -2
- qiskit/circuit/library/hamiltonian_gate.py +1 -1
- qiskit/circuit/library/n_local/evolved_operator_ansatz.py +1 -1
- qiskit/circuit/library/n_local/n_local.py +1 -1
- qiskit/circuit/library/n_local/qaoa_ansatz.py +1 -1
- qiskit/circuit/library/overlap.py +2 -2
- qiskit/circuit/library/pauli_evolution.py +39 -24
- qiskit/circuit/library/phase_oracle.py +130 -51
- qiskit/circuit/library/standard_gates/__init__.py +0 -1
- qiskit/circuit/library/standard_gates/dcx.py +3 -4
- qiskit/circuit/library/standard_gates/ecr.py +3 -4
- qiskit/circuit/library/standard_gates/global_phase.py +5 -6
- qiskit/circuit/library/standard_gates/h.py +4 -9
- qiskit/circuit/library/standard_gates/i.py +2 -2
- qiskit/circuit/library/standard_gates/iswap.py +3 -4
- qiskit/circuit/library/standard_gates/p.py +15 -34
- qiskit/circuit/library/standard_gates/r.py +2 -6
- qiskit/circuit/library/standard_gates/rx.py +5 -15
- qiskit/circuit/library/standard_gates/rxx.py +3 -6
- qiskit/circuit/library/standard_gates/ry.py +5 -17
- qiskit/circuit/library/standard_gates/ryy.py +3 -6
- qiskit/circuit/library/standard_gates/rz.py +5 -17
- qiskit/circuit/library/standard_gates/rzx.py +3 -6
- qiskit/circuit/library/standard_gates/rzz.py +3 -6
- qiskit/circuit/library/standard_gates/s.py +6 -15
- qiskit/circuit/library/standard_gates/swap.py +4 -11
- qiskit/circuit/library/standard_gates/sx.py +7 -12
- qiskit/circuit/library/standard_gates/t.py +6 -7
- qiskit/circuit/library/standard_gates/u.py +2 -10
- qiskit/circuit/library/standard_gates/u1.py +5 -16
- qiskit/circuit/library/standard_gates/u2.py +2 -6
- qiskit/circuit/library/standard_gates/u3.py +3 -11
- qiskit/circuit/library/standard_gates/x.py +13 -60
- qiskit/circuit/library/standard_gates/xx_minus_yy.py +2 -5
- qiskit/circuit/library/standard_gates/xx_plus_yy.py +2 -5
- qiskit/circuit/library/standard_gates/y.py +4 -9
- qiskit/circuit/library/standard_gates/z.py +5 -15
- qiskit/circuit/measure.py +11 -2
- qiskit/circuit/parameterexpression.py +4 -0
- qiskit/circuit/quantumcircuit.py +881 -555
- qiskit/circuit/random/utils.py +12 -6
- qiskit/circuit/reset.py +5 -2
- qiskit/circuit/singleton.py +5 -11
- qiskit/circuit/store.py +0 -8
- qiskit/compiler/__init__.py +1 -7
- qiskit/compiler/transpiler.py +38 -196
- qiskit/converters/circuit_to_dag.py +4 -2
- qiskit/converters/circuit_to_dagdependency.py +0 -2
- qiskit/converters/circuit_to_dagdependency_v2.py +0 -1
- qiskit/converters/circuit_to_gate.py +1 -1
- qiskit/converters/circuit_to_instruction.py +16 -29
- qiskit/converters/dag_to_circuit.py +5 -5
- qiskit/converters/dag_to_dagdependency.py +0 -1
- qiskit/converters/dag_to_dagdependency_v2.py +0 -1
- qiskit/converters/dagdependency_to_circuit.py +0 -6
- qiskit/converters/dagdependency_to_dag.py +0 -6
- qiskit/dagcircuit/collect_blocks.py +32 -20
- qiskit/dagcircuit/dagdependency.py +3 -37
- qiskit/dagcircuit/dagdependency_v2.py +2 -80
- qiskit/dagcircuit/dagnode.py +14 -2
- qiskit/passmanager/__init__.py +24 -6
- qiskit/passmanager/passmanager.py +26 -24
- qiskit/primitives/__init__.py +44 -35
- qiskit/primitives/backend_estimator_v2.py +102 -23
- qiskit/primitives/backend_sampler_v2.py +5 -20
- qiskit/primitives/base/__init__.py +4 -4
- qiskit/primitives/base/base_estimator.py +77 -82
- qiskit/primitives/base/base_primitive_job.py +2 -2
- qiskit/primitives/base/{base_primitive.py → base_primitive_v1.py} +1 -1
- qiskit/primitives/base/{base_result.py → base_result_v1.py} +1 -1
- qiskit/primitives/base/base_sampler.py +52 -60
- qiskit/primitives/base/{estimator_result.py → estimator_result_v1.py} +2 -2
- qiskit/primitives/base/{sampler_result.py → sampler_result_v1.py} +2 -2
- qiskit/primitives/base/{validation.py → validation_v1.py} +34 -15
- qiskit/primitives/containers/bindings_array.py +3 -1
- qiskit/primitives/containers/bit_array.py +23 -0
- qiskit/primitives/containers/data_bin.py +3 -1
- qiskit/primitives/containers/observables_array.py +19 -2
- qiskit/primitives/statevector_sampler.py +6 -8
- qiskit/primitives/utils.py +14 -189
- qiskit/providers/__init__.py +4 -130
- qiskit/providers/backend.py +11 -314
- qiskit/providers/basic_provider/__init__.py +3 -1
- qiskit/providers/basic_provider/basic_provider.py +29 -9
- qiskit/providers/basic_provider/basic_simulator.py +158 -298
- qiskit/providers/exceptions.py +0 -33
- qiskit/providers/fake_provider/__init__.py +0 -37
- qiskit/providers/fake_provider/generic_backend_v2.py +32 -693
- qiskit/qasm2/__init__.py +21 -6
- qiskit/qasm2/export.py +2 -10
- qiskit/qasm2/parse.py +11 -25
- qiskit/qasm3/__init__.py +5 -1
- qiskit/qasm3/ast.py +44 -0
- qiskit/qasm3/exporter.py +65 -27
- qiskit/qasm3/printer.py +35 -4
- qiskit/qpy/__init__.py +141 -19
- qiskit/qpy/binary_io/__init__.py +0 -1
- qiskit/qpy/binary_io/circuits.py +91 -116
- qiskit/qpy/binary_io/schedules.py +61 -388
- qiskit/qpy/binary_io/value.py +154 -28
- qiskit/qpy/common.py +10 -7
- qiskit/qpy/formats.py +41 -0
- qiskit/qpy/interface.py +29 -62
- qiskit/qpy/type_keys.py +58 -221
- qiskit/quantum_info/analysis/distance.py +3 -1
- qiskit/quantum_info/operators/dihedral/dihedral.py +3 -1
- qiskit/quantum_info/operators/operator.py +6 -2
- qiskit/quantum_info/operators/symplectic/clifford.py +3 -1
- qiskit/quantum_info/operators/symplectic/pauli.py +4 -2
- qiskit/quantum_info/operators/symplectic/pauli_list.py +17 -5
- qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +40 -6
- qiskit/quantum_info/states/densitymatrix.py +16 -6
- qiskit/quantum_info/states/stabilizerstate.py +35 -4
- qiskit/quantum_info/states/statevector.py +16 -6
- qiskit/result/__init__.py +5 -17
- qiskit/result/models.py +18 -10
- qiskit/result/result.py +28 -126
- qiskit/result/sampled_expval.py +1 -2
- qiskit/result/utils.py +3 -4
- qiskit/synthesis/__init__.py +21 -1
- qiskit/synthesis/arithmetic/__init__.py +3 -1
- qiskit/synthesis/arithmetic/adders/cdkm_ripple_carry_adder.py +1 -1
- qiskit/synthesis/arithmetic/adders/draper_qft_adder.py +1 -1
- qiskit/synthesis/arithmetic/adders/vbe_ripple_carry_adder.py +2 -2
- qiskit/{providers/fake_provider/backends_v1/fake_20q → synthesis/arithmetic/comparators}/__init__.py +4 -6
- qiskit/synthesis/arithmetic/comparators/compare_2s.py +112 -0
- qiskit/synthesis/arithmetic/comparators/compare_greedy.py +66 -0
- qiskit/synthesis/arithmetic/multipliers/hrs_cumulative_multiplier.py +1 -1
- qiskit/synthesis/arithmetic/multipliers/rg_qft_multiplier.py +1 -1
- qiskit/synthesis/arithmetic/weighted_sum.py +155 -0
- qiskit/{result/mitigation → synthesis/boolean}/__init__.py +2 -2
- qiskit/synthesis/boolean/boolean_expression.py +231 -0
- qiskit/synthesis/boolean/boolean_expression_synth.py +124 -0
- qiskit/synthesis/boolean/boolean_expression_visitor.py +96 -0
- qiskit/synthesis/discrete_basis/generate_basis_approximations.py +2 -0
- qiskit/synthesis/evolution/lie_trotter.py +10 -7
- qiskit/synthesis/evolution/product_formula.py +44 -35
- qiskit/synthesis/evolution/qdrift.py +17 -24
- qiskit/synthesis/evolution/suzuki_trotter.py +20 -27
- qiskit/synthesis/linear/linear_depth_lnn.py +6 -221
- qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py +4 -205
- qiskit/synthesis/multi_controlled/__init__.py +1 -0
- qiskit/synthesis/multi_controlled/mcx_synthesis.py +5 -2
- qiskit/synthesis/multi_controlled/multi_control_rotation_gates.py +206 -0
- qiskit/synthesis/one_qubit/one_qubit_decompose.py +1 -1
- qiskit/synthesis/two_qubit/__init__.py +1 -0
- qiskit/synthesis/two_qubit/two_qubit_decompose.py +28 -145
- qiskit/transpiler/__init__.py +32 -232
- qiskit/transpiler/basepasses.py +20 -51
- qiskit/transpiler/layout.py +1 -1
- qiskit/transpiler/passes/__init__.py +2 -40
- qiskit/transpiler/passes/basis/basis_translator.py +4 -3
- qiskit/transpiler/passes/basis/decompose.py +1 -15
- qiskit/transpiler/passes/basis/unroll_3q_or_more.py +1 -5
- qiskit/transpiler/passes/basis/unroll_custom_definitions.py +3 -2
- qiskit/transpiler/passes/layout/apply_layout.py +4 -0
- qiskit/transpiler/passes/layout/dense_layout.py +2 -39
- qiskit/transpiler/passes/layout/full_ancilla_allocation.py +4 -4
- qiskit/transpiler/passes/layout/sabre_layout.py +7 -3
- qiskit/transpiler/passes/layout/vf2_layout.py +2 -20
- qiskit/transpiler/passes/layout/vf2_post_layout.py +60 -125
- qiskit/transpiler/passes/layout/vf2_utils.py +2 -26
- qiskit/transpiler/passes/optimization/__init__.py +1 -3
- qiskit/transpiler/passes/optimization/collect_and_collapse.py +2 -0
- qiskit/transpiler/passes/optimization/collect_cliffords.py +5 -0
- qiskit/transpiler/passes/optimization/collect_linear_functions.py +5 -0
- qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py +16 -1
- qiskit/transpiler/passes/optimization/commutation_analysis.py +3 -3
- qiskit/transpiler/passes/optimization/consolidate_blocks.py +41 -19
- qiskit/transpiler/passes/optimization/contract_idle_wires_in_control_flow.py +104 -0
- qiskit/transpiler/passes/optimization/light_cone.py +135 -0
- qiskit/transpiler/passes/optimization/optimize_1q_commutation.py +0 -1
- qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +18 -22
- qiskit/transpiler/passes/optimization/optimize_annotated.py +3 -2
- qiskit/transpiler/passes/optimization/remove_identity_equiv.py +6 -4
- qiskit/transpiler/passes/optimization/reset_after_measure_simplification.py +5 -2
- qiskit/transpiler/passes/optimization/split_2q_unitaries.py +26 -3
- qiskit/transpiler/passes/optimization/template_matching/template_substitution.py +1 -0
- qiskit/transpiler/passes/routing/__init__.py +0 -1
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py +3 -1
- qiskit/transpiler/passes/routing/sabre_swap.py +14 -6
- qiskit/transpiler/passes/routing/star_prerouting.py +1 -1
- qiskit/transpiler/passes/scheduling/__init__.py +1 -7
- qiskit/transpiler/passes/scheduling/alignments/__init__.py +2 -4
- qiskit/transpiler/passes/scheduling/alignments/check_durations.py +1 -9
- qiskit/transpiler/passes/scheduling/alignments/reschedule.py +17 -16
- qiskit/transpiler/passes/scheduling/padding/base_padding.py +30 -2
- qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +20 -58
- qiskit/transpiler/passes/scheduling/padding/pad_delay.py +11 -3
- qiskit/transpiler/passes/scheduling/scheduling/alap.py +5 -39
- qiskit/transpiler/passes/scheduling/scheduling/asap.py +4 -35
- qiskit/transpiler/passes/scheduling/scheduling/base_scheduler.py +10 -16
- qiskit/transpiler/passes/scheduling/time_unit_conversion.py +127 -59
- qiskit/transpiler/passes/synthesis/default_unitary_synth_plugin.py +653 -0
- qiskit/transpiler/passes/synthesis/high_level_synthesis.py +176 -601
- qiskit/transpiler/passes/synthesis/hls_plugins.py +294 -1
- qiskit/transpiler/passes/synthesis/plugin.py +4 -0
- qiskit/transpiler/passes/synthesis/solovay_kitaev_synthesis.py +16 -10
- qiskit/transpiler/passes/synthesis/unitary_synthesis.py +34 -697
- qiskit/transpiler/passes/utils/__init__.py +0 -1
- qiskit/transpiler/passes/utils/check_gate_direction.py +13 -5
- qiskit/transpiler/passes/utils/control_flow.py +2 -6
- qiskit/transpiler/passes/utils/gate_direction.py +7 -0
- qiskit/transpiler/passes/utils/remove_final_measurements.py +40 -33
- qiskit/transpiler/passmanager.py +13 -0
- qiskit/transpiler/passmanager_config.py +5 -81
- qiskit/transpiler/preset_passmanagers/builtin_plugins.py +225 -344
- qiskit/transpiler/preset_passmanagers/common.py +140 -167
- qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py +101 -322
- qiskit/transpiler/preset_passmanagers/level0.py +2 -11
- qiskit/transpiler/preset_passmanagers/level1.py +2 -14
- qiskit/transpiler/preset_passmanagers/level2.py +2 -12
- qiskit/transpiler/preset_passmanagers/level3.py +2 -11
- qiskit/transpiler/preset_passmanagers/plugin.py +5 -3
- qiskit/transpiler/target.py +67 -524
- qiskit/user_config.py +8 -4
- qiskit/utils/__init__.py +13 -12
- qiskit/utils/deprecation.py +4 -112
- qiskit/utils/optionals.py +11 -4
- qiskit/utils/parallel.py +214 -87
- qiskit/utils/units.py +4 -1
- qiskit/visualization/__init__.py +3 -7
- qiskit/visualization/array.py +4 -1
- qiskit/visualization/bloch.py +1 -1
- qiskit/visualization/circuit/_utils.py +19 -19
- qiskit/visualization/circuit/circuit_visualization.py +11 -4
- qiskit/visualization/circuit/matplotlib.py +13 -23
- qiskit/visualization/circuit/text.py +7 -3
- qiskit/visualization/dag_visualization.py +2 -1
- qiskit/visualization/gate_map.py +39 -154
- qiskit/visualization/pass_manager_visualization.py +6 -2
- qiskit/visualization/state_visualization.py +6 -0
- qiskit/visualization/timeline/core.py +18 -12
- qiskit/visualization/timeline/interface.py +19 -18
- {qiskit-1.4.1.dist-info → qiskit-2.0.0rc1.dist-info}/METADATA +2 -2
- {qiskit-1.4.1.dist-info → qiskit-2.0.0rc1.dist-info}/RECORD +297 -444
- {qiskit-1.4.1.dist-info → qiskit-2.0.0rc1.dist-info}/WHEEL +1 -1
- {qiskit-1.4.1.dist-info → qiskit-2.0.0rc1.dist-info}/entry_points.txt +8 -2
- qiskit/assembler/__init__.py +0 -42
- qiskit/assembler/assemble_circuits.py +0 -451
- qiskit/assembler/assemble_schedules.py +0 -367
- qiskit/assembler/disassemble.py +0 -310
- qiskit/assembler/run_config.py +0 -77
- qiskit/circuit/bit.py +0 -106
- qiskit/circuit/classicalfunction/__init__.py +0 -152
- qiskit/circuit/classicalfunction/boolean_expression.py +0 -138
- qiskit/circuit/classicalfunction/classical_element.py +0 -54
- qiskit/circuit/classicalfunction/classical_function_visitor.py +0 -155
- qiskit/circuit/classicalfunction/classicalfunction.py +0 -182
- qiskit/circuit/classicalfunction/exceptions.py +0 -41
- qiskit/circuit/classicalfunction/types.py +0 -18
- qiskit/circuit/classicalfunction/utils.py +0 -91
- qiskit/circuit/classicalregister.py +0 -57
- qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py +0 -405
- qiskit/circuit/quantumregister.py +0 -75
- qiskit/circuit/register.py +0 -246
- qiskit/compiler/assembler.py +0 -689
- qiskit/compiler/scheduler.py +0 -109
- qiskit/compiler/sequencer.py +0 -71
- qiskit/primitives/backend_estimator.py +0 -486
- qiskit/primitives/backend_sampler.py +0 -222
- qiskit/primitives/estimator.py +0 -172
- qiskit/primitives/sampler.py +0 -162
- qiskit/providers/backend_compat.py +0 -507
- qiskit/providers/fake_provider/backends_v1/__init__.py +0 -22
- qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/__init__.py +0 -18
- qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/conf_washington.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/defs_washington.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/fake_127q_pulse_v1.py +0 -37
- qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/props_washington.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_20q/conf_singapore.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_20q/fake_20q.py +0 -43
- qiskit/providers/fake_provider/backends_v1/fake_20q/props_singapore.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/__init__.py +0 -18
- qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/conf_hanoi.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/defs_hanoi.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/fake_27q_pulse_v1.py +0 -50
- qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/props_hanoi.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_5q/__init__.py +0 -18
- qiskit/providers/fake_provider/backends_v1/fake_5q/conf_yorktown.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_5q/fake_5q_v1.py +0 -41
- qiskit/providers/fake_provider/backends_v1/fake_5q/props_yorktown.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/__init__.py +0 -18
- qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/conf_nairobi.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/defs_nairobi.json +0 -1
- qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/fake_7q_pulse_v1.py +0 -44
- qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/props_nairobi.json +0 -1
- qiskit/providers/fake_provider/fake_1q.py +0 -91
- qiskit/providers/fake_provider/fake_backend.py +0 -165
- qiskit/providers/fake_provider/fake_openpulse_2q.py +0 -391
- qiskit/providers/fake_provider/fake_openpulse_3q.py +0 -340
- qiskit/providers/fake_provider/fake_pulse_backend.py +0 -49
- qiskit/providers/fake_provider/fake_qasm_backend.py +0 -77
- qiskit/providers/fake_provider/utils/backend_converter.py +0 -150
- qiskit/providers/fake_provider/utils/json_decoder.py +0 -109
- qiskit/providers/models/__init__.py +0 -89
- qiskit/providers/models/backendconfiguration.py +0 -1040
- qiskit/providers/models/backendproperties.py +0 -535
- qiskit/providers/models/backendstatus.py +0 -104
- qiskit/providers/models/jobstatus.py +0 -77
- qiskit/providers/models/pulsedefaults.py +0 -305
- qiskit/providers/provider.py +0 -95
- qiskit/pulse/__init__.py +0 -158
- qiskit/pulse/builder.py +0 -2262
- qiskit/pulse/calibration_entries.py +0 -381
- qiskit/pulse/channels.py +0 -227
- qiskit/pulse/configuration.py +0 -245
- qiskit/pulse/exceptions.py +0 -45
- qiskit/pulse/filters.py +0 -309
- qiskit/pulse/instruction_schedule_map.py +0 -424
- qiskit/pulse/instructions/__init__.py +0 -67
- qiskit/pulse/instructions/acquire.py +0 -150
- qiskit/pulse/instructions/delay.py +0 -71
- qiskit/pulse/instructions/directives.py +0 -154
- qiskit/pulse/instructions/frequency.py +0 -135
- qiskit/pulse/instructions/instruction.py +0 -270
- qiskit/pulse/instructions/phase.py +0 -152
- qiskit/pulse/instructions/play.py +0 -99
- qiskit/pulse/instructions/reference.py +0 -100
- qiskit/pulse/instructions/snapshot.py +0 -82
- qiskit/pulse/library/__init__.py +0 -97
- qiskit/pulse/library/continuous.py +0 -430
- qiskit/pulse/library/pulse.py +0 -148
- qiskit/pulse/library/samplers/__init__.py +0 -15
- qiskit/pulse/library/samplers/decorators.py +0 -295
- qiskit/pulse/library/samplers/strategies.py +0 -71
- qiskit/pulse/library/symbolic_pulses.py +0 -1989
- qiskit/pulse/library/waveform.py +0 -136
- qiskit/pulse/macros.py +0 -262
- qiskit/pulse/parameter_manager.py +0 -445
- qiskit/pulse/parser.py +0 -314
- qiskit/pulse/reference_manager.py +0 -58
- qiskit/pulse/schedule.py +0 -1854
- qiskit/pulse/transforms/__init__.py +0 -106
- qiskit/pulse/transforms/alignments.py +0 -406
- qiskit/pulse/transforms/base_transforms.py +0 -71
- qiskit/pulse/transforms/canonicalization.py +0 -498
- qiskit/pulse/transforms/dag.py +0 -122
- qiskit/pulse/utils.py +0 -149
- qiskit/qobj/__init__.py +0 -75
- qiskit/qobj/common.py +0 -81
- qiskit/qobj/converters/__init__.py +0 -18
- qiskit/qobj/converters/lo_config.py +0 -177
- qiskit/qobj/converters/pulse_instruction.py +0 -897
- qiskit/qobj/pulse_qobj.py +0 -709
- qiskit/qobj/qasm_qobj.py +0 -708
- qiskit/qobj/utils.py +0 -46
- qiskit/result/mitigation/base_readout_mitigator.py +0 -79
- qiskit/result/mitigation/correlated_readout_mitigator.py +0 -277
- qiskit/result/mitigation/local_readout_mitigator.py +0 -328
- qiskit/result/mitigation/utils.py +0 -217
- qiskit/scheduler/__init__.py +0 -40
- qiskit/scheduler/config.py +0 -37
- qiskit/scheduler/lowering.py +0 -187
- qiskit/scheduler/methods/__init__.py +0 -15
- qiskit/scheduler/methods/basic.py +0 -140
- qiskit/scheduler/schedule_circuit.py +0 -69
- qiskit/scheduler/sequence.py +0 -104
- qiskit/transpiler/passes/calibration/__init__.py +0 -17
- qiskit/transpiler/passes/calibration/base_builder.py +0 -79
- qiskit/transpiler/passes/calibration/builders.py +0 -20
- qiskit/transpiler/passes/calibration/exceptions.py +0 -22
- qiskit/transpiler/passes/calibration/pulse_gate.py +0 -100
- qiskit/transpiler/passes/calibration/rx_builder.py +0 -164
- qiskit/transpiler/passes/calibration/rzx_builder.py +0 -411
- qiskit/transpiler/passes/calibration/rzx_templates.py +0 -58
- qiskit/transpiler/passes/optimization/cx_cancellation.py +0 -65
- qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposition.py +0 -162
- qiskit/transpiler/passes/optimization/normalize_rx_angle.py +0 -157
- qiskit/transpiler/passes/routing/stochastic_swap.py +0 -532
- qiskit/transpiler/passes/scheduling/alap.py +0 -153
- qiskit/transpiler/passes/scheduling/alignments/align_measures.py +0 -255
- qiskit/transpiler/passes/scheduling/alignments/pulse_gate_validation.py +0 -107
- qiskit/transpiler/passes/scheduling/asap.py +0 -175
- qiskit/transpiler/passes/scheduling/base_scheduler.py +0 -310
- qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +0 -313
- qiskit/transpiler/passes/utils/convert_conditions_to_if_ops.py +0 -93
- qiskit/utils/deprecate_pulse.py +0 -119
- qiskit/utils/multiprocessing.py +0 -56
- qiskit/visualization/pulse_v2/__init__.py +0 -21
- qiskit/visualization/pulse_v2/core.py +0 -901
- qiskit/visualization/pulse_v2/device_info.py +0 -173
- qiskit/visualization/pulse_v2/drawings.py +0 -253
- qiskit/visualization/pulse_v2/events.py +0 -254
- qiskit/visualization/pulse_v2/generators/__init__.py +0 -40
- qiskit/visualization/pulse_v2/generators/barrier.py +0 -76
- qiskit/visualization/pulse_v2/generators/chart.py +0 -208
- qiskit/visualization/pulse_v2/generators/frame.py +0 -436
- qiskit/visualization/pulse_v2/generators/snapshot.py +0 -133
- qiskit/visualization/pulse_v2/generators/waveform.py +0 -645
- qiskit/visualization/pulse_v2/interface.py +0 -459
- qiskit/visualization/pulse_v2/layouts.py +0 -387
- qiskit/visualization/pulse_v2/plotters/__init__.py +0 -17
- qiskit/visualization/pulse_v2/plotters/base_plotter.py +0 -53
- qiskit/visualization/pulse_v2/plotters/matplotlib.py +0 -201
- qiskit/visualization/pulse_v2/stylesheet.py +0 -312
- qiskit/visualization/pulse_v2/types.py +0 -242
- {qiskit-1.4.1.dist-info → qiskit-2.0.0rc1.dist-info}/LICENSE.txt +0 -0
- {qiskit-1.4.1.dist-info → qiskit-2.0.0rc1.dist-info}/top_level.txt +0 -0
@@ -1,173 +0,0 @@
|
|
1
|
-
# This code is part of Qiskit.
|
2
|
-
#
|
3
|
-
# (C) Copyright IBM 2020.
|
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
|
-
"""A collection of backend information formatted to generate drawing data.
|
14
|
-
|
15
|
-
This instance will be provided to generator functions. The module provides an abstract
|
16
|
-
class :py:class:``DrawerBackendInfo`` with necessary methods to generate drawing objects.
|
17
|
-
|
18
|
-
Because the data structure of backend class may depend on providers, this abstract class
|
19
|
-
has an abstract factory method `create_from_backend`. Each subclass should provide
|
20
|
-
the factory method which conforms to the associated provider. By default we provide
|
21
|
-
:py:class:``OpenPulseBackendInfo`` class that has the factory method taking backends
|
22
|
-
satisfying OpenPulse specification [1].
|
23
|
-
|
24
|
-
This class can be also initialized without the factory method by manually specifying
|
25
|
-
required information. This may be convenient for visualizing a pulse program for simulator
|
26
|
-
backend that only has a device Hamiltonian information. This requires two mapping objects
|
27
|
-
for channel/qubit and channel/frequency along with the system cycle time.
|
28
|
-
|
29
|
-
If those information are not provided, this class will be initialized with a set of
|
30
|
-
empty data and the drawer illustrates a pulse program without any specific information.
|
31
|
-
|
32
|
-
Reference:
|
33
|
-
- [1] Qiskit Backend Specifications for OpenQASM and OpenPulse Experiments,
|
34
|
-
https://arxiv.org/abs/1809.03452
|
35
|
-
"""
|
36
|
-
|
37
|
-
from abc import ABC, abstractmethod
|
38
|
-
from collections import defaultdict
|
39
|
-
from typing import Dict, List, Union, Optional
|
40
|
-
|
41
|
-
from qiskit import pulse
|
42
|
-
from qiskit.providers import BackendConfigurationError
|
43
|
-
from qiskit.providers.backend import Backend, BackendV2
|
44
|
-
|
45
|
-
|
46
|
-
class DrawerBackendInfo(ABC):
|
47
|
-
"""Backend information to be used for the drawing data generation."""
|
48
|
-
|
49
|
-
def __init__(
|
50
|
-
self,
|
51
|
-
name: Optional[str] = None,
|
52
|
-
dt: Optional[float] = None,
|
53
|
-
channel_frequency_map: Optional[Dict[pulse.channels.Channel, float]] = None,
|
54
|
-
qubit_channel_map: Optional[Dict[int, List[pulse.channels.Channel]]] = None,
|
55
|
-
):
|
56
|
-
"""Create new backend information.
|
57
|
-
|
58
|
-
Args:
|
59
|
-
name: Name of the backend.
|
60
|
-
dt: System cycle time.
|
61
|
-
channel_frequency_map: Mapping of channel and associated frequency.
|
62
|
-
qubit_channel_map: Mapping of qubit and associated channels.
|
63
|
-
"""
|
64
|
-
self.backend_name = name or "no-backend"
|
65
|
-
self._dt = dt
|
66
|
-
self._chan_freq_map = channel_frequency_map or {}
|
67
|
-
self._qubit_channel_map = qubit_channel_map or {}
|
68
|
-
|
69
|
-
@classmethod
|
70
|
-
@abstractmethod
|
71
|
-
def create_from_backend(cls, backend: Backend):
|
72
|
-
"""Initialize a class with backend information provided by provider.
|
73
|
-
|
74
|
-
Args:
|
75
|
-
backend: Backend object.
|
76
|
-
"""
|
77
|
-
raise NotImplementedError
|
78
|
-
|
79
|
-
@property
|
80
|
-
def dt(self):
|
81
|
-
"""Return cycle time."""
|
82
|
-
return self._dt
|
83
|
-
|
84
|
-
def get_qubit_index(self, chan: pulse.channels.Channel) -> Union[int, None]:
|
85
|
-
"""Get associated qubit index of given channel object."""
|
86
|
-
for qind, chans in self._qubit_channel_map.items():
|
87
|
-
if chan in chans:
|
88
|
-
return qind
|
89
|
-
return chan.index
|
90
|
-
|
91
|
-
def get_channel_frequency(self, chan: pulse.channels.Channel) -> Union[float, None]:
|
92
|
-
"""Get frequency of given channel object."""
|
93
|
-
return self._chan_freq_map.get(chan, None)
|
94
|
-
|
95
|
-
|
96
|
-
class OpenPulseBackendInfo(DrawerBackendInfo):
|
97
|
-
"""Drawing information of backend that conforms to OpenPulse specification."""
|
98
|
-
|
99
|
-
@classmethod
|
100
|
-
def create_from_backend(cls, backend: Backend):
|
101
|
-
"""Initialize a class with backend information provided by provider.
|
102
|
-
|
103
|
-
Args:
|
104
|
-
backend: Backend object.
|
105
|
-
|
106
|
-
Returns:
|
107
|
-
OpenPulseBackendInfo: New configured instance.
|
108
|
-
"""
|
109
|
-
chan_freqs = {}
|
110
|
-
qubit_channel_map = defaultdict(list)
|
111
|
-
|
112
|
-
if hasattr(backend, "configuration") and hasattr(backend, "defaults"):
|
113
|
-
configuration = backend.configuration()
|
114
|
-
defaults = backend.defaults()
|
115
|
-
|
116
|
-
name = configuration.backend_name
|
117
|
-
dt = configuration.dt
|
118
|
-
|
119
|
-
# load frequencies
|
120
|
-
chan_freqs.update(
|
121
|
-
{
|
122
|
-
pulse.DriveChannel(qind): freq
|
123
|
-
for qind, freq in enumerate(defaults.qubit_freq_est)
|
124
|
-
}
|
125
|
-
)
|
126
|
-
chan_freqs.update(
|
127
|
-
{
|
128
|
-
pulse.MeasureChannel(qind): freq
|
129
|
-
for qind, freq in enumerate(defaults.meas_freq_est)
|
130
|
-
}
|
131
|
-
)
|
132
|
-
for qind, u_lo_mappers in enumerate(configuration.u_channel_lo):
|
133
|
-
temp_val = 0.0 + 0.0j
|
134
|
-
for u_lo_mapper in u_lo_mappers:
|
135
|
-
temp_val += defaults.qubit_freq_est[u_lo_mapper.q] * u_lo_mapper.scale
|
136
|
-
chan_freqs[pulse.ControlChannel(qind)] = temp_val.real
|
137
|
-
|
138
|
-
# load qubit channel mapping
|
139
|
-
for qind in range(configuration.n_qubits):
|
140
|
-
qubit_channel_map[qind].append(configuration.drive(qubit=qind))
|
141
|
-
qubit_channel_map[qind].append(configuration.measure(qubit=qind))
|
142
|
-
for tind in range(configuration.n_qubits):
|
143
|
-
try:
|
144
|
-
qubit_channel_map[qind].extend(configuration.control(qubits=(qind, tind)))
|
145
|
-
except BackendConfigurationError:
|
146
|
-
pass
|
147
|
-
elif isinstance(backend, BackendV2):
|
148
|
-
# Pure V2 model doesn't contain channel frequency information.
|
149
|
-
name = backend.name
|
150
|
-
dt = backend.dt
|
151
|
-
|
152
|
-
# load qubit channel mapping
|
153
|
-
for qind in range(backend.num_qubits):
|
154
|
-
# channels are NotImplemented by default so we must catch arbitrary error.
|
155
|
-
try:
|
156
|
-
qubit_channel_map[qind].append(backend.drive_channel(qind))
|
157
|
-
except Exception: # pylint: disable=broad-except
|
158
|
-
pass
|
159
|
-
try:
|
160
|
-
qubit_channel_map[qind].append(backend.measure_channel(qind))
|
161
|
-
except Exception: # pylint: disable=broad-except
|
162
|
-
pass
|
163
|
-
for tind in range(backend.num_qubits):
|
164
|
-
try:
|
165
|
-
qubit_channel_map[qind].extend(backend.control_channel(qubits=(qind, tind)))
|
166
|
-
except Exception: # pylint: disable=broad-except
|
167
|
-
pass
|
168
|
-
else:
|
169
|
-
raise RuntimeError("Backend object not yet supported")
|
170
|
-
|
171
|
-
return OpenPulseBackendInfo(
|
172
|
-
name=name, dt=dt, channel_frequency_map=chan_freqs, qubit_channel_map=qubit_channel_map
|
173
|
-
)
|
@@ -1,253 +0,0 @@
|
|
1
|
-
# This code is part of Qiskit.
|
2
|
-
#
|
3
|
-
# (C) Copyright IBM 2020.
|
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
|
-
Drawing objects for pulse drawer.
|
15
|
-
|
16
|
-
Drawing objects play two important roles:
|
17
|
-
- Allowing unittests of visualization module. Usually it is hard for image files to be tested.
|
18
|
-
- Removing program parser from each plotter interface. We can easily add new plotter.
|
19
|
-
|
20
|
-
This module is based on the structure of matplotlib as it is the primary plotter
|
21
|
-
of the pulse drawer. However this interface is agnostic to the actual plotter.
|
22
|
-
|
23
|
-
Design concept
|
24
|
-
~~~~~~~~~~~~~~
|
25
|
-
When we think about dynamically updating drawings, it will be most efficient to
|
26
|
-
update only the changed properties of drawings rather than regenerating entirely from scratch.
|
27
|
-
Thus the core :py:class:`qiskit.visualization.pulse_v2.core.DrawerCanvas` generates
|
28
|
-
all possible drawings in the beginning and then the canvas instance manages
|
29
|
-
visibility of each drawing according to the end-user request.
|
30
|
-
|
31
|
-
Data key
|
32
|
-
~~~~~~~~
|
33
|
-
In the abstract class ``ElementaryData`` common attributes to represent a drawing are
|
34
|
-
specified. In addition, drawings have the `data_key` property that returns an
|
35
|
-
unique hash of the object for comparison.
|
36
|
-
This key is generated from a data type and the location of the drawing in the canvas.
|
37
|
-
See py:mod:`qiskit.visualization.pulse_v2.types` for detail on the data type.
|
38
|
-
If a data key cannot distinguish two independent objects, you need to add a new data type.
|
39
|
-
The data key may be used in the plotter interface to identify the object.
|
40
|
-
|
41
|
-
Drawing objects
|
42
|
-
~~~~~~~~~~~~~~~
|
43
|
-
To support not only `matplotlib` but also multiple plotters, those drawings should be
|
44
|
-
universal and designed without strong dependency on modules in `matplotlib`.
|
45
|
-
This means drawings that represent primitive geometries are preferred.
|
46
|
-
It should be noted that there will be no unittest for each plotter API, which takes
|
47
|
-
drawings and outputs image data, we should avoid adding a complicated geometry
|
48
|
-
that has a context of the pulse program.
|
49
|
-
|
50
|
-
For example, a pulse envelope is complex valued number array and may be represented
|
51
|
-
by two lines with different colors associated with the real and the imaginary component.
|
52
|
-
We can use two line-type objects rather than defining a new drawing that takes
|
53
|
-
complex value. As many plotters don't support an API that visualizes complex-valued
|
54
|
-
data arrays, if we introduced such a drawing and wrote a custom wrapper function
|
55
|
-
on top of the existing API, it could be difficult to prevent bugs with the CI tools
|
56
|
-
due to lack of the effective unittest.
|
57
|
-
"""
|
58
|
-
from __future__ import annotations
|
59
|
-
|
60
|
-
from abc import ABC
|
61
|
-
from enum import Enum
|
62
|
-
from typing import Any
|
63
|
-
|
64
|
-
import numpy as np
|
65
|
-
|
66
|
-
from qiskit.pulse.channels import Channel
|
67
|
-
from qiskit.visualization.pulse_v2 import types
|
68
|
-
from qiskit.visualization.exceptions import VisualizationError
|
69
|
-
|
70
|
-
|
71
|
-
class ElementaryData(ABC):
|
72
|
-
"""Base class of the pulse visualization interface."""
|
73
|
-
|
74
|
-
__hash__ = None
|
75
|
-
|
76
|
-
def __init__(
|
77
|
-
self,
|
78
|
-
data_type: str | Enum,
|
79
|
-
xvals: np.ndarray,
|
80
|
-
yvals: np.ndarray,
|
81
|
-
channels: Channel | list[Channel] | None = None,
|
82
|
-
meta: dict[str, Any] | None = None,
|
83
|
-
ignore_scaling: bool = False,
|
84
|
-
styles: dict[str, Any] | None = None,
|
85
|
-
):
|
86
|
-
"""Create new drawing.
|
87
|
-
|
88
|
-
Args:
|
89
|
-
data_type: String representation of this drawing.
|
90
|
-
xvals: Series of horizontal coordinate that the object is drawn.
|
91
|
-
yvals: Series of vertical coordinate that the object is drawn.
|
92
|
-
channels: Pulse channel object bound to this drawing.
|
93
|
-
meta: Meta data dictionary of the object.
|
94
|
-
ignore_scaling: Set ``True`` to disable scaling.
|
95
|
-
styles: Style keyword args of the object. This conforms to `matplotlib`.
|
96
|
-
"""
|
97
|
-
if channels and isinstance(channels, Channel):
|
98
|
-
channels = [channels]
|
99
|
-
|
100
|
-
if isinstance(data_type, Enum):
|
101
|
-
data_type = data_type.value
|
102
|
-
|
103
|
-
self.data_type = str(data_type)
|
104
|
-
self.xvals = np.array(xvals, dtype=object)
|
105
|
-
self.yvals = np.array(yvals, dtype=object)
|
106
|
-
self.channels: list[Channel] = channels or []
|
107
|
-
self.meta = meta or {}
|
108
|
-
self.ignore_scaling = ignore_scaling
|
109
|
-
self.styles = styles or {}
|
110
|
-
|
111
|
-
@property
|
112
|
-
def data_key(self):
|
113
|
-
"""Return unique hash of this object."""
|
114
|
-
return str(
|
115
|
-
hash((self.__class__.__name__, self.data_type, tuple(self.xvals), tuple(self.yvals)))
|
116
|
-
)
|
117
|
-
|
118
|
-
def __repr__(self):
|
119
|
-
return f"{self.__class__.__name__}(type={self.data_type}, key={self.data_key})"
|
120
|
-
|
121
|
-
def __eq__(self, other):
|
122
|
-
return isinstance(other, self.__class__) and self.data_key == other.data_key
|
123
|
-
|
124
|
-
|
125
|
-
class LineData(ElementaryData):
|
126
|
-
"""Drawing object to represent object appears as a line.
|
127
|
-
|
128
|
-
This is the counterpart of `matplotlib.pyplot.plot`.
|
129
|
-
"""
|
130
|
-
|
131
|
-
def __init__(
|
132
|
-
self,
|
133
|
-
data_type: str | Enum,
|
134
|
-
xvals: np.ndarray | list[types.Coordinate],
|
135
|
-
yvals: np.ndarray | list[types.Coordinate],
|
136
|
-
fill: bool = False,
|
137
|
-
channels: Channel | list[Channel] | None = None,
|
138
|
-
meta: dict[str, Any] | None = None,
|
139
|
-
ignore_scaling: bool = False,
|
140
|
-
styles: dict[str, Any] | None = None,
|
141
|
-
):
|
142
|
-
"""Create new drawing.
|
143
|
-
|
144
|
-
Args:
|
145
|
-
data_type: String representation of this drawing.
|
146
|
-
channels: Pulse channel object bound to this drawing.
|
147
|
-
xvals: Series of horizontal coordinate that the object is drawn.
|
148
|
-
yvals: Series of vertical coordinate that the object is drawn.
|
149
|
-
fill: Set ``True`` to fill the area under curve.
|
150
|
-
meta: Meta data dictionary of the object.
|
151
|
-
ignore_scaling: Set ``True`` to disable scaling.
|
152
|
-
styles: Style keyword args of the object. This conforms to `matplotlib`.
|
153
|
-
"""
|
154
|
-
self.fill = fill
|
155
|
-
|
156
|
-
super().__init__(
|
157
|
-
data_type=data_type,
|
158
|
-
xvals=xvals,
|
159
|
-
yvals=yvals,
|
160
|
-
channels=channels,
|
161
|
-
meta=meta,
|
162
|
-
ignore_scaling=ignore_scaling,
|
163
|
-
styles=styles,
|
164
|
-
)
|
165
|
-
|
166
|
-
|
167
|
-
class TextData(ElementaryData):
|
168
|
-
"""Drawing object to represent object appears as a text.
|
169
|
-
|
170
|
-
This is the counterpart of `matplotlib.pyplot.text`.
|
171
|
-
"""
|
172
|
-
|
173
|
-
def __init__(
|
174
|
-
self,
|
175
|
-
data_type: str | Enum,
|
176
|
-
xvals: np.ndarray | list[types.Coordinate],
|
177
|
-
yvals: np.ndarray | list[types.Coordinate],
|
178
|
-
text: str,
|
179
|
-
latex: str | None = None,
|
180
|
-
channels: Channel | list[Channel] | None = None,
|
181
|
-
meta: dict[str, Any] | None = None,
|
182
|
-
ignore_scaling: bool = False,
|
183
|
-
styles: dict[str, Any] | None = None,
|
184
|
-
):
|
185
|
-
"""Create new drawing.
|
186
|
-
|
187
|
-
Args:
|
188
|
-
data_type: String representation of this drawing.
|
189
|
-
channels: Pulse channel object bound to this drawing.
|
190
|
-
xvals: Series of horizontal coordinate that the object is drawn.
|
191
|
-
yvals: Series of vertical coordinate that the object is drawn.
|
192
|
-
text: String to show in the canvas.
|
193
|
-
latex: Latex representation of the text (if backend supports latex drawing).
|
194
|
-
meta: Meta data dictionary of the object.
|
195
|
-
ignore_scaling: Set ``True`` to disable scaling.
|
196
|
-
styles: Style keyword args of the object. This conforms to `matplotlib`.
|
197
|
-
"""
|
198
|
-
self.text = text
|
199
|
-
self.latex = latex or ""
|
200
|
-
|
201
|
-
super().__init__(
|
202
|
-
data_type=data_type,
|
203
|
-
xvals=xvals,
|
204
|
-
yvals=yvals,
|
205
|
-
channels=channels,
|
206
|
-
meta=meta,
|
207
|
-
ignore_scaling=ignore_scaling,
|
208
|
-
styles=styles,
|
209
|
-
)
|
210
|
-
|
211
|
-
|
212
|
-
class BoxData(ElementaryData):
|
213
|
-
"""Drawing object that represents box shape.
|
214
|
-
|
215
|
-
This is the counterpart of `matplotlib.patches.Rectangle`.
|
216
|
-
"""
|
217
|
-
|
218
|
-
def __init__(
|
219
|
-
self,
|
220
|
-
data_type: str | Enum,
|
221
|
-
xvals: np.ndarray | list[types.Coordinate],
|
222
|
-
yvals: np.ndarray | list[types.Coordinate],
|
223
|
-
channels: Channel | list[Channel] | None = None,
|
224
|
-
meta: dict[str, Any] | None = None,
|
225
|
-
ignore_scaling: bool = False,
|
226
|
-
styles: dict[str, Any] | None = None,
|
227
|
-
):
|
228
|
-
"""Create new box.
|
229
|
-
|
230
|
-
Args:
|
231
|
-
data_type: String representation of this drawing.
|
232
|
-
xvals: Left and right coordinate that the object is drawn.
|
233
|
-
yvals: Top and bottom coordinate that the object is drawn.
|
234
|
-
channels: Pulse channel object bound to this drawing.
|
235
|
-
meta: Meta data dictionary of the object.
|
236
|
-
ignore_scaling: Set ``True`` to disable scaling.
|
237
|
-
styles: Style keyword args of the object. This conforms to `matplotlib`.
|
238
|
-
|
239
|
-
Raises:
|
240
|
-
VisualizationError: When number of data points are not equals to 2.
|
241
|
-
"""
|
242
|
-
if len(xvals) != 2 or len(yvals) != 2:
|
243
|
-
raise VisualizationError("Length of data points are not equals to 2.")
|
244
|
-
|
245
|
-
super().__init__(
|
246
|
-
data_type=data_type,
|
247
|
-
xvals=xvals,
|
248
|
-
yvals=yvals,
|
249
|
-
channels=channels,
|
250
|
-
meta=meta,
|
251
|
-
ignore_scaling=ignore_scaling,
|
252
|
-
styles=styles,
|
253
|
-
)
|
@@ -1,254 +0,0 @@
|
|
1
|
-
# This code is part of Qiskit.
|
2
|
-
#
|
3
|
-
# (C) Copyright IBM 2020.
|
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
|
-
r"""
|
14
|
-
Channel event manager for pulse schedules.
|
15
|
-
|
16
|
-
This module provides a `ChannelEvents` class that manages a series of instructions for a
|
17
|
-
pulse channel. Channel-wise filtering of the pulse program makes
|
18
|
-
the arrangement of channels easier in the core drawer function.
|
19
|
-
The `ChannelEvents` class is expected to be called by other programs (not by end-users).
|
20
|
-
|
21
|
-
The `ChannelEvents` class instance is created with the class method ``load_program``:
|
22
|
-
|
23
|
-
.. code-block:: python
|
24
|
-
|
25
|
-
event = ChannelEvents.load_program(sched, DriveChannel(0))
|
26
|
-
|
27
|
-
The `ChannelEvents` is created for a specific pulse channel and loosely assorts pulse
|
28
|
-
instructions within the channel with different visualization purposes.
|
29
|
-
|
30
|
-
Phase and frequency related instructions are loosely grouped as frame changes.
|
31
|
-
The instantaneous value of those operands are combined and provided as ``PhaseFreqTuple``.
|
32
|
-
Instructions that have finite duration are grouped as waveforms.
|
33
|
-
|
34
|
-
The grouped instructions are returned as an iterator by the corresponding method call:
|
35
|
-
|
36
|
-
.. code-block:: python
|
37
|
-
|
38
|
-
for t0, frame, instruction in event.get_waveforms():
|
39
|
-
...
|
40
|
-
|
41
|
-
for t0, frame_change, instructions in event.get_frame_changes():
|
42
|
-
...
|
43
|
-
|
44
|
-
The class method ``get_waveforms`` returns the iterator of waveform type instructions with
|
45
|
-
the ``PhaseFreqTuple`` (frame) at the time when instruction is issued.
|
46
|
-
This is because a pulse envelope of ``Waveform`` may be modulated with a
|
47
|
-
phase factor $exp(-i \omega t - \phi)$ with frequency $\omega$ and phase $\phi$ and
|
48
|
-
appear on the canvas. Thus, it is better to tell users in which phase and frequency
|
49
|
-
the pulse envelope is modulated from a viewpoint of program debugging.
|
50
|
-
|
51
|
-
On the other hand, the class method ``get_frame_changes`` returns a ``PhaseFreqTuple`` that
|
52
|
-
represents a total amount of change at that time because it is convenient to know
|
53
|
-
the operand value itself when we debug a program.
|
54
|
-
|
55
|
-
Because frame change type instructions are usually zero duration, multiple instructions
|
56
|
-
can be issued at the same time and those operand values should be appropriately
|
57
|
-
combined. In Qiskit Pulse we have set and shift type instructions for the frame control,
|
58
|
-
the set type instruction will be converted into the relevant shift amount for visualization.
|
59
|
-
Note that these instructions are not interchangeable and the order should be kept.
|
60
|
-
For example:
|
61
|
-
|
62
|
-
.. code-block:: python
|
63
|
-
|
64
|
-
sched1 = Schedule()
|
65
|
-
sched1 = sched1.insert(0, ShiftPhase(-1.57, DriveChannel(0))
|
66
|
-
sched1 = sched1.insert(0, SetPhase(3.14, DriveChannel(0))
|
67
|
-
|
68
|
-
sched2 = Schedule()
|
69
|
-
sched2 = sched2.insert(0, SetPhase(3.14, DriveChannel(0))
|
70
|
-
sched2 = sched2.insert(0, ShiftPhase(-1.57, DriveChannel(0))
|
71
|
-
|
72
|
-
In this example, ``sched1`` and ``sched2`` will have different frames.
|
73
|
-
On the drawer canvas, the total frame change amount of +3.14 should be shown for ``sched1``,
|
74
|
-
while ``sched2`` is +1.57. Since the `SetPhase` and the `ShiftPhase` instruction behave
|
75
|
-
differently, we cannot simply sum up the operand values in visualization output.
|
76
|
-
|
77
|
-
It should be also noted that zero duration instructions issued at the same time will be
|
78
|
-
overlapped on the canvas. Thus it is convenient to plot a total frame change amount rather
|
79
|
-
than plotting each operand value bound to the instruction.
|
80
|
-
"""
|
81
|
-
from __future__ import annotations
|
82
|
-
from collections import defaultdict
|
83
|
-
from collections.abc import Iterator
|
84
|
-
|
85
|
-
from qiskit import pulse, circuit
|
86
|
-
from qiskit.visualization.pulse_v2.types import PhaseFreqTuple, PulseInstruction
|
87
|
-
|
88
|
-
|
89
|
-
class ChannelEvents:
|
90
|
-
"""Channel event manager."""
|
91
|
-
|
92
|
-
_waveform_group = (
|
93
|
-
pulse.instructions.Play,
|
94
|
-
pulse.instructions.Delay,
|
95
|
-
pulse.instructions.Acquire,
|
96
|
-
)
|
97
|
-
_frame_group = (
|
98
|
-
pulse.instructions.SetFrequency,
|
99
|
-
pulse.instructions.ShiftFrequency,
|
100
|
-
pulse.instructions.SetPhase,
|
101
|
-
pulse.instructions.ShiftPhase,
|
102
|
-
)
|
103
|
-
|
104
|
-
def __init__(
|
105
|
-
self,
|
106
|
-
waveforms: dict[int, pulse.Instruction],
|
107
|
-
frames: dict[int, list[pulse.Instruction]],
|
108
|
-
channel: pulse.channels.Channel,
|
109
|
-
):
|
110
|
-
"""Create new event manager.
|
111
|
-
|
112
|
-
Args:
|
113
|
-
waveforms: List of waveforms shown in this channel.
|
114
|
-
frames: List of frame change type instructions shown in this channel.
|
115
|
-
channel: Channel object associated with this manager.
|
116
|
-
"""
|
117
|
-
self._waveforms = waveforms
|
118
|
-
self._frames = frames
|
119
|
-
self.channel = channel
|
120
|
-
|
121
|
-
# initial frame
|
122
|
-
self._init_phase = 0.0
|
123
|
-
self._init_frequency = 0.0
|
124
|
-
|
125
|
-
# time resolution
|
126
|
-
self._dt = 0.0
|
127
|
-
|
128
|
-
@classmethod
|
129
|
-
def load_program(cls, program: pulse.Schedule, channel: pulse.channels.Channel):
|
130
|
-
"""Load a pulse program represented by ``Schedule``.
|
131
|
-
|
132
|
-
Args:
|
133
|
-
program: Target ``Schedule`` to visualize.
|
134
|
-
channel: The channel managed by this instance.
|
135
|
-
|
136
|
-
Returns:
|
137
|
-
ChannelEvents: The channel event manager for the specified channel.
|
138
|
-
"""
|
139
|
-
waveforms = {}
|
140
|
-
frames = defaultdict(list)
|
141
|
-
|
142
|
-
# parse instructions
|
143
|
-
for t0, inst in program.filter(channels=[channel]).instructions:
|
144
|
-
if isinstance(inst, cls._waveform_group):
|
145
|
-
if inst.duration == 0:
|
146
|
-
# special case, duration of delay can be zero
|
147
|
-
continue
|
148
|
-
waveforms[t0] = inst
|
149
|
-
elif isinstance(inst, cls._frame_group):
|
150
|
-
frames[t0].append(inst)
|
151
|
-
|
152
|
-
return ChannelEvents(waveforms, frames, channel)
|
153
|
-
|
154
|
-
def set_config(self, dt: float, init_frequency: float, init_phase: float):
|
155
|
-
"""Setup system status.
|
156
|
-
|
157
|
-
Args:
|
158
|
-
dt: Time resolution in sec.
|
159
|
-
init_frequency: Modulation frequency in Hz.
|
160
|
-
init_phase: Initial phase in rad.
|
161
|
-
"""
|
162
|
-
self._dt = dt or 1.0
|
163
|
-
self._init_frequency = init_frequency or 0.0
|
164
|
-
self._init_phase = init_phase or 0.0
|
165
|
-
|
166
|
-
def get_waveforms(self) -> Iterator[PulseInstruction]:
|
167
|
-
"""Return waveform type instructions with frame."""
|
168
|
-
sorted_frame_changes = sorted(self._frames.items(), key=lambda x: x[0], reverse=True)
|
169
|
-
sorted_waveforms = sorted(self._waveforms.items(), key=lambda x: x[0])
|
170
|
-
|
171
|
-
# bind phase and frequency with instruction
|
172
|
-
phase = self._init_phase
|
173
|
-
frequency = self._init_frequency
|
174
|
-
for t0, inst in sorted_waveforms:
|
175
|
-
is_opaque = False
|
176
|
-
|
177
|
-
while len(sorted_frame_changes) > 0 and sorted_frame_changes[-1][0] <= t0:
|
178
|
-
_, frame_changes = sorted_frame_changes.pop()
|
179
|
-
phase, frequency = ChannelEvents._calculate_current_frame(
|
180
|
-
frame_changes=frame_changes, phase=phase, frequency=frequency
|
181
|
-
)
|
182
|
-
|
183
|
-
# Convert parameter expression into float
|
184
|
-
if isinstance(phase, circuit.ParameterExpression):
|
185
|
-
phase = float(phase.bind({param: 0 for param in phase.parameters}))
|
186
|
-
if isinstance(frequency, circuit.ParameterExpression):
|
187
|
-
frequency = float(frequency.bind({param: 0 for param in frequency.parameters}))
|
188
|
-
|
189
|
-
frame = PhaseFreqTuple(phase, frequency)
|
190
|
-
|
191
|
-
# Check if pulse has unbound parameters
|
192
|
-
if isinstance(inst, pulse.Play):
|
193
|
-
is_opaque = inst.pulse.is_parameterized()
|
194
|
-
|
195
|
-
yield PulseInstruction(t0, self._dt, frame, inst, is_opaque)
|
196
|
-
|
197
|
-
def get_frame_changes(self) -> Iterator[PulseInstruction]:
|
198
|
-
"""Return frame change type instructions with total frame change amount."""
|
199
|
-
# TODO parse parametrized FCs correctly
|
200
|
-
|
201
|
-
sorted_frame_changes = sorted(self._frames.items(), key=lambda x: x[0])
|
202
|
-
|
203
|
-
phase = self._init_phase
|
204
|
-
frequency = self._init_frequency
|
205
|
-
for t0, frame_changes in sorted_frame_changes:
|
206
|
-
is_opaque = False
|
207
|
-
|
208
|
-
pre_phase = phase
|
209
|
-
pre_frequency = frequency
|
210
|
-
phase, frequency = ChannelEvents._calculate_current_frame(
|
211
|
-
frame_changes=frame_changes, phase=phase, frequency=frequency
|
212
|
-
)
|
213
|
-
|
214
|
-
# keep parameter expression to check either phase or frequency is parameterized
|
215
|
-
frame = PhaseFreqTuple(phase - pre_phase, frequency - pre_frequency)
|
216
|
-
|
217
|
-
# remove parameter expressions to find if next frame is parameterized
|
218
|
-
if isinstance(phase, circuit.ParameterExpression):
|
219
|
-
phase = float(phase.bind({param: 0 for param in phase.parameters}))
|
220
|
-
is_opaque = True
|
221
|
-
if isinstance(frequency, circuit.ParameterExpression):
|
222
|
-
frequency = float(frequency.bind({param: 0 for param in frequency.parameters}))
|
223
|
-
is_opaque = True
|
224
|
-
|
225
|
-
yield PulseInstruction(t0, self._dt, frame, frame_changes, is_opaque)
|
226
|
-
|
227
|
-
@classmethod
|
228
|
-
def _calculate_current_frame(
|
229
|
-
cls, frame_changes: list[pulse.instructions.Instruction], phase: float, frequency: float
|
230
|
-
) -> tuple[float, float]:
|
231
|
-
"""Calculate the current frame from the previous frame.
|
232
|
-
|
233
|
-
If parameter is unbound phase or frequency accumulation with this instruction is skipped.
|
234
|
-
|
235
|
-
Args:
|
236
|
-
frame_changes: List of frame change instructions at a specific time.
|
237
|
-
phase: Phase of previous frame.
|
238
|
-
frequency: Frequency of previous frame.
|
239
|
-
|
240
|
-
Returns:
|
241
|
-
Phase and frequency of new frame.
|
242
|
-
"""
|
243
|
-
|
244
|
-
for frame_change in frame_changes:
|
245
|
-
if isinstance(frame_change, pulse.instructions.SetFrequency):
|
246
|
-
frequency = frame_change.frequency
|
247
|
-
elif isinstance(frame_change, pulse.instructions.ShiftFrequency):
|
248
|
-
frequency += frame_change.frequency
|
249
|
-
elif isinstance(frame_change, pulse.instructions.SetPhase):
|
250
|
-
phase = frame_change.phase
|
251
|
-
elif isinstance(frame_change, pulse.instructions.ShiftPhase):
|
252
|
-
phase += frame_change.phase
|
253
|
-
|
254
|
-
return phase, frequency
|