qiskit 1.3.0__cp39-abi3-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qiskit/VERSION.txt +1 -0
- qiskit/__init__.py +146 -0
- qiskit/_accelerate.abi3.so +0 -0
- qiskit/_numpy_compat.py +73 -0
- qiskit/assembler/__init__.py +42 -0
- qiskit/assembler/assemble_circuits.py +451 -0
- qiskit/assembler/assemble_schedules.py +367 -0
- qiskit/assembler/disassemble.py +310 -0
- qiskit/assembler/run_config.py +77 -0
- qiskit/circuit/__init__.py +1313 -0
- qiskit/circuit/_classical_resource_map.py +148 -0
- qiskit/circuit/_standard_gates_commutations.py +3849 -0
- qiskit/circuit/_utils.py +167 -0
- qiskit/circuit/add_control.py +274 -0
- qiskit/circuit/annotated_operation.py +279 -0
- qiskit/circuit/barrier.py +50 -0
- qiskit/circuit/bit.py +94 -0
- qiskit/circuit/classical/__init__.py +41 -0
- qiskit/circuit/classical/expr/__init__.py +238 -0
- qiskit/circuit/classical/expr/constructors.py +556 -0
- qiskit/circuit/classical/expr/expr.py +397 -0
- qiskit/circuit/classical/expr/visitors.py +300 -0
- qiskit/circuit/classical/types/__init__.py +109 -0
- qiskit/circuit/classical/types/ordering.py +222 -0
- qiskit/circuit/classical/types/types.py +117 -0
- qiskit/circuit/classicalfunction/__init__.py +140 -0
- qiskit/circuit/classicalfunction/boolean_expression.py +129 -0
- qiskit/circuit/classicalfunction/classical_element.py +54 -0
- qiskit/circuit/classicalfunction/classical_function_visitor.py +155 -0
- qiskit/circuit/classicalfunction/classicalfunction.py +173 -0
- qiskit/circuit/classicalfunction/exceptions.py +35 -0
- qiskit/circuit/classicalfunction/types.py +18 -0
- qiskit/circuit/classicalfunction/utils.py +91 -0
- qiskit/circuit/classicalregister.py +57 -0
- qiskit/circuit/commutation_checker.py +106 -0
- qiskit/circuit/commutation_library.py +20 -0
- qiskit/circuit/controlflow/__init__.py +28 -0
- qiskit/circuit/controlflow/_builder_utils.py +207 -0
- qiskit/circuit/controlflow/break_loop.py +56 -0
- qiskit/circuit/controlflow/builder.py +691 -0
- qiskit/circuit/controlflow/continue_loop.py +58 -0
- qiskit/circuit/controlflow/control_flow.py +84 -0
- qiskit/circuit/controlflow/for_loop.py +217 -0
- qiskit/circuit/controlflow/if_else.py +511 -0
- qiskit/circuit/controlflow/switch_case.py +417 -0
- qiskit/circuit/controlflow/while_loop.py +171 -0
- qiskit/circuit/controlledgate.py +274 -0
- qiskit/circuit/delay.py +123 -0
- qiskit/circuit/duration.py +95 -0
- qiskit/circuit/equivalence.py +94 -0
- qiskit/circuit/equivalence_library.py +18 -0
- qiskit/circuit/exceptions.py +19 -0
- qiskit/circuit/gate.py +263 -0
- qiskit/circuit/instruction.py +697 -0
- qiskit/circuit/instructionset.py +179 -0
- qiskit/circuit/library/__init__.py +668 -0
- qiskit/circuit/library/arithmetic/__init__.py +34 -0
- qiskit/circuit/library/arithmetic/adders/__init__.py +18 -0
- qiskit/circuit/library/arithmetic/adders/adder.py +210 -0
- qiskit/circuit/library/arithmetic/adders/cdkm_ripple_carry_adder.py +123 -0
- qiskit/circuit/library/arithmetic/adders/draper_qft_adder.py +129 -0
- qiskit/circuit/library/arithmetic/adders/vbe_ripple_carry_adder.py +95 -0
- qiskit/circuit/library/arithmetic/exact_reciprocal.py +88 -0
- qiskit/circuit/library/arithmetic/functional_pauli_rotations.py +114 -0
- qiskit/circuit/library/arithmetic/integer_comparator.py +243 -0
- qiskit/circuit/library/arithmetic/linear_amplitude_function.py +196 -0
- qiskit/circuit/library/arithmetic/linear_pauli_rotations.py +189 -0
- qiskit/circuit/library/arithmetic/multipliers/__init__.py +17 -0
- qiskit/circuit/library/arithmetic/multipliers/hrs_cumulative_multiplier.py +145 -0
- qiskit/circuit/library/arithmetic/multipliers/multiplier.py +192 -0
- qiskit/circuit/library/arithmetic/multipliers/rg_qft_multiplier.py +108 -0
- qiskit/circuit/library/arithmetic/piecewise_chebyshev.py +353 -0
- qiskit/circuit/library/arithmetic/piecewise_linear_pauli_rotations.py +277 -0
- qiskit/circuit/library/arithmetic/piecewise_polynomial_pauli_rotations.py +317 -0
- qiskit/circuit/library/arithmetic/polynomial_pauli_rotations.py +335 -0
- qiskit/circuit/library/arithmetic/quadratic_form.py +198 -0
- qiskit/circuit/library/arithmetic/weighted_adder.py +337 -0
- qiskit/circuit/library/basis_change/__init__.py +15 -0
- qiskit/circuit/library/basis_change/qft.py +313 -0
- qiskit/circuit/library/blueprintcircuit.py +280 -0
- qiskit/circuit/library/boolean_logic/__init__.py +18 -0
- qiskit/circuit/library/boolean_logic/inner_product.py +155 -0
- qiskit/circuit/library/boolean_logic/quantum_and.py +200 -0
- qiskit/circuit/library/boolean_logic/quantum_or.py +202 -0
- qiskit/circuit/library/boolean_logic/quantum_xor.py +165 -0
- qiskit/circuit/library/data_preparation/__init__.py +57 -0
- qiskit/circuit/library/data_preparation/_z_feature_map.py +115 -0
- qiskit/circuit/library/data_preparation/_zz_feature_map.py +150 -0
- qiskit/circuit/library/data_preparation/initializer.py +107 -0
- qiskit/circuit/library/data_preparation/pauli_feature_map.py +656 -0
- qiskit/circuit/library/data_preparation/state_preparation.py +336 -0
- qiskit/circuit/library/fourier_checking.py +158 -0
- qiskit/circuit/library/generalized_gates/__init__.py +30 -0
- qiskit/circuit/library/generalized_gates/diagonal.py +159 -0
- qiskit/circuit/library/generalized_gates/gms.py +174 -0
- qiskit/circuit/library/generalized_gates/gr.py +215 -0
- qiskit/circuit/library/generalized_gates/isometry.py +370 -0
- qiskit/circuit/library/generalized_gates/linear_function.py +318 -0
- qiskit/circuit/library/generalized_gates/mcg_up_to_diagonal.py +143 -0
- qiskit/circuit/library/generalized_gates/mcmt.py +316 -0
- qiskit/circuit/library/generalized_gates/pauli.py +85 -0
- qiskit/circuit/library/generalized_gates/permutation.py +194 -0
- qiskit/circuit/library/generalized_gates/rv.py +96 -0
- qiskit/circuit/library/generalized_gates/uc.py +213 -0
- qiskit/circuit/library/generalized_gates/uc_pauli_rot.py +164 -0
- qiskit/circuit/library/generalized_gates/ucrx.py +32 -0
- qiskit/circuit/library/generalized_gates/ucry.py +32 -0
- qiskit/circuit/library/generalized_gates/ucrz.py +32 -0
- qiskit/circuit/library/generalized_gates/unitary.py +215 -0
- qiskit/circuit/library/graph_state.py +169 -0
- qiskit/circuit/library/grover_operator.py +579 -0
- qiskit/circuit/library/hamiltonian_gate.py +142 -0
- qiskit/circuit/library/hidden_linear_function.py +161 -0
- qiskit/circuit/library/iqp.py +175 -0
- qiskit/circuit/library/n_local/__init__.py +45 -0
- qiskit/circuit/library/n_local/efficient_su2.py +277 -0
- qiskit/circuit/library/n_local/evolved_operator_ansatz.py +515 -0
- qiskit/circuit/library/n_local/excitation_preserving.py +297 -0
- qiskit/circuit/library/n_local/n_local.py +1472 -0
- qiskit/circuit/library/n_local/pauli_two_design.py +243 -0
- qiskit/circuit/library/n_local/qaoa_ansatz.py +366 -0
- qiskit/circuit/library/n_local/real_amplitudes.py +306 -0
- qiskit/circuit/library/n_local/two_local.py +289 -0
- qiskit/circuit/library/overlap.py +182 -0
- qiskit/circuit/library/pauli_evolution.py +186 -0
- qiskit/circuit/library/phase_estimation.py +175 -0
- qiskit/circuit/library/phase_oracle.py +153 -0
- qiskit/circuit/library/quantum_volume.py +167 -0
- qiskit/circuit/library/standard_gates/__init__.py +142 -0
- qiskit/circuit/library/standard_gates/dcx.py +78 -0
- qiskit/circuit/library/standard_gates/ecr.py +130 -0
- qiskit/circuit/library/standard_gates/equivalence_library.py +1800 -0
- qiskit/circuit/library/standard_gates/global_phase.py +85 -0
- qiskit/circuit/library/standard_gates/h.py +258 -0
- qiskit/circuit/library/standard_gates/i.py +76 -0
- qiskit/circuit/library/standard_gates/iswap.py +134 -0
- qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py +405 -0
- qiskit/circuit/library/standard_gates/p.py +441 -0
- qiskit/circuit/library/standard_gates/r.py +117 -0
- qiskit/circuit/library/standard_gates/rx.py +303 -0
- qiskit/circuit/library/standard_gates/rxx.py +183 -0
- qiskit/circuit/library/standard_gates/ry.py +298 -0
- qiskit/circuit/library/standard_gates/ryy.py +183 -0
- qiskit/circuit/library/standard_gates/rz.py +319 -0
- qiskit/circuit/library/standard_gates/rzx.py +229 -0
- qiskit/circuit/library/standard_gates/rzz.py +196 -0
- qiskit/circuit/library/standard_gates/s.py +428 -0
- qiskit/circuit/library/standard_gates/swap.py +288 -0
- qiskit/circuit/library/standard_gates/sx.py +315 -0
- qiskit/circuit/library/standard_gates/t.py +179 -0
- qiskit/circuit/library/standard_gates/u.py +403 -0
- qiskit/circuit/library/standard_gates/u1.py +501 -0
- qiskit/circuit/library/standard_gates/u2.py +149 -0
- qiskit/circuit/library/standard_gates/u3.py +436 -0
- qiskit/circuit/library/standard_gates/x.py +1529 -0
- qiskit/circuit/library/standard_gates/xx_minus_yy.py +235 -0
- qiskit/circuit/library/standard_gates/xx_plus_yy.py +239 -0
- qiskit/circuit/library/standard_gates/y.py +262 -0
- qiskit/circuit/library/standard_gates/z.py +348 -0
- qiskit/circuit/library/templates/__init__.py +92 -0
- qiskit/circuit/library/templates/clifford/__init__.py +33 -0
- qiskit/circuit/library/templates/clifford/clifford_2_1.py +34 -0
- qiskit/circuit/library/templates/clifford/clifford_2_2.py +35 -0
- qiskit/circuit/library/templates/clifford/clifford_2_3.py +34 -0
- qiskit/circuit/library/templates/clifford/clifford_2_4.py +34 -0
- qiskit/circuit/library/templates/clifford/clifford_3_1.py +35 -0
- qiskit/circuit/library/templates/clifford/clifford_4_1.py +38 -0
- qiskit/circuit/library/templates/clifford/clifford_4_2.py +37 -0
- qiskit/circuit/library/templates/clifford/clifford_4_3.py +38 -0
- qiskit/circuit/library/templates/clifford/clifford_4_4.py +37 -0
- qiskit/circuit/library/templates/clifford/clifford_5_1.py +40 -0
- qiskit/circuit/library/templates/clifford/clifford_6_1.py +40 -0
- qiskit/circuit/library/templates/clifford/clifford_6_2.py +40 -0
- qiskit/circuit/library/templates/clifford/clifford_6_3.py +40 -0
- qiskit/circuit/library/templates/clifford/clifford_6_4.py +38 -0
- qiskit/circuit/library/templates/clifford/clifford_6_5.py +40 -0
- qiskit/circuit/library/templates/clifford/clifford_8_1.py +42 -0
- qiskit/circuit/library/templates/clifford/clifford_8_2.py +42 -0
- qiskit/circuit/library/templates/clifford/clifford_8_3.py +41 -0
- qiskit/circuit/library/templates/nct/__init__.py +67 -0
- qiskit/circuit/library/templates/nct/template_nct_2a_1.py +34 -0
- qiskit/circuit/library/templates/nct/template_nct_2a_2.py +35 -0
- qiskit/circuit/library/templates/nct/template_nct_2a_3.py +37 -0
- qiskit/circuit/library/templates/nct/template_nct_4a_1.py +43 -0
- qiskit/circuit/library/templates/nct/template_nct_4a_2.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_4a_3.py +39 -0
- qiskit/circuit/library/templates/nct/template_nct_4b_1.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_4b_2.py +39 -0
- qiskit/circuit/library/templates/nct/template_nct_5a_1.py +40 -0
- qiskit/circuit/library/templates/nct/template_nct_5a_2.py +40 -0
- qiskit/circuit/library/templates/nct/template_nct_5a_3.py +40 -0
- qiskit/circuit/library/templates/nct/template_nct_5a_4.py +39 -0
- qiskit/circuit/library/templates/nct/template_nct_6a_1.py +40 -0
- qiskit/circuit/library/templates/nct/template_nct_6a_2.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_6a_3.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_6a_4.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_6b_1.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_6b_2.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_6c_1.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_7a_1.py +43 -0
- qiskit/circuit/library/templates/nct/template_nct_7b_1.py +43 -0
- qiskit/circuit/library/templates/nct/template_nct_7c_1.py +43 -0
- qiskit/circuit/library/templates/nct/template_nct_7d_1.py +43 -0
- qiskit/circuit/library/templates/nct/template_nct_7e_1.py +43 -0
- qiskit/circuit/library/templates/nct/template_nct_9a_1.py +45 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_1.py +43 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_10.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_11.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_12.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_2.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_3.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_4.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_5.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_6.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_7.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_8.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_9.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_1.py +43 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_10.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_2.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_3.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_4.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_5.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_6.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_7.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_8.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_9.py +44 -0
- qiskit/circuit/library/templates/rzx/__init__.py +25 -0
- qiskit/circuit/library/templates/rzx/rzx_cy.py +47 -0
- qiskit/circuit/library/templates/rzx/rzx_xz.py +54 -0
- qiskit/circuit/library/templates/rzx/rzx_yz.py +45 -0
- qiskit/circuit/library/templates/rzx/rzx_zz1.py +69 -0
- qiskit/circuit/library/templates/rzx/rzx_zz2.py +59 -0
- qiskit/circuit/library/templates/rzx/rzx_zz3.py +59 -0
- qiskit/circuit/measure.py +44 -0
- qiskit/circuit/operation.py +67 -0
- qiskit/circuit/parameter.py +178 -0
- qiskit/circuit/parameterexpression.py +692 -0
- qiskit/circuit/parametertable.py +119 -0
- qiskit/circuit/parametervector.py +120 -0
- qiskit/circuit/quantumcircuit.py +6829 -0
- qiskit/circuit/quantumcircuitdata.py +136 -0
- qiskit/circuit/quantumregister.py +75 -0
- qiskit/circuit/random/__init__.py +15 -0
- qiskit/circuit/random/utils.py +358 -0
- qiskit/circuit/register.py +233 -0
- qiskit/circuit/reset.py +34 -0
- qiskit/circuit/singleton.py +606 -0
- qiskit/circuit/store.py +97 -0
- qiskit/circuit/tools/__init__.py +16 -0
- qiskit/circuit/tools/pi_check.py +190 -0
- qiskit/circuit/twirling.py +145 -0
- qiskit/compiler/__init__.py +33 -0
- qiskit/compiler/assembler.py +681 -0
- qiskit/compiler/scheduler.py +109 -0
- qiskit/compiler/sequencer.py +71 -0
- qiskit/compiler/transpiler.py +533 -0
- qiskit/converters/__init__.py +74 -0
- qiskit/converters/circuit_to_dag.py +78 -0
- qiskit/converters/circuit_to_dagdependency.py +51 -0
- qiskit/converters/circuit_to_dagdependency_v2.py +47 -0
- qiskit/converters/circuit_to_gate.py +107 -0
- qiskit/converters/circuit_to_instruction.py +155 -0
- qiskit/converters/dag_to_circuit.py +79 -0
- qiskit/converters/dag_to_dagdependency.py +55 -0
- qiskit/converters/dag_to_dagdependency_v2.py +44 -0
- qiskit/converters/dagdependency_to_circuit.py +46 -0
- qiskit/converters/dagdependency_to_dag.py +54 -0
- qiskit/dagcircuit/__init__.py +44 -0
- qiskit/dagcircuit/collect_blocks.py +391 -0
- qiskit/dagcircuit/dagcircuit.py +24 -0
- qiskit/dagcircuit/dagdependency.py +646 -0
- qiskit/dagcircuit/dagdependency_v2.py +641 -0
- qiskit/dagcircuit/dagdepnode.py +160 -0
- qiskit/dagcircuit/dagnode.py +176 -0
- qiskit/dagcircuit/exceptions.py +42 -0
- qiskit/exceptions.py +153 -0
- qiskit/passmanager/__init__.py +240 -0
- qiskit/passmanager/base_tasks.py +230 -0
- qiskit/passmanager/compilation_status.py +74 -0
- qiskit/passmanager/exceptions.py +19 -0
- qiskit/passmanager/flow_controllers.py +116 -0
- qiskit/passmanager/passmanager.py +333 -0
- qiskit/primitives/__init__.py +481 -0
- qiskit/primitives/backend_estimator.py +486 -0
- qiskit/primitives/backend_estimator_v2.py +434 -0
- qiskit/primitives/backend_sampler.py +222 -0
- qiskit/primitives/backend_sampler_v2.py +339 -0
- qiskit/primitives/base/__init__.py +20 -0
- qiskit/primitives/base/base_estimator.py +252 -0
- qiskit/primitives/base/base_primitive.py +45 -0
- qiskit/primitives/base/base_primitive_job.py +78 -0
- qiskit/primitives/base/base_result.py +65 -0
- qiskit/primitives/base/base_sampler.py +204 -0
- qiskit/primitives/base/estimator_result.py +46 -0
- qiskit/primitives/base/sampler_result.py +45 -0
- qiskit/primitives/base/validation.py +231 -0
- qiskit/primitives/containers/__init__.py +26 -0
- qiskit/primitives/containers/bindings_array.py +389 -0
- qiskit/primitives/containers/bit_array.py +741 -0
- qiskit/primitives/containers/data_bin.py +173 -0
- qiskit/primitives/containers/estimator_pub.py +222 -0
- qiskit/primitives/containers/object_array.py +94 -0
- qiskit/primitives/containers/observables_array.py +279 -0
- qiskit/primitives/containers/primitive_result.py +53 -0
- qiskit/primitives/containers/pub_result.py +51 -0
- qiskit/primitives/containers/sampler_pub.py +193 -0
- qiskit/primitives/containers/sampler_pub_result.py +74 -0
- qiskit/primitives/containers/shape.py +129 -0
- qiskit/primitives/estimator.py +172 -0
- qiskit/primitives/primitive_job.py +81 -0
- qiskit/primitives/sampler.py +162 -0
- qiskit/primitives/statevector_estimator.py +174 -0
- qiskit/primitives/statevector_sampler.py +292 -0
- qiskit/primitives/utils.py +247 -0
- qiskit/providers/__init__.py +803 -0
- qiskit/providers/backend.py +667 -0
- qiskit/providers/backend_compat.py +472 -0
- qiskit/providers/basic_provider/__init__.py +45 -0
- qiskit/providers/basic_provider/basic_provider.py +101 -0
- qiskit/providers/basic_provider/basic_provider_job.py +65 -0
- qiskit/providers/basic_provider/basic_provider_tools.py +218 -0
- qiskit/providers/basic_provider/basic_simulator.py +821 -0
- qiskit/providers/basic_provider/exceptions.py +30 -0
- qiskit/providers/exceptions.py +45 -0
- qiskit/providers/fake_provider/__init__.py +105 -0
- qiskit/providers/fake_provider/backends_v1/__init__.py +22 -0
- qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/__init__.py +18 -0
- qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/conf_washington.json +1 -0
- qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/defs_washington.json +1 -0
- qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/fake_127q_pulse_v1.py +37 -0
- qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/props_washington.json +1 -0
- qiskit/providers/fake_provider/backends_v1/fake_20q/__init__.py +18 -0
- qiskit/providers/fake_provider/backends_v1/fake_20q/conf_singapore.json +1 -0
- qiskit/providers/fake_provider/backends_v1/fake_20q/fake_20q.py +43 -0
- qiskit/providers/fake_provider/backends_v1/fake_20q/props_singapore.json +1 -0
- qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/__init__.py +18 -0
- qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/conf_hanoi.json +1 -0
- qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/defs_hanoi.json +1 -0
- qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/fake_27q_pulse_v1.py +50 -0
- qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/props_hanoi.json +1 -0
- qiskit/providers/fake_provider/backends_v1/fake_5q/__init__.py +18 -0
- qiskit/providers/fake_provider/backends_v1/fake_5q/conf_yorktown.json +1 -0
- qiskit/providers/fake_provider/backends_v1/fake_5q/fake_5q_v1.py +41 -0
- qiskit/providers/fake_provider/backends_v1/fake_5q/props_yorktown.json +1 -0
- qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/__init__.py +18 -0
- qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/conf_nairobi.json +1 -0
- qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/defs_nairobi.json +1 -0
- qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/fake_7q_pulse_v1.py +44 -0
- qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/props_nairobi.json +1 -0
- qiskit/providers/fake_provider/fake_1q.py +91 -0
- qiskit/providers/fake_provider/fake_backend.py +165 -0
- qiskit/providers/fake_provider/fake_openpulse_2q.py +391 -0
- qiskit/providers/fake_provider/fake_openpulse_3q.py +340 -0
- qiskit/providers/fake_provider/fake_pulse_backend.py +49 -0
- qiskit/providers/fake_provider/fake_qasm_backend.py +77 -0
- qiskit/providers/fake_provider/generic_backend_v2.py +1035 -0
- qiskit/providers/fake_provider/utils/__init__.py +15 -0
- qiskit/providers/fake_provider/utils/backend_converter.py +150 -0
- qiskit/providers/fake_provider/utils/json_decoder.py +109 -0
- qiskit/providers/job.py +147 -0
- qiskit/providers/jobstatus.py +30 -0
- qiskit/providers/models/__init__.py +89 -0
- qiskit/providers/models/backendconfiguration.py +1040 -0
- qiskit/providers/models/backendproperties.py +517 -0
- qiskit/providers/models/backendstatus.py +94 -0
- qiskit/providers/models/jobstatus.py +66 -0
- qiskit/providers/models/pulsedefaults.py +305 -0
- qiskit/providers/options.py +273 -0
- qiskit/providers/provider.py +95 -0
- qiskit/providers/providerutils.py +110 -0
- qiskit/pulse/__init__.py +158 -0
- qiskit/pulse/builder.py +2254 -0
- qiskit/pulse/calibration_entries.py +381 -0
- qiskit/pulse/channels.py +227 -0
- qiskit/pulse/configuration.py +245 -0
- qiskit/pulse/exceptions.py +45 -0
- qiskit/pulse/filters.py +309 -0
- qiskit/pulse/instruction_schedule_map.py +424 -0
- qiskit/pulse/instructions/__init__.py +67 -0
- qiskit/pulse/instructions/acquire.py +150 -0
- qiskit/pulse/instructions/delay.py +71 -0
- qiskit/pulse/instructions/directives.py +154 -0
- qiskit/pulse/instructions/frequency.py +135 -0
- qiskit/pulse/instructions/instruction.py +270 -0
- qiskit/pulse/instructions/phase.py +152 -0
- qiskit/pulse/instructions/play.py +99 -0
- qiskit/pulse/instructions/reference.py +100 -0
- qiskit/pulse/instructions/snapshot.py +82 -0
- qiskit/pulse/library/__init__.py +97 -0
- qiskit/pulse/library/continuous.py +430 -0
- qiskit/pulse/library/pulse.py +148 -0
- qiskit/pulse/library/samplers/__init__.py +15 -0
- qiskit/pulse/library/samplers/decorators.py +295 -0
- qiskit/pulse/library/samplers/strategies.py +71 -0
- qiskit/pulse/library/symbolic_pulses.py +1988 -0
- qiskit/pulse/library/waveform.py +136 -0
- qiskit/pulse/macros.py +262 -0
- qiskit/pulse/parameter_manager.py +445 -0
- qiskit/pulse/parser.py +314 -0
- qiskit/pulse/reference_manager.py +58 -0
- qiskit/pulse/schedule.py +1854 -0
- qiskit/pulse/transforms/__init__.py +106 -0
- qiskit/pulse/transforms/alignments.py +406 -0
- qiskit/pulse/transforms/base_transforms.py +71 -0
- qiskit/pulse/transforms/canonicalization.py +498 -0
- qiskit/pulse/transforms/dag.py +122 -0
- qiskit/pulse/utils.py +149 -0
- qiskit/qasm/libs/dummy/stdgates.inc +75 -0
- qiskit/qasm/libs/qelib1.inc +266 -0
- qiskit/qasm/libs/stdgates.inc +82 -0
- qiskit/qasm2/__init__.py +654 -0
- qiskit/qasm2/exceptions.py +27 -0
- qiskit/qasm2/export.py +372 -0
- qiskit/qasm2/parse.py +452 -0
- qiskit/qasm3/__init__.py +367 -0
- qiskit/qasm3/ast.py +738 -0
- qiskit/qasm3/exceptions.py +27 -0
- qiskit/qasm3/experimental.py +70 -0
- qiskit/qasm3/exporter.py +1299 -0
- qiskit/qasm3/printer.py +577 -0
- qiskit/qobj/__init__.py +75 -0
- qiskit/qobj/common.py +81 -0
- qiskit/qobj/converters/__init__.py +18 -0
- qiskit/qobj/converters/lo_config.py +177 -0
- qiskit/qobj/converters/pulse_instruction.py +897 -0
- qiskit/qobj/pulse_qobj.py +709 -0
- qiskit/qobj/qasm_qobj.py +708 -0
- qiskit/qobj/utils.py +46 -0
- qiskit/qpy/__init__.py +1822 -0
- qiskit/qpy/binary_io/__init__.py +36 -0
- qiskit/qpy/binary_io/circuits.py +1475 -0
- qiskit/qpy/binary_io/schedules.py +635 -0
- qiskit/qpy/binary_io/value.py +1025 -0
- qiskit/qpy/common.py +350 -0
- qiskit/qpy/exceptions.py +53 -0
- qiskit/qpy/formats.py +401 -0
- qiskit/qpy/interface.py +377 -0
- qiskit/qpy/type_keys.py +572 -0
- qiskit/quantum_info/__init__.py +162 -0
- qiskit/quantum_info/analysis/__init__.py +17 -0
- qiskit/quantum_info/analysis/average.py +47 -0
- qiskit/quantum_info/analysis/distance.py +102 -0
- qiskit/quantum_info/analysis/make_observable.py +44 -0
- qiskit/quantum_info/analysis/z2_symmetries.py +484 -0
- qiskit/quantum_info/operators/__init__.py +28 -0
- qiskit/quantum_info/operators/base_operator.py +145 -0
- qiskit/quantum_info/operators/channel/__init__.py +29 -0
- qiskit/quantum_info/operators/channel/chi.py +191 -0
- qiskit/quantum_info/operators/channel/choi.py +218 -0
- qiskit/quantum_info/operators/channel/kraus.py +337 -0
- qiskit/quantum_info/operators/channel/ptm.py +204 -0
- qiskit/quantum_info/operators/channel/quantum_channel.py +348 -0
- qiskit/quantum_info/operators/channel/stinespring.py +296 -0
- qiskit/quantum_info/operators/channel/superop.py +377 -0
- qiskit/quantum_info/operators/channel/transformations.py +475 -0
- qiskit/quantum_info/operators/custom_iterator.py +48 -0
- qiskit/quantum_info/operators/dihedral/__init__.py +18 -0
- qiskit/quantum_info/operators/dihedral/dihedral.py +509 -0
- qiskit/quantum_info/operators/dihedral/dihedral_circuits.py +216 -0
- qiskit/quantum_info/operators/dihedral/polynomial.py +313 -0
- qiskit/quantum_info/operators/dihedral/random.py +64 -0
- qiskit/quantum_info/operators/linear_op.py +25 -0
- qiskit/quantum_info/operators/measures.py +418 -0
- qiskit/quantum_info/operators/mixins/__init__.py +52 -0
- qiskit/quantum_info/operators/mixins/adjoint.py +52 -0
- qiskit/quantum_info/operators/mixins/group.py +171 -0
- qiskit/quantum_info/operators/mixins/linear.py +84 -0
- qiskit/quantum_info/operators/mixins/multiply.py +62 -0
- qiskit/quantum_info/operators/mixins/tolerances.py +72 -0
- qiskit/quantum_info/operators/op_shape.py +525 -0
- qiskit/quantum_info/operators/operator.py +865 -0
- qiskit/quantum_info/operators/operator_utils.py +76 -0
- qiskit/quantum_info/operators/predicates.py +183 -0
- qiskit/quantum_info/operators/random.py +154 -0
- qiskit/quantum_info/operators/scalar_op.py +254 -0
- qiskit/quantum_info/operators/symplectic/__init__.py +23 -0
- qiskit/quantum_info/operators/symplectic/base_pauli.py +719 -0
- qiskit/quantum_info/operators/symplectic/clifford.py +1030 -0
- qiskit/quantum_info/operators/symplectic/clifford_circuits.py +558 -0
- qiskit/quantum_info/operators/symplectic/pauli.py +753 -0
- qiskit/quantum_info/operators/symplectic/pauli_list.py +1230 -0
- qiskit/quantum_info/operators/symplectic/pauli_utils.py +40 -0
- qiskit/quantum_info/operators/symplectic/random.py +117 -0
- qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +1196 -0
- qiskit/quantum_info/operators/utils/__init__.py +20 -0
- qiskit/quantum_info/operators/utils/anti_commutator.py +36 -0
- qiskit/quantum_info/operators/utils/commutator.py +36 -0
- qiskit/quantum_info/operators/utils/double_commutator.py +76 -0
- qiskit/quantum_info/quaternion.py +156 -0
- qiskit/quantum_info/random.py +26 -0
- qiskit/quantum_info/states/__init__.py +28 -0
- qiskit/quantum_info/states/densitymatrix.py +845 -0
- qiskit/quantum_info/states/measures.py +288 -0
- qiskit/quantum_info/states/quantum_state.py +503 -0
- qiskit/quantum_info/states/random.py +157 -0
- qiskit/quantum_info/states/stabilizerstate.py +773 -0
- qiskit/quantum_info/states/statevector.py +958 -0
- qiskit/quantum_info/states/utils.py +247 -0
- qiskit/result/__init__.py +73 -0
- qiskit/result/counts.py +189 -0
- qiskit/result/distributions/__init__.py +17 -0
- qiskit/result/distributions/probability.py +100 -0
- qiskit/result/distributions/quasi.py +154 -0
- qiskit/result/exceptions.py +40 -0
- qiskit/result/mitigation/__init__.py +13 -0
- qiskit/result/mitigation/base_readout_mitigator.py +79 -0
- qiskit/result/mitigation/correlated_readout_mitigator.py +277 -0
- qiskit/result/mitigation/local_readout_mitigator.py +328 -0
- qiskit/result/mitigation/utils.py +217 -0
- qiskit/result/models.py +234 -0
- qiskit/result/postprocess.py +239 -0
- qiskit/result/result.py +392 -0
- qiskit/result/sampled_expval.py +75 -0
- qiskit/result/utils.py +295 -0
- qiskit/scheduler/__init__.py +40 -0
- qiskit/scheduler/config.py +37 -0
- qiskit/scheduler/lowering.py +187 -0
- qiskit/scheduler/methods/__init__.py +15 -0
- qiskit/scheduler/methods/basic.py +140 -0
- qiskit/scheduler/schedule_circuit.py +69 -0
- qiskit/scheduler/sequence.py +104 -0
- qiskit/synthesis/__init__.py +220 -0
- qiskit/synthesis/arithmetic/__init__.py +16 -0
- qiskit/synthesis/arithmetic/adders/__init__.py +17 -0
- qiskit/synthesis/arithmetic/adders/cdkm_ripple_carry_adder.py +154 -0
- qiskit/synthesis/arithmetic/adders/draper_qft_adder.py +103 -0
- qiskit/synthesis/arithmetic/adders/vbe_ripple_carry_adder.py +161 -0
- qiskit/synthesis/arithmetic/multipliers/__init__.py +16 -0
- qiskit/synthesis/arithmetic/multipliers/hrs_cumulative_multiplier.py +102 -0
- qiskit/synthesis/arithmetic/multipliers/rg_qft_multiplier.py +99 -0
- qiskit/synthesis/clifford/__init__.py +19 -0
- qiskit/synthesis/clifford/clifford_decompose_ag.py +178 -0
- qiskit/synthesis/clifford/clifford_decompose_bm.py +46 -0
- qiskit/synthesis/clifford/clifford_decompose_full.py +64 -0
- qiskit/synthesis/clifford/clifford_decompose_greedy.py +58 -0
- qiskit/synthesis/clifford/clifford_decompose_layers.py +447 -0
- qiskit/synthesis/cnotdihedral/__init__.py +17 -0
- qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_full.py +52 -0
- qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_general.py +141 -0
- qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_two_qubits.py +266 -0
- qiskit/synthesis/discrete_basis/__init__.py +16 -0
- qiskit/synthesis/discrete_basis/commutator_decompose.py +241 -0
- qiskit/synthesis/discrete_basis/gate_sequence.py +415 -0
- qiskit/synthesis/discrete_basis/generate_basis_approximations.py +163 -0
- qiskit/synthesis/discrete_basis/solovay_kitaev.py +217 -0
- qiskit/synthesis/evolution/__init__.py +21 -0
- qiskit/synthesis/evolution/evolution_synthesis.py +48 -0
- qiskit/synthesis/evolution/lie_trotter.py +117 -0
- qiskit/synthesis/evolution/matrix_synthesis.py +47 -0
- qiskit/synthesis/evolution/pauli_network.py +80 -0
- qiskit/synthesis/evolution/product_formula.py +311 -0
- qiskit/synthesis/evolution/qdrift.py +138 -0
- qiskit/synthesis/evolution/suzuki_trotter.py +215 -0
- qiskit/synthesis/linear/__init__.py +26 -0
- qiskit/synthesis/linear/cnot_synth.py +69 -0
- qiskit/synthesis/linear/linear_circuits_utils.py +128 -0
- qiskit/synthesis/linear/linear_depth_lnn.py +276 -0
- qiskit/synthesis/linear/linear_matrix_utils.py +27 -0
- qiskit/synthesis/linear_phase/__init__.py +17 -0
- qiskit/synthesis/linear_phase/cnot_phase_synth.py +206 -0
- qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py +262 -0
- qiskit/synthesis/linear_phase/cz_depth_lnn.py +58 -0
- qiskit/synthesis/multi_controlled/__init__.py +24 -0
- qiskit/synthesis/multi_controlled/mcmt_vchain.py +52 -0
- qiskit/synthesis/multi_controlled/mcx_synthesis.py +356 -0
- qiskit/synthesis/one_qubit/__init__.py +15 -0
- qiskit/synthesis/one_qubit/one_qubit_decompose.py +288 -0
- qiskit/synthesis/permutation/__init__.py +18 -0
- qiskit/synthesis/permutation/permutation_full.py +78 -0
- qiskit/synthesis/permutation/permutation_lnn.py +54 -0
- qiskit/synthesis/permutation/permutation_reverse_lnn.py +93 -0
- qiskit/synthesis/permutation/permutation_utils.py +16 -0
- qiskit/synthesis/qft/__init__.py +16 -0
- qiskit/synthesis/qft/qft_decompose_full.py +97 -0
- qiskit/synthesis/qft/qft_decompose_lnn.py +79 -0
- qiskit/synthesis/stabilizer/__init__.py +16 -0
- qiskit/synthesis/stabilizer/stabilizer_circuit.py +149 -0
- qiskit/synthesis/stabilizer/stabilizer_decompose.py +194 -0
- qiskit/synthesis/two_qubit/__init__.py +19 -0
- qiskit/synthesis/two_qubit/local_invariance.py +63 -0
- qiskit/synthesis/two_qubit/two_qubit_decompose.py +700 -0
- qiskit/synthesis/two_qubit/xx_decompose/__init__.py +19 -0
- qiskit/synthesis/two_qubit/xx_decompose/circuits.py +300 -0
- qiskit/synthesis/two_qubit/xx_decompose/decomposer.py +324 -0
- qiskit/synthesis/two_qubit/xx_decompose/embodiments.py +163 -0
- qiskit/synthesis/two_qubit/xx_decompose/paths.py +412 -0
- qiskit/synthesis/two_qubit/xx_decompose/polytopes.py +262 -0
- qiskit/synthesis/two_qubit/xx_decompose/utilities.py +40 -0
- qiskit/synthesis/two_qubit/xx_decompose/weyl.py +133 -0
- qiskit/synthesis/unitary/__init__.py +13 -0
- qiskit/synthesis/unitary/aqc/__init__.py +177 -0
- qiskit/synthesis/unitary/aqc/approximate.py +116 -0
- qiskit/synthesis/unitary/aqc/aqc.py +175 -0
- qiskit/synthesis/unitary/aqc/cnot_structures.py +300 -0
- qiskit/synthesis/unitary/aqc/cnot_unit_circuit.py +103 -0
- qiskit/synthesis/unitary/aqc/cnot_unit_objective.py +299 -0
- qiskit/synthesis/unitary/aqc/elementary_operations.py +108 -0
- qiskit/synthesis/unitary/aqc/fast_gradient/__init__.py +164 -0
- qiskit/synthesis/unitary/aqc/fast_gradient/fast_grad_utils.py +237 -0
- qiskit/synthesis/unitary/aqc/fast_gradient/fast_gradient.py +226 -0
- qiskit/synthesis/unitary/aqc/fast_gradient/layer.py +370 -0
- qiskit/synthesis/unitary/aqc/fast_gradient/pmatrix.py +312 -0
- qiskit/synthesis/unitary/qsd.py +288 -0
- qiskit/transpiler/__init__.py +1290 -0
- qiskit/transpiler/basepasses.py +221 -0
- qiskit/transpiler/coupling.py +500 -0
- qiskit/transpiler/exceptions.py +59 -0
- qiskit/transpiler/instruction_durations.py +281 -0
- qiskit/transpiler/layout.py +737 -0
- qiskit/transpiler/passes/__init__.py +312 -0
- qiskit/transpiler/passes/analysis/__init__.py +23 -0
- qiskit/transpiler/passes/analysis/count_ops.py +30 -0
- qiskit/transpiler/passes/analysis/count_ops_longest_path.py +26 -0
- qiskit/transpiler/passes/analysis/dag_longest_path.py +24 -0
- qiskit/transpiler/passes/analysis/depth.py +33 -0
- qiskit/transpiler/passes/analysis/num_qubits.py +26 -0
- qiskit/transpiler/passes/analysis/num_tensor_factors.py +26 -0
- qiskit/transpiler/passes/analysis/resource_estimation.py +41 -0
- qiskit/transpiler/passes/analysis/size.py +36 -0
- qiskit/transpiler/passes/analysis/width.py +27 -0
- qiskit/transpiler/passes/basis/__init__.py +19 -0
- qiskit/transpiler/passes/basis/basis_translator.py +137 -0
- qiskit/transpiler/passes/basis/decompose.py +131 -0
- qiskit/transpiler/passes/basis/translate_parameterized.py +175 -0
- qiskit/transpiler/passes/basis/unroll_3q_or_more.py +88 -0
- qiskit/transpiler/passes/basis/unroll_custom_definitions.py +109 -0
- qiskit/transpiler/passes/calibration/__init__.py +17 -0
- qiskit/transpiler/passes/calibration/base_builder.py +79 -0
- qiskit/transpiler/passes/calibration/builders.py +20 -0
- qiskit/transpiler/passes/calibration/exceptions.py +22 -0
- qiskit/transpiler/passes/calibration/pulse_gate.py +100 -0
- qiskit/transpiler/passes/calibration/rx_builder.py +164 -0
- qiskit/transpiler/passes/calibration/rzx_builder.py +411 -0
- qiskit/transpiler/passes/calibration/rzx_templates.py +51 -0
- qiskit/transpiler/passes/layout/__init__.py +26 -0
- qiskit/transpiler/passes/layout/_csp_custom_solver.py +65 -0
- qiskit/transpiler/passes/layout/apply_layout.py +123 -0
- qiskit/transpiler/passes/layout/csp_layout.py +132 -0
- qiskit/transpiler/passes/layout/dense_layout.py +202 -0
- qiskit/transpiler/passes/layout/disjoint_utils.py +219 -0
- qiskit/transpiler/passes/layout/enlarge_with_ancilla.py +49 -0
- qiskit/transpiler/passes/layout/full_ancilla_allocation.py +117 -0
- qiskit/transpiler/passes/layout/layout_2q_distance.py +77 -0
- qiskit/transpiler/passes/layout/sabre_layout.py +487 -0
- qiskit/transpiler/passes/layout/sabre_pre_layout.py +225 -0
- qiskit/transpiler/passes/layout/set_layout.py +69 -0
- qiskit/transpiler/passes/layout/trivial_layout.py +66 -0
- qiskit/transpiler/passes/layout/vf2_layout.py +263 -0
- qiskit/transpiler/passes/layout/vf2_post_layout.py +419 -0
- qiskit/transpiler/passes/layout/vf2_utils.py +260 -0
- qiskit/transpiler/passes/optimization/__init__.py +43 -0
- qiskit/transpiler/passes/optimization/_gate_extension.py +80 -0
- qiskit/transpiler/passes/optimization/collect_1q_runs.py +31 -0
- qiskit/transpiler/passes/optimization/collect_2q_blocks.py +35 -0
- qiskit/transpiler/passes/optimization/collect_and_collapse.py +115 -0
- qiskit/transpiler/passes/optimization/collect_cliffords.py +104 -0
- qiskit/transpiler/passes/optimization/collect_linear_functions.py +80 -0
- qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py +227 -0
- qiskit/transpiler/passes/optimization/commutation_analysis.py +44 -0
- qiskit/transpiler/passes/optimization/commutative_cancellation.py +82 -0
- qiskit/transpiler/passes/optimization/commutative_inverse_cancellation.py +140 -0
- qiskit/transpiler/passes/optimization/consolidate_blocks.py +149 -0
- qiskit/transpiler/passes/optimization/cx_cancellation.py +65 -0
- qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposition.py +162 -0
- qiskit/transpiler/passes/optimization/elide_permutations.py +91 -0
- qiskit/transpiler/passes/optimization/hoare_opt.py +420 -0
- qiskit/transpiler/passes/optimization/inverse_cancellation.py +95 -0
- qiskit/transpiler/passes/optimization/normalize_rx_angle.py +149 -0
- qiskit/transpiler/passes/optimization/optimize_1q_commutation.py +268 -0
- qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +254 -0
- qiskit/transpiler/passes/optimization/optimize_1q_gates.py +384 -0
- qiskit/transpiler/passes/optimization/optimize_annotated.py +448 -0
- qiskit/transpiler/passes/optimization/optimize_cliffords.py +89 -0
- qiskit/transpiler/passes/optimization/optimize_swap_before_measure.py +71 -0
- qiskit/transpiler/passes/optimization/remove_diagonal_gates_before_measure.py +41 -0
- qiskit/transpiler/passes/optimization/remove_final_reset.py +37 -0
- qiskit/transpiler/passes/optimization/remove_identity_equiv.py +69 -0
- qiskit/transpiler/passes/optimization/remove_reset_in_zero_state.py +37 -0
- qiskit/transpiler/passes/optimization/reset_after_measure_simplification.py +47 -0
- qiskit/transpiler/passes/optimization/split_2q_unitaries.py +40 -0
- qiskit/transpiler/passes/optimization/template_matching/__init__.py +19 -0
- qiskit/transpiler/passes/optimization/template_matching/backward_match.py +749 -0
- qiskit/transpiler/passes/optimization/template_matching/forward_match.py +452 -0
- qiskit/transpiler/passes/optimization/template_matching/maximal_matches.py +77 -0
- qiskit/transpiler/passes/optimization/template_matching/template_matching.py +370 -0
- qiskit/transpiler/passes/optimization/template_matching/template_substitution.py +638 -0
- qiskit/transpiler/passes/optimization/template_optimization.py +158 -0
- qiskit/transpiler/passes/routing/__init__.py +22 -0
- qiskit/transpiler/passes/routing/algorithms/__init__.py +33 -0
- qiskit/transpiler/passes/routing/algorithms/token_swapper.py +105 -0
- qiskit/transpiler/passes/routing/algorithms/types.py +46 -0
- qiskit/transpiler/passes/routing/algorithms/util.py +103 -0
- qiskit/transpiler/passes/routing/basic_swap.py +166 -0
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/__init__.py +25 -0
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_block.py +60 -0
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py +395 -0
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/pauli_2q_evolution_commutation.py +145 -0
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/swap_strategy.py +306 -0
- qiskit/transpiler/passes/routing/layout_transformation.py +119 -0
- qiskit/transpiler/passes/routing/lookahead_swap.py +390 -0
- qiskit/transpiler/passes/routing/sabre_swap.py +447 -0
- qiskit/transpiler/passes/routing/star_prerouting.py +392 -0
- qiskit/transpiler/passes/routing/stochastic_swap.py +532 -0
- qiskit/transpiler/passes/routing/utils.py +35 -0
- qiskit/transpiler/passes/scheduling/__init__.py +27 -0
- qiskit/transpiler/passes/scheduling/alap.py +153 -0
- qiskit/transpiler/passes/scheduling/alignments/__init__.py +81 -0
- qiskit/transpiler/passes/scheduling/alignments/align_measures.py +255 -0
- qiskit/transpiler/passes/scheduling/alignments/check_durations.py +78 -0
- qiskit/transpiler/passes/scheduling/alignments/pulse_gate_validation.py +107 -0
- qiskit/transpiler/passes/scheduling/alignments/reschedule.py +250 -0
- qiskit/transpiler/passes/scheduling/asap.py +175 -0
- qiskit/transpiler/passes/scheduling/base_scheduler.py +310 -0
- qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +312 -0
- qiskit/transpiler/passes/scheduling/padding/__init__.py +16 -0
- qiskit/transpiler/passes/scheduling/padding/base_padding.py +256 -0
- qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +452 -0
- qiskit/transpiler/passes/scheduling/padding/pad_delay.py +82 -0
- qiskit/transpiler/passes/scheduling/scheduling/__init__.py +17 -0
- qiskit/transpiler/passes/scheduling/scheduling/alap.py +127 -0
- qiskit/transpiler/passes/scheduling/scheduling/asap.py +131 -0
- qiskit/transpiler/passes/scheduling/scheduling/base_scheduler.py +94 -0
- qiskit/transpiler/passes/scheduling/scheduling/set_io_latency.py +64 -0
- qiskit/transpiler/passes/scheduling/time_unit_conversion.py +165 -0
- qiskit/transpiler/passes/synthesis/__init__.py +20 -0
- qiskit/transpiler/passes/synthesis/aqc_plugin.py +153 -0
- qiskit/transpiler/passes/synthesis/high_level_synthesis.py +854 -0
- qiskit/transpiler/passes/synthesis/hls_plugins.py +1559 -0
- qiskit/transpiler/passes/synthesis/linear_functions_synthesis.py +41 -0
- qiskit/transpiler/passes/synthesis/plugin.py +734 -0
- qiskit/transpiler/passes/synthesis/solovay_kitaev_synthesis.py +297 -0
- qiskit/transpiler/passes/synthesis/unitary_synthesis.py +1076 -0
- qiskit/transpiler/passes/utils/__init__.py +33 -0
- qiskit/transpiler/passes/utils/barrier_before_final_measurements.py +41 -0
- qiskit/transpiler/passes/utils/check_gate_direction.py +52 -0
- qiskit/transpiler/passes/utils/check_map.py +78 -0
- qiskit/transpiler/passes/utils/contains_instruction.py +45 -0
- qiskit/transpiler/passes/utils/control_flow.py +65 -0
- qiskit/transpiler/passes/utils/convert_conditions_to_if_ops.py +93 -0
- qiskit/transpiler/passes/utils/dag_fixed_point.py +36 -0
- qiskit/transpiler/passes/utils/error.py +69 -0
- qiskit/transpiler/passes/utils/filter_op_nodes.py +65 -0
- qiskit/transpiler/passes/utils/fixed_point.py +48 -0
- qiskit/transpiler/passes/utils/gate_direction.py +86 -0
- qiskit/transpiler/passes/utils/gates_basis.py +51 -0
- qiskit/transpiler/passes/utils/merge_adjacent_barriers.py +163 -0
- qiskit/transpiler/passes/utils/minimum_point.py +118 -0
- qiskit/transpiler/passes/utils/remove_barriers.py +49 -0
- qiskit/transpiler/passes/utils/remove_final_measurements.py +114 -0
- qiskit/transpiler/passes/utils/unroll_forloops.py +81 -0
- qiskit/transpiler/passmanager.py +490 -0
- qiskit/transpiler/passmanager_config.py +216 -0
- qiskit/transpiler/preset_passmanagers/__init__.py +73 -0
- qiskit/transpiler/preset_passmanagers/builtin_plugins.py +1045 -0
- qiskit/transpiler/preset_passmanagers/common.py +649 -0
- qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py +626 -0
- qiskit/transpiler/preset_passmanagers/level0.py +113 -0
- qiskit/transpiler/preset_passmanagers/level1.py +120 -0
- qiskit/transpiler/preset_passmanagers/level2.py +119 -0
- qiskit/transpiler/preset_passmanagers/level3.py +119 -0
- qiskit/transpiler/preset_passmanagers/plugin.py +353 -0
- qiskit/transpiler/target.py +1319 -0
- qiskit/transpiler/timing_constraints.py +59 -0
- qiskit/user_config.py +262 -0
- qiskit/utils/__init__.py +89 -0
- qiskit/utils/classtools.py +146 -0
- qiskit/utils/deprecate_pulse.py +119 -0
- qiskit/utils/deprecation.py +490 -0
- qiskit/utils/lazy_tester.py +363 -0
- qiskit/utils/multiprocessing.py +56 -0
- qiskit/utils/optionals.py +347 -0
- qiskit/utils/parallel.py +191 -0
- qiskit/utils/units.py +143 -0
- qiskit/version.py +84 -0
- qiskit/visualization/__init__.py +288 -0
- qiskit/visualization/array.py +204 -0
- qiskit/visualization/bloch.py +778 -0
- qiskit/visualization/circuit/__init__.py +15 -0
- qiskit/visualization/circuit/_utils.py +675 -0
- qiskit/visualization/circuit/circuit_visualization.py +727 -0
- qiskit/visualization/circuit/latex.py +661 -0
- qiskit/visualization/circuit/matplotlib.py +2029 -0
- qiskit/visualization/circuit/qcstyle.py +278 -0
- qiskit/visualization/circuit/styles/__init__.py +13 -0
- qiskit/visualization/circuit/styles/bw.json +202 -0
- qiskit/visualization/circuit/styles/clifford.json +202 -0
- qiskit/visualization/circuit/styles/iqp-dark.json +214 -0
- qiskit/visualization/circuit/styles/iqp.json +214 -0
- qiskit/visualization/circuit/styles/textbook.json +202 -0
- qiskit/visualization/circuit/text.py +1844 -0
- qiskit/visualization/circuit_visualization.py +19 -0
- qiskit/visualization/counts_visualization.py +481 -0
- qiskit/visualization/dag_visualization.py +316 -0
- qiskit/visualization/exceptions.py +21 -0
- qiskit/visualization/gate_map.py +1485 -0
- qiskit/visualization/library.py +37 -0
- qiskit/visualization/pass_manager_visualization.py +308 -0
- qiskit/visualization/pulse_v2/__init__.py +21 -0
- qiskit/visualization/pulse_v2/core.py +901 -0
- qiskit/visualization/pulse_v2/device_info.py +173 -0
- qiskit/visualization/pulse_v2/drawings.py +253 -0
- qiskit/visualization/pulse_v2/events.py +254 -0
- qiskit/visualization/pulse_v2/generators/__init__.py +40 -0
- qiskit/visualization/pulse_v2/generators/barrier.py +76 -0
- qiskit/visualization/pulse_v2/generators/chart.py +208 -0
- qiskit/visualization/pulse_v2/generators/frame.py +436 -0
- qiskit/visualization/pulse_v2/generators/snapshot.py +133 -0
- qiskit/visualization/pulse_v2/generators/waveform.py +645 -0
- qiskit/visualization/pulse_v2/interface.py +458 -0
- qiskit/visualization/pulse_v2/layouts.py +387 -0
- qiskit/visualization/pulse_v2/plotters/__init__.py +17 -0
- qiskit/visualization/pulse_v2/plotters/base_plotter.py +53 -0
- qiskit/visualization/pulse_v2/plotters/matplotlib.py +201 -0
- qiskit/visualization/pulse_v2/stylesheet.py +312 -0
- qiskit/visualization/pulse_v2/types.py +242 -0
- qiskit/visualization/state_visualization.py +1518 -0
- qiskit/visualization/timeline/__init__.py +21 -0
- qiskit/visualization/timeline/core.py +480 -0
- qiskit/visualization/timeline/drawings.py +260 -0
- qiskit/visualization/timeline/generators.py +506 -0
- qiskit/visualization/timeline/interface.py +436 -0
- qiskit/visualization/timeline/layouts.py +115 -0
- qiskit/visualization/timeline/plotters/__init__.py +16 -0
- qiskit/visualization/timeline/plotters/base_plotter.py +58 -0
- qiskit/visualization/timeline/plotters/matplotlib.py +192 -0
- qiskit/visualization/timeline/stylesheet.py +301 -0
- qiskit/visualization/timeline/types.py +148 -0
- qiskit/visualization/transition_visualization.py +369 -0
- qiskit/visualization/utils.py +49 -0
- qiskit-1.3.0.dist-info/LICENSE.txt +203 -0
- qiskit-1.3.0.dist-info/METADATA +222 -0
- qiskit-1.3.0.dist-info/RECORD +836 -0
- qiskit-1.3.0.dist-info/WHEEL +5 -0
- qiskit-1.3.0.dist-info/entry_points.txt +76 -0
- qiskit-1.3.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1319 @@
|
|
1
|
+
# This code is part of Qiskit.
|
2
|
+
#
|
3
|
+
# (C) Copyright IBM 2021, 2023.
|
4
|
+
#
|
5
|
+
# This code is licensed under the Apache License, Version 2.0. You may
|
6
|
+
# obtain a copy of this license in the LICENSE.txt file in the root directory
|
7
|
+
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
|
8
|
+
#
|
9
|
+
# Any modifications or derivative works of this code must retain this
|
10
|
+
# copyright notice, and modified files need to carry a notice indicating
|
11
|
+
# that they have been altered from the originals.
|
12
|
+
|
13
|
+
# pylint: disable=too-many-return-statements
|
14
|
+
|
15
|
+
"""
|
16
|
+
A target object represents the minimum set of information the transpiler needs
|
17
|
+
from a backend
|
18
|
+
"""
|
19
|
+
|
20
|
+
from __future__ import annotations
|
21
|
+
|
22
|
+
import itertools
|
23
|
+
import warnings
|
24
|
+
|
25
|
+
from typing import Optional, List, Any
|
26
|
+
from collections.abc import Mapping
|
27
|
+
import datetime
|
28
|
+
import io
|
29
|
+
import logging
|
30
|
+
import inspect
|
31
|
+
|
32
|
+
import rustworkx as rx
|
33
|
+
|
34
|
+
# import target class from the rust side
|
35
|
+
from qiskit._accelerate.target import (
|
36
|
+
BaseTarget,
|
37
|
+
BaseInstructionProperties,
|
38
|
+
)
|
39
|
+
|
40
|
+
from qiskit.circuit.parameter import Parameter
|
41
|
+
from qiskit.circuit.parameterexpression import ParameterValueType
|
42
|
+
from qiskit.circuit.gate import Gate
|
43
|
+
from qiskit.circuit.library.standard_gates import get_standard_gate_name_mapping
|
44
|
+
from qiskit.pulse.instruction_schedule_map import InstructionScheduleMap
|
45
|
+
from qiskit.pulse.calibration_entries import CalibrationEntry, ScheduleDef
|
46
|
+
from qiskit.pulse.schedule import Schedule, ScheduleBlock
|
47
|
+
from qiskit.transpiler.coupling import CouplingMap
|
48
|
+
from qiskit.transpiler.exceptions import TranspilerError
|
49
|
+
from qiskit.transpiler.instruction_durations import InstructionDurations
|
50
|
+
from qiskit.transpiler.timing_constraints import TimingConstraints
|
51
|
+
from qiskit.providers.exceptions import BackendPropertyError
|
52
|
+
from qiskit.pulse.exceptions import PulseError, UnassignedDurationError
|
53
|
+
from qiskit.exceptions import QiskitError
|
54
|
+
|
55
|
+
# import QubitProperties here to provide convenience alias for building a
|
56
|
+
# full target
|
57
|
+
from qiskit.providers.backend import QubitProperties # pylint: disable=unused-import
|
58
|
+
from qiskit.providers.models.backendproperties import BackendProperties
|
59
|
+
from qiskit.utils import deprecate_func
|
60
|
+
from qiskit.utils.deprecate_pulse import deprecate_pulse_dependency, deprecate_pulse_arg
|
61
|
+
|
62
|
+
logger = logging.getLogger(__name__)
|
63
|
+
|
64
|
+
|
65
|
+
class InstructionProperties(BaseInstructionProperties):
|
66
|
+
"""A representation of the properties of a gate implementation.
|
67
|
+
|
68
|
+
This class provides the optional properties that a backend can provide
|
69
|
+
about an instruction. These represent the set that the transpiler can
|
70
|
+
currently work with if present. However, if your backend provides additional
|
71
|
+
properties for instructions you should subclass this to add additional
|
72
|
+
custom attributes for those custom/additional properties by the backend.
|
73
|
+
"""
|
74
|
+
|
75
|
+
__slots__ = [
|
76
|
+
"_calibration",
|
77
|
+
]
|
78
|
+
|
79
|
+
def __new__( # pylint: disable=keyword-arg-before-vararg
|
80
|
+
cls,
|
81
|
+
duration=None, # pylint: disable=keyword-arg-before-vararg
|
82
|
+
error=None, # pylint: disable=keyword-arg-before-vararg
|
83
|
+
*args, # pylint: disable=unused-argument
|
84
|
+
**kwargs, # pylint: disable=unused-argument
|
85
|
+
):
|
86
|
+
return super(InstructionProperties, cls).__new__( # pylint: disable=too-many-function-args
|
87
|
+
cls, duration, error
|
88
|
+
)
|
89
|
+
|
90
|
+
@deprecate_pulse_arg("calibration", predicate=lambda cals: cals is not None)
|
91
|
+
def __init__(
|
92
|
+
self,
|
93
|
+
duration: float | None = None, # pylint: disable=unused-argument
|
94
|
+
error: float | None = None, # pylint: disable=unused-argument
|
95
|
+
calibration: Schedule | ScheduleBlock | CalibrationEntry | None = None,
|
96
|
+
):
|
97
|
+
"""Create a new ``InstructionProperties`` object
|
98
|
+
|
99
|
+
Args:
|
100
|
+
duration: The duration, in seconds, of the instruction on the
|
101
|
+
specified set of qubits
|
102
|
+
error: The average error rate for the instruction on the specified
|
103
|
+
set of qubits.
|
104
|
+
calibration: DEPRECATED. The pulse representation of the instruction.
|
105
|
+
"""
|
106
|
+
super().__init__()
|
107
|
+
self._calibration: CalibrationEntry | None = None
|
108
|
+
self._calibration_prop = calibration
|
109
|
+
|
110
|
+
@property
|
111
|
+
@deprecate_pulse_dependency(is_property=True)
|
112
|
+
def calibration(self):
|
113
|
+
"""The pulse representation of the instruction.
|
114
|
+
|
115
|
+
.. note::
|
116
|
+
|
117
|
+
This attribute always returns a Qiskit pulse program, but it is internally
|
118
|
+
wrapped by the :class:`.CalibrationEntry` to manage unbound parameters
|
119
|
+
and to uniformly handle different data representation,
|
120
|
+
for example, un-parsed Pulse Qobj JSON that a backend provider may provide.
|
121
|
+
|
122
|
+
This value can be overridden through the property setter in following manner.
|
123
|
+
When you set either :class:`.Schedule` or :class:`.ScheduleBlock` this is
|
124
|
+
always treated as a user-defined (custom) calibration and
|
125
|
+
the transpiler may automatically attach the calibration data to the output circuit.
|
126
|
+
This calibration data may appear in the wire format as an inline calibration,
|
127
|
+
which may further update the backend standard instruction set architecture.
|
128
|
+
|
129
|
+
If you are a backend provider who provides a default calibration data
|
130
|
+
that is not needed to be attached to the transpiled quantum circuit,
|
131
|
+
you can directly set :class:`.CalibrationEntry` instance to this attribute,
|
132
|
+
in which you should set :code:`user_provided=False` when you define
|
133
|
+
calibration data for the entry. End users can still intentionally utilize
|
134
|
+
the calibration data, for example, to run pulse-level simulation of the circuit.
|
135
|
+
However, such entry doesn't appear in the wire format, and backend must
|
136
|
+
use own definition to compile the circuit down to the execution format.
|
137
|
+
|
138
|
+
"""
|
139
|
+
return self._calibration_prop
|
140
|
+
|
141
|
+
@calibration.setter
|
142
|
+
@deprecate_pulse_dependency(is_property=True)
|
143
|
+
def calibration(self, calibration: Schedule | ScheduleBlock | CalibrationEntry):
|
144
|
+
self._calibration_prop = calibration
|
145
|
+
|
146
|
+
@property
|
147
|
+
def _calibration_prop(self):
|
148
|
+
if self._calibration is None:
|
149
|
+
return None
|
150
|
+
with warnings.catch_warnings():
|
151
|
+
warnings.simplefilter(action="ignore", category=DeprecationWarning)
|
152
|
+
# Clean this alternative path from deprecation warning emitted by `get_schedule`
|
153
|
+
return self._calibration.get_schedule()
|
154
|
+
|
155
|
+
@_calibration_prop.setter
|
156
|
+
def _calibration_prop(self, calibration: Schedule | ScheduleBlock | CalibrationEntry):
|
157
|
+
if isinstance(calibration, (Schedule, ScheduleBlock)):
|
158
|
+
new_entry = ScheduleDef()
|
159
|
+
new_entry.define(calibration, user_provided=True)
|
160
|
+
else:
|
161
|
+
new_entry = calibration
|
162
|
+
self._calibration = new_entry
|
163
|
+
|
164
|
+
def __repr__(self):
|
165
|
+
return (
|
166
|
+
f"InstructionProperties(duration={self.duration}, error={self.error}"
|
167
|
+
f", calibration={self._calibration})"
|
168
|
+
)
|
169
|
+
|
170
|
+
def __getstate__(self) -> tuple:
|
171
|
+
return (super().__getstate__(), self._calibration_prop, self._calibration)
|
172
|
+
|
173
|
+
def __setstate__(self, state: tuple):
|
174
|
+
super().__setstate__(state[0])
|
175
|
+
self._calibration_prop = state[1]
|
176
|
+
self._calibration = state[2]
|
177
|
+
|
178
|
+
|
179
|
+
class Target(BaseTarget):
|
180
|
+
"""
|
181
|
+
The intent of the ``Target`` object is to inform Qiskit's compiler about
|
182
|
+
the constraints of a particular backend so the compiler can compile an
|
183
|
+
input circuit to something that works and is optimized for a device. It
|
184
|
+
currently contains a description of instructions on a backend and their
|
185
|
+
properties as well as some timing information. However, this exact
|
186
|
+
interface may evolve over time as the needs of the compiler change. These
|
187
|
+
changes will be done in a backwards compatible and controlled manner when
|
188
|
+
they are made (either through versioning, subclassing, or mixins) to add
|
189
|
+
on to the set of information exposed by a target.
|
190
|
+
|
191
|
+
As a basic example, let's assume backend has two qubits, supports
|
192
|
+
:class:`~qiskit.circuit.library.UGate` on both qubits and
|
193
|
+
:class:`~qiskit.circuit.library.CXGate` in both directions. To model this
|
194
|
+
you would create the target like::
|
195
|
+
|
196
|
+
from qiskit.transpiler import Target, InstructionProperties
|
197
|
+
from qiskit.circuit.library import UGate, CXGate
|
198
|
+
from qiskit.circuit import Parameter
|
199
|
+
|
200
|
+
gmap = Target()
|
201
|
+
theta = Parameter('theta')
|
202
|
+
phi = Parameter('phi')
|
203
|
+
lam = Parameter('lambda')
|
204
|
+
u_props = {
|
205
|
+
(0,): InstructionProperties(duration=5.23e-8, error=0.00038115),
|
206
|
+
(1,): InstructionProperties(duration=4.52e-8, error=0.00032115),
|
207
|
+
}
|
208
|
+
gmap.add_instruction(UGate(theta, phi, lam), u_props)
|
209
|
+
cx_props = {
|
210
|
+
(0,1): InstructionProperties(duration=5.23e-7, error=0.00098115),
|
211
|
+
(1,0): InstructionProperties(duration=4.52e-7, error=0.00132115),
|
212
|
+
}
|
213
|
+
gmap.add_instruction(CXGate(), cx_props)
|
214
|
+
|
215
|
+
Each instruction in the ``Target`` is indexed by a unique string name that uniquely
|
216
|
+
identifies that instance of an :class:`~qiskit.circuit.Instruction` object in
|
217
|
+
the Target. There is a 1:1 mapping between a name and an
|
218
|
+
:class:`~qiskit.circuit.Instruction` instance in the target and each name must
|
219
|
+
be unique. By default, the name is the :attr:`~qiskit.circuit.Instruction.name`
|
220
|
+
attribute of the instruction, but can be set to anything. This lets a single
|
221
|
+
target have multiple instances of the same instruction class with different
|
222
|
+
parameters. For example, if a backend target has two instances of an
|
223
|
+
:class:`~qiskit.circuit.library.RXGate` one is parameterized over any theta
|
224
|
+
while the other is tuned up for a theta of pi/6 you can add these by doing something
|
225
|
+
like::
|
226
|
+
|
227
|
+
import math
|
228
|
+
|
229
|
+
from qiskit.transpiler import Target, InstructionProperties
|
230
|
+
from qiskit.circuit.library import RXGate
|
231
|
+
from qiskit.circuit import Parameter
|
232
|
+
|
233
|
+
target = Target()
|
234
|
+
theta = Parameter('theta')
|
235
|
+
rx_props = {
|
236
|
+
(0,): InstructionProperties(duration=5.23e-8, error=0.00038115),
|
237
|
+
}
|
238
|
+
target.add_instruction(RXGate(theta), rx_props)
|
239
|
+
rx_30_props = {
|
240
|
+
(0,): InstructionProperties(duration=1.74e-6, error=.00012)
|
241
|
+
}
|
242
|
+
target.add_instruction(RXGate(math.pi / 6), rx_30_props, name='rx_30')
|
243
|
+
|
244
|
+
Then in the ``target`` object accessing by ``rx_30`` will get the fixed
|
245
|
+
angle :class:`~qiskit.circuit.library.RXGate` while ``rx`` will get the
|
246
|
+
parameterized :class:`~qiskit.circuit.library.RXGate`.
|
247
|
+
|
248
|
+
.. note::
|
249
|
+
|
250
|
+
This class assumes that qubit indices start at 0 and are a contiguous
|
251
|
+
set if you want a submapping the bits will need to be reindexed in
|
252
|
+
a new``Target`` object.
|
253
|
+
|
254
|
+
.. note::
|
255
|
+
|
256
|
+
This class only supports additions of gates, qargs, and qubits.
|
257
|
+
If you need to remove one of these the best option is to iterate over
|
258
|
+
an existing object and create a new subset (or use one of the methods
|
259
|
+
to do this). The object internally caches different views and these
|
260
|
+
would potentially be invalidated by removals.
|
261
|
+
"""
|
262
|
+
|
263
|
+
__slots__ = (
|
264
|
+
"_gate_map",
|
265
|
+
"_coupling_graph",
|
266
|
+
"_instruction_durations",
|
267
|
+
"_instruction_schedule_map",
|
268
|
+
)
|
269
|
+
|
270
|
+
def __new__( # pylint: disable=keyword-arg-before-vararg
|
271
|
+
cls,
|
272
|
+
description: str | None = None,
|
273
|
+
num_qubits: int = 0,
|
274
|
+
dt: float | None = None,
|
275
|
+
granularity: int = 1,
|
276
|
+
min_length: int = 1,
|
277
|
+
pulse_alignment: int = 1,
|
278
|
+
acquire_alignment: int = 1,
|
279
|
+
qubit_properties: list | None = None,
|
280
|
+
concurrent_measurements: list | None = None,
|
281
|
+
*args, # pylint: disable=unused-argument disable=keyword-arg-before-vararg
|
282
|
+
**kwargs, # pylint: disable=unused-argument
|
283
|
+
):
|
284
|
+
"""
|
285
|
+
Create a new ``Target`` object
|
286
|
+
|
287
|
+
Args:
|
288
|
+
description (str): An optional string to describe the Target.
|
289
|
+
num_qubits (int): An optional int to specify the number of qubits
|
290
|
+
the backend target has. If not set it will be implicitly set
|
291
|
+
based on the qargs when :meth:`~qiskit.Target.add_instruction`
|
292
|
+
is called. Note this must be set if the backend target is for a
|
293
|
+
noiseless simulator that doesn't have constraints on the
|
294
|
+
instructions so the transpiler knows how many qubits are
|
295
|
+
available.
|
296
|
+
dt (float): The system time resolution of input signals in seconds
|
297
|
+
granularity (int): An integer value representing minimum pulse gate
|
298
|
+
resolution in units of ``dt``. A user-defined pulse gate should
|
299
|
+
have duration of a multiple of this granularity value.
|
300
|
+
min_length (int): An integer value representing minimum pulse gate
|
301
|
+
length in units of ``dt``. A user-defined pulse gate should be
|
302
|
+
longer than this length.
|
303
|
+
pulse_alignment (int): An integer value representing a time
|
304
|
+
resolution of gate instruction starting time. Gate instruction
|
305
|
+
should start at time which is a multiple of the alignment
|
306
|
+
value.
|
307
|
+
acquire_alignment (int): An integer value representing a time
|
308
|
+
resolution of measure instruction starting time. Measure
|
309
|
+
instruction should start at time which is a multiple of the
|
310
|
+
alignment value.
|
311
|
+
qubit_properties (list): A list of :class:`~.QubitProperties`
|
312
|
+
objects defining the characteristics of each qubit on the
|
313
|
+
target device. If specified the length of this list must match
|
314
|
+
the number of qubits in the target, where the index in the list
|
315
|
+
matches the qubit number the properties are defined for. If some
|
316
|
+
qubits don't have properties available you can set that entry to
|
317
|
+
``None``
|
318
|
+
concurrent_measurements(list): A list of sets of qubits that must be
|
319
|
+
measured together. This must be provided
|
320
|
+
as a nested list like ``[[0, 1], [2, 3, 4]]``.
|
321
|
+
Raises:
|
322
|
+
ValueError: If both ``num_qubits`` and ``qubit_properties`` are both
|
323
|
+
defined and the value of ``num_qubits`` differs from the length of
|
324
|
+
``qubit_properties``.
|
325
|
+
"""
|
326
|
+
if description is not None:
|
327
|
+
description = str(description)
|
328
|
+
return super(Target, cls).__new__( # pylint: disable=too-many-function-args
|
329
|
+
cls,
|
330
|
+
description,
|
331
|
+
num_qubits,
|
332
|
+
dt,
|
333
|
+
granularity,
|
334
|
+
min_length,
|
335
|
+
pulse_alignment,
|
336
|
+
acquire_alignment,
|
337
|
+
qubit_properties,
|
338
|
+
concurrent_measurements,
|
339
|
+
)
|
340
|
+
|
341
|
+
def __init__(
|
342
|
+
self,
|
343
|
+
description=None, # pylint: disable=unused-argument
|
344
|
+
num_qubits=0, # pylint: disable=unused-argument
|
345
|
+
dt=None, # pylint: disable=unused-argument
|
346
|
+
granularity=1, # pylint: disable=unused-argument
|
347
|
+
min_length=1, # pylint: disable=unused-argument
|
348
|
+
pulse_alignment=1, # pylint: disable=unused-argument
|
349
|
+
acquire_alignment=1, # pylint: disable=unused-argument
|
350
|
+
qubit_properties=None, # pylint: disable=unused-argument
|
351
|
+
concurrent_measurements=None, # pylint: disable=unused-argument
|
352
|
+
):
|
353
|
+
# A nested mapping of gate name -> qargs -> properties
|
354
|
+
self._gate_map = {}
|
355
|
+
self._coupling_graph = None
|
356
|
+
self._instruction_durations = None
|
357
|
+
self._instruction_schedule_map = None
|
358
|
+
|
359
|
+
def add_instruction(self, instruction, properties=None, name=None):
|
360
|
+
"""Add a new instruction to the :class:`~qiskit.transpiler.Target`
|
361
|
+
|
362
|
+
As ``Target`` objects are strictly additive this is the primary method
|
363
|
+
for modifying a ``Target``. Typically, you will use this to fully populate
|
364
|
+
a ``Target`` before using it in :class:`~qiskit.providers.BackendV2`. For
|
365
|
+
example::
|
366
|
+
|
367
|
+
from qiskit.circuit.library import CXGate
|
368
|
+
from qiskit.transpiler import Target, InstructionProperties
|
369
|
+
|
370
|
+
target = Target()
|
371
|
+
cx_properties = {
|
372
|
+
(0, 1): None,
|
373
|
+
(1, 0): None,
|
374
|
+
(0, 2): None,
|
375
|
+
(2, 0): None,
|
376
|
+
(0, 3): None,
|
377
|
+
(2, 3): None,
|
378
|
+
(3, 0): None,
|
379
|
+
(3, 2): None
|
380
|
+
}
|
381
|
+
target.add_instruction(CXGate(), cx_properties)
|
382
|
+
|
383
|
+
Will add a :class:`~qiskit.circuit.library.CXGate` to the target with no
|
384
|
+
properties (duration, error, etc) with the coupling edge list:
|
385
|
+
``(0, 1), (1, 0), (0, 2), (2, 0), (0, 3), (2, 3), (3, 0), (3, 2)``. If
|
386
|
+
there are properties available for the instruction you can replace the
|
387
|
+
``None`` value in the properties dictionary with an
|
388
|
+
:class:`~qiskit.transpiler.InstructionProperties` object. This pattern
|
389
|
+
is repeated for each :class:`~qiskit.circuit.Instruction` the target
|
390
|
+
supports.
|
391
|
+
|
392
|
+
Args:
|
393
|
+
instruction (Union[qiskit.circuit.Instruction, Type[qiskit.circuit.Instruction]]):
|
394
|
+
The operation object to add to the map. If it's parameterized any value
|
395
|
+
of the parameter can be set. Optionally for variable width
|
396
|
+
instructions (such as control flow operations such as :class:`~.ForLoop` or
|
397
|
+
:class:`~MCXGate`) you can specify the class. If the class is specified than the
|
398
|
+
``name`` argument must be specified. When a class is used the gate is treated as global
|
399
|
+
and not having any properties set.
|
400
|
+
properties (dict): A dictionary of qarg entries to an
|
401
|
+
:class:`~qiskit.transpiler.InstructionProperties` object for that
|
402
|
+
instruction implementation on the backend. Properties are optional
|
403
|
+
for any instruction implementation, if there are no
|
404
|
+
:class:`~qiskit.transpiler.InstructionProperties` available for the
|
405
|
+
backend the value can be None. If there are no constraints on the
|
406
|
+
instruction (as in a noiseless/ideal simulation) this can be set to
|
407
|
+
``{None, None}`` which will indicate it runs on all qubits (or all
|
408
|
+
available permutations of qubits for multi-qubit gates). The first
|
409
|
+
``None`` indicates it applies to all qubits and the second ``None``
|
410
|
+
indicates there are no
|
411
|
+
:class:`~qiskit.transpiler.InstructionProperties` for the
|
412
|
+
instruction. By default, if properties is not set it is equivalent to
|
413
|
+
passing ``{None: None}``.
|
414
|
+
name (str): An optional name to use for identifying the instruction. If not
|
415
|
+
specified the :attr:`~qiskit.circuit.Instruction.name` attribute
|
416
|
+
of ``gate`` will be used. All gates in the ``Target`` need unique
|
417
|
+
names. Backends can differentiate between different
|
418
|
+
parameterization of a single gate by providing a unique name for
|
419
|
+
each (e.g. `"rx30"`, `"rx60", ``"rx90"`` similar to the example in the
|
420
|
+
documentation for the :class:`~qiskit.transpiler.Target` class).
|
421
|
+
Raises:
|
422
|
+
AttributeError: If gate is already in map
|
423
|
+
TranspilerError: If an operation class is passed in for ``instruction`` and no name
|
424
|
+
is specified or ``properties`` is set.
|
425
|
+
"""
|
426
|
+
is_class = inspect.isclass(instruction)
|
427
|
+
if not is_class:
|
428
|
+
instruction_name = name or instruction.name
|
429
|
+
else:
|
430
|
+
# Invalid to have class input without a name with characters set "" is not a valid name
|
431
|
+
if not name:
|
432
|
+
raise TranspilerError(
|
433
|
+
"A name must be specified when defining a supported global operation by class"
|
434
|
+
)
|
435
|
+
if properties is not None:
|
436
|
+
raise TranspilerError(
|
437
|
+
"An instruction added globally by class can't have properties set."
|
438
|
+
)
|
439
|
+
instruction_name = name
|
440
|
+
if properties is None or is_class:
|
441
|
+
properties = {None: None}
|
442
|
+
if instruction_name in self._gate_map:
|
443
|
+
raise AttributeError(f"Instruction {instruction_name} is already in the target")
|
444
|
+
super().add_instruction(instruction, instruction_name, properties)
|
445
|
+
self._gate_map[instruction_name] = properties
|
446
|
+
self._coupling_graph = None
|
447
|
+
self._instruction_durations = None
|
448
|
+
self._instruction_schedule_map = None
|
449
|
+
|
450
|
+
def update_instruction_properties(self, instruction, qargs, properties):
|
451
|
+
"""Update the property object for an instruction qarg pair already in the Target
|
452
|
+
|
453
|
+
Args:
|
454
|
+
instruction (str): The instruction name to update
|
455
|
+
qargs (tuple): The qargs to update the properties of
|
456
|
+
properties (InstructionProperties): The properties to set for this instruction
|
457
|
+
Raises:
|
458
|
+
KeyError: If ``instruction`` or ``qarg`` are not in the target
|
459
|
+
"""
|
460
|
+
super().update_instruction_properties(instruction, qargs, properties)
|
461
|
+
self._gate_map[instruction][qargs] = properties
|
462
|
+
self._instruction_durations = None
|
463
|
+
self._instruction_schedule_map = None
|
464
|
+
|
465
|
+
@deprecate_pulse_dependency
|
466
|
+
def update_from_instruction_schedule_map(self, inst_map, inst_name_map=None, error_dict=None):
|
467
|
+
"""Update the target from an instruction schedule map.
|
468
|
+
|
469
|
+
If the input instruction schedule map contains new instructions not in
|
470
|
+
the target they will be added. However, if it contains additional qargs
|
471
|
+
for an existing instruction in the target it will error.
|
472
|
+
|
473
|
+
Args:
|
474
|
+
inst_map (InstructionScheduleMap): The instruction
|
475
|
+
inst_name_map (dict): An optional dictionary that maps any
|
476
|
+
instruction name in ``inst_map`` to an instruction object.
|
477
|
+
If not provided, instruction is pulled from the standard Qiskit gates,
|
478
|
+
and finally custom gate instance is created with schedule name.
|
479
|
+
error_dict (dict): A dictionary of errors of the form::
|
480
|
+
|
481
|
+
{gate_name: {qarg: error}}
|
482
|
+
|
483
|
+
for example::
|
484
|
+
|
485
|
+
{'rx': {(0, ): 1.4e-4, (1, ): 1.2e-4}}
|
486
|
+
|
487
|
+
For each entry in the ``inst_map`` if ``error_dict`` is defined
|
488
|
+
a when updating the ``Target`` the error value will be pulled from
|
489
|
+
this dictionary. If one is not found in ``error_dict`` then
|
490
|
+
``None`` will be used.
|
491
|
+
"""
|
492
|
+
get_calibration = getattr(inst_map, "_get_calibration_entry")
|
493
|
+
|
494
|
+
# Expand name mapping with custom gate name provided by user.
|
495
|
+
qiskit_inst_name_map = get_standard_gate_name_mapping()
|
496
|
+
if inst_name_map is not None:
|
497
|
+
qiskit_inst_name_map.update(inst_name_map)
|
498
|
+
|
499
|
+
for inst_name in inst_map.instructions:
|
500
|
+
# Prepare dictionary of instruction properties
|
501
|
+
out_props = {}
|
502
|
+
for qargs in inst_map.qubits_with_instruction(inst_name):
|
503
|
+
try:
|
504
|
+
qargs = tuple(qargs)
|
505
|
+
except TypeError:
|
506
|
+
qargs = (qargs,)
|
507
|
+
try:
|
508
|
+
props = self._gate_map[inst_name][qargs]
|
509
|
+
except (KeyError, TypeError):
|
510
|
+
props = None
|
511
|
+
|
512
|
+
entry = get_calibration(inst_name, qargs)
|
513
|
+
if entry.user_provided and getattr(props, "_calibration", None) != entry:
|
514
|
+
# It only copies user-provided calibration from the inst map.
|
515
|
+
# Backend defined entry must already exist in Target.
|
516
|
+
if self.dt is not None:
|
517
|
+
try:
|
518
|
+
duration = entry.get_schedule().duration * self.dt
|
519
|
+
except UnassignedDurationError:
|
520
|
+
# duration of schedule is parameterized
|
521
|
+
duration = None
|
522
|
+
else:
|
523
|
+
duration = None
|
524
|
+
props = InstructionProperties(
|
525
|
+
duration=duration,
|
526
|
+
calibration=entry,
|
527
|
+
)
|
528
|
+
else:
|
529
|
+
if props is None:
|
530
|
+
# Edge case. Calibration is backend defined, but this is not
|
531
|
+
# registered in the backend target. Ignore this entry.
|
532
|
+
continue
|
533
|
+
try:
|
534
|
+
# Update gate error if provided.
|
535
|
+
props.error = error_dict[inst_name][qargs]
|
536
|
+
except (KeyError, TypeError):
|
537
|
+
pass
|
538
|
+
out_props[qargs] = props
|
539
|
+
if not out_props:
|
540
|
+
continue
|
541
|
+
# Prepare Qiskit Gate object assigned to the entries
|
542
|
+
if inst_name not in self._gate_map:
|
543
|
+
# Entry not found: Add new instruction
|
544
|
+
if inst_name in qiskit_inst_name_map:
|
545
|
+
# Remove qargs with length that doesn't match with instruction qubit number
|
546
|
+
inst_obj = qiskit_inst_name_map[inst_name]
|
547
|
+
normalized_props = {}
|
548
|
+
for qargs, prop in out_props.items():
|
549
|
+
if len(qargs) != inst_obj.num_qubits:
|
550
|
+
continue
|
551
|
+
normalized_props[qargs] = prop
|
552
|
+
self.add_instruction(inst_obj, normalized_props, name=inst_name)
|
553
|
+
else:
|
554
|
+
# Check qubit length parameter name uniformity.
|
555
|
+
qlen = set()
|
556
|
+
param_names = set()
|
557
|
+
for qargs in inst_map.qubits_with_instruction(inst_name):
|
558
|
+
if isinstance(qargs, int):
|
559
|
+
qargs = (qargs,)
|
560
|
+
qlen.add(len(qargs))
|
561
|
+
cal = getattr(out_props[tuple(qargs)], "_calibration")
|
562
|
+
param_names.add(tuple(cal.get_signature().parameters.keys()))
|
563
|
+
if len(qlen) > 1 or len(param_names) > 1:
|
564
|
+
raise QiskitError(
|
565
|
+
f"Schedules for {inst_name} are defined non-uniformly for "
|
566
|
+
f"multiple qubit lengths {qlen}, "
|
567
|
+
f"or different parameter names {param_names}. "
|
568
|
+
"Provide these schedules with inst_name_map or define them with "
|
569
|
+
"different names for different gate parameters."
|
570
|
+
)
|
571
|
+
inst_obj = Gate(
|
572
|
+
name=inst_name,
|
573
|
+
num_qubits=next(iter(qlen)),
|
574
|
+
params=list(map(Parameter, next(iter(param_names)))),
|
575
|
+
)
|
576
|
+
self.add_instruction(inst_obj, out_props, name=inst_name)
|
577
|
+
else:
|
578
|
+
# Entry found: Update "existing" instructions.
|
579
|
+
for qargs, prop in out_props.items():
|
580
|
+
if qargs not in self._gate_map[inst_name]:
|
581
|
+
continue
|
582
|
+
self.update_instruction_properties(inst_name, qargs, prop)
|
583
|
+
|
584
|
+
def qargs_for_operation_name(self, operation):
|
585
|
+
"""Get the qargs for a given operation name
|
586
|
+
|
587
|
+
Args:
|
588
|
+
operation (str): The operation name to get qargs for
|
589
|
+
Returns:
|
590
|
+
set: The set of qargs the gate instance applies to.
|
591
|
+
"""
|
592
|
+
if None in self._gate_map[operation]:
|
593
|
+
return None
|
594
|
+
return self._gate_map[operation].keys()
|
595
|
+
|
596
|
+
def durations(self):
|
597
|
+
"""Get an InstructionDurations object from the target
|
598
|
+
|
599
|
+
Returns:
|
600
|
+
InstructionDurations: The instruction duration represented in the
|
601
|
+
target
|
602
|
+
"""
|
603
|
+
if self._instruction_durations is not None:
|
604
|
+
return self._instruction_durations
|
605
|
+
out_durations = []
|
606
|
+
for instruction, props_map in self._gate_map.items():
|
607
|
+
for qarg, properties in props_map.items():
|
608
|
+
if properties is not None and properties.duration is not None:
|
609
|
+
out_durations.append((instruction, list(qarg), properties.duration, "s"))
|
610
|
+
self._instruction_durations = InstructionDurations(out_durations, dt=self.dt)
|
611
|
+
return self._instruction_durations
|
612
|
+
|
613
|
+
def timing_constraints(self):
|
614
|
+
"""Get an :class:`~qiskit.transpiler.TimingConstraints` object from the target
|
615
|
+
|
616
|
+
Returns:
|
617
|
+
TimingConstraints: The timing constraints represented in the ``Target``
|
618
|
+
"""
|
619
|
+
return TimingConstraints(
|
620
|
+
self.granularity, self.min_length, self.pulse_alignment, self.acquire_alignment
|
621
|
+
)
|
622
|
+
|
623
|
+
@deprecate_pulse_dependency
|
624
|
+
def instruction_schedule_map(self):
|
625
|
+
"""Return an :class:`~qiskit.pulse.InstructionScheduleMap` for the
|
626
|
+
instructions in the target with a pulse schedule defined.
|
627
|
+
|
628
|
+
Returns:
|
629
|
+
InstructionScheduleMap: The instruction schedule map for the
|
630
|
+
instructions in this target with a pulse schedule defined.
|
631
|
+
"""
|
632
|
+
return self._get_instruction_schedule_map()
|
633
|
+
|
634
|
+
def _get_instruction_schedule_map(self):
|
635
|
+
if self._instruction_schedule_map is not None:
|
636
|
+
return self._instruction_schedule_map
|
637
|
+
with warnings.catch_warnings():
|
638
|
+
warnings.simplefilter(action="ignore", category=DeprecationWarning)
|
639
|
+
# `InstructionScheduleMap` is deprecated in Qiskit 1.3 but we want this alternative
|
640
|
+
# path to be clean of deprecation warnings
|
641
|
+
out_inst_schedule_map = InstructionScheduleMap()
|
642
|
+
|
643
|
+
for instruction, qargs in self._gate_map.items():
|
644
|
+
for qarg, properties in qargs.items():
|
645
|
+
# Directly getting CalibrationEntry not to invoke .get_schedule().
|
646
|
+
# This keeps PulseQobjDef un-parsed.
|
647
|
+
cal_entry = getattr(properties, "_calibration", None)
|
648
|
+
if cal_entry is not None:
|
649
|
+
# Use fast-path to add entries to the inst map.
|
650
|
+
out_inst_schedule_map._add(instruction, qarg, cal_entry)
|
651
|
+
self._instruction_schedule_map = out_inst_schedule_map
|
652
|
+
return out_inst_schedule_map
|
653
|
+
|
654
|
+
@deprecate_pulse_dependency
|
655
|
+
def has_calibration(
|
656
|
+
self,
|
657
|
+
operation_name: str,
|
658
|
+
qargs: tuple[int, ...],
|
659
|
+
) -> bool:
|
660
|
+
"""Return whether the instruction (operation + qubits) defines a calibration.
|
661
|
+
|
662
|
+
Args:
|
663
|
+
operation_name: The name of the operation for the instruction.
|
664
|
+
qargs: The tuple of qubit indices for the instruction.
|
665
|
+
|
666
|
+
Returns:
|
667
|
+
Returns ``True`` if the calibration is supported and ``False`` if it isn't.
|
668
|
+
"""
|
669
|
+
return self._has_calibration(operation_name, qargs)
|
670
|
+
|
671
|
+
def _has_calibration(
|
672
|
+
self,
|
673
|
+
operation_name: str,
|
674
|
+
qargs: tuple[int, ...],
|
675
|
+
) -> bool:
|
676
|
+
qargs = tuple(qargs)
|
677
|
+
if operation_name not in self._gate_map:
|
678
|
+
return False
|
679
|
+
if qargs not in self._gate_map[operation_name]:
|
680
|
+
return False
|
681
|
+
return getattr(self._gate_map[operation_name][qargs], "_calibration", None) is not None
|
682
|
+
|
683
|
+
@deprecate_pulse_dependency
|
684
|
+
def get_calibration(
|
685
|
+
self,
|
686
|
+
operation_name: str,
|
687
|
+
qargs: tuple[int, ...],
|
688
|
+
*args: ParameterValueType,
|
689
|
+
**kwargs: ParameterValueType,
|
690
|
+
) -> Schedule | ScheduleBlock:
|
691
|
+
"""Get calibrated pulse schedule for the instruction.
|
692
|
+
|
693
|
+
If calibration is templated with parameters, one can also provide those values
|
694
|
+
to build a schedule with assigned parameters.
|
695
|
+
|
696
|
+
Args:
|
697
|
+
operation_name: The name of the operation for the instruction.
|
698
|
+
qargs: The tuple of qubit indices for the instruction.
|
699
|
+
args: Parameter values to build schedule if any.
|
700
|
+
kwargs: Parameter values with name to build schedule if any.
|
701
|
+
|
702
|
+
Returns:
|
703
|
+
Calibrated pulse schedule of corresponding instruction.
|
704
|
+
"""
|
705
|
+
return self._get_calibration(operation_name, qargs, *args, *kwargs)
|
706
|
+
|
707
|
+
def _get_calibration(
|
708
|
+
self,
|
709
|
+
operation_name: str,
|
710
|
+
qargs: tuple[int, ...],
|
711
|
+
*args: ParameterValueType,
|
712
|
+
**kwargs: ParameterValueType,
|
713
|
+
) -> Schedule | ScheduleBlock:
|
714
|
+
if not self._has_calibration(operation_name, qargs):
|
715
|
+
raise KeyError(
|
716
|
+
f"Calibration of instruction {operation_name} for qubit {qargs} is not defined."
|
717
|
+
)
|
718
|
+
cal_entry = getattr(self._gate_map[operation_name][qargs], "_calibration")
|
719
|
+
return cal_entry.get_schedule(*args, **kwargs)
|
720
|
+
|
721
|
+
@property
|
722
|
+
def operation_names(self):
|
723
|
+
"""Get the operation names in the target."""
|
724
|
+
return self._gate_map.keys()
|
725
|
+
|
726
|
+
@property
|
727
|
+
def instructions(self):
|
728
|
+
"""Get the list of tuples ``(:class:`~qiskit.circuit.Instruction`, (qargs))``
|
729
|
+
for the target
|
730
|
+
|
731
|
+
For globally defined variable width operations the tuple will be of the form
|
732
|
+
``(class, None)`` where class is the actual operation class that
|
733
|
+
is globally defined.
|
734
|
+
"""
|
735
|
+
return [
|
736
|
+
(self._gate_name_map[op], qarg)
|
737
|
+
for op, qargs in self._gate_map.items()
|
738
|
+
for qarg in qargs
|
739
|
+
]
|
740
|
+
|
741
|
+
def instruction_properties(self, index):
|
742
|
+
"""Get the instruction properties for a specific instruction tuple
|
743
|
+
|
744
|
+
This method is to be used in conjunction with the
|
745
|
+
:attr:`~qiskit.transpiler.Target.instructions` attribute of a
|
746
|
+
:class:`~qiskit.transpiler.Target` object. You can use this method to quickly
|
747
|
+
get the instruction properties for an element of
|
748
|
+
:attr:`~qiskit.transpiler.Target.instructions` by using the index in that list.
|
749
|
+
However, if you're not working with :attr:`~qiskit.transpiler.Target.instructions`
|
750
|
+
directly it is likely more efficient to access the target directly via the name
|
751
|
+
and qubits to get the instruction properties. For example, if
|
752
|
+
:attr:`~qiskit.transpiler.Target.instructions` returned::
|
753
|
+
|
754
|
+
[(XGate(), (0,)), (XGate(), (1,))]
|
755
|
+
|
756
|
+
you could get the properties of the ``XGate`` on qubit 1 with::
|
757
|
+
|
758
|
+
props = target.instruction_properties(1)
|
759
|
+
|
760
|
+
but just accessing it directly via the name would be more efficient::
|
761
|
+
|
762
|
+
props = target['x'][(1,)]
|
763
|
+
|
764
|
+
(assuming the ``XGate``'s canonical name in the target is ``'x'``)
|
765
|
+
This is especially true for larger targets as this will scale worse with the number
|
766
|
+
of instruction tuples in a target.
|
767
|
+
|
768
|
+
Args:
|
769
|
+
index (int): The index of the instruction tuple from the
|
770
|
+
:attr:`~qiskit.transpiler.Target.instructions` attribute. For, example
|
771
|
+
if you want the properties from the third element in
|
772
|
+
:attr:`~qiskit.transpiler.Target.instructions` you would set this to be ``2``.
|
773
|
+
Returns:
|
774
|
+
InstructionProperties: The instruction properties for the specified instruction tuple
|
775
|
+
"""
|
776
|
+
instruction_properties = [
|
777
|
+
inst_props for qargs in self._gate_map.values() for inst_props in qargs.values()
|
778
|
+
]
|
779
|
+
return instruction_properties[index]
|
780
|
+
|
781
|
+
def _build_coupling_graph(self):
|
782
|
+
self._coupling_graph = rx.PyDiGraph(multigraph=False)
|
783
|
+
if self.num_qubits is not None:
|
784
|
+
self._coupling_graph.add_nodes_from([{} for _ in range(self.num_qubits)])
|
785
|
+
for gate, qarg_map in self._gate_map.items():
|
786
|
+
if qarg_map is None:
|
787
|
+
if self._gate_name_map[gate].num_qubits == 2:
|
788
|
+
self._coupling_graph = None # pylint: disable=attribute-defined-outside-init
|
789
|
+
return
|
790
|
+
continue
|
791
|
+
for qarg, properties in qarg_map.items():
|
792
|
+
if qarg is None:
|
793
|
+
if self.operation_from_name(gate).num_qubits == 2:
|
794
|
+
self._coupling_graph = None
|
795
|
+
return
|
796
|
+
continue
|
797
|
+
if len(qarg) == 1:
|
798
|
+
self._coupling_graph[qarg[0]] = (
|
799
|
+
properties # pylint: disable=attribute-defined-outside-init
|
800
|
+
)
|
801
|
+
elif len(qarg) == 2:
|
802
|
+
try:
|
803
|
+
edge_data = self._coupling_graph.get_edge_data(*qarg)
|
804
|
+
edge_data[gate] = properties
|
805
|
+
except rx.NoEdgeBetweenNodes:
|
806
|
+
self._coupling_graph.add_edge(*qarg, {gate: properties})
|
807
|
+
qargs = self.qargs
|
808
|
+
if self._coupling_graph.num_edges() == 0 and (
|
809
|
+
qargs is None or any(x is None for x in qargs)
|
810
|
+
):
|
811
|
+
self._coupling_graph = None # pylint: disable=attribute-defined-outside-init
|
812
|
+
|
813
|
+
def build_coupling_map(self, two_q_gate=None, filter_idle_qubits=False):
|
814
|
+
"""Get a :class:`~qiskit.transpiler.CouplingMap` from this target.
|
815
|
+
|
816
|
+
If there is a mix of two qubit operations that have a connectivity
|
817
|
+
constraint and those that are globally defined this will also return
|
818
|
+
``None`` because the globally connectivity means there is no constraint
|
819
|
+
on the target. If you wish to see the constraints of the two qubit
|
820
|
+
operations that have constraints you should use the ``two_q_gate``
|
821
|
+
argument to limit the output to the gates which have a constraint.
|
822
|
+
|
823
|
+
Args:
|
824
|
+
two_q_gate (str): An optional gate name for a two qubit gate in
|
825
|
+
the ``Target`` to generate the coupling map for. If specified the
|
826
|
+
output coupling map will only have edges between qubits where
|
827
|
+
this gate is present.
|
828
|
+
filter_idle_qubits (bool): If set to ``True`` the output :class:`~.CouplingMap`
|
829
|
+
will remove any qubits that don't have any operations defined in the
|
830
|
+
target. Note that using this argument will result in an output
|
831
|
+
:class:`~.CouplingMap` object which has holes in its indices
|
832
|
+
which might differ from the assumptions of the class. The typical use
|
833
|
+
case of this argument is to be paired with
|
834
|
+
:meth:`.CouplingMap.connected_components` which will handle the holes
|
835
|
+
as expected.
|
836
|
+
Returns:
|
837
|
+
CouplingMap: The :class:`~qiskit.transpiler.CouplingMap` object
|
838
|
+
for this target. If there are no connectivity constraints in
|
839
|
+
the target this will return ``None``.
|
840
|
+
|
841
|
+
Raises:
|
842
|
+
ValueError: If a non-two qubit gate is passed in for ``two_q_gate``.
|
843
|
+
IndexError: If an Instruction not in the ``Target`` is passed in for
|
844
|
+
``two_q_gate``.
|
845
|
+
"""
|
846
|
+
if self.qargs is None:
|
847
|
+
return None
|
848
|
+
if None not in self.qargs and any(len(x) > 2 for x in self.qargs):
|
849
|
+
logger.warning(
|
850
|
+
"This Target object contains multiqubit gates that "
|
851
|
+
"operate on > 2 qubits. This will not be reflected in "
|
852
|
+
"the output coupling map."
|
853
|
+
)
|
854
|
+
|
855
|
+
if two_q_gate is not None:
|
856
|
+
coupling_graph = rx.PyDiGraph(multigraph=False)
|
857
|
+
coupling_graph.add_nodes_from([None] * self.num_qubits)
|
858
|
+
for qargs, properties in self[two_q_gate].items():
|
859
|
+
if len(qargs) != 2:
|
860
|
+
raise ValueError(
|
861
|
+
f"Specified two_q_gate: {two_q_gate} is not a 2 qubit instruction"
|
862
|
+
)
|
863
|
+
coupling_graph.add_edge(*qargs, {two_q_gate: properties})
|
864
|
+
cmap = CouplingMap()
|
865
|
+
cmap.graph = coupling_graph
|
866
|
+
return cmap
|
867
|
+
if self._coupling_graph is None:
|
868
|
+
self._build_coupling_graph()
|
869
|
+
# if there is no connectivity constraints in the coupling graph treat it as not
|
870
|
+
# existing and return
|
871
|
+
if self._coupling_graph is not None:
|
872
|
+
cmap = CouplingMap()
|
873
|
+
if filter_idle_qubits:
|
874
|
+
cmap.graph = self._filter_coupling_graph()
|
875
|
+
else:
|
876
|
+
cmap.graph = self._coupling_graph.copy()
|
877
|
+
return cmap
|
878
|
+
else:
|
879
|
+
return None
|
880
|
+
|
881
|
+
def _filter_coupling_graph(self):
|
882
|
+
has_operations = set(itertools.chain.from_iterable(x for x in self.qargs if x is not None))
|
883
|
+
graph = self._coupling_graph.copy()
|
884
|
+
to_remove = set(graph.node_indices()).difference(has_operations)
|
885
|
+
if to_remove:
|
886
|
+
graph.remove_nodes_from(list(to_remove))
|
887
|
+
return graph
|
888
|
+
|
889
|
+
def __iter__(self):
|
890
|
+
return iter(self._gate_map)
|
891
|
+
|
892
|
+
def __getitem__(self, key):
|
893
|
+
return self._gate_map[key]
|
894
|
+
|
895
|
+
def get(self, key, default=None):
|
896
|
+
"""Gets an item from the Target. If not found return a provided default or `None`."""
|
897
|
+
try:
|
898
|
+
return self[key]
|
899
|
+
except KeyError:
|
900
|
+
return default
|
901
|
+
|
902
|
+
def __len__(self):
|
903
|
+
return len(self._gate_map)
|
904
|
+
|
905
|
+
def __contains__(self, item):
|
906
|
+
return item in self._gate_map
|
907
|
+
|
908
|
+
def keys(self):
|
909
|
+
"""Return the keys (operation_names) of the Target"""
|
910
|
+
return self._gate_map.keys()
|
911
|
+
|
912
|
+
def values(self):
|
913
|
+
"""Return the Property Map (qargs -> InstructionProperties) of every instruction in the Target"""
|
914
|
+
return self._gate_map.values()
|
915
|
+
|
916
|
+
def items(self):
|
917
|
+
"""Returns pairs of Gate names and its property map (str, dict[tuple, InstructionProperties])"""
|
918
|
+
return self._gate_map.items()
|
919
|
+
|
920
|
+
def __str__(self):
|
921
|
+
output = io.StringIO()
|
922
|
+
if self.description is not None:
|
923
|
+
output.write(f"Target: {self.description}\n")
|
924
|
+
else:
|
925
|
+
output.write("Target\n")
|
926
|
+
output.write(f"Number of qubits: {self.num_qubits}\n")
|
927
|
+
output.write("Instructions:\n")
|
928
|
+
for inst, qarg_props in self._gate_map.items():
|
929
|
+
output.write(f"\t{inst}\n")
|
930
|
+
for qarg, props in qarg_props.items():
|
931
|
+
if qarg is None:
|
932
|
+
continue
|
933
|
+
if props is None:
|
934
|
+
output.write(f"\t\t{qarg}\n")
|
935
|
+
continue
|
936
|
+
prop_str_pieces = [f"\t\t{qarg}:\n"]
|
937
|
+
duration = getattr(props, "duration", None)
|
938
|
+
if duration is not None:
|
939
|
+
prop_str_pieces.append(f"\t\t\tDuration: {duration:g} sec.\n")
|
940
|
+
error = getattr(props, "error", None)
|
941
|
+
if error is not None:
|
942
|
+
prop_str_pieces.append(f"\t\t\tError Rate: {error:g}\n")
|
943
|
+
schedule = getattr(props, "_calibration", None)
|
944
|
+
if schedule is not None:
|
945
|
+
prop_str_pieces.append("\t\t\tWith pulse schedule calibration\n")
|
946
|
+
extra_props = getattr(props, "properties", None)
|
947
|
+
if extra_props is not None:
|
948
|
+
extra_props_pieces = [
|
949
|
+
f"\t\t\t\t{key}: {value}\n" for key, value in extra_props.items()
|
950
|
+
]
|
951
|
+
extra_props_str = "".join(extra_props_pieces)
|
952
|
+
prop_str_pieces.append(f"\t\t\tExtra properties:\n{extra_props_str}\n")
|
953
|
+
output.write("".join(prop_str_pieces))
|
954
|
+
return output.getvalue()
|
955
|
+
|
956
|
+
def __getstate__(self) -> dict:
|
957
|
+
return {
|
958
|
+
"_gate_map": self._gate_map,
|
959
|
+
"coupling_graph": self._coupling_graph,
|
960
|
+
"instruction_durations": self._instruction_durations,
|
961
|
+
"instruction_schedule_map": self._instruction_schedule_map,
|
962
|
+
"base": super().__getstate__(),
|
963
|
+
}
|
964
|
+
|
965
|
+
def __setstate__(self, state: tuple):
|
966
|
+
self._gate_map = state["_gate_map"]
|
967
|
+
self._coupling_graph = state["coupling_graph"]
|
968
|
+
self._instruction_durations = state["instruction_durations"]
|
969
|
+
self._instruction_schedule_map = state["instruction_schedule_map"]
|
970
|
+
super().__setstate__(state["base"])
|
971
|
+
|
972
|
+
@classmethod
|
973
|
+
@deprecate_pulse_arg("inst_map")
|
974
|
+
def from_configuration(
|
975
|
+
cls,
|
976
|
+
basis_gates: list[str],
|
977
|
+
num_qubits: int | None = None,
|
978
|
+
coupling_map: CouplingMap | None = None,
|
979
|
+
inst_map: InstructionScheduleMap | None = None,
|
980
|
+
backend_properties: BackendProperties | None = None,
|
981
|
+
instruction_durations: InstructionDurations | None = None,
|
982
|
+
concurrent_measurements: Optional[List[List[int]]] = None,
|
983
|
+
dt: float | None = None,
|
984
|
+
timing_constraints: TimingConstraints | None = None,
|
985
|
+
custom_name_mapping: dict[str, Any] | None = None,
|
986
|
+
) -> Target:
|
987
|
+
"""Create a target object from the individual global configuration
|
988
|
+
|
989
|
+
Prior to the creation of the :class:`~.Target` class, the constraints
|
990
|
+
of a backend were represented by a collection of different objects
|
991
|
+
which combined represent a subset of the information contained in
|
992
|
+
the :class:`~.Target`. This function provides a simple interface
|
993
|
+
to convert those separate objects to a :class:`~.Target`.
|
994
|
+
|
995
|
+
This constructor will use the input from ``basis_gates``, ``num_qubits``,
|
996
|
+
and ``coupling_map`` to build a base model of the backend and the
|
997
|
+
``instruction_durations``, ``backend_properties``, and ``inst_map`` inputs
|
998
|
+
are then queried (in that order) based on that model to look up the properties
|
999
|
+
of each instruction and qubit. If there is an inconsistency between the inputs
|
1000
|
+
any extra or conflicting information present in ``instruction_durations``,
|
1001
|
+
``backend_properties``, or ``inst_map`` will be ignored.
|
1002
|
+
|
1003
|
+
Args:
|
1004
|
+
basis_gates: The list of basis gate names for the backend. For the
|
1005
|
+
target to be created these names must either be in the output
|
1006
|
+
from :func:`~.get_standard_gate_name_mapping` or present in the
|
1007
|
+
specified ``custom_name_mapping`` argument.
|
1008
|
+
num_qubits: The number of qubits supported on the backend.
|
1009
|
+
coupling_map: The coupling map representing connectivity constraints
|
1010
|
+
on the backend. If specified all gates from ``basis_gates`` will
|
1011
|
+
be supported on all qubits (or pairs of qubits).
|
1012
|
+
inst_map: DEPRECATED. The instruction schedule map representing the pulse
|
1013
|
+
:class:`~.Schedule` definitions for each instruction. If this
|
1014
|
+
is specified ``coupling_map`` must be specified. The
|
1015
|
+
``coupling_map`` is used as the source of truth for connectivity
|
1016
|
+
and if ``inst_map`` is used the schedule is looked up based
|
1017
|
+
on the instructions from the pair of ``basis_gates`` and
|
1018
|
+
``coupling_map``. If you want to define a custom gate for
|
1019
|
+
a particular qubit or qubit pair, you can manually build :class:`.Target`.
|
1020
|
+
backend_properties: The :class:`~.BackendProperties` object which is
|
1021
|
+
used for instruction properties and qubit properties.
|
1022
|
+
If specified and instruction properties are intended to be used
|
1023
|
+
then the ``coupling_map`` argument must be specified. This is
|
1024
|
+
only used to lookup error rates and durations (unless
|
1025
|
+
``instruction_durations`` is specified which would take
|
1026
|
+
precedence) for instructions specified via ``coupling_map`` and
|
1027
|
+
``basis_gates``.
|
1028
|
+
instruction_durations: Optional instruction durations for instructions. If specified
|
1029
|
+
it will take priority for setting the ``duration`` field in the
|
1030
|
+
:class:`~InstructionProperties` objects for the instructions in the target.
|
1031
|
+
concurrent_measurements(list): A list of sets of qubits that must be
|
1032
|
+
measured together. This must be provided
|
1033
|
+
as a nested list like ``[[0, 1], [2, 3, 4]]``.
|
1034
|
+
dt: The system time resolution of input signals in seconds
|
1035
|
+
timing_constraints: Optional timing constraints to include in the
|
1036
|
+
:class:`~.Target`
|
1037
|
+
custom_name_mapping: An optional dictionary that maps custom gate/operation names in
|
1038
|
+
``basis_gates`` to an :class:`~.Operation` object representing that
|
1039
|
+
gate/operation. By default, most standard gates names are mapped to the
|
1040
|
+
standard gate object from :mod:`qiskit.circuit.library` this only needs
|
1041
|
+
to be specified if the input ``basis_gates`` defines gates in names outside
|
1042
|
+
that set.
|
1043
|
+
|
1044
|
+
Returns:
|
1045
|
+
Target: the target built from the input configuration
|
1046
|
+
|
1047
|
+
Raises:
|
1048
|
+
TranspilerError: If the input basis gates contain > 2 qubits and ``coupling_map`` is
|
1049
|
+
specified.
|
1050
|
+
KeyError: If no mapping is available for a specified ``basis_gate``.
|
1051
|
+
"""
|
1052
|
+
granularity = 1
|
1053
|
+
min_length = 1
|
1054
|
+
pulse_alignment = 1
|
1055
|
+
acquire_alignment = 1
|
1056
|
+
if timing_constraints is not None:
|
1057
|
+
granularity = timing_constraints.granularity
|
1058
|
+
min_length = timing_constraints.min_length
|
1059
|
+
pulse_alignment = timing_constraints.pulse_alignment
|
1060
|
+
acquire_alignment = timing_constraints.acquire_alignment
|
1061
|
+
|
1062
|
+
qubit_properties = None
|
1063
|
+
if backend_properties is not None:
|
1064
|
+
# pylint: disable=cyclic-import
|
1065
|
+
from qiskit.providers.backend_compat import qubit_props_list_from_props
|
1066
|
+
|
1067
|
+
qubit_properties = qubit_props_list_from_props(properties=backend_properties)
|
1068
|
+
|
1069
|
+
target = cls(
|
1070
|
+
num_qubits=num_qubits,
|
1071
|
+
dt=dt,
|
1072
|
+
granularity=granularity,
|
1073
|
+
min_length=min_length,
|
1074
|
+
pulse_alignment=pulse_alignment,
|
1075
|
+
acquire_alignment=acquire_alignment,
|
1076
|
+
qubit_properties=qubit_properties,
|
1077
|
+
concurrent_measurements=concurrent_measurements,
|
1078
|
+
)
|
1079
|
+
name_mapping = get_standard_gate_name_mapping()
|
1080
|
+
if custom_name_mapping is not None:
|
1081
|
+
name_mapping.update(custom_name_mapping)
|
1082
|
+
|
1083
|
+
# While BackendProperties can also contain coupling information we
|
1084
|
+
# rely solely on CouplingMap to determine connectivity. This is because
|
1085
|
+
# in legacy transpiler usage (and implicitly in the BackendV1 data model)
|
1086
|
+
# the coupling map is used to define connectivity constraints and
|
1087
|
+
# the properties is only used for error rate and duration population.
|
1088
|
+
# If coupling map is not specified we ignore the backend_properties
|
1089
|
+
if coupling_map is None:
|
1090
|
+
for gate in basis_gates:
|
1091
|
+
if gate not in name_mapping:
|
1092
|
+
raise KeyError(
|
1093
|
+
f"The specified basis gate: {gate} is not present in the standard gate "
|
1094
|
+
"names or a provided custom_name_mapping"
|
1095
|
+
)
|
1096
|
+
target.add_instruction(name_mapping[gate], name=gate)
|
1097
|
+
else:
|
1098
|
+
one_qubit_gates = []
|
1099
|
+
two_qubit_gates = []
|
1100
|
+
global_ideal_variable_width_gates = [] # pylint: disable=invalid-name
|
1101
|
+
if num_qubits is None:
|
1102
|
+
num_qubits = len(coupling_map.graph)
|
1103
|
+
for gate in basis_gates:
|
1104
|
+
if gate not in name_mapping:
|
1105
|
+
raise KeyError(
|
1106
|
+
f"The specified basis gate: {gate} is not present in the standard gate "
|
1107
|
+
"names or a provided custom_name_mapping"
|
1108
|
+
)
|
1109
|
+
gate_obj = name_mapping[gate]
|
1110
|
+
if gate_obj.num_qubits == 1:
|
1111
|
+
one_qubit_gates.append(gate)
|
1112
|
+
elif gate_obj.num_qubits == 2:
|
1113
|
+
two_qubit_gates.append(gate)
|
1114
|
+
elif inspect.isclass(gate_obj):
|
1115
|
+
global_ideal_variable_width_gates.append(gate)
|
1116
|
+
else:
|
1117
|
+
raise TranspilerError(
|
1118
|
+
f"The specified basis gate: {gate} has {gate_obj.num_qubits} "
|
1119
|
+
"qubits. This constructor method only supports fixed width operations "
|
1120
|
+
"with <= 2 qubits (because connectivity is defined on a CouplingMap)."
|
1121
|
+
)
|
1122
|
+
for gate in one_qubit_gates:
|
1123
|
+
gate_properties: dict[tuple, InstructionProperties] = {}
|
1124
|
+
for qubit in range(num_qubits):
|
1125
|
+
error = None
|
1126
|
+
duration = None
|
1127
|
+
calibration = None
|
1128
|
+
if backend_properties is not None:
|
1129
|
+
if duration is None:
|
1130
|
+
try:
|
1131
|
+
duration = backend_properties.gate_length(gate, qubit)
|
1132
|
+
except BackendPropertyError:
|
1133
|
+
duration = None
|
1134
|
+
try:
|
1135
|
+
error = backend_properties.gate_error(gate, qubit)
|
1136
|
+
except BackendPropertyError:
|
1137
|
+
error = None
|
1138
|
+
if inst_map is not None:
|
1139
|
+
try:
|
1140
|
+
calibration = inst_map._get_calibration_entry(gate, qubit)
|
1141
|
+
# If we have dt defined and there is a custom calibration which is user
|
1142
|
+
# generate use that custom pulse schedule for the duration. If it is
|
1143
|
+
# not user generated than we assume it's the same duration as what is
|
1144
|
+
# defined in the backend properties
|
1145
|
+
if dt and calibration.user_provided:
|
1146
|
+
duration = calibration.get_schedule().duration * dt
|
1147
|
+
except PulseError:
|
1148
|
+
calibration = None
|
1149
|
+
# Durations if specified manually should override model objects
|
1150
|
+
if instruction_durations is not None:
|
1151
|
+
try:
|
1152
|
+
duration = instruction_durations.get(gate, qubit, unit="s")
|
1153
|
+
except TranspilerError:
|
1154
|
+
duration = None
|
1155
|
+
|
1156
|
+
if error is None and duration is None and calibration is None:
|
1157
|
+
gate_properties[(qubit,)] = None
|
1158
|
+
else:
|
1159
|
+
with warnings.catch_warnings():
|
1160
|
+
warnings.filterwarnings(
|
1161
|
+
"ignore",
|
1162
|
+
category=DeprecationWarning,
|
1163
|
+
message=".*``calibration`` is deprecated as of Qiskit 1.3.*",
|
1164
|
+
module="qiskit",
|
1165
|
+
)
|
1166
|
+
gate_properties[(qubit,)] = InstructionProperties(
|
1167
|
+
duration=duration, error=error, calibration=calibration
|
1168
|
+
)
|
1169
|
+
target.add_instruction(name_mapping[gate], properties=gate_properties, name=gate)
|
1170
|
+
edges = list(coupling_map.get_edges())
|
1171
|
+
for gate in two_qubit_gates:
|
1172
|
+
gate_properties = {}
|
1173
|
+
for edge in edges:
|
1174
|
+
error = None
|
1175
|
+
duration = None
|
1176
|
+
calibration = None
|
1177
|
+
if backend_properties is not None:
|
1178
|
+
if duration is None:
|
1179
|
+
try:
|
1180
|
+
duration = backend_properties.gate_length(gate, edge)
|
1181
|
+
except BackendPropertyError:
|
1182
|
+
duration = None
|
1183
|
+
try:
|
1184
|
+
error = backend_properties.gate_error(gate, edge)
|
1185
|
+
except BackendPropertyError:
|
1186
|
+
error = None
|
1187
|
+
if inst_map is not None:
|
1188
|
+
try:
|
1189
|
+
calibration = inst_map._get_calibration_entry(gate, edge)
|
1190
|
+
# If we have dt defined and there is a custom calibration which is user
|
1191
|
+
# generate use that custom pulse schedule for the duration. If it is
|
1192
|
+
# not user generated than we assume it's the same duration as what is
|
1193
|
+
# defined in the backend properties
|
1194
|
+
if dt and calibration.user_provided:
|
1195
|
+
duration = calibration.get_schedule().duration * dt
|
1196
|
+
except PulseError:
|
1197
|
+
calibration = None
|
1198
|
+
# Durations if specified manually should override model objects
|
1199
|
+
if instruction_durations is not None:
|
1200
|
+
try:
|
1201
|
+
duration = instruction_durations.get(gate, edge, unit="s")
|
1202
|
+
except TranspilerError:
|
1203
|
+
duration = None
|
1204
|
+
|
1205
|
+
if error is None and duration is None and calibration is None:
|
1206
|
+
gate_properties[edge] = None
|
1207
|
+
else:
|
1208
|
+
with warnings.catch_warnings():
|
1209
|
+
warnings.filterwarnings(
|
1210
|
+
"ignore",
|
1211
|
+
category=DeprecationWarning,
|
1212
|
+
message=".*``calibration`` is deprecated as of Qiskit 1.3.*",
|
1213
|
+
module="qiskit",
|
1214
|
+
)
|
1215
|
+
gate_properties[edge] = InstructionProperties(
|
1216
|
+
duration=duration, error=error, calibration=calibration
|
1217
|
+
)
|
1218
|
+
target.add_instruction(name_mapping[gate], properties=gate_properties, name=gate)
|
1219
|
+
for gate in global_ideal_variable_width_gates:
|
1220
|
+
target.add_instruction(name_mapping[gate], name=gate)
|
1221
|
+
return target
|
1222
|
+
|
1223
|
+
|
1224
|
+
Mapping.register(Target)
|
1225
|
+
|
1226
|
+
|
1227
|
+
@deprecate_func(
|
1228
|
+
since="1.2",
|
1229
|
+
removal_timeline="in the 2.0 release",
|
1230
|
+
additional_msg="This method is used to build an element from the deprecated "
|
1231
|
+
"``qiskit.providers.models`` module. These models are part of the deprecated `BackendV1` "
|
1232
|
+
"workflow and no longer necessary for `BackendV2`. If a user workflow requires these "
|
1233
|
+
"representations it likely relies on deprecated functionality and "
|
1234
|
+
"should be updated to use `BackendV2`.",
|
1235
|
+
)
|
1236
|
+
def target_to_backend_properties(target: Target):
|
1237
|
+
"""Convert a :class:`~.Target` object into a legacy :class:`~.BackendProperties`"""
|
1238
|
+
|
1239
|
+
properties_dict: dict[str, Any] = {
|
1240
|
+
"backend_name": "",
|
1241
|
+
"backend_version": "",
|
1242
|
+
"last_update_date": None,
|
1243
|
+
"general": [],
|
1244
|
+
}
|
1245
|
+
gates = []
|
1246
|
+
qubits = []
|
1247
|
+
for gate, qargs_list in target.items():
|
1248
|
+
if gate != "measure":
|
1249
|
+
for qargs, props in qargs_list.items():
|
1250
|
+
property_list = []
|
1251
|
+
if getattr(props, "duration", None) is not None:
|
1252
|
+
property_list.append(
|
1253
|
+
{
|
1254
|
+
"date": datetime.datetime.now(datetime.timezone.utc),
|
1255
|
+
"name": "gate_length",
|
1256
|
+
"unit": "s",
|
1257
|
+
"value": props.duration,
|
1258
|
+
}
|
1259
|
+
)
|
1260
|
+
if getattr(props, "error", None) is not None:
|
1261
|
+
property_list.append(
|
1262
|
+
{
|
1263
|
+
"date": datetime.datetime.now(datetime.timezone.utc),
|
1264
|
+
"name": "gate_error",
|
1265
|
+
"unit": "",
|
1266
|
+
"value": props.error,
|
1267
|
+
}
|
1268
|
+
)
|
1269
|
+
if property_list:
|
1270
|
+
gates.append(
|
1271
|
+
{
|
1272
|
+
"gate": gate,
|
1273
|
+
"qubits": list(qargs),
|
1274
|
+
"parameters": property_list,
|
1275
|
+
"name": gate + "_".join([str(x) for x in qargs]),
|
1276
|
+
}
|
1277
|
+
)
|
1278
|
+
else:
|
1279
|
+
qubit_props: dict[int, Any] = {}
|
1280
|
+
if target.num_qubits is not None:
|
1281
|
+
qubit_props = {x: None for x in range(target.num_qubits)}
|
1282
|
+
for qargs, props in qargs_list.items():
|
1283
|
+
if qargs is None:
|
1284
|
+
continue
|
1285
|
+
qubit = qargs[0]
|
1286
|
+
props_list = []
|
1287
|
+
if getattr(props, "error", None) is not None:
|
1288
|
+
props_list.append(
|
1289
|
+
{
|
1290
|
+
"date": datetime.datetime.now(datetime.timezone.utc),
|
1291
|
+
"name": "readout_error",
|
1292
|
+
"unit": "",
|
1293
|
+
"value": props.error,
|
1294
|
+
}
|
1295
|
+
)
|
1296
|
+
if getattr(props, "duration", None) is not None:
|
1297
|
+
props_list.append(
|
1298
|
+
{
|
1299
|
+
"date": datetime.datetime.now(datetime.timezone.utc),
|
1300
|
+
"name": "readout_length",
|
1301
|
+
"unit": "s",
|
1302
|
+
"value": props.duration,
|
1303
|
+
}
|
1304
|
+
)
|
1305
|
+
if not props_list:
|
1306
|
+
qubit_props = {}
|
1307
|
+
break
|
1308
|
+
qubit_props[qubit] = props_list
|
1309
|
+
if qubit_props and all(x is not None for x in qubit_props.values()):
|
1310
|
+
qubits = [qubit_props[i] for i in range(target.num_qubits)]
|
1311
|
+
if gates or qubits:
|
1312
|
+
properties_dict["gates"] = gates
|
1313
|
+
properties_dict["qubits"] = qubits
|
1314
|
+
with warnings.catch_warnings():
|
1315
|
+
# This raises BackendProperties internally
|
1316
|
+
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
1317
|
+
return BackendProperties.from_dict(properties_dict)
|
1318
|
+
else:
|
1319
|
+
return None
|