qiskit 1.1.2__cp38-abi3-macosx_10_9_universal2.whl → 1.2.0__cp38-abi3-macosx_10_9_universal2.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 +27 -24
- qiskit/_accelerate.abi3.so +0 -0
- qiskit/_numpy_compat.py +1 -1
- qiskit/assembler/assemble_circuits.py +107 -64
- qiskit/assembler/assemble_schedules.py +5 -12
- qiskit/assembler/disassemble.py +10 -1
- qiskit/circuit/__init__.py +6 -3
- qiskit/circuit/_classical_resource_map.py +5 -5
- qiskit/circuit/_utils.py +0 -13
- qiskit/circuit/add_control.py +1 -1
- qiskit/circuit/annotated_operation.py +23 -1
- qiskit/circuit/classical/expr/expr.py +4 -4
- qiskit/circuit/classical/expr/visitors.py +1 -1
- qiskit/circuit/classical/types/__init__.py +1 -1
- qiskit/circuit/classical/types/types.py +2 -2
- qiskit/circuit/classicalfunction/boolean_expression.py +1 -1
- qiskit/circuit/classicalfunction/classical_function_visitor.py +5 -5
- qiskit/circuit/classicalfunction/utils.py +1 -1
- qiskit/circuit/classicalregister.py +1 -1
- qiskit/circuit/commutation_checker.py +83 -35
- qiskit/circuit/controlflow/_builder_utils.py +1 -1
- qiskit/circuit/controlflow/builder.py +10 -6
- qiskit/circuit/controlflow/if_else.py +2 -2
- qiskit/circuit/controlflow/switch_case.py +1 -1
- qiskit/circuit/delay.py +1 -1
- qiskit/circuit/duration.py +2 -2
- qiskit/circuit/equivalence.py +5 -7
- qiskit/circuit/gate.py +11 -8
- qiskit/circuit/instruction.py +31 -13
- qiskit/circuit/instructionset.py +2 -5
- qiskit/circuit/library/__init__.py +2 -1
- qiskit/circuit/library/arithmetic/linear_amplitude_function.py +1 -1
- qiskit/circuit/library/arithmetic/linear_pauli_rotations.py +1 -1
- qiskit/circuit/library/arithmetic/piecewise_chebyshev.py +1 -1
- qiskit/circuit/library/arithmetic/piecewise_linear_pauli_rotations.py +1 -1
- qiskit/circuit/library/arithmetic/piecewise_polynomial_pauli_rotations.py +3 -3
- qiskit/circuit/library/arithmetic/polynomial_pauli_rotations.py +1 -1
- qiskit/circuit/library/basis_change/__init__.py +1 -1
- qiskit/circuit/library/basis_change/qft.py +40 -6
- qiskit/circuit/library/blueprintcircuit.py +3 -5
- qiskit/circuit/library/data_preparation/__init__.py +9 -2
- qiskit/circuit/library/data_preparation/initializer.py +8 -0
- qiskit/circuit/library/data_preparation/state_preparation.py +98 -178
- qiskit/circuit/library/generalized_gates/isometry.py +8 -8
- qiskit/circuit/library/generalized_gates/linear_function.py +3 -2
- qiskit/circuit/library/generalized_gates/mcg_up_to_diagonal.py +4 -4
- qiskit/circuit/library/generalized_gates/permutation.py +8 -9
- qiskit/circuit/library/generalized_gates/uc.py +3 -3
- qiskit/circuit/library/generalized_gates/uc_pauli_rot.py +2 -2
- qiskit/circuit/library/generalized_gates/unitary.py +13 -11
- qiskit/circuit/library/graph_state.py +1 -1
- qiskit/circuit/library/hamiltonian_gate.py +1 -2
- qiskit/circuit/library/hidden_linear_function.py +1 -1
- qiskit/circuit/library/n_local/evolved_operator_ansatz.py +3 -2
- qiskit/circuit/library/n_local/n_local.py +4 -5
- qiskit/circuit/library/n_local/pauli_two_design.py +1 -1
- qiskit/circuit/library/n_local/qaoa_ansatz.py +6 -8
- qiskit/circuit/library/n_local/two_local.py +1 -1
- qiskit/circuit/library/overlap.py +11 -5
- qiskit/circuit/library/pauli_evolution.py +7 -3
- qiskit/circuit/library/standard_gates/dcx.py +3 -0
- qiskit/circuit/library/standard_gates/ecr.py +3 -0
- qiskit/circuit/library/standard_gates/global_phase.py +3 -0
- qiskit/circuit/library/standard_gates/h.py +13 -5
- qiskit/circuit/library/standard_gates/i.py +3 -0
- qiskit/circuit/library/standard_gates/iswap.py +3 -0
- qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py +19 -10
- qiskit/circuit/library/standard_gates/p.py +14 -9
- qiskit/circuit/library/standard_gates/r.py +3 -0
- qiskit/circuit/library/standard_gates/rx.py +21 -6
- qiskit/circuit/library/standard_gates/rxx.py +40 -1
- qiskit/circuit/library/standard_gates/ry.py +21 -6
- qiskit/circuit/library/standard_gates/ryy.py +40 -1
- qiskit/circuit/library/standard_gates/rz.py +22 -6
- qiskit/circuit/library/standard_gates/rzx.py +40 -1
- qiskit/circuit/library/standard_gates/rzz.py +41 -2
- qiskit/circuit/library/standard_gates/s.py +77 -0
- qiskit/circuit/library/standard_gates/swap.py +12 -5
- qiskit/circuit/library/standard_gates/sx.py +14 -5
- qiskit/circuit/library/standard_gates/t.py +5 -0
- qiskit/circuit/library/standard_gates/u.py +22 -7
- qiskit/circuit/library/standard_gates/u1.py +8 -3
- qiskit/circuit/library/standard_gates/u2.py +3 -0
- qiskit/circuit/library/standard_gates/u3.py +22 -7
- qiskit/circuit/library/standard_gates/x.py +156 -92
- qiskit/circuit/library/standard_gates/xx_minus_yy.py +40 -1
- qiskit/circuit/library/standard_gates/xx_plus_yy.py +52 -11
- qiskit/circuit/library/standard_gates/y.py +6 -1
- qiskit/circuit/library/standard_gates/z.py +8 -1
- qiskit/circuit/operation.py +1 -1
- qiskit/circuit/parameter.py +9 -10
- qiskit/circuit/parameterexpression.py +16 -13
- qiskit/circuit/parametertable.py +1 -190
- qiskit/circuit/parametervector.py +1 -1
- qiskit/circuit/quantumcircuit.py +395 -387
- qiskit/circuit/quantumcircuitdata.py +3 -5
- qiskit/circuit/quantumregister.py +1 -1
- qiskit/circuit/random/__init__.py +1 -1
- qiskit/circuit/random/utils.py +175 -26
- qiskit/circuit/register.py +5 -7
- qiskit/circuit/singleton.py +3 -3
- qiskit/circuit/tools/pi_check.py +4 -4
- qiskit/compiler/assembler.py +95 -24
- qiskit/compiler/scheduler.py +2 -2
- qiskit/compiler/transpiler.py +42 -128
- qiskit/converters/circuit_to_dag.py +4 -6
- qiskit/converters/circuit_to_gate.py +4 -8
- qiskit/converters/circuit_to_instruction.py +5 -17
- qiskit/converters/dag_to_circuit.py +2 -6
- qiskit/dagcircuit/collect_blocks.py +2 -2
- qiskit/dagcircuit/dagcircuit.py +190 -187
- qiskit/dagcircuit/dagdependency.py +4 -4
- qiskit/dagcircuit/dagdependency_v2.py +4 -4
- qiskit/dagcircuit/dagdepnode.py +1 -1
- qiskit/dagcircuit/dagnode.py +66 -157
- qiskit/passmanager/flow_controllers.py +1 -1
- qiskit/passmanager/passmanager.py +3 -3
- qiskit/primitives/__init__.py +1 -5
- qiskit/primitives/backend_estimator.py +25 -15
- qiskit/primitives/backend_estimator_v2.py +31 -7
- qiskit/primitives/backend_sampler.py +21 -12
- qiskit/primitives/backend_sampler_v2.py +12 -3
- qiskit/primitives/base/base_estimator.py +31 -4
- qiskit/primitives/base/base_primitive.py +2 -2
- qiskit/primitives/base/base_result.py +2 -2
- qiskit/primitives/base/base_sampler.py +26 -2
- qiskit/primitives/base/estimator_result.py +2 -2
- qiskit/primitives/base/sampler_result.py +2 -2
- qiskit/primitives/containers/__init__.py +0 -1
- qiskit/primitives/containers/bindings_array.py +2 -2
- qiskit/primitives/containers/bit_array.py +108 -10
- qiskit/primitives/containers/shape.py +3 -3
- qiskit/primitives/estimator.py +9 -2
- qiskit/primitives/primitive_job.py +1 -1
- qiskit/primitives/sampler.py +10 -3
- qiskit/primitives/statevector_estimator.py +5 -3
- qiskit/primitives/statevector_sampler.py +11 -5
- qiskit/primitives/utils.py +16 -0
- qiskit/providers/backend.py +15 -6
- qiskit/providers/backend_compat.py +7 -4
- qiskit/providers/basic_provider/basic_provider_tools.py +1 -1
- qiskit/providers/basic_provider/basic_simulator.py +33 -25
- qiskit/providers/fake_provider/fake_backend.py +10 -3
- qiskit/providers/fake_provider/fake_openpulse_2q.py +157 -149
- qiskit/providers/fake_provider/fake_openpulse_3q.py +228 -220
- qiskit/providers/fake_provider/fake_pulse_backend.py +2 -1
- qiskit/providers/fake_provider/fake_qasm_backend.py +7 -2
- qiskit/providers/fake_provider/generic_backend_v2.py +514 -68
- qiskit/providers/models/__init__.py +48 -11
- qiskit/providers/models/backendconfiguration.py +50 -4
- qiskit/providers/models/backendproperties.py +13 -2
- qiskit/providers/models/pulsedefaults.py +10 -11
- qiskit/providers/options.py +13 -13
- qiskit/providers/providerutils.py +3 -1
- qiskit/pulse/configuration.py +8 -12
- qiskit/pulse/instruction_schedule_map.py +3 -5
- qiskit/pulse/instructions/acquire.py +7 -8
- qiskit/pulse/instructions/instruction.py +2 -3
- qiskit/pulse/library/samplers/decorators.py +5 -9
- qiskit/pulse/library/symbolic_pulses.py +4 -7
- qiskit/pulse/library/waveform.py +2 -5
- qiskit/pulse/macros.py +11 -6
- qiskit/pulse/parser.py +8 -10
- qiskit/pulse/schedule.py +9 -17
- qiskit/pulse/transforms/alignments.py +1 -3
- qiskit/pulse/utils.py +1 -2
- qiskit/qasm/libs/stdgates.inc +35 -28
- qiskit/qasm2/__init__.py +7 -7
- qiskit/qasm2/export.py +5 -9
- qiskit/qasm2/parse.py +1 -1
- qiskit/qasm3/ast.py +9 -25
- qiskit/qasm3/exporter.py +582 -479
- qiskit/qasm3/printer.py +7 -16
- qiskit/qobj/common.py +10 -0
- qiskit/qobj/converters/lo_config.py +9 -0
- qiskit/qobj/converters/pulse_instruction.py +13 -6
- qiskit/qobj/pulse_qobj.py +69 -15
- qiskit/qobj/qasm_qobj.py +72 -20
- qiskit/qobj/utils.py +9 -0
- qiskit/qpy/__init__.py +1 -1
- qiskit/qpy/binary_io/circuits.py +8 -5
- qiskit/qpy/binary_io/schedules.py +1 -1
- qiskit/qpy/binary_io/value.py +3 -3
- qiskit/qpy/interface.py +3 -2
- qiskit/qpy/type_keys.py +2 -2
- qiskit/quantum_info/operators/channel/quantum_channel.py +3 -6
- qiskit/quantum_info/operators/channel/superop.py +2 -2
- qiskit/quantum_info/operators/channel/transformations.py +1 -1
- qiskit/quantum_info/operators/dihedral/dihedral.py +3 -4
- qiskit/quantum_info/operators/dihedral/dihedral_circuits.py +1 -3
- qiskit/quantum_info/operators/dihedral/random.py +6 -3
- qiskit/quantum_info/operators/measures.py +2 -2
- qiskit/quantum_info/operators/op_shape.py +12 -20
- qiskit/quantum_info/operators/operator.py +14 -21
- qiskit/quantum_info/operators/predicates.py +1 -0
- qiskit/quantum_info/operators/symplectic/base_pauli.py +7 -11
- qiskit/quantum_info/operators/symplectic/clifford.py +1 -1
- qiskit/quantum_info/operators/symplectic/pauli.py +3 -3
- qiskit/quantum_info/operators/symplectic/pauli_list.py +9 -10
- qiskit/quantum_info/operators/symplectic/random.py +1 -1
- qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +15 -17
- qiskit/quantum_info/quaternion.py +1 -1
- qiskit/quantum_info/states/densitymatrix.py +5 -8
- qiskit/quantum_info/states/stabilizerstate.py +128 -37
- qiskit/quantum_info/states/statevector.py +4 -8
- qiskit/result/counts.py +2 -2
- qiskit/result/mitigation/correlated_readout_mitigator.py +2 -2
- qiskit/result/mitigation/local_readout_mitigator.py +2 -2
- qiskit/result/mitigation/utils.py +1 -3
- qiskit/result/models.py +17 -16
- qiskit/result/result.py +15 -20
- qiskit/scheduler/lowering.py +2 -2
- qiskit/synthesis/__init__.py +2 -1
- qiskit/synthesis/clifford/__init__.py +1 -1
- qiskit/synthesis/clifford/clifford_decompose_ag.py +2 -2
- qiskit/synthesis/clifford/clifford_decompose_bm.py +10 -240
- qiskit/synthesis/clifford/clifford_decompose_greedy.py +9 -303
- qiskit/synthesis/clifford/clifford_decompose_layers.py +25 -23
- qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_full.py +1 -1
- qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_general.py +1 -1
- qiskit/synthesis/discrete_basis/generate_basis_approximations.py +1 -1
- qiskit/synthesis/discrete_basis/solovay_kitaev.py +2 -2
- qiskit/synthesis/evolution/evolution_synthesis.py +4 -2
- qiskit/synthesis/evolution/lie_trotter.py +46 -19
- qiskit/synthesis/evolution/product_formula.py +111 -55
- qiskit/synthesis/evolution/qdrift.py +40 -10
- qiskit/synthesis/evolution/suzuki_trotter.py +43 -33
- qiskit/synthesis/linear/__init__.py +1 -0
- qiskit/synthesis/linear/cnot_synth.py +22 -96
- qiskit/synthesis/linear/linear_depth_lnn.py +8 -8
- qiskit/synthesis/linear/linear_matrix_utils.py +13 -161
- qiskit/synthesis/linear_phase/cnot_phase_synth.py +1 -1
- qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py +3 -3
- qiskit/synthesis/linear_phase/cz_depth_lnn.py +1 -1
- qiskit/synthesis/one_qubit/one_qubit_decompose.py +29 -29
- qiskit/synthesis/permutation/permutation_full.py +5 -29
- qiskit/synthesis/permutation/permutation_lnn.py +2 -24
- qiskit/synthesis/permutation/permutation_utils.py +2 -59
- qiskit/synthesis/qft/__init__.py +1 -0
- qiskit/synthesis/qft/qft_decompose_full.py +79 -0
- qiskit/synthesis/qft/qft_decompose_lnn.py +17 -9
- qiskit/synthesis/stabilizer/stabilizer_circuit.py +6 -6
- qiskit/synthesis/stabilizer/stabilizer_decompose.py +2 -2
- qiskit/synthesis/two_qubit/local_invariance.py +8 -38
- qiskit/synthesis/two_qubit/two_qubit_decompose.py +48 -129
- qiskit/synthesis/unitary/aqc/cnot_structures.py +1 -1
- qiskit/synthesis/unitary/qsd.py +5 -3
- qiskit/transpiler/__init__.py +1 -0
- qiskit/transpiler/basepasses.py +1 -1
- qiskit/transpiler/coupling.py +3 -3
- qiskit/transpiler/instruction_durations.py +1 -2
- qiskit/transpiler/layout.py +3 -3
- qiskit/transpiler/passes/__init__.py +2 -0
- qiskit/transpiler/passes/basis/basis_translator.py +84 -64
- qiskit/transpiler/passes/basis/translate_parameterized.py +3 -5
- qiskit/transpiler/passes/basis/unroll_3q_or_more.py +1 -1
- qiskit/transpiler/passes/basis/unroll_custom_definitions.py +10 -10
- qiskit/transpiler/passes/calibration/rx_builder.py +3 -3
- qiskit/transpiler/passes/calibration/rzx_builder.py +3 -3
- qiskit/transpiler/passes/layout/apply_layout.py +13 -3
- qiskit/transpiler/passes/layout/sabre_layout.py +10 -8
- qiskit/transpiler/passes/layout/sabre_pre_layout.py +4 -1
- qiskit/transpiler/passes/layout/set_layout.py +2 -2
- qiskit/transpiler/passes/layout/vf2_layout.py +1 -1
- qiskit/transpiler/passes/layout/vf2_utils.py +3 -3
- qiskit/transpiler/passes/optimization/__init__.py +1 -0
- qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py +2 -2
- qiskit/transpiler/passes/optimization/commutation_analysis.py +7 -10
- qiskit/transpiler/passes/optimization/commutative_cancellation.py +35 -19
- qiskit/transpiler/passes/optimization/consolidate_blocks.py +17 -8
- qiskit/transpiler/passes/optimization/inverse_cancellation.py +6 -6
- qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +64 -41
- qiskit/transpiler/passes/optimization/optimize_1q_gates.py +1 -1
- qiskit/transpiler/passes/optimization/split_2q_unitaries.py +83 -0
- qiskit/transpiler/passes/optimization/template_matching/backward_match.py +1 -1
- qiskit/transpiler/passes/optimization/template_matching/forward_match.py +2 -2
- qiskit/transpiler/passes/optimization/template_matching/template_substitution.py +1 -1
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py +3 -2
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/swap_strategy.py +1 -1
- qiskit/transpiler/passes/routing/layout_transformation.py +2 -1
- qiskit/transpiler/passes/routing/sabre_swap.py +35 -26
- qiskit/transpiler/passes/routing/star_prerouting.py +80 -105
- qiskit/transpiler/passes/routing/stochastic_swap.py +1 -3
- qiskit/transpiler/passes/scheduling/alap.py +1 -2
- qiskit/transpiler/passes/scheduling/alignments/__init__.py +2 -2
- qiskit/transpiler/passes/scheduling/alignments/check_durations.py +1 -1
- qiskit/transpiler/passes/scheduling/alignments/pulse_gate_validation.py +2 -2
- qiskit/transpiler/passes/scheduling/alignments/reschedule.py +1 -1
- qiskit/transpiler/passes/scheduling/asap.py +1 -2
- qiskit/transpiler/passes/scheduling/base_scheduler.py +5 -5
- qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +3 -3
- qiskit/transpiler/passes/scheduling/padding/base_padding.py +1 -1
- qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +20 -14
- qiskit/transpiler/passes/scheduling/scheduling/base_scheduler.py +7 -6
- qiskit/transpiler/passes/scheduling/time_unit_conversion.py +4 -3
- qiskit/transpiler/passes/synthesis/high_level_synthesis.py +211 -36
- qiskit/transpiler/passes/synthesis/plugin.py +2 -2
- qiskit/transpiler/passes/synthesis/unitary_synthesis.py +80 -40
- qiskit/transpiler/passes/utils/__init__.py +0 -1
- qiskit/transpiler/passes/utils/check_gate_direction.py +4 -4
- qiskit/transpiler/passes/utils/check_map.py +3 -6
- qiskit/transpiler/passes/utils/convert_conditions_to_if_ops.py +3 -4
- qiskit/transpiler/passes/utils/error.py +2 -2
- qiskit/transpiler/passes/utils/fixed_point.py +3 -3
- qiskit/transpiler/passes/utils/gate_direction.py +1 -1
- qiskit/transpiler/passes/utils/gates_basis.py +1 -2
- qiskit/transpiler/passmanager.py +7 -6
- qiskit/transpiler/preset_passmanagers/__init__.py +4 -228
- qiskit/transpiler/preset_passmanagers/builtin_plugins.py +73 -18
- qiskit/transpiler/preset_passmanagers/common.py +3 -6
- qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py +518 -0
- qiskit/transpiler/preset_passmanagers/level0.py +1 -1
- qiskit/transpiler/target.py +27 -8
- qiskit/user_config.py +29 -6
- qiskit/utils/classtools.py +3 -3
- qiskit/utils/deprecation.py +3 -2
- qiskit/utils/lazy_tester.py +2 -2
- qiskit/utils/optionals.py +8 -8
- qiskit/visualization/bloch.py +18 -23
- qiskit/visualization/circuit/_utils.py +34 -10
- qiskit/visualization/circuit/circuit_visualization.py +23 -16
- qiskit/visualization/circuit/latex.py +29 -27
- qiskit/visualization/circuit/matplotlib.py +4 -2
- qiskit/visualization/circuit/qcstyle.py +2 -2
- qiskit/visualization/circuit/text.py +9 -15
- qiskit/visualization/dag_visualization.py +2 -2
- qiskit/visualization/pulse_v2/core.py +1 -1
- qiskit/visualization/pulse_v2/events.py +1 -1
- qiskit/visualization/pulse_v2/generators/frame.py +3 -4
- qiskit/visualization/pulse_v2/generators/waveform.py +5 -9
- qiskit/visualization/pulse_v2/layouts.py +1 -5
- qiskit/visualization/pulse_v2/plotters/matplotlib.py +1 -2
- qiskit/visualization/state_visualization.py +5 -6
- qiskit/visualization/timeline/plotters/matplotlib.py +1 -2
- qiskit/visualization/transition_visualization.py +7 -2
- {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/METADATA +12 -12
- {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/RECORD +342 -340
- {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/entry_points.txt +3 -0
- qiskit/transpiler/passes/utils/block_to_matrix.py +0 -47
- {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/LICENSE.txt +0 -0
- {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/WHEEL +0 -0
- {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/top_level.txt +0 -0
qiskit/qasm3/printer.py
CHANGED
@@ -431,26 +431,17 @@ class BasicPrinter:
|
|
431
431
|
self.stream.write("return")
|
432
432
|
self._end_statement()
|
433
433
|
|
434
|
-
def _visit_QuantumArgument(self, node: ast.QuantumArgument) -> None:
|
435
|
-
self.stream.write("qubit")
|
436
|
-
if node.designator:
|
437
|
-
self.visit(node.designator)
|
438
|
-
self.stream.write(" ")
|
439
|
-
self.visit(node.identifier)
|
440
|
-
|
441
|
-
def _visit_QuantumGateSignature(self, node: ast.QuantumGateSignature) -> None:
|
442
|
-
self.visit(node.name)
|
443
|
-
if node.params:
|
444
|
-
self._visit_sequence(node.params, start="(", end=")", separator=", ")
|
445
|
-
self.stream.write(" ")
|
446
|
-
self._visit_sequence(node.qargList, separator=", ")
|
447
|
-
|
448
434
|
def _visit_QuantumGateDefinition(self, node: ast.QuantumGateDefinition) -> None:
|
449
435
|
self._start_line()
|
450
436
|
self.stream.write("gate ")
|
451
|
-
self.visit(node.
|
437
|
+
self.visit(node.name)
|
438
|
+
if node.params:
|
439
|
+
self._visit_sequence(node.params, start="(", end=")", separator=", ")
|
452
440
|
self.stream.write(" ")
|
453
|
-
|
441
|
+
if node.qubits:
|
442
|
+
self._visit_sequence(node.qubits, separator=", ")
|
443
|
+
self.stream.write(" ")
|
444
|
+
self.visit(node.body)
|
454
445
|
self._end_line()
|
455
446
|
|
456
447
|
def _visit_CalibrationDefinition(self, node: ast.CalibrationDefinition) -> None:
|
qiskit/qobj/common.py
CHANGED
@@ -13,6 +13,8 @@
|
|
13
13
|
"""Module providing definitions of common Qobj classes."""
|
14
14
|
from types import SimpleNamespace
|
15
15
|
|
16
|
+
from qiskit.utils import deprecate_func
|
17
|
+
|
16
18
|
|
17
19
|
class QobjDictField(SimpleNamespace):
|
18
20
|
"""A class used to represent a dictionary field in Qobj
|
@@ -21,6 +23,14 @@ class QobjDictField(SimpleNamespace):
|
|
21
23
|
previously constructed using marshmallow.
|
22
24
|
"""
|
23
25
|
|
26
|
+
@deprecate_func(
|
27
|
+
since="1.2",
|
28
|
+
removal_timeline="in the 2.0 release",
|
29
|
+
additional_msg="The `Qobj` class and related functionality are part of the deprecated "
|
30
|
+
"`BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
|
31
|
+
"workflow requires `Qobj` it likely relies on deprecated functionality and "
|
32
|
+
"should be updated to use `BackendV2`.",
|
33
|
+
)
|
24
34
|
def __init__(self, **kwargs):
|
25
35
|
"""Instantiate a new Qobj dict field object.
|
26
36
|
|
@@ -15,6 +15,7 @@
|
|
15
15
|
from qiskit.pulse.channels import DriveChannel, MeasureChannel
|
16
16
|
from qiskit.pulse.configuration import LoConfig
|
17
17
|
from qiskit.exceptions import QiskitError
|
18
|
+
from qiskit.utils import deprecate_func
|
18
19
|
|
19
20
|
|
20
21
|
class LoConfigConverter:
|
@@ -23,6 +24,14 @@ class LoConfigConverter:
|
|
23
24
|
``get_qubit_los`` and ``get_meas_los`` to align with your backend.
|
24
25
|
"""
|
25
26
|
|
27
|
+
@deprecate_func(
|
28
|
+
since="1.2",
|
29
|
+
removal_timeline="in the 2.0 release",
|
30
|
+
additional_msg="The `Qobj` class and related functionality are part of the deprecated "
|
31
|
+
"`BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
|
32
|
+
"workflow requires `Qobj` it likely relies on deprecated functionality and "
|
33
|
+
"should be updated to use `BackendV2`.",
|
34
|
+
)
|
26
35
|
def __init__(
|
27
36
|
self,
|
28
37
|
qobj_model,
|
@@ -30,6 +30,7 @@ from qiskit.pulse.parser import parse_string_expr
|
|
30
30
|
from qiskit.pulse.schedule import Schedule
|
31
31
|
from qiskit.qobj import QobjMeasurementOption, PulseLibraryItem, PulseQobjInstruction
|
32
32
|
from qiskit.qobj.utils import MeasLevel
|
33
|
+
from qiskit.utils import deprecate_func
|
33
34
|
|
34
35
|
|
35
36
|
class ParametricPulseShapes(Enum):
|
@@ -89,7 +90,7 @@ class InstructionToQobjConverter:
|
|
89
90
|
The transfer layer format must be the text representation that coforms to
|
90
91
|
the `OpenPulse specification<https://arxiv.org/abs/1809.03452>`__.
|
91
92
|
Extention to the OpenPulse can be achieved by subclassing this this with
|
92
|
-
extra methods corresponding to each
|
93
|
+
extra methods corresponding to each augmented instruction. For example,
|
93
94
|
|
94
95
|
.. code-block:: python
|
95
96
|
|
@@ -107,6 +108,14 @@ class InstructionToQobjConverter:
|
|
107
108
|
where ``NewInstruction`` must be a class name of Qiskit Pulse instruction.
|
108
109
|
"""
|
109
110
|
|
111
|
+
@deprecate_func(
|
112
|
+
since="1.2",
|
113
|
+
removal_timeline="in the 2.0 release",
|
114
|
+
additional_msg="The `Qobj` class and related functionality are part of the deprecated "
|
115
|
+
"`BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
|
116
|
+
"workflow requires `Qobj` it likely relies on deprecated functionality and "
|
117
|
+
"should be updated to use `BackendV2`.",
|
118
|
+
)
|
110
119
|
def __init__(
|
111
120
|
self,
|
112
121
|
qobj_model: PulseQobjInstruction,
|
@@ -503,7 +512,7 @@ class QobjToInstructionConverter:
|
|
503
512
|
The transfer layer format must be the text representation that coforms to
|
504
513
|
the `OpenPulse specification<https://arxiv.org/abs/1809.03452>`__.
|
505
514
|
Extention to the OpenPulse can be achieved by subclassing this this with
|
506
|
-
extra methods corresponding to each
|
515
|
+
extra methods corresponding to each augmented instruction. For example,
|
507
516
|
|
508
517
|
.. code-block:: python
|
509
518
|
|
@@ -621,7 +630,7 @@ class QobjToInstructionConverter:
|
|
621
630
|
elif prefix == channels.ControlChannel.prefix:
|
622
631
|
return channels.ControlChannel(index)
|
623
632
|
|
624
|
-
raise QiskitError("Channel
|
633
|
+
raise QiskitError(f"Channel {channel} is not valid")
|
625
634
|
|
626
635
|
@staticmethod
|
627
636
|
def disassemble_value(value_expr: Union[float, str]) -> Union[float, ParameterExpression]:
|
@@ -827,9 +836,7 @@ class QobjToInstructionConverter:
|
|
827
836
|
pulse_name = instruction.label
|
828
837
|
except AttributeError:
|
829
838
|
sorted_params = sorted(instruction.parameters.items(), key=lambda x: x[0])
|
830
|
-
base_str = "{
|
831
|
-
pulse=instruction.pulse_shape, params=str(sorted_params)
|
832
|
-
)
|
839
|
+
base_str = f"{instruction.pulse_shape}_{str(sorted_params)}"
|
833
840
|
short_pulse_id = hashlib.md5(base_str.encode("utf-8")).hexdigest()[:4]
|
834
841
|
pulse_name = f"{instruction.pulse_shape}_{short_pulse_id}"
|
835
842
|
params = dict(instruction.parameters)
|
qiskit/qobj/pulse_qobj.py
CHANGED
@@ -23,11 +23,20 @@ import numpy
|
|
23
23
|
from qiskit.qobj.common import QobjDictField
|
24
24
|
from qiskit.qobj.common import QobjHeader
|
25
25
|
from qiskit.qobj.common import QobjExperimentHeader
|
26
|
+
from qiskit.utils import deprecate_func
|
26
27
|
|
27
28
|
|
28
29
|
class QobjMeasurementOption:
|
29
30
|
"""An individual measurement option."""
|
30
31
|
|
32
|
+
@deprecate_func(
|
33
|
+
since="1.2",
|
34
|
+
removal_timeline="in the 2.0 release",
|
35
|
+
additional_msg="The `Qobj` class and related functionality are part of the deprecated "
|
36
|
+
"`BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
|
37
|
+
"workflow requires `Qobj` it likely relies on deprecated functionality and "
|
38
|
+
"should be updated to use `BackendV2`.",
|
39
|
+
)
|
31
40
|
def __init__(self, name, params=None):
|
32
41
|
"""Instantiate a new QobjMeasurementOption object.
|
33
42
|
|
@@ -89,6 +98,14 @@ class PulseQobjInstruction:
|
|
89
98
|
"parameters",
|
90
99
|
]
|
91
100
|
|
101
|
+
@deprecate_func(
|
102
|
+
since="1.2",
|
103
|
+
removal_timeline="in the 2.0 release",
|
104
|
+
additional_msg="The `Qobj` class and related functionality are part of the deprecated "
|
105
|
+
"`BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
|
106
|
+
"workflow requires `Qobj` it likely relies on deprecated functionality and "
|
107
|
+
"should be updated to use `BackendV2`.",
|
108
|
+
)
|
92
109
|
def __init__(
|
93
110
|
self,
|
94
111
|
name,
|
@@ -209,8 +226,8 @@ class PulseQobjInstruction:
|
|
209
226
|
return out
|
210
227
|
|
211
228
|
def __str__(self):
|
212
|
-
out = "Instruction:
|
213
|
-
out += "\t\tt0:
|
229
|
+
out = f"Instruction: {self.name}\n"
|
230
|
+
out += f"\t\tt0: {self.t0}\n"
|
214
231
|
for attr in self._COMMON_ATTRS:
|
215
232
|
if hasattr(self, attr):
|
216
233
|
out += f"\t\t{attr}: {getattr(self, attr)}\n"
|
@@ -282,6 +299,14 @@ def _to_complex(value: Union[List[float], complex]) -> complex:
|
|
282
299
|
class PulseQobjConfig(QobjDictField):
|
283
300
|
"""A configuration for a Pulse Qobj."""
|
284
301
|
|
302
|
+
@deprecate_func(
|
303
|
+
since="1.2",
|
304
|
+
removal_timeline="in the 2.0 release",
|
305
|
+
additional_msg="The `Qobj` class and related functionality are part of the deprecated "
|
306
|
+
"`BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
|
307
|
+
"workflow requires `Qobj` it likely relies on deprecated functionality and "
|
308
|
+
"should be updated to use `BackendV2`.",
|
309
|
+
)
|
285
310
|
def __init__(
|
286
311
|
self,
|
287
312
|
meas_level,
|
@@ -383,6 +408,14 @@ class PulseQobjExperiment:
|
|
383
408
|
experiment as part of a larger Pulse Qobj.
|
384
409
|
"""
|
385
410
|
|
411
|
+
@deprecate_func(
|
412
|
+
since="1.2",
|
413
|
+
removal_timeline="in the 2.0 release",
|
414
|
+
additional_msg="The `Qobj` class and related functionality are part of the deprecated "
|
415
|
+
"`BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
|
416
|
+
"workflow requires `Qobj` it likely relies on deprecated functionality and "
|
417
|
+
"should be updated to use `BackendV2`.",
|
418
|
+
)
|
386
419
|
def __init__(self, instructions, config=None, header=None):
|
387
420
|
"""Instantiate a PulseQobjExperiment.
|
388
421
|
|
@@ -434,10 +467,10 @@ class PulseQobjExperiment:
|
|
434
467
|
header = pprint.pformat(self.header.to_dict() or {})
|
435
468
|
else:
|
436
469
|
header = "{}"
|
437
|
-
out += "Header:\n
|
438
|
-
out += "Config:\n
|
470
|
+
out += f"Header:\n{header}\n"
|
471
|
+
out += f"Config:\n{config}\n\n"
|
439
472
|
for instruction in self.instructions:
|
440
|
-
out += "\t
|
473
|
+
out += f"\t{instruction}\n"
|
441
474
|
return out
|
442
475
|
|
443
476
|
@classmethod
|
@@ -473,6 +506,14 @@ class PulseQobjExperiment:
|
|
473
506
|
class PulseQobjExperimentConfig(QobjDictField):
|
474
507
|
"""A config for a single Pulse experiment in the qobj."""
|
475
508
|
|
509
|
+
@deprecate_func(
|
510
|
+
since="1.2",
|
511
|
+
removal_timeline="in the 2.0 release",
|
512
|
+
additional_msg="The `Qobj` class and related functionality are part of the deprecated "
|
513
|
+
"`BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
|
514
|
+
"workflow requires `Qobj` it likely relies on deprecated functionality and "
|
515
|
+
"should be updated to use `BackendV2`.",
|
516
|
+
)
|
476
517
|
def __init__(self, qubit_lo_freq=None, meas_lo_freq=None, **kwargs):
|
477
518
|
"""Instantiate a PulseQobjExperimentConfig object.
|
478
519
|
|
@@ -492,6 +533,14 @@ class PulseQobjExperimentConfig(QobjDictField):
|
|
492
533
|
class PulseLibraryItem:
|
493
534
|
"""An item in a pulse library."""
|
494
535
|
|
536
|
+
@deprecate_func(
|
537
|
+
since="1.2",
|
538
|
+
removal_timeline="in the 2.0 release",
|
539
|
+
additional_msg="The `Qobj` class and related functionality are part of the deprecated "
|
540
|
+
"`BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
|
541
|
+
"workflow requires `Qobj` it likely relies on deprecated functionality and "
|
542
|
+
"should be updated to use `BackendV2`.",
|
543
|
+
)
|
495
544
|
def __init__(self, name, samples):
|
496
545
|
"""Instantiate a pulse library item.
|
497
546
|
|
@@ -542,6 +591,14 @@ class PulseLibraryItem:
|
|
542
591
|
class PulseQobj:
|
543
592
|
"""A Pulse Qobj."""
|
544
593
|
|
594
|
+
@deprecate_func(
|
595
|
+
since="1.2",
|
596
|
+
removal_timeline="in the 2.0 release",
|
597
|
+
additional_msg="The `Qobj` class and related functionality are part of the deprecated "
|
598
|
+
"`BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
|
599
|
+
"workflow requires `Qobj` it likely relies on deprecated functionality and "
|
600
|
+
"should be updated to use `BackendV2`.",
|
601
|
+
)
|
545
602
|
def __init__(self, qobj_id, config, experiments, header=None):
|
546
603
|
"""Instantiate a new Pulse Qobj Object.
|
547
604
|
|
@@ -567,23 +624,20 @@ class PulseQobj:
|
|
567
624
|
def __repr__(self):
|
568
625
|
experiments_str = [repr(x) for x in self.experiments]
|
569
626
|
experiments_repr = "[" + ", ".join(experiments_str) + "]"
|
570
|
-
|
571
|
-
self.qobj_id,
|
572
|
-
repr(self.
|
573
|
-
experiments_repr,
|
574
|
-
repr(self.header),
|
627
|
+
return (
|
628
|
+
f"PulseQobj(qobj_id='{self.qobj_id}', config={repr(self.config)}, "
|
629
|
+
f"experiments={experiments_repr}, header={repr(self.header)})"
|
575
630
|
)
|
576
|
-
return out
|
577
631
|
|
578
632
|
def __str__(self):
|
579
|
-
out = "Pulse Qobj:
|
633
|
+
out = f"Pulse Qobj: {self.qobj_id}:\n"
|
580
634
|
config = pprint.pformat(self.config.to_dict())
|
581
|
-
out += "Config:
|
635
|
+
out += f"Config: {str(config)}\n"
|
582
636
|
header = pprint.pformat(self.header.to_dict())
|
583
|
-
out += "Header:
|
637
|
+
out += f"Header: {str(header)}\n"
|
584
638
|
out += "Experiments:\n"
|
585
639
|
for experiment in self.experiments:
|
586
|
-
out +=
|
640
|
+
out += str(experiment)
|
587
641
|
return out
|
588
642
|
|
589
643
|
def to_dict(self):
|
qiskit/qobj/qasm_qobj.py
CHANGED
@@ -18,11 +18,20 @@ from types import SimpleNamespace
|
|
18
18
|
from qiskit.circuit.parameterexpression import ParameterExpression
|
19
19
|
from qiskit.qobj.pulse_qobj import PulseQobjInstruction, PulseLibraryItem
|
20
20
|
from qiskit.qobj.common import QobjDictField, QobjHeader
|
21
|
+
from qiskit.utils import deprecate_func
|
21
22
|
|
22
23
|
|
23
24
|
class QasmQobjInstruction:
|
24
25
|
"""A class representing a single instruction in an QasmQobj Experiment."""
|
25
26
|
|
27
|
+
@deprecate_func(
|
28
|
+
since="1.2",
|
29
|
+
removal_timeline="in the 2.0 release",
|
30
|
+
additional_msg="The `Qobj` class and related functionality are part of the deprecated "
|
31
|
+
"`BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
|
32
|
+
"workflow requires `Qobj` it likely relies on deprecated functionality and "
|
33
|
+
"should be updated to use `BackendV2`.",
|
34
|
+
)
|
26
35
|
def __init__(
|
27
36
|
self,
|
28
37
|
name,
|
@@ -131,7 +140,7 @@ class QasmQobjInstruction:
|
|
131
140
|
return out_dict
|
132
141
|
|
133
142
|
def __repr__(self):
|
134
|
-
out = "QasmQobjInstruction(name='
|
143
|
+
out = f"QasmQobjInstruction(name='{self.name}'"
|
135
144
|
for attr in [
|
136
145
|
"params",
|
137
146
|
"qubits",
|
@@ -155,7 +164,7 @@ class QasmQobjInstruction:
|
|
155
164
|
return out
|
156
165
|
|
157
166
|
def __str__(self):
|
158
|
-
out = "Instruction:
|
167
|
+
out = f"Instruction: {self.name}\n"
|
159
168
|
for attr in [
|
160
169
|
"params",
|
161
170
|
"qubits",
|
@@ -200,6 +209,14 @@ class QasmQobjExperiment:
|
|
200
209
|
part of a larger OpenQASM 2 qobj.
|
201
210
|
"""
|
202
211
|
|
212
|
+
@deprecate_func(
|
213
|
+
since="1.2",
|
214
|
+
removal_timeline="in the 2.0 release",
|
215
|
+
additional_msg="The `Qobj` class and related functionality are part of the deprecated "
|
216
|
+
"`BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
|
217
|
+
"workflow requires `Qobj` it likely relies on deprecated functionality and "
|
218
|
+
"should be updated to use `BackendV2`.",
|
219
|
+
)
|
203
220
|
def __init__(self, config=None, header=None, instructions=None):
|
204
221
|
"""Instantiate a QasmQobjExperiment.
|
205
222
|
|
@@ -215,21 +232,19 @@ class QasmQobjExperiment:
|
|
215
232
|
def __repr__(self):
|
216
233
|
instructions_str = [repr(x) for x in self.instructions]
|
217
234
|
instructions_repr = "[" + ", ".join(instructions_str) + "]"
|
218
|
-
|
219
|
-
repr(self.config),
|
220
|
-
|
221
|
-
instructions_repr,
|
235
|
+
return (
|
236
|
+
f"QasmQobjExperiment(config={repr(self.config)}, header={repr(self.header)},"
|
237
|
+
f" instructions={instructions_repr})"
|
222
238
|
)
|
223
|
-
return out
|
224
239
|
|
225
240
|
def __str__(self):
|
226
241
|
out = "\nOpenQASM2 Experiment:\n"
|
227
242
|
config = pprint.pformat(self.config.to_dict())
|
228
243
|
header = pprint.pformat(self.header.to_dict())
|
229
|
-
out += "Header:\n
|
230
|
-
out += "Config:\n
|
244
|
+
out += f"Header:\n{header}\n"
|
245
|
+
out += f"Config:\n{config}\n\n"
|
231
246
|
for instruction in self.instructions:
|
232
|
-
out += "\t
|
247
|
+
out += f"\t{instruction}\n"
|
233
248
|
return out
|
234
249
|
|
235
250
|
def to_dict(self):
|
@@ -278,6 +293,14 @@ class QasmQobjExperiment:
|
|
278
293
|
class QasmQobjConfig(SimpleNamespace):
|
279
294
|
"""A configuration for an OpenQASM 2 Qobj."""
|
280
295
|
|
296
|
+
@deprecate_func(
|
297
|
+
since="1.2",
|
298
|
+
removal_timeline="in the 2.0 release",
|
299
|
+
additional_msg="The `Qobj` class and related functionality are part of the deprecated "
|
300
|
+
"`BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
|
301
|
+
"workflow requires `Qobj` it likely relies on deprecated functionality and "
|
302
|
+
"should be updated to use `BackendV2`.",
|
303
|
+
)
|
281
304
|
def __init__(
|
282
305
|
self,
|
283
306
|
shots=None,
|
@@ -412,6 +435,14 @@ class QasmQobjExperimentHeader(QobjDictField):
|
|
412
435
|
class QasmQobjExperimentConfig(QobjDictField):
|
413
436
|
"""Configuration for a single OpenQASM 2 experiment in the qobj."""
|
414
437
|
|
438
|
+
@deprecate_func(
|
439
|
+
since="1.2",
|
440
|
+
removal_timeline="in the 2.0 release",
|
441
|
+
additional_msg="The `Qobj` class and related functionality are part of the deprecated "
|
442
|
+
"`BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
|
443
|
+
"workflow requires `Qobj` it likely relies on deprecated functionality and "
|
444
|
+
"should be updated to use `BackendV2`.",
|
445
|
+
)
|
415
446
|
def __init__(self, calibrations=None, qubit_lo_freq=None, meas_lo_freq=None, **kwargs):
|
416
447
|
"""
|
417
448
|
Args:
|
@@ -448,6 +479,14 @@ class QasmExperimentCalibrations:
|
|
448
479
|
GateCalibrations.
|
449
480
|
"""
|
450
481
|
|
482
|
+
@deprecate_func(
|
483
|
+
since="1.2",
|
484
|
+
removal_timeline="in the 2.0 release",
|
485
|
+
additional_msg="The `Qobj` class and related functionality are part of the deprecated "
|
486
|
+
"`BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
|
487
|
+
"workflow requires `Qobj` it likely relies on deprecated functionality and "
|
488
|
+
"should be updated to use `BackendV2`.",
|
489
|
+
)
|
451
490
|
def __init__(self, gates):
|
452
491
|
"""
|
453
492
|
Initialize a container for calibrations.
|
@@ -488,6 +527,14 @@ class GateCalibration:
|
|
488
527
|
"""Each calibration specifies a unique gate by name, qubits and params, and
|
489
528
|
contains the Pulse instructions to implement it."""
|
490
529
|
|
530
|
+
@deprecate_func(
|
531
|
+
since="1.2",
|
532
|
+
removal_timeline="in the 2.0 release",
|
533
|
+
additional_msg="The `Qobj` class and related functionality are part of the deprecated "
|
534
|
+
"`BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
|
535
|
+
"workflow requires `Qobj` it likely relies on deprecated functionality and "
|
536
|
+
"should be updated to use `BackendV2`.",
|
537
|
+
)
|
491
538
|
def __init__(self, name, qubits, params, instructions):
|
492
539
|
"""
|
493
540
|
Initialize a single gate calibration. Instructions may reference waveforms which should be
|
@@ -543,6 +590,14 @@ class GateCalibration:
|
|
543
590
|
class QasmQobj:
|
544
591
|
"""An OpenQASM 2 Qobj."""
|
545
592
|
|
593
|
+
@deprecate_func(
|
594
|
+
since="1.2",
|
595
|
+
removal_timeline="in the 2.0 release",
|
596
|
+
additional_msg="The `Qobj` class and related functionality are part of the deprecated "
|
597
|
+
"`BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
|
598
|
+
"workflow requires `Qobj` it likely relies on deprecated functionality and "
|
599
|
+
"should be updated to use `BackendV2`.",
|
600
|
+
)
|
546
601
|
def __init__(self, qobj_id=None, config=None, experiments=None, header=None):
|
547
602
|
"""Instantiate a new OpenQASM 2 Qobj Object.
|
548
603
|
|
@@ -568,23 +623,20 @@ class QasmQobj:
|
|
568
623
|
def __repr__(self):
|
569
624
|
experiments_str = [repr(x) for x in self.experiments]
|
570
625
|
experiments_repr = "[" + ", ".join(experiments_str) + "]"
|
571
|
-
|
572
|
-
self.qobj_id,
|
573
|
-
repr(self.
|
574
|
-
experiments_repr,
|
575
|
-
repr(self.header),
|
626
|
+
return (
|
627
|
+
f"QasmQobj(qobj_id='{self.qobj_id}', config={repr(self.config)},"
|
628
|
+
f" experiments={experiments_repr}, header={repr(self.header)})"
|
576
629
|
)
|
577
|
-
return out
|
578
630
|
|
579
631
|
def __str__(self):
|
580
|
-
out = "QASM Qobj:
|
632
|
+
out = f"QASM Qobj: {self.qobj_id}:\n"
|
581
633
|
config = pprint.pformat(self.config.to_dict())
|
582
|
-
out += "Config:
|
634
|
+
out += f"Config: {str(config)}\n"
|
583
635
|
header = pprint.pformat(self.header.to_dict())
|
584
|
-
out += "Header:
|
636
|
+
out += f"Header: {str(header)}\n"
|
585
637
|
out += "Experiments:\n"
|
586
638
|
for experiment in self.experiments:
|
587
|
-
out +=
|
639
|
+
out += str(experiment)
|
588
640
|
return out
|
589
641
|
|
590
642
|
def to_dict(self):
|
qiskit/qobj/utils.py
CHANGED
@@ -14,7 +14,16 @@
|
|
14
14
|
|
15
15
|
from enum import Enum, IntEnum
|
16
16
|
|
17
|
+
from qiskit.utils import deprecate_func
|
17
18
|
|
19
|
+
|
20
|
+
@deprecate_func(
|
21
|
+
since="1.2",
|
22
|
+
removal_timeline="in the 2.0 release",
|
23
|
+
additional_msg="The `Qobj` class and related functionality are part of the deprecated `BackendV1` "
|
24
|
+
"workflow, and no longer necessary for `BackendV2`. If a user workflow requires `Qobj` it likely "
|
25
|
+
"relies on deprecated functionality and should be updated to use `BackendV2`.",
|
26
|
+
)
|
18
27
|
class QobjType(str, Enum):
|
19
28
|
"""Qobj.type allowed values."""
|
20
29
|
|
qiskit/qpy/__init__.py
CHANGED
@@ -774,7 +774,7 @@ In addition, new payload MAP_ITEM is defined to implement the :ref:`qpy_mapping`
|
|
774
774
|
|
775
775
|
With the support of :class:`.~ScheduleBlock`, now :class:`~.QuantumCircuit` can be
|
776
776
|
serialized together with :attr:`~.QuantumCircuit.calibrations`, or
|
777
|
-
`Pulse Gates <https://docs.quantum.ibm.com/
|
777
|
+
`Pulse Gates <https://docs.quantum.ibm.com/guides/pulse>`_.
|
778
778
|
In QPY version 5 and above, :ref:`qpy_circuit_calibrations` payload is
|
779
779
|
packed after the :ref:`qpy_instructions` block.
|
780
780
|
|
qiskit/qpy/binary_io/circuits.py
CHANGED
@@ -128,7 +128,7 @@ def _read_registers_v4(file_obj, num_registers):
|
|
128
128
|
)
|
129
129
|
)
|
130
130
|
name = file_obj.read(data.name_size).decode("utf8")
|
131
|
-
REGISTER_ARRAY_PACK = "
|
131
|
+
REGISTER_ARRAY_PACK = f"!{data.size}q"
|
132
132
|
bit_indices_raw = file_obj.read(struct.calcsize(REGISTER_ARRAY_PACK))
|
133
133
|
bit_indices = list(struct.unpack(REGISTER_ARRAY_PACK, bit_indices_raw))
|
134
134
|
if data.type.decode("utf8") == "q":
|
@@ -148,7 +148,7 @@ def _read_registers(file_obj, num_registers):
|
|
148
148
|
)
|
149
149
|
)
|
150
150
|
name = file_obj.read(data.name_size).decode("utf8")
|
151
|
-
REGISTER_ARRAY_PACK = "
|
151
|
+
REGISTER_ARRAY_PACK = f"!{data.size}I"
|
152
152
|
bit_indices_raw = file_obj.read(struct.calcsize(REGISTER_ARRAY_PACK))
|
153
153
|
bit_indices = list(struct.unpack(REGISTER_ARRAY_PACK, bit_indices_raw))
|
154
154
|
if data.type.decode("utf8") == "q":
|
@@ -352,7 +352,7 @@ def _read_instruction(
|
|
352
352
|
elif gate_name == "Clifford":
|
353
353
|
gate_class = Clifford
|
354
354
|
else:
|
355
|
-
raise AttributeError("Invalid instruction type:
|
355
|
+
raise AttributeError(f"Invalid instruction type: {gate_name}")
|
356
356
|
|
357
357
|
if instruction.label_size <= 0:
|
358
358
|
label = None
|
@@ -397,6 +397,8 @@ def _read_instruction(
|
|
397
397
|
"DiagonalGate",
|
398
398
|
}:
|
399
399
|
gate = gate_class(params)
|
400
|
+
elif gate_name == "QFTGate":
|
401
|
+
gate = gate_class(len(qargs), *params)
|
400
402
|
else:
|
401
403
|
if gate_name == "Barrier":
|
402
404
|
params = [len(qargs)]
|
@@ -446,6 +448,7 @@ def _parse_custom_operation(
|
|
446
448
|
) = custom_operations[gate_name]
|
447
449
|
else:
|
448
450
|
type_str, num_qubits, num_clbits, definition = custom_operations[gate_name]
|
451
|
+
base_gate_raw = ctrl_state = num_ctrl_qubits = None
|
449
452
|
# Strip the trailing "_{uuid}" from the gate name if the version >=11
|
450
453
|
if version >= 11:
|
451
454
|
gate_name = "_".join(gate_name.split("_")[:-1])
|
@@ -506,7 +509,7 @@ def _parse_custom_operation(
|
|
506
509
|
if type_key == type_keys.CircuitInstruction.PAULI_EVOL_GATE:
|
507
510
|
return definition
|
508
511
|
|
509
|
-
raise ValueError("Invalid custom instruction type '
|
512
|
+
raise ValueError(f"Invalid custom instruction type '{type_str}'")
|
510
513
|
|
511
514
|
|
512
515
|
def _read_pauli_evolution_gate(file_obj, version, vectors):
|
@@ -1030,7 +1033,7 @@ def _write_registers(file_obj, in_circ_regs, full_bits):
|
|
1030
1033
|
)
|
1031
1034
|
)
|
1032
1035
|
file_obj.write(reg_name)
|
1033
|
-
REGISTER_ARRAY_PACK = "
|
1036
|
+
REGISTER_ARRAY_PACK = f"!{reg.size}q"
|
1034
1037
|
bit_indices = []
|
1035
1038
|
for bit in reg:
|
1036
1039
|
bit_indices.append(bitmap.get(bit, -1))
|
@@ -522,7 +522,7 @@ def read_schedule_block(file_obj, version, metadata_deserializer=None, use_symen
|
|
522
522
|
metadata_deserializer (JSONDecoder): An optional JSONDecoder class
|
523
523
|
that will be used for the ``cls`` kwarg on the internal
|
524
524
|
``json.load`` call used to deserialize the JSON payload used for
|
525
|
-
the :attr:`.ScheduleBlock.metadata` attribute for a
|
525
|
+
the :attr:`.ScheduleBlock.metadata` attribute for a schedule block
|
526
526
|
in the file-like object. If this is not specified the circuit metadata will
|
527
527
|
be parsed as JSON with the stdlib ``json.load()`` function using
|
528
528
|
the default ``JSONDecoder`` class.
|
qiskit/qpy/binary_io/value.py
CHANGED
@@ -277,7 +277,7 @@ def _read_parameter_expression(file_obj):
|
|
277
277
|
elif elem_key == type_keys.Value.PARAMETER_EXPRESSION:
|
278
278
|
value = common.data_from_binary(binary_data, _read_parameter_expression)
|
279
279
|
else:
|
280
|
-
raise exceptions.QpyError("Invalid parameter expression map type:
|
280
|
+
raise exceptions.QpyError(f"Invalid parameter expression map type: {elem_key}")
|
281
281
|
symbol_map[symbol] = value
|
282
282
|
|
283
283
|
return ParameterExpression(symbol_map, expr_)
|
@@ -311,7 +311,7 @@ def _read_parameter_expression_v3(file_obj, vectors, use_symengine):
|
|
311
311
|
elif symbol_key == type_keys.Value.PARAMETER_VECTOR:
|
312
312
|
symbol = _read_parameter_vec(file_obj, vectors)
|
313
313
|
else:
|
314
|
-
raise exceptions.QpyError("Invalid parameter expression map type:
|
314
|
+
raise exceptions.QpyError(f"Invalid parameter expression map type: {symbol_key}")
|
315
315
|
|
316
316
|
elem_key = type_keys.Value(elem_data.type)
|
317
317
|
binary_data = file_obj.read(elem_data.size)
|
@@ -331,7 +331,7 @@ def _read_parameter_expression_v3(file_obj, vectors, use_symengine):
|
|
331
331
|
use_symengine=use_symengine,
|
332
332
|
)
|
333
333
|
else:
|
334
|
-
raise exceptions.QpyError("Invalid parameter expression map type:
|
334
|
+
raise exceptions.QpyError(f"Invalid parameter expression map type: {elem_key}")
|
335
335
|
symbol_map[symbol] = value
|
336
336
|
|
337
337
|
return ParameterExpression(symbol_map, expr_)
|
qiskit/qpy/interface.py
CHANGED
@@ -304,10 +304,11 @@ def load(
|
|
304
304
|
):
|
305
305
|
warnings.warn(
|
306
306
|
"The qiskit version used to generate the provided QPY "
|
307
|
-
"file,
|
307
|
+
f"file, {'.'.join([str(x) for x in qiskit_version])}, "
|
308
|
+
f"is newer than the current qiskit version {__version__}. "
|
308
309
|
"This may result in an error if the QPY file uses "
|
309
310
|
"instructions not present in this current qiskit "
|
310
|
-
"version"
|
311
|
+
"version"
|
311
312
|
)
|
312
313
|
|
313
314
|
if data.qpy_version < 5:
|
qiskit/qpy/type_keys.py
CHANGED
@@ -159,7 +159,7 @@ class Condition(IntEnum):
|
|
159
159
|
"""Type keys for the ``conditional_key`` field of the INSTRUCTION struct."""
|
160
160
|
|
161
161
|
# This class is deliberately raw integers and not in terms of ASCII characters for backwards
|
162
|
-
#
|
162
|
+
# compatibility in the form as an old Boolean value was expanded; `NONE` and `TWO_TUPLE` must
|
163
163
|
# have the enumeration values 0 and 1.
|
164
164
|
|
165
165
|
NONE = 0
|
@@ -276,7 +276,7 @@ class ScheduleInstruction(TypeKeyBase):
|
|
276
276
|
REFERENCE = b"y"
|
277
277
|
|
278
278
|
# 's' is reserved by ScheduleBlock, i.e. block can be nested as an element.
|
279
|
-
# Call
|
279
|
+
# Call instruction is not supported by QPY.
|
280
280
|
# This instruction has been excluded from ScheduleBlock instructions with
|
281
281
|
# qiskit-terra/#8005 and new instruction Reference will be added instead.
|
282
282
|
# Call is only applied to Schedule which is not supported by QPY.
|