qiskit 2.0.3__cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.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 +141 -0
- qiskit/_accelerate.abi3.so +0 -0
- qiskit/_numpy_compat.py +73 -0
- qiskit/circuit/__init__.py +1343 -0
- qiskit/circuit/_add_control.py +312 -0
- qiskit/circuit/_classical_resource_map.py +150 -0
- qiskit/circuit/_standard_gates_commutations.py +3849 -0
- qiskit/circuit/_utils.py +167 -0
- qiskit/circuit/annotated_operation.py +279 -0
- qiskit/circuit/barrier.py +46 -0
- qiskit/circuit/classical/__init__.py +41 -0
- qiskit/circuit/classical/expr/__init__.py +266 -0
- qiskit/circuit/classical/expr/constructors.py +764 -0
- qiskit/circuit/classical/expr/expr.py +498 -0
- qiskit/circuit/classical/expr/visitors.py +375 -0
- qiskit/circuit/classical/types/__init__.py +113 -0
- qiskit/circuit/classical/types/ordering.py +229 -0
- qiskit/circuit/classical/types/types.py +153 -0
- qiskit/circuit/commutation_checker.py +133 -0
- qiskit/circuit/commutation_library.py +20 -0
- qiskit/circuit/controlflow/__init__.py +59 -0
- qiskit/circuit/controlflow/_builder_utils.py +211 -0
- qiskit/circuit/controlflow/box.py +163 -0
- qiskit/circuit/controlflow/break_loop.py +56 -0
- qiskit/circuit/controlflow/builder.py +791 -0
- qiskit/circuit/controlflow/continue_loop.py +56 -0
- qiskit/circuit/controlflow/control_flow.py +94 -0
- qiskit/circuit/controlflow/for_loop.py +218 -0
- qiskit/circuit/controlflow/if_else.py +498 -0
- qiskit/circuit/controlflow/switch_case.py +411 -0
- qiskit/circuit/controlflow/while_loop.py +166 -0
- qiskit/circuit/controlledgate.py +274 -0
- qiskit/circuit/delay.py +157 -0
- qiskit/circuit/duration.py +80 -0
- qiskit/circuit/equivalence.py +94 -0
- qiskit/circuit/equivalence_library.py +18 -0
- qiskit/circuit/exceptions.py +19 -0
- qiskit/circuit/gate.py +261 -0
- qiskit/circuit/instruction.py +564 -0
- qiskit/circuit/instructionset.py +132 -0
- qiskit/circuit/library/__init__.py +984 -0
- qiskit/circuit/library/arithmetic/__init__.py +40 -0
- qiskit/circuit/library/arithmetic/adders/__init__.py +18 -0
- qiskit/circuit/library/arithmetic/adders/adder.py +235 -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 +131 -0
- qiskit/circuit/library/arithmetic/functional_pauli_rotations.py +114 -0
- qiskit/circuit/library/arithmetic/integer_comparator.py +200 -0
- qiskit/circuit/library/arithmetic/linear_amplitude_function.py +363 -0
- qiskit/circuit/library/arithmetic/linear_pauli_rotations.py +243 -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 +201 -0
- qiskit/circuit/library/arithmetic/multipliers/rg_qft_multiplier.py +108 -0
- qiskit/circuit/library/arithmetic/piecewise_chebyshev.py +502 -0
- qiskit/circuit/library/arithmetic/piecewise_linear_pauli_rotations.py +387 -0
- qiskit/circuit/library/arithmetic/piecewise_polynomial_pauli_rotations.py +493 -0
- qiskit/circuit/library/arithmetic/polynomial_pauli_rotations.py +389 -0
- qiskit/circuit/library/arithmetic/quadratic_form.py +364 -0
- qiskit/circuit/library/arithmetic/weighted_adder.py +409 -0
- qiskit/circuit/library/basis_change/__init__.py +15 -0
- qiskit/circuit/library/basis_change/qft.py +316 -0
- qiskit/circuit/library/bit_flip_oracle.py +130 -0
- qiskit/circuit/library/blueprintcircuit.py +316 -0
- qiskit/circuit/library/boolean_logic/__init__.py +18 -0
- qiskit/circuit/library/boolean_logic/inner_product.py +157 -0
- qiskit/circuit/library/boolean_logic/quantum_and.py +204 -0
- qiskit/circuit/library/boolean_logic/quantum_or.py +206 -0
- qiskit/circuit/library/boolean_logic/quantum_xor.py +167 -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 +160 -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 +175 -0
- qiskit/circuit/library/generalized_gates/gr.py +219 -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 +84 -0
- qiskit/circuit/library/generalized_gates/permutation.py +198 -0
- qiskit/circuit/library/generalized_gates/rv.py +96 -0
- qiskit/circuit/library/generalized_gates/uc.py +303 -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 +217 -0
- qiskit/circuit/library/graph_state.py +172 -0
- qiskit/circuit/library/grover_operator.py +583 -0
- qiskit/circuit/library/hamiltonian_gate.py +142 -0
- qiskit/circuit/library/hidden_linear_function.py +163 -0
- qiskit/circuit/library/iqp.py +180 -0
- qiskit/circuit/library/n_local/__init__.py +45 -0
- qiskit/circuit/library/n_local/efficient_su2.py +282 -0
- qiskit/circuit/library/n_local/evolved_operator_ansatz.py +520 -0
- qiskit/circuit/library/n_local/excitation_preserving.py +303 -0
- qiskit/circuit/library/n_local/n_local.py +1477 -0
- qiskit/circuit/library/n_local/pauli_two_design.py +246 -0
- qiskit/circuit/library/n_local/qaoa_ansatz.py +367 -0
- qiskit/circuit/library/n_local/real_amplitudes.py +312 -0
- qiskit/circuit/library/n_local/two_local.py +289 -0
- qiskit/circuit/library/overlap.py +183 -0
- qiskit/circuit/library/pauli_evolution.py +201 -0
- qiskit/circuit/library/phase_estimation.py +177 -0
- qiskit/circuit/library/phase_oracle.py +239 -0
- qiskit/circuit/library/quantum_volume.py +180 -0
- qiskit/circuit/library/standard_gates/__init__.py +141 -0
- qiskit/circuit/library/standard_gates/dcx.py +77 -0
- qiskit/circuit/library/standard_gates/ecr.py +129 -0
- qiskit/circuit/library/standard_gates/equivalence_library.py +1800 -0
- qiskit/circuit/library/standard_gates/global_phase.py +84 -0
- qiskit/circuit/library/standard_gates/h.py +253 -0
- qiskit/circuit/library/standard_gates/i.py +76 -0
- qiskit/circuit/library/standard_gates/iswap.py +133 -0
- qiskit/circuit/library/standard_gates/p.py +422 -0
- qiskit/circuit/library/standard_gates/r.py +114 -0
- qiskit/circuit/library/standard_gates/rx.py +293 -0
- qiskit/circuit/library/standard_gates/rxx.py +180 -0
- qiskit/circuit/library/standard_gates/ry.py +286 -0
- qiskit/circuit/library/standard_gates/ryy.py +180 -0
- qiskit/circuit/library/standard_gates/rz.py +307 -0
- qiskit/circuit/library/standard_gates/rzx.py +226 -0
- qiskit/circuit/library/standard_gates/rzz.py +193 -0
- qiskit/circuit/library/standard_gates/s.py +419 -0
- qiskit/circuit/library/standard_gates/swap.py +281 -0
- qiskit/circuit/library/standard_gates/sx.py +310 -0
- qiskit/circuit/library/standard_gates/t.py +178 -0
- qiskit/circuit/library/standard_gates/u.py +395 -0
- qiskit/circuit/library/standard_gates/u1.py +490 -0
- qiskit/circuit/library/standard_gates/u2.py +145 -0
- qiskit/circuit/library/standard_gates/u3.py +428 -0
- qiskit/circuit/library/standard_gates/x.py +1481 -0
- qiskit/circuit/library/standard_gates/xx_minus_yy.py +202 -0
- qiskit/circuit/library/standard_gates/xx_plus_yy.py +236 -0
- qiskit/circuit/library/standard_gates/y.py +257 -0
- qiskit/circuit/library/standard_gates/z.py +338 -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 +53 -0
- qiskit/circuit/operation.py +68 -0
- qiskit/circuit/parameter.py +179 -0
- qiskit/circuit/parameterexpression.py +703 -0
- qiskit/circuit/parametertable.py +119 -0
- qiskit/circuit/parametervector.py +140 -0
- qiskit/circuit/quantumcircuit.py +7540 -0
- qiskit/circuit/quantumcircuitdata.py +136 -0
- qiskit/circuit/random/__init__.py +15 -0
- qiskit/circuit/random/utils.py +366 -0
- qiskit/circuit/reset.py +37 -0
- qiskit/circuit/singleton.py +600 -0
- qiskit/circuit/store.py +89 -0
- qiskit/circuit/tools/__init__.py +16 -0
- qiskit/circuit/tools/pi_check.py +193 -0
- qiskit/circuit/twirling.py +145 -0
- qiskit/compiler/__init__.py +27 -0
- qiskit/compiler/transpiler.py +375 -0
- qiskit/converters/__init__.py +74 -0
- qiskit/converters/circuit_to_dag.py +80 -0
- qiskit/converters/circuit_to_dagdependency.py +49 -0
- qiskit/converters/circuit_to_dagdependency_v2.py +46 -0
- qiskit/converters/circuit_to_gate.py +107 -0
- qiskit/converters/circuit_to_instruction.py +142 -0
- qiskit/converters/dag_to_circuit.py +79 -0
- qiskit/converters/dag_to_dagdependency.py +54 -0
- qiskit/converters/dag_to_dagdependency_v2.py +43 -0
- qiskit/converters/dagdependency_to_circuit.py +40 -0
- qiskit/converters/dagdependency_to_dag.py +48 -0
- qiskit/dagcircuit/__init__.py +55 -0
- qiskit/dagcircuit/collect_blocks.py +407 -0
- qiskit/dagcircuit/dagcircuit.py +24 -0
- qiskit/dagcircuit/dagdependency.py +612 -0
- qiskit/dagcircuit/dagdependency_v2.py +566 -0
- qiskit/dagcircuit/dagdepnode.py +160 -0
- qiskit/dagcircuit/dagnode.py +188 -0
- qiskit/dagcircuit/exceptions.py +42 -0
- qiskit/exceptions.py +153 -0
- qiskit/passmanager/__init__.py +258 -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 +353 -0
- qiskit/primitives/__init__.py +490 -0
- qiskit/primitives/backend_estimator_v2.py +530 -0
- qiskit/primitives/backend_sampler_v2.py +339 -0
- qiskit/primitives/base/__init__.py +20 -0
- qiskit/primitives/base/base_estimator.py +247 -0
- qiskit/primitives/base/base_primitive_job.py +78 -0
- qiskit/primitives/base/base_primitive_v1.py +45 -0
- qiskit/primitives/base/base_result_v1.py +65 -0
- qiskit/primitives/base/base_sampler.py +196 -0
- qiskit/primitives/base/estimator_result_v1.py +46 -0
- qiskit/primitives/base/sampler_result_v1.py +45 -0
- qiskit/primitives/base/validation_v1.py +250 -0
- qiskit/primitives/containers/__init__.py +26 -0
- qiskit/primitives/containers/bindings_array.py +391 -0
- qiskit/primitives/containers/bit_array.py +764 -0
- qiskit/primitives/containers/data_bin.py +175 -0
- qiskit/primitives/containers/estimator_pub.py +222 -0
- qiskit/primitives/containers/object_array.py +94 -0
- qiskit/primitives/containers/observables_array.py +296 -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/primitive_job.py +81 -0
- qiskit/primitives/statevector_estimator.py +175 -0
- qiskit/primitives/statevector_sampler.py +290 -0
- qiskit/primitives/utils.py +72 -0
- qiskit/providers/__init__.py +677 -0
- qiskit/providers/backend.py +364 -0
- qiskit/providers/basic_provider/__init__.py +47 -0
- qiskit/providers/basic_provider/basic_provider.py +121 -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 +693 -0
- qiskit/providers/basic_provider/exceptions.py +30 -0
- qiskit/providers/exceptions.py +33 -0
- qiskit/providers/fake_provider/__init__.py +69 -0
- qiskit/providers/fake_provider/generic_backend_v2.py +374 -0
- qiskit/providers/fake_provider/utils/__init__.py +15 -0
- qiskit/providers/job.py +147 -0
- qiskit/providers/jobstatus.py +30 -0
- qiskit/providers/options.py +273 -0
- qiskit/providers/providerutils.py +110 -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 +669 -0
- qiskit/qasm2/exceptions.py +27 -0
- qiskit/qasm2/export.py +364 -0
- qiskit/qasm2/parse.py +438 -0
- qiskit/qasm3/__init__.py +372 -0
- qiskit/qasm3/ast.py +782 -0
- qiskit/qasm3/exceptions.py +27 -0
- qiskit/qasm3/experimental.py +70 -0
- qiskit/qasm3/exporter.py +1340 -0
- qiskit/qasm3/printer.py +608 -0
- qiskit/qpy/__init__.py +1965 -0
- qiskit/qpy/binary_io/__init__.py +35 -0
- qiskit/qpy/binary_io/circuits.py +1455 -0
- qiskit/qpy/binary_io/parse_sympy_repr.py +121 -0
- qiskit/qpy/binary_io/schedules.py +308 -0
- qiskit/qpy/binary_io/value.py +1165 -0
- qiskit/qpy/common.py +353 -0
- qiskit/qpy/exceptions.py +53 -0
- qiskit/qpy/formats.py +442 -0
- qiskit/qpy/interface.py +344 -0
- qiskit/qpy/type_keys.py +409 -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 +104 -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 +373 -0
- qiskit/quantum_info/operators/channel/transformations.py +490 -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 +511 -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 +869 -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 +1032 -0
- qiskit/quantum_info/operators/symplectic/clifford_circuits.py +558 -0
- qiskit/quantum_info/operators/symplectic/pauli.py +755 -0
- qiskit/quantum_info/operators/symplectic/pauli_list.py +1242 -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 +1239 -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 +857 -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 +805 -0
- qiskit/quantum_info/states/statevector.py +977 -0
- qiskit/quantum_info/states/utils.py +247 -0
- qiskit/result/__init__.py +61 -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/models.py +241 -0
- qiskit/result/postprocess.py +239 -0
- qiskit/result/result.py +385 -0
- qiskit/result/sampled_expval.py +74 -0
- qiskit/result/utils.py +294 -0
- qiskit/synthesis/__init__.py +240 -0
- qiskit/synthesis/arithmetic/__init__.py +18 -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/comparators/__init__.py +16 -0
- qiskit/synthesis/arithmetic/comparators/compare_2s.py +112 -0
- qiskit/synthesis/arithmetic/comparators/compare_greedy.py +66 -0
- qiskit/synthesis/arithmetic/multipliers/__init__.py +16 -0
- qiskit/synthesis/arithmetic/multipliers/hrs_cumulative_multiplier.py +103 -0
- qiskit/synthesis/arithmetic/multipliers/rg_qft_multiplier.py +100 -0
- qiskit/synthesis/arithmetic/weighted_sum.py +155 -0
- qiskit/synthesis/boolean/__init__.py +13 -0
- qiskit/synthesis/boolean/boolean_expression.py +231 -0
- qiskit/synthesis/boolean/boolean_expression_synth.py +124 -0
- qiskit/synthesis/boolean/boolean_expression_visitor.py +96 -0
- qiskit/synthesis/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 +265 -0
- qiskit/synthesis/discrete_basis/gate_sequence.py +421 -0
- qiskit/synthesis/discrete_basis/generate_basis_approximations.py +165 -0
- qiskit/synthesis/discrete_basis/solovay_kitaev.py +240 -0
- qiskit/synthesis/evolution/__init__.py +21 -0
- qiskit/synthesis/evolution/evolution_synthesis.py +48 -0
- qiskit/synthesis/evolution/lie_trotter.py +120 -0
- qiskit/synthesis/evolution/matrix_synthesis.py +47 -0
- qiskit/synthesis/evolution/pauli_network.py +80 -0
- qiskit/synthesis/evolution/product_formula.py +313 -0
- qiskit/synthesis/evolution/qdrift.py +130 -0
- qiskit/synthesis/evolution/suzuki_trotter.py +224 -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 +61 -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 +61 -0
- qiskit/synthesis/linear_phase/cz_depth_lnn.py +58 -0
- qiskit/synthesis/multi_controlled/__init__.py +25 -0
- qiskit/synthesis/multi_controlled/mcmt_vchain.py +52 -0
- qiskit/synthesis/multi_controlled/mcx_synthesis.py +359 -0
- qiskit/synthesis/multi_controlled/multi_control_rotation_gates.py +206 -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 +20 -0
- qiskit/synthesis/two_qubit/local_invariance.py +63 -0
- qiskit/synthesis/two_qubit/two_qubit_decompose.py +583 -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 +1345 -0
- qiskit/transpiler/basepasses.py +190 -0
- qiskit/transpiler/coupling.py +500 -0
- qiskit/transpiler/exceptions.py +59 -0
- qiskit/transpiler/instruction_durations.py +281 -0
- qiskit/transpiler/layout.py +740 -0
- qiskit/transpiler/passes/__init__.py +276 -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 +138 -0
- qiskit/transpiler/passes/basis/decompose.py +137 -0
- qiskit/transpiler/passes/basis/translate_parameterized.py +175 -0
- qiskit/transpiler/passes/basis/unroll_3q_or_more.py +84 -0
- qiskit/transpiler/passes/basis/unroll_custom_definitions.py +110 -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 +128 -0
- qiskit/transpiler/passes/layout/csp_layout.py +132 -0
- qiskit/transpiler/passes/layout/dense_layout.py +177 -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 +116 -0
- qiskit/transpiler/passes/layout/layout_2q_distance.py +77 -0
- qiskit/transpiler/passes/layout/sabre_layout.py +506 -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 +256 -0
- qiskit/transpiler/passes/layout/vf2_post_layout.py +376 -0
- qiskit/transpiler/passes/layout/vf2_utils.py +235 -0
- qiskit/transpiler/passes/optimization/__init__.py +42 -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 +117 -0
- qiskit/transpiler/passes/optimization/collect_cliffords.py +109 -0
- qiskit/transpiler/passes/optimization/collect_linear_functions.py +85 -0
- qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py +242 -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 +176 -0
- qiskit/transpiler/passes/optimization/contract_idle_wires_in_control_flow.py +104 -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/light_cone.py +135 -0
- qiskit/transpiler/passes/optimization/optimize_1q_commutation.py +267 -0
- qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +250 -0
- qiskit/transpiler/passes/optimization/optimize_1q_gates.py +384 -0
- qiskit/transpiler/passes/optimization/optimize_annotated.py +449 -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 +70 -0
- qiskit/transpiler/passes/optimization/remove_reset_in_zero_state.py +37 -0
- qiskit/transpiler/passes/optimization/reset_after_measure_simplification.py +50 -0
- qiskit/transpiler/passes/optimization/split_2q_unitaries.py +63 -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 +639 -0
- qiskit/transpiler/passes/optimization/template_optimization.py +158 -0
- qiskit/transpiler/passes/routing/__init__.py +21 -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 +397 -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 +463 -0
- qiskit/transpiler/passes/routing/star_prerouting.py +408 -0
- qiskit/transpiler/passes/routing/utils.py +35 -0
- qiskit/transpiler/passes/scheduling/__init__.py +21 -0
- qiskit/transpiler/passes/scheduling/alignments/__init__.py +79 -0
- qiskit/transpiler/passes/scheduling/alignments/check_durations.py +70 -0
- qiskit/transpiler/passes/scheduling/alignments/reschedule.py +251 -0
- qiskit/transpiler/passes/scheduling/padding/__init__.py +16 -0
- qiskit/transpiler/passes/scheduling/padding/base_padding.py +284 -0
- qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +415 -0
- qiskit/transpiler/passes/scheduling/padding/pad_delay.py +90 -0
- qiskit/transpiler/passes/scheduling/scheduling/__init__.py +17 -0
- qiskit/transpiler/passes/scheduling/scheduling/alap.py +93 -0
- qiskit/transpiler/passes/scheduling/scheduling/asap.py +100 -0
- qiskit/transpiler/passes/scheduling/scheduling/base_scheduler.py +88 -0
- qiskit/transpiler/passes/scheduling/scheduling/set_io_latency.py +64 -0
- qiskit/transpiler/passes/scheduling/time_unit_conversion.py +237 -0
- qiskit/transpiler/passes/synthesis/__init__.py +20 -0
- qiskit/transpiler/passes/synthesis/aqc_plugin.py +153 -0
- qiskit/transpiler/passes/synthesis/default_unitary_synth_plugin.py +653 -0
- qiskit/transpiler/passes/synthesis/high_level_synthesis.py +429 -0
- qiskit/transpiler/passes/synthesis/hls_plugins.py +1963 -0
- qiskit/transpiler/passes/synthesis/linear_functions_synthesis.py +41 -0
- qiskit/transpiler/passes/synthesis/plugin.py +738 -0
- qiskit/transpiler/passes/synthesis/solovay_kitaev_synthesis.py +313 -0
- qiskit/transpiler/passes/synthesis/unitary_synthesis.py +425 -0
- qiskit/transpiler/passes/utils/__init__.py +32 -0
- qiskit/transpiler/passes/utils/barrier_before_final_measurements.py +41 -0
- qiskit/transpiler/passes/utils/check_gate_direction.py +60 -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 +61 -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 +66 -0
- qiskit/transpiler/passes/utils/fixed_point.py +48 -0
- qiskit/transpiler/passes/utils/gate_direction.py +93 -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 +50 -0
- qiskit/transpiler/passes/utils/remove_final_measurements.py +121 -0
- qiskit/transpiler/passes/utils/unroll_forloops.py +81 -0
- qiskit/transpiler/passmanager.py +503 -0
- qiskit/transpiler/passmanager_config.py +151 -0
- qiskit/transpiler/preset_passmanagers/__init__.py +93 -0
- qiskit/transpiler/preset_passmanagers/builtin_plugins.py +993 -0
- qiskit/transpiler/preset_passmanagers/common.py +672 -0
- qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py +437 -0
- qiskit/transpiler/preset_passmanagers/level0.py +104 -0
- qiskit/transpiler/preset_passmanagers/level1.py +108 -0
- qiskit/transpiler/preset_passmanagers/level2.py +109 -0
- qiskit/transpiler/preset_passmanagers/level3.py +110 -0
- qiskit/transpiler/preset_passmanagers/plugin.py +346 -0
- qiskit/transpiler/target.py +905 -0
- qiskit/transpiler/timing_constraints.py +59 -0
- qiskit/user_config.py +266 -0
- qiskit/utils/__init__.py +90 -0
- qiskit/utils/classtools.py +146 -0
- qiskit/utils/deprecation.py +382 -0
- qiskit/utils/lazy_tester.py +363 -0
- qiskit/utils/optionals.py +354 -0
- qiskit/utils/parallel.py +318 -0
- qiskit/utils/units.py +146 -0
- qiskit/version.py +84 -0
- qiskit/visualization/__init__.py +290 -0
- qiskit/visualization/array.py +207 -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 +735 -0
- qiskit/visualization/circuit/latex.py +661 -0
- qiskit/visualization/circuit/matplotlib.py +2019 -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 +1849 -0
- qiskit/visualization/circuit_visualization.py +19 -0
- qiskit/visualization/counts_visualization.py +487 -0
- qiskit/visualization/dag_visualization.py +318 -0
- qiskit/visualization/exceptions.py +21 -0
- qiskit/visualization/gate_map.py +1424 -0
- qiskit/visualization/library.py +40 -0
- qiskit/visualization/pass_manager_visualization.py +312 -0
- qiskit/visualization/state_visualization.py +1546 -0
- qiskit/visualization/timeline/__init__.py +21 -0
- qiskit/visualization/timeline/core.py +495 -0
- qiskit/visualization/timeline/drawings.py +260 -0
- qiskit/visualization/timeline/generators.py +506 -0
- qiskit/visualization/timeline/interface.py +444 -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 +195 -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-2.0.3.dist-info/METADATA +220 -0
- qiskit-2.0.3.dist-info/RECORD +690 -0
- qiskit-2.0.3.dist-info/WHEEL +6 -0
- qiskit-2.0.3.dist-info/entry_points.txt +82 -0
- qiskit-2.0.3.dist-info/licenses/LICENSE.txt +203 -0
- qiskit-2.0.3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,905 @@
|
|
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
|
+
|
24
|
+
from typing import Optional, List, Any
|
25
|
+
from collections.abc import Mapping
|
26
|
+
import io
|
27
|
+
import copy
|
28
|
+
import logging
|
29
|
+
import inspect
|
30
|
+
|
31
|
+
import rustworkx as rx
|
32
|
+
|
33
|
+
# import target class from the rust side
|
34
|
+
from qiskit._accelerate.target import (
|
35
|
+
BaseTarget,
|
36
|
+
BaseInstructionProperties,
|
37
|
+
)
|
38
|
+
|
39
|
+
from qiskit.circuit.library.standard_gates import get_standard_gate_name_mapping
|
40
|
+
from qiskit.circuit.duration import duration_in_dt
|
41
|
+
from qiskit.transpiler.coupling import CouplingMap
|
42
|
+
from qiskit.transpiler.exceptions import TranspilerError
|
43
|
+
from qiskit.transpiler.instruction_durations import InstructionDurations
|
44
|
+
from qiskit.transpiler.timing_constraints import TimingConstraints
|
45
|
+
|
46
|
+
# import QubitProperties here to provide convenience alias for building a
|
47
|
+
# full target
|
48
|
+
from qiskit.providers.backend import QubitProperties # pylint: disable=unused-import
|
49
|
+
|
50
|
+
logger = logging.getLogger(__name__)
|
51
|
+
|
52
|
+
|
53
|
+
class InstructionProperties(BaseInstructionProperties):
|
54
|
+
"""A representation of the properties of a gate implementation.
|
55
|
+
|
56
|
+
This class provides the optional properties that a backend can provide
|
57
|
+
about an instruction. These represent the set that the transpiler can
|
58
|
+
currently work with if present. However, if your backend provides additional
|
59
|
+
properties for instructions you should subclass this to add additional
|
60
|
+
custom attributes for those custom/additional properties by the backend.
|
61
|
+
"""
|
62
|
+
|
63
|
+
def __new__( # pylint: disable=keyword-arg-before-vararg
|
64
|
+
cls,
|
65
|
+
duration=None, # pylint: disable=keyword-arg-before-vararg
|
66
|
+
error=None, # pylint: disable=keyword-arg-before-vararg
|
67
|
+
*args, # pylint: disable=unused-argument
|
68
|
+
**kwargs, # pylint: disable=unused-argument
|
69
|
+
):
|
70
|
+
return super(InstructionProperties, cls).__new__( # pylint: disable=too-many-function-args
|
71
|
+
cls, duration, error
|
72
|
+
)
|
73
|
+
|
74
|
+
def __init__(
|
75
|
+
self,
|
76
|
+
duration: float | None = None, # pylint: disable=unused-argument
|
77
|
+
error: float | None = None, # pylint: disable=unused-argument
|
78
|
+
):
|
79
|
+
"""Create a new ``InstructionProperties`` object
|
80
|
+
|
81
|
+
Args:
|
82
|
+
duration: The duration, in seconds, of the instruction on the
|
83
|
+
specified set of qubits
|
84
|
+
error: The average error rate for the instruction on the specified
|
85
|
+
set of qubits.
|
86
|
+
"""
|
87
|
+
super().__init__()
|
88
|
+
|
89
|
+
def __repr__(self):
|
90
|
+
return f"InstructionProperties(duration={self.duration}, error={self.error})"
|
91
|
+
|
92
|
+
|
93
|
+
class Target(BaseTarget):
|
94
|
+
"""
|
95
|
+
The intent of the ``Target`` object is to inform Qiskit's compiler about
|
96
|
+
the constraints of a particular backend so the compiler can compile an
|
97
|
+
input circuit to something that works and is optimized for a device. It
|
98
|
+
currently contains a description of instructions on a backend and their
|
99
|
+
properties as well as some timing information. However, this exact
|
100
|
+
interface may evolve over time as the needs of the compiler change. These
|
101
|
+
changes will be done in a backwards compatible and controlled manner when
|
102
|
+
they are made (either through versioning, subclassing, or mixins) to add
|
103
|
+
on to the set of information exposed by a target.
|
104
|
+
|
105
|
+
As a basic example, let's assume backend has two qubits, supports
|
106
|
+
:class:`~qiskit.circuit.library.UGate` on both qubits and
|
107
|
+
:class:`~qiskit.circuit.library.CXGate` in both directions. To model this
|
108
|
+
you would create the target like::
|
109
|
+
|
110
|
+
from qiskit.transpiler import Target, InstructionProperties
|
111
|
+
from qiskit.circuit.library import UGate, CXGate
|
112
|
+
from qiskit.circuit import Parameter
|
113
|
+
|
114
|
+
gmap = Target()
|
115
|
+
theta = Parameter('theta')
|
116
|
+
phi = Parameter('phi')
|
117
|
+
lam = Parameter('lambda')
|
118
|
+
u_props = {
|
119
|
+
(0,): InstructionProperties(duration=5.23e-8, error=0.00038115),
|
120
|
+
(1,): InstructionProperties(duration=4.52e-8, error=0.00032115),
|
121
|
+
}
|
122
|
+
gmap.add_instruction(UGate(theta, phi, lam), u_props)
|
123
|
+
cx_props = {
|
124
|
+
(0,1): InstructionProperties(duration=5.23e-7, error=0.00098115),
|
125
|
+
(1,0): InstructionProperties(duration=4.52e-7, error=0.00132115),
|
126
|
+
}
|
127
|
+
gmap.add_instruction(CXGate(), cx_props)
|
128
|
+
|
129
|
+
Each instruction in the ``Target`` is indexed by a unique string name that uniquely
|
130
|
+
identifies that instance of an :class:`~qiskit.circuit.Instruction` object in
|
131
|
+
the Target. There is a 1:1 mapping between a name and an
|
132
|
+
:class:`~qiskit.circuit.Instruction` instance in the target and each name must
|
133
|
+
be unique. By default, the name is the :attr:`~qiskit.circuit.Instruction.name`
|
134
|
+
attribute of the instruction, but can be set to anything. This lets a single
|
135
|
+
target have multiple instances of the same instruction class with different
|
136
|
+
parameters. For example, if a backend target has two instances of an
|
137
|
+
:class:`~qiskit.circuit.library.RXGate` one is parameterized over any theta
|
138
|
+
while the other is tuned up for a theta of pi/6 you can add these by doing something
|
139
|
+
like::
|
140
|
+
|
141
|
+
import math
|
142
|
+
|
143
|
+
from qiskit.transpiler import Target, InstructionProperties
|
144
|
+
from qiskit.circuit.library import RXGate
|
145
|
+
from qiskit.circuit import Parameter
|
146
|
+
|
147
|
+
target = Target()
|
148
|
+
theta = Parameter('theta')
|
149
|
+
rx_props = {
|
150
|
+
(0,): InstructionProperties(duration=5.23e-8, error=0.00038115),
|
151
|
+
}
|
152
|
+
target.add_instruction(RXGate(theta), rx_props)
|
153
|
+
rx_30_props = {
|
154
|
+
(0,): InstructionProperties(duration=1.74e-6, error=.00012)
|
155
|
+
}
|
156
|
+
target.add_instruction(RXGate(math.pi / 6), rx_30_props, name='rx_30')
|
157
|
+
|
158
|
+
Then in the ``target`` object accessing by ``rx_30`` will get the fixed
|
159
|
+
angle :class:`~qiskit.circuit.library.RXGate` while ``rx`` will get the
|
160
|
+
parameterized :class:`~qiskit.circuit.library.RXGate`.
|
161
|
+
|
162
|
+
.. note::
|
163
|
+
|
164
|
+
This class assumes that qubit indices start at 0 and are a contiguous
|
165
|
+
set if you want a submapping the bits will need to be reindexed in
|
166
|
+
a new``Target`` object.
|
167
|
+
|
168
|
+
.. note::
|
169
|
+
|
170
|
+
This class only supports additions of gates, qargs, and qubits.
|
171
|
+
If you need to remove one of these the best option is to iterate over
|
172
|
+
an existing object and create a new subset (or use one of the methods
|
173
|
+
to do this). The object internally caches different views and these
|
174
|
+
would potentially be invalidated by removals.
|
175
|
+
"""
|
176
|
+
|
177
|
+
__slots__ = (
|
178
|
+
"_gate_map",
|
179
|
+
"_coupling_graph",
|
180
|
+
"_instruction_durations",
|
181
|
+
"_instruction_schedule_map",
|
182
|
+
)
|
183
|
+
|
184
|
+
def __new__( # pylint: disable=keyword-arg-before-vararg
|
185
|
+
cls,
|
186
|
+
description: str | None = None,
|
187
|
+
num_qubits: int = 0,
|
188
|
+
dt: float | None = None,
|
189
|
+
granularity: int = 1,
|
190
|
+
min_length: int = 1,
|
191
|
+
pulse_alignment: int = 1,
|
192
|
+
acquire_alignment: int = 1,
|
193
|
+
qubit_properties: list | None = None,
|
194
|
+
concurrent_measurements: list | None = None,
|
195
|
+
*args, # pylint: disable=unused-argument disable=keyword-arg-before-vararg
|
196
|
+
**kwargs, # pylint: disable=unused-argument
|
197
|
+
):
|
198
|
+
"""
|
199
|
+
Create a new ``Target`` object
|
200
|
+
|
201
|
+
Args:
|
202
|
+
description (str): An optional string to describe the Target.
|
203
|
+
num_qubits (int): An optional int to specify the number of qubits
|
204
|
+
the backend target has. If not set it will be implicitly set
|
205
|
+
based on the qargs when :meth:`~qiskit.Target.add_instruction`
|
206
|
+
is called. Note this must be set if the backend target is for a
|
207
|
+
noiseless simulator that doesn't have constraints on the
|
208
|
+
instructions so the transpiler knows how many qubits are
|
209
|
+
available.
|
210
|
+
dt (float): The system time resolution of input signals in seconds
|
211
|
+
granularity (int): An integer value representing minimum pulse gate
|
212
|
+
resolution in units of ``dt``. A user-defined pulse gate should
|
213
|
+
have duration of a multiple of this granularity value.
|
214
|
+
min_length (int): An integer value representing minimum pulse gate
|
215
|
+
length in units of ``dt``. A user-defined pulse gate should be
|
216
|
+
longer than this length.
|
217
|
+
pulse_alignment (int): An integer value representing a time
|
218
|
+
resolution of gate instruction starting time. Gate instruction
|
219
|
+
should start at time which is a multiple of the alignment
|
220
|
+
value.
|
221
|
+
acquire_alignment (int): An integer value representing a time
|
222
|
+
resolution of measure instruction starting time. Measure
|
223
|
+
instruction should start at time which is a multiple of the
|
224
|
+
alignment value.
|
225
|
+
qubit_properties (list): A list of :class:`~.QubitProperties`
|
226
|
+
objects defining the characteristics of each qubit on the
|
227
|
+
target device. If specified the length of this list must match
|
228
|
+
the number of qubits in the target, where the index in the list
|
229
|
+
matches the qubit number the properties are defined for. If some
|
230
|
+
qubits don't have properties available you can set that entry to
|
231
|
+
``None``
|
232
|
+
concurrent_measurements(list): A list of sets of qubits that must be
|
233
|
+
measured together. This must be provided
|
234
|
+
as a nested list like ``[[0, 1], [2, 3, 4]]``.
|
235
|
+
Raises:
|
236
|
+
ValueError: If both ``num_qubits`` and ``qubit_properties`` are both
|
237
|
+
defined and the value of ``num_qubits`` differs from the length of
|
238
|
+
``qubit_properties``.
|
239
|
+
"""
|
240
|
+
if description is not None:
|
241
|
+
description = str(description)
|
242
|
+
return super(Target, cls).__new__( # pylint: disable=too-many-function-args
|
243
|
+
cls,
|
244
|
+
description,
|
245
|
+
num_qubits,
|
246
|
+
dt,
|
247
|
+
granularity,
|
248
|
+
min_length,
|
249
|
+
pulse_alignment,
|
250
|
+
acquire_alignment,
|
251
|
+
qubit_properties,
|
252
|
+
concurrent_measurements,
|
253
|
+
)
|
254
|
+
|
255
|
+
def __init__(
|
256
|
+
self,
|
257
|
+
description=None, # pylint: disable=unused-argument
|
258
|
+
num_qubits=0, # pylint: disable=unused-argument
|
259
|
+
dt=None, # pylint: disable=unused-argument
|
260
|
+
granularity=1, # pylint: disable=unused-argument
|
261
|
+
min_length=1, # pylint: disable=unused-argument
|
262
|
+
pulse_alignment=1, # pylint: disable=unused-argument
|
263
|
+
acquire_alignment=1, # pylint: disable=unused-argument
|
264
|
+
qubit_properties=None, # pylint: disable=unused-argument
|
265
|
+
concurrent_measurements=None, # pylint: disable=unused-argument
|
266
|
+
):
|
267
|
+
# A nested mapping of gate name -> qargs -> properties
|
268
|
+
self._gate_map = {}
|
269
|
+
self._coupling_graph = None
|
270
|
+
self._instruction_durations = None
|
271
|
+
self._instruction_schedule_map = None
|
272
|
+
|
273
|
+
@property
|
274
|
+
def dt(self):
|
275
|
+
"""Return dt."""
|
276
|
+
return self._dt
|
277
|
+
|
278
|
+
@dt.setter
|
279
|
+
def dt(self, dt):
|
280
|
+
"""Set dt and invalidate instruction duration cache"""
|
281
|
+
self._dt = dt
|
282
|
+
self._instruction_durations = None
|
283
|
+
|
284
|
+
def add_instruction(self, instruction, properties=None, name=None):
|
285
|
+
"""Add a new instruction to the :class:`~qiskit.transpiler.Target`
|
286
|
+
|
287
|
+
As ``Target`` objects are strictly additive this is the primary method
|
288
|
+
for modifying a ``Target``. Typically, you will use this to fully populate
|
289
|
+
a ``Target`` before using it in :class:`~qiskit.providers.BackendV2`. For
|
290
|
+
example::
|
291
|
+
|
292
|
+
from qiskit.circuit.library import CXGate
|
293
|
+
from qiskit.transpiler import Target, InstructionProperties
|
294
|
+
|
295
|
+
target = Target()
|
296
|
+
cx_properties = {
|
297
|
+
(0, 1): None,
|
298
|
+
(1, 0): None,
|
299
|
+
(0, 2): None,
|
300
|
+
(2, 0): None,
|
301
|
+
(0, 3): None,
|
302
|
+
(2, 3): None,
|
303
|
+
(3, 0): None,
|
304
|
+
(3, 2): None
|
305
|
+
}
|
306
|
+
target.add_instruction(CXGate(), cx_properties)
|
307
|
+
|
308
|
+
Will add a :class:`~qiskit.circuit.library.CXGate` to the target with no
|
309
|
+
properties (duration, error, etc) with the coupling edge list:
|
310
|
+
``(0, 1), (1, 0), (0, 2), (2, 0), (0, 3), (2, 3), (3, 0), (3, 2)``. If
|
311
|
+
there are properties available for the instruction you can replace the
|
312
|
+
``None`` value in the properties dictionary with an
|
313
|
+
:class:`~qiskit.transpiler.InstructionProperties` object. This pattern
|
314
|
+
is repeated for each :class:`~qiskit.circuit.Instruction` the target
|
315
|
+
supports.
|
316
|
+
|
317
|
+
Args:
|
318
|
+
instruction (Union[qiskit.circuit.Instruction, Type[qiskit.circuit.Instruction]]):
|
319
|
+
The operation object to add to the map. If it's parameterized any value
|
320
|
+
of the parameter can be set. Optionally for variable width
|
321
|
+
instructions (such as control flow operations such as :class:`~.ForLoop` or
|
322
|
+
:class:`~MCXGate`) you can specify the class. If the class is specified than the
|
323
|
+
``name`` argument must be specified. When a class is used the gate is treated as global
|
324
|
+
and not having any properties set.
|
325
|
+
properties (dict): A dictionary of qarg entries to an
|
326
|
+
:class:`~qiskit.transpiler.InstructionProperties` object for that
|
327
|
+
instruction implementation on the backend. Properties are optional
|
328
|
+
for any instruction implementation, if there are no
|
329
|
+
:class:`~qiskit.transpiler.InstructionProperties` available for the
|
330
|
+
backend the value can be None. If there are no constraints on the
|
331
|
+
instruction (as in a noiseless/ideal simulation) this can be set to
|
332
|
+
``{None, None}`` which will indicate it runs on all qubits (or all
|
333
|
+
available permutations of qubits for multi-qubit gates). The first
|
334
|
+
``None`` indicates it applies to all qubits and the second ``None``
|
335
|
+
indicates there are no
|
336
|
+
:class:`~qiskit.transpiler.InstructionProperties` for the
|
337
|
+
instruction. By default, if properties is not set it is equivalent to
|
338
|
+
passing ``{None: None}``.
|
339
|
+
name (str): An optional name to use for identifying the instruction. If not
|
340
|
+
specified the :attr:`~qiskit.circuit.Instruction.name` attribute
|
341
|
+
of ``gate`` will be used. All gates in the ``Target`` need unique
|
342
|
+
names. Backends can differentiate between different
|
343
|
+
parameterization of a single gate by providing a unique name for
|
344
|
+
each (e.g. `"rx30"`, `"rx60", ``"rx90"`` similar to the example in the
|
345
|
+
documentation for the :class:`~qiskit.transpiler.Target` class).
|
346
|
+
Raises:
|
347
|
+
AttributeError: If gate is already in map
|
348
|
+
TranspilerError: If an operation class is passed in for ``instruction`` and no name
|
349
|
+
is specified or ``properties`` is set.
|
350
|
+
"""
|
351
|
+
is_class = inspect.isclass(instruction)
|
352
|
+
if not is_class:
|
353
|
+
instruction_name = name or instruction.name
|
354
|
+
else:
|
355
|
+
# Invalid to have class input without a name with characters set "" is not a valid name
|
356
|
+
if not name:
|
357
|
+
raise TranspilerError(
|
358
|
+
"A name must be specified when defining a supported global operation by class"
|
359
|
+
)
|
360
|
+
if properties is not None:
|
361
|
+
raise TranspilerError(
|
362
|
+
"An instruction added globally by class can't have properties set."
|
363
|
+
)
|
364
|
+
instruction_name = name
|
365
|
+
if properties is None or is_class:
|
366
|
+
properties = {None: None}
|
367
|
+
if instruction_name in self._gate_map:
|
368
|
+
raise AttributeError(f"Instruction {instruction_name} is already in the target")
|
369
|
+
super().add_instruction(instruction, instruction_name, properties)
|
370
|
+
self._gate_map[instruction_name] = properties
|
371
|
+
self._coupling_graph = None
|
372
|
+
self._instruction_durations = None
|
373
|
+
self._instruction_schedule_map = None
|
374
|
+
|
375
|
+
def update_instruction_properties(self, instruction, qargs, properties):
|
376
|
+
"""Update the property object for an instruction qarg pair already in the Target
|
377
|
+
|
378
|
+
Args:
|
379
|
+
instruction (str): The instruction name to update
|
380
|
+
qargs (tuple): The qargs to update the properties of
|
381
|
+
properties (InstructionProperties): The properties to set for this instruction
|
382
|
+
Raises:
|
383
|
+
KeyError: If ``instruction`` or ``qarg`` are not in the target
|
384
|
+
"""
|
385
|
+
super().update_instruction_properties(instruction, qargs, properties)
|
386
|
+
self._gate_map[instruction][qargs] = properties
|
387
|
+
self._instruction_durations = None
|
388
|
+
self._instruction_schedule_map = None
|
389
|
+
|
390
|
+
def qargs_for_operation_name(self, operation):
|
391
|
+
"""Get the qargs for a given operation name
|
392
|
+
|
393
|
+
Args:
|
394
|
+
operation (str): The operation name to get qargs for
|
395
|
+
Returns:
|
396
|
+
set: The set of qargs the gate instance applies to.
|
397
|
+
"""
|
398
|
+
if None in self._gate_map[operation]:
|
399
|
+
return None
|
400
|
+
return self._gate_map[operation].keys()
|
401
|
+
|
402
|
+
def durations(self):
|
403
|
+
"""Get an InstructionDurations object from the target
|
404
|
+
|
405
|
+
Returns:
|
406
|
+
InstructionDurations: The instruction duration represented in the
|
407
|
+
target
|
408
|
+
"""
|
409
|
+
if self._instruction_durations is not None:
|
410
|
+
return self._instruction_durations
|
411
|
+
out_durations = []
|
412
|
+
for instruction, props_map in self._gate_map.items():
|
413
|
+
for qarg, properties in props_map.items():
|
414
|
+
if properties is not None and properties.duration is not None:
|
415
|
+
out_durations.append((instruction, list(qarg), properties.duration, "s"))
|
416
|
+
self._instruction_durations = InstructionDurations(out_durations, dt=self.dt)
|
417
|
+
return self._instruction_durations
|
418
|
+
|
419
|
+
def timing_constraints(self):
|
420
|
+
"""Get an :class:`~qiskit.transpiler.TimingConstraints` object from the target
|
421
|
+
|
422
|
+
Returns:
|
423
|
+
TimingConstraints: The timing constraints represented in the ``Target``
|
424
|
+
"""
|
425
|
+
return TimingConstraints(
|
426
|
+
self.granularity, self.min_length, self.pulse_alignment, self.acquire_alignment
|
427
|
+
)
|
428
|
+
|
429
|
+
@property
|
430
|
+
def operation_names(self):
|
431
|
+
"""Get the operation names in the target."""
|
432
|
+
return self._gate_map.keys()
|
433
|
+
|
434
|
+
@property
|
435
|
+
def instructions(self):
|
436
|
+
"""Get the list of tuples (:class:`~qiskit.circuit.Instruction`, (qargs))
|
437
|
+
for the target
|
438
|
+
|
439
|
+
For globally defined variable width operations the tuple will be of the form
|
440
|
+
``(class, None)`` where class is the actual operation class that
|
441
|
+
is globally defined.
|
442
|
+
"""
|
443
|
+
return [
|
444
|
+
(self._gate_name_map[op], qarg)
|
445
|
+
for op, qargs in self._gate_map.items()
|
446
|
+
for qarg in qargs
|
447
|
+
]
|
448
|
+
|
449
|
+
def instruction_properties(self, index):
|
450
|
+
"""Get the instruction properties for a specific instruction tuple
|
451
|
+
|
452
|
+
This method is to be used in conjunction with the
|
453
|
+
:attr:`~qiskit.transpiler.Target.instructions` attribute of a
|
454
|
+
:class:`~qiskit.transpiler.Target` object. You can use this method to quickly
|
455
|
+
get the instruction properties for an element of
|
456
|
+
:attr:`~qiskit.transpiler.Target.instructions` by using the index in that list.
|
457
|
+
However, if you're not working with :attr:`~qiskit.transpiler.Target.instructions`
|
458
|
+
directly it is likely more efficient to access the target directly via the name
|
459
|
+
and qubits to get the instruction properties. For example, if
|
460
|
+
:attr:`~qiskit.transpiler.Target.instructions` returned::
|
461
|
+
|
462
|
+
[(XGate(), (0,)), (XGate(), (1,))]
|
463
|
+
|
464
|
+
you could get the properties of the ``XGate`` on qubit 1 with::
|
465
|
+
|
466
|
+
props = target.instruction_properties(1)
|
467
|
+
|
468
|
+
but just accessing it directly via the name would be more efficient::
|
469
|
+
|
470
|
+
props = target['x'][(1,)]
|
471
|
+
|
472
|
+
(assuming the ``XGate``'s canonical name in the target is ``'x'``)
|
473
|
+
This is especially true for larger targets as this will scale worse with the number
|
474
|
+
of instruction tuples in a target.
|
475
|
+
|
476
|
+
Args:
|
477
|
+
index (int): The index of the instruction tuple from the
|
478
|
+
:attr:`~qiskit.transpiler.Target.instructions` attribute. For, example
|
479
|
+
if you want the properties from the third element in
|
480
|
+
:attr:`~qiskit.transpiler.Target.instructions` you would set this to be ``2``.
|
481
|
+
Returns:
|
482
|
+
InstructionProperties: The instruction properties for the specified instruction tuple
|
483
|
+
"""
|
484
|
+
instruction_properties = [
|
485
|
+
inst_props for qargs in self._gate_map.values() for inst_props in qargs.values()
|
486
|
+
]
|
487
|
+
return instruction_properties[index]
|
488
|
+
|
489
|
+
def _build_coupling_graph(self):
|
490
|
+
self._coupling_graph = rx.PyDiGraph(multigraph=False)
|
491
|
+
if self.num_qubits is not None:
|
492
|
+
self._coupling_graph.add_nodes_from([{} for _ in range(self.num_qubits)])
|
493
|
+
for gate, qarg_map in self._gate_map.items():
|
494
|
+
if qarg_map is None:
|
495
|
+
if self._gate_name_map[gate].num_qubits == 2:
|
496
|
+
self._coupling_graph = None # pylint: disable=attribute-defined-outside-init
|
497
|
+
return
|
498
|
+
continue
|
499
|
+
for qarg, properties in qarg_map.items():
|
500
|
+
if qarg is None:
|
501
|
+
if self.operation_from_name(gate).num_qubits == 2:
|
502
|
+
self._coupling_graph = None
|
503
|
+
return
|
504
|
+
continue
|
505
|
+
if len(qarg) == 1:
|
506
|
+
self._coupling_graph[qarg[0]] = (
|
507
|
+
properties # pylint: disable=attribute-defined-outside-init
|
508
|
+
)
|
509
|
+
elif len(qarg) == 2:
|
510
|
+
try:
|
511
|
+
edge_data = self._coupling_graph.get_edge_data(*qarg)
|
512
|
+
edge_data[gate] = properties
|
513
|
+
except rx.NoEdgeBetweenNodes:
|
514
|
+
self._coupling_graph.add_edge(*qarg, {gate: properties})
|
515
|
+
qargs = self.qargs
|
516
|
+
if self._coupling_graph.num_edges() == 0 and (
|
517
|
+
qargs is None or any(x is None for x in qargs)
|
518
|
+
):
|
519
|
+
self._coupling_graph = None # pylint: disable=attribute-defined-outside-init
|
520
|
+
|
521
|
+
def build_coupling_map(self, two_q_gate=None, filter_idle_qubits=False):
|
522
|
+
"""Get a :class:`~qiskit.transpiler.CouplingMap` from this target.
|
523
|
+
|
524
|
+
If there is a mix of two qubit operations that have a connectivity
|
525
|
+
constraint and those that are globally defined this will also return
|
526
|
+
``None`` because the globally connectivity means there is no constraint
|
527
|
+
on the target. If you wish to see the constraints of the two qubit
|
528
|
+
operations that have constraints you should use the ``two_q_gate``
|
529
|
+
argument to limit the output to the gates which have a constraint.
|
530
|
+
|
531
|
+
Args:
|
532
|
+
two_q_gate (str): An optional gate name for a two qubit gate in
|
533
|
+
the ``Target`` to generate the coupling map for. If specified the
|
534
|
+
output coupling map will only have edges between qubits where
|
535
|
+
this gate is present.
|
536
|
+
filter_idle_qubits (bool): If set to ``True`` the output :class:`~.CouplingMap`
|
537
|
+
will remove any qubits that don't have any operations defined in the
|
538
|
+
target. Note that using this argument will result in an output
|
539
|
+
:class:`~.CouplingMap` object which has holes in its indices
|
540
|
+
which might differ from the assumptions of the class. The typical use
|
541
|
+
case of this argument is to be paired with
|
542
|
+
:meth:`.CouplingMap.connected_components` which will handle the holes
|
543
|
+
as expected.
|
544
|
+
Returns:
|
545
|
+
CouplingMap: The :class:`~qiskit.transpiler.CouplingMap` object
|
546
|
+
for this target. If there are no connectivity constraints in
|
547
|
+
the target this will return ``None``.
|
548
|
+
|
549
|
+
Raises:
|
550
|
+
ValueError: If a non-two qubit gate is passed in for ``two_q_gate``.
|
551
|
+
IndexError: If an Instruction not in the ``Target`` is passed in for
|
552
|
+
``two_q_gate``.
|
553
|
+
"""
|
554
|
+
if self.qargs is None:
|
555
|
+
return None
|
556
|
+
if None not in self.qargs and any(len(x) > 2 for x in self.qargs):
|
557
|
+
logger.warning(
|
558
|
+
"This Target object contains multiqubit gates that "
|
559
|
+
"operate on > 2 qubits. This will not be reflected in "
|
560
|
+
"the output coupling map."
|
561
|
+
)
|
562
|
+
|
563
|
+
if two_q_gate is not None:
|
564
|
+
coupling_graph = rx.PyDiGraph(multigraph=False)
|
565
|
+
coupling_graph.add_nodes_from([None] * self.num_qubits)
|
566
|
+
for qargs, properties in self[two_q_gate].items():
|
567
|
+
if len(qargs) != 2:
|
568
|
+
raise ValueError(
|
569
|
+
f"Specified two_q_gate: {two_q_gate} is not a 2 qubit instruction"
|
570
|
+
)
|
571
|
+
coupling_graph.add_edge(*qargs, {two_q_gate: properties})
|
572
|
+
cmap = CouplingMap()
|
573
|
+
cmap.graph = coupling_graph
|
574
|
+
return cmap
|
575
|
+
if self._coupling_graph is None:
|
576
|
+
self._build_coupling_graph()
|
577
|
+
# if there is no connectivity constraints in the coupling graph treat it as not
|
578
|
+
# existing and return
|
579
|
+
if self._coupling_graph is not None:
|
580
|
+
cmap = CouplingMap()
|
581
|
+
if filter_idle_qubits:
|
582
|
+
cmap.graph = self._filter_coupling_graph()
|
583
|
+
else:
|
584
|
+
cmap.graph = self._coupling_graph.copy()
|
585
|
+
return cmap
|
586
|
+
else:
|
587
|
+
return None
|
588
|
+
|
589
|
+
def _filter_coupling_graph(self):
|
590
|
+
has_operations = set(itertools.chain.from_iterable(x for x in self.qargs if x is not None))
|
591
|
+
graph = self._coupling_graph.copy()
|
592
|
+
to_remove = set(graph.node_indices()).difference(has_operations)
|
593
|
+
if to_remove:
|
594
|
+
graph.remove_nodes_from(list(to_remove))
|
595
|
+
return graph
|
596
|
+
|
597
|
+
def __iter__(self):
|
598
|
+
return iter(self._gate_map)
|
599
|
+
|
600
|
+
def __getitem__(self, key):
|
601
|
+
return self._gate_map[key]
|
602
|
+
|
603
|
+
def get(self, key, default=None):
|
604
|
+
"""Gets an item from the Target. If not found return a provided default or `None`."""
|
605
|
+
try:
|
606
|
+
return self[key]
|
607
|
+
except KeyError:
|
608
|
+
return default
|
609
|
+
|
610
|
+
def __len__(self):
|
611
|
+
return len(self._gate_map)
|
612
|
+
|
613
|
+
def __contains__(self, item):
|
614
|
+
return item in self._gate_map
|
615
|
+
|
616
|
+
def keys(self):
|
617
|
+
"""Return the keys (operation_names) of the Target"""
|
618
|
+
return self._gate_map.keys()
|
619
|
+
|
620
|
+
def values(self):
|
621
|
+
"""Return the Property Map (qargs -> InstructionProperties) of every instruction in the Target"""
|
622
|
+
return self._gate_map.values()
|
623
|
+
|
624
|
+
def items(self):
|
625
|
+
"""Returns pairs of Gate names and its property map (str, dict[tuple, InstructionProperties])"""
|
626
|
+
return self._gate_map.items()
|
627
|
+
|
628
|
+
def __str__(self):
|
629
|
+
output = io.StringIO()
|
630
|
+
if self.description is not None:
|
631
|
+
output.write(f"Target: {self.description}\n")
|
632
|
+
else:
|
633
|
+
output.write("Target\n")
|
634
|
+
output.write(f"Number of qubits: {self.num_qubits}\n")
|
635
|
+
output.write("Instructions:\n")
|
636
|
+
for inst, qarg_props in self._gate_map.items():
|
637
|
+
output.write(f"\t{inst}\n")
|
638
|
+
for qarg, props in qarg_props.items():
|
639
|
+
if qarg is None:
|
640
|
+
continue
|
641
|
+
if props is None:
|
642
|
+
output.write(f"\t\t{qarg}\n")
|
643
|
+
continue
|
644
|
+
prop_str_pieces = [f"\t\t{qarg}:\n"]
|
645
|
+
duration = getattr(props, "duration", None)
|
646
|
+
if duration is not None:
|
647
|
+
prop_str_pieces.append(f"\t\t\tDuration: {duration:g} sec.\n")
|
648
|
+
error = getattr(props, "error", None)
|
649
|
+
if error is not None:
|
650
|
+
prop_str_pieces.append(f"\t\t\tError Rate: {error:g}\n")
|
651
|
+
extra_props = getattr(props, "properties", None)
|
652
|
+
if extra_props is not None:
|
653
|
+
extra_props_pieces = [
|
654
|
+
f"\t\t\t\t{key}: {value}\n" for key, value in extra_props.items()
|
655
|
+
]
|
656
|
+
extra_props_str = "".join(extra_props_pieces)
|
657
|
+
prop_str_pieces.append(f"\t\t\tExtra properties:\n{extra_props_str}\n")
|
658
|
+
output.write("".join(prop_str_pieces))
|
659
|
+
return output.getvalue()
|
660
|
+
|
661
|
+
def __getstate__(self) -> dict:
|
662
|
+
return {
|
663
|
+
"_gate_map": self._gate_map,
|
664
|
+
"coupling_graph": self._coupling_graph,
|
665
|
+
"instruction_durations": self._instruction_durations,
|
666
|
+
"instruction_schedule_map": self._instruction_schedule_map,
|
667
|
+
"base": super().__getstate__(),
|
668
|
+
}
|
669
|
+
|
670
|
+
def __setstate__(self, state: tuple):
|
671
|
+
self._gate_map = state["_gate_map"]
|
672
|
+
self._coupling_graph = state["coupling_graph"]
|
673
|
+
self._instruction_durations = state["instruction_durations"]
|
674
|
+
self._instruction_schedule_map = state["instruction_schedule_map"]
|
675
|
+
super().__setstate__(state["base"])
|
676
|
+
|
677
|
+
def seconds_to_dt(self, duration: float) -> int:
|
678
|
+
"""Convert a given duration in seconds to units of dt
|
679
|
+
|
680
|
+
Args:
|
681
|
+
duration: The duration in seconds, such as in an :class:`.InstructionProperties`
|
682
|
+
field for an instruction in the target.
|
683
|
+
|
684
|
+
Returns
|
685
|
+
duration: The duration in units of dt
|
686
|
+
"""
|
687
|
+
return duration_in_dt(duration, self.dt)
|
688
|
+
|
689
|
+
@classmethod
|
690
|
+
def from_configuration(
|
691
|
+
cls,
|
692
|
+
basis_gates: list[str],
|
693
|
+
num_qubits: int | None = None,
|
694
|
+
coupling_map: CouplingMap | None = None,
|
695
|
+
instruction_durations: InstructionDurations | None = None,
|
696
|
+
concurrent_measurements: Optional[List[List[int]]] = None,
|
697
|
+
dt: float | None = None,
|
698
|
+
timing_constraints: TimingConstraints | None = None,
|
699
|
+
custom_name_mapping: dict[str, Any] | None = None,
|
700
|
+
) -> Target:
|
701
|
+
"""Create a target object from the individual global configuration
|
702
|
+
|
703
|
+
Prior to the creation of the :class:`~.Target` class, the constraints
|
704
|
+
of a backend were represented by a collection of different objects
|
705
|
+
which combined represent a subset of the information contained in
|
706
|
+
the :class:`~.Target`. This function provides a simple interface
|
707
|
+
to convert those separate objects to a :class:`~.Target`.
|
708
|
+
|
709
|
+
This constructor will use the input from ``basis_gates``, ``num_qubits``,
|
710
|
+
and ``coupling_map`` to build a base model of the backend and the
|
711
|
+
``instruction_durations``, ``backend_properties``, and ``inst_map`` inputs
|
712
|
+
are then queried (in that order) based on that model to look up the properties
|
713
|
+
of each instruction and qubit. If there is an inconsistency between the inputs
|
714
|
+
any extra or conflicting information present in ``instruction_durations``,
|
715
|
+
``backend_properties``, or ``inst_map`` will be ignored.
|
716
|
+
|
717
|
+
Args:
|
718
|
+
basis_gates: The list of basis gate names for the backend. For the
|
719
|
+
target to be created these names must either be in the output
|
720
|
+
from :func:`~.get_standard_gate_name_mapping` or present in the
|
721
|
+
specified ``custom_name_mapping`` argument.
|
722
|
+
num_qubits: The number of qubits supported on the backend.
|
723
|
+
coupling_map: The coupling map representing connectivity constraints
|
724
|
+
on the backend. If specified all gates from ``basis_gates`` will
|
725
|
+
be supported on all qubits (or pairs of qubits).
|
726
|
+
instruction_durations: Optional instruction durations for instructions. If specified
|
727
|
+
it will take priority for setting the ``duration`` field in the
|
728
|
+
:class:`~InstructionProperties` objects for the instructions in the target.
|
729
|
+
concurrent_measurements(list): A list of sets of qubits that must be
|
730
|
+
measured together. This must be provided
|
731
|
+
as a nested list like ``[[0, 1], [2, 3, 4]]``.
|
732
|
+
dt: The system time resolution of input signals in seconds
|
733
|
+
timing_constraints: Optional timing constraints to include in the
|
734
|
+
:class:`~.Target`
|
735
|
+
custom_name_mapping: An optional dictionary that maps custom gate/operation names in
|
736
|
+
``basis_gates`` to an :class:`~.Operation` object representing that
|
737
|
+
gate/operation. By default, most standard gates names are mapped to the
|
738
|
+
standard gate object from :mod:`qiskit.circuit.library` this only needs
|
739
|
+
to be specified if the input ``basis_gates`` defines gates in names outside
|
740
|
+
that set.
|
741
|
+
|
742
|
+
Returns:
|
743
|
+
Target: the target built from the input configuration
|
744
|
+
|
745
|
+
Raises:
|
746
|
+
TranspilerError: If the input basis gates contain > 2 qubits and ``coupling_map`` is
|
747
|
+
specified.
|
748
|
+
KeyError: If no mapping is available for a specified ``basis_gate``.
|
749
|
+
"""
|
750
|
+
granularity = 1
|
751
|
+
min_length = 1
|
752
|
+
pulse_alignment = 1
|
753
|
+
acquire_alignment = 1
|
754
|
+
if timing_constraints is not None:
|
755
|
+
granularity = timing_constraints.granularity
|
756
|
+
min_length = timing_constraints.min_length
|
757
|
+
pulse_alignment = timing_constraints.pulse_alignment
|
758
|
+
acquire_alignment = timing_constraints.acquire_alignment
|
759
|
+
|
760
|
+
qubit_properties = None
|
761
|
+
|
762
|
+
target = cls(
|
763
|
+
num_qubits=num_qubits,
|
764
|
+
dt=dt,
|
765
|
+
granularity=granularity,
|
766
|
+
min_length=min_length,
|
767
|
+
pulse_alignment=pulse_alignment,
|
768
|
+
acquire_alignment=acquire_alignment,
|
769
|
+
qubit_properties=qubit_properties,
|
770
|
+
concurrent_measurements=concurrent_measurements,
|
771
|
+
)
|
772
|
+
name_mapping = get_standard_gate_name_mapping()
|
773
|
+
if custom_name_mapping is not None:
|
774
|
+
name_mapping.update(custom_name_mapping)
|
775
|
+
|
776
|
+
# While BackendProperties can also contain coupling information we
|
777
|
+
# rely solely on CouplingMap to determine connectivity. This is because
|
778
|
+
# in legacy transpiler usage
|
779
|
+
# the coupling map is used to define connectivity constraints and
|
780
|
+
# the properties is only used for error rate and duration population.
|
781
|
+
# If coupling map is not specified we ignore the backend_properties
|
782
|
+
if coupling_map is None:
|
783
|
+
for gate in basis_gates:
|
784
|
+
if gate not in name_mapping:
|
785
|
+
raise KeyError(
|
786
|
+
f"The specified basis gate: {gate} is not present in the standard gate "
|
787
|
+
"names or a provided custom_name_mapping"
|
788
|
+
)
|
789
|
+
target.add_instruction(name_mapping[gate], name=gate)
|
790
|
+
else:
|
791
|
+
one_qubit_gates = []
|
792
|
+
two_qubit_gates = []
|
793
|
+
global_ideal_variable_width_gates = [] # pylint: disable=invalid-name
|
794
|
+
if num_qubits is None:
|
795
|
+
num_qubits = len(coupling_map.graph)
|
796
|
+
for gate in basis_gates:
|
797
|
+
if gate not in name_mapping:
|
798
|
+
raise KeyError(
|
799
|
+
f"The specified basis gate: {gate} is not present in the standard gate "
|
800
|
+
"names or a provided custom_name_mapping"
|
801
|
+
)
|
802
|
+
gate_obj = name_mapping[gate]
|
803
|
+
if gate_obj.num_qubits == 1:
|
804
|
+
one_qubit_gates.append(gate)
|
805
|
+
elif gate_obj.num_qubits == 2:
|
806
|
+
two_qubit_gates.append(gate)
|
807
|
+
elif inspect.isclass(gate_obj):
|
808
|
+
global_ideal_variable_width_gates.append(gate)
|
809
|
+
else:
|
810
|
+
raise TranspilerError(
|
811
|
+
f"The specified basis gate: {gate} has {gate_obj.num_qubits} "
|
812
|
+
"qubits. This constructor method only supports fixed width operations "
|
813
|
+
"with <= 2 qubits (because connectivity is defined on a CouplingMap)."
|
814
|
+
)
|
815
|
+
for gate in one_qubit_gates:
|
816
|
+
gate_properties: dict[tuple, InstructionProperties] = {}
|
817
|
+
for qubit in range(num_qubits):
|
818
|
+
error = None
|
819
|
+
duration = None
|
820
|
+
# Durations if specified manually should override model objects
|
821
|
+
if instruction_durations is not None:
|
822
|
+
try:
|
823
|
+
duration = instruction_durations.get(gate, qubit, unit="s")
|
824
|
+
except TranspilerError:
|
825
|
+
duration = None
|
826
|
+
|
827
|
+
if error is None and duration is None:
|
828
|
+
gate_properties[(qubit,)] = None
|
829
|
+
else:
|
830
|
+
gate_properties[(qubit,)] = InstructionProperties(
|
831
|
+
duration=duration, error=error
|
832
|
+
)
|
833
|
+
target.add_instruction(name_mapping[gate], properties=gate_properties, name=gate)
|
834
|
+
edges = list(coupling_map.get_edges())
|
835
|
+
for gate in two_qubit_gates:
|
836
|
+
gate_properties = {}
|
837
|
+
for edge in edges:
|
838
|
+
error = None
|
839
|
+
duration = None
|
840
|
+
# Durations if specified manually should override model objects
|
841
|
+
if instruction_durations is not None:
|
842
|
+
try:
|
843
|
+
duration = instruction_durations.get(gate, edge, unit="s")
|
844
|
+
except TranspilerError:
|
845
|
+
duration = None
|
846
|
+
|
847
|
+
if error is None and duration is None:
|
848
|
+
gate_properties[edge] = None
|
849
|
+
else:
|
850
|
+
gate_properties[edge] = InstructionProperties(
|
851
|
+
duration=duration, error=error
|
852
|
+
)
|
853
|
+
target.add_instruction(name_mapping[gate], properties=gate_properties, name=gate)
|
854
|
+
for gate in global_ideal_variable_width_gates:
|
855
|
+
target.add_instruction(name_mapping[gate], name=gate)
|
856
|
+
return target
|
857
|
+
|
858
|
+
|
859
|
+
Mapping.register(Target)
|
860
|
+
|
861
|
+
|
862
|
+
class _FakeTarget(Target):
|
863
|
+
"""
|
864
|
+
Pseudo-target class for INTERNAL use in the transpilation pipeline.
|
865
|
+
It's essentially an empty :class:`.Target` instance with a `coupling_map`
|
866
|
+
argument that allows to store connectivity constraints without basis gates.
|
867
|
+
This is intended to replace the use of loose constraints in the pipeline.
|
868
|
+
"""
|
869
|
+
|
870
|
+
def __init__(self, coupling_map=None, **kwargs):
|
871
|
+
super().__init__(**kwargs)
|
872
|
+
if coupling_map is None or isinstance(coupling_map, CouplingMap):
|
873
|
+
self._coupling_map = coupling_map
|
874
|
+
else:
|
875
|
+
self._coupling_map = CouplingMap(coupling_map)
|
876
|
+
|
877
|
+
def __len__(self):
|
878
|
+
return len(self._gate_map)
|
879
|
+
|
880
|
+
def build_coupling_map(self, *args, **kwargs): # pylint: disable=unused-argument
|
881
|
+
return copy.deepcopy(self._coupling_map)
|
882
|
+
|
883
|
+
def instruction_supported(self, *args, **kwargs):
|
884
|
+
"""Checks whether an instruction is supported by the
|
885
|
+
Target based on instruction name and qargs. Note that if there are no
|
886
|
+
basis gates in the Target, this method will always return ``True``.
|
887
|
+
"""
|
888
|
+
if len(self.operation_names) == 0:
|
889
|
+
return True
|
890
|
+
else:
|
891
|
+
return super().instruction_supported(*args, **kwargs)
|
892
|
+
|
893
|
+
@classmethod
|
894
|
+
def from_configuration(
|
895
|
+
cls,
|
896
|
+
*args,
|
897
|
+
num_qubits: int | None = None,
|
898
|
+
coupling_map: CouplingMap | list | None = None,
|
899
|
+
**kwargs,
|
900
|
+
) -> _FakeTarget:
|
901
|
+
|
902
|
+
if num_qubits is None and coupling_map is not None:
|
903
|
+
num_qubits = len(coupling_map.graph)
|
904
|
+
|
905
|
+
return cls(num_qubits=num_qubits, coupling_map=coupling_map, *args, **kwargs)
|