qiskit 1.0.0b1__cp38-abi3-manylinux_2_17_aarch64.manylinux2014_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 +195 -0
- qiskit/_accelerate.abi3.so +0 -0
- qiskit/_qasm2.abi3.so +0 -0
- qiskit/assembler/__init__.py +47 -0
- qiskit/assembler/assemble_circuits.py +408 -0
- qiskit/assembler/assemble_schedules.py +372 -0
- qiskit/assembler/disassemble.py +318 -0
- qiskit/assembler/run_config.py +77 -0
- qiskit/circuit/__init__.py +425 -0
- qiskit/circuit/_classical_resource_map.py +144 -0
- qiskit/circuit/_utils.py +170 -0
- qiskit/circuit/add_control.py +274 -0
- qiskit/circuit/annotated_operation.py +188 -0
- qiskit/circuit/barrier.py +51 -0
- qiskit/circuit/bit.py +142 -0
- qiskit/circuit/classical/__init__.py +41 -0
- qiskit/circuit/classical/expr/__init__.py +218 -0
- qiskit/circuit/classical/expr/constructors.py +473 -0
- qiskit/circuit/classical/expr/expr.py +356 -0
- qiskit/circuit/classical/expr/visitors.py +280 -0
- qiskit/circuit/classical/types/__init__.py +108 -0
- qiskit/circuit/classical/types/ordering.py +222 -0
- qiskit/circuit/classical/types/types.py +117 -0
- qiskit/circuit/classicalfunction/__init__.py +131 -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 +71 -0
- qiskit/circuit/commutation_checker.py +176 -0
- qiskit/circuit/controlflow/__init__.py +27 -0
- qiskit/circuit/controlflow/_builder_utils.py +199 -0
- qiskit/circuit/controlflow/break_loop.py +70 -0
- qiskit/circuit/controlflow/builder.py +651 -0
- qiskit/circuit/controlflow/continue_loop.py +72 -0
- qiskit/circuit/controlflow/control_flow.py +52 -0
- qiskit/circuit/controlflow/for_loop.py +232 -0
- qiskit/circuit/controlflow/if_else.py +517 -0
- qiskit/circuit/controlflow/switch_case.py +424 -0
- qiskit/circuit/controlflow/while_loop.py +177 -0
- qiskit/circuit/controlledgate.py +271 -0
- qiskit/circuit/delay.py +104 -0
- qiskit/circuit/duration.py +88 -0
- qiskit/circuit/equivalence.py +291 -0
- qiskit/circuit/equivalence_library.py +18 -0
- qiskit/circuit/exceptions.py +19 -0
- qiskit/circuit/gate.py +245 -0
- qiskit/circuit/instruction.py +655 -0
- qiskit/circuit/instructionset.py +191 -0
- qiskit/circuit/library/__init__.py +581 -0
- qiskit/circuit/library/arithmetic/__init__.py +27 -0
- qiskit/circuit/library/arithmetic/adders/__init__.py +17 -0
- qiskit/circuit/library/arithmetic/adders/adder.py +58 -0
- qiskit/circuit/library/arithmetic/adders/cdkm_ripple_carry_adder.py +159 -0
- qiskit/circuit/library/arithmetic/adders/draper_qft_adder.py +116 -0
- qiskit/circuit/library/arithmetic/adders/vbe_ripple_carry_adder.py +165 -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 +16 -0
- qiskit/circuit/library/arithmetic/multipliers/hrs_cumulative_multiplier.py +138 -0
- qiskit/circuit/library/arithmetic/multipliers/multiplier.py +101 -0
- qiskit/circuit/library/arithmetic/multipliers/rg_qft_multiplier.py +101 -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 +197 -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 +289 -0
- qiskit/circuit/library/blueprintcircuit.py +186 -0
- qiskit/circuit/library/boolean_logic/__init__.py +18 -0
- qiskit/circuit/library/boolean_logic/inner_product.py +78 -0
- qiskit/circuit/library/boolean_logic/quantum_and.py +97 -0
- qiskit/circuit/library/boolean_logic/quantum_or.py +98 -0
- qiskit/circuit/library/boolean_logic/quantum_xor.py +71 -0
- qiskit/circuit/library/data_preparation/__init__.py +47 -0
- qiskit/circuit/library/data_preparation/initializer.py +96 -0
- qiskit/circuit/library/data_preparation/pauli_feature_map.py +296 -0
- qiskit/circuit/library/data_preparation/state_preparation.py +526 -0
- qiskit/circuit/library/data_preparation/z_feature_map.py +104 -0
- qiskit/circuit/library/data_preparation/zz_feature_map.py +114 -0
- qiskit/circuit/library/evolved_operator_ansatz.py +245 -0
- qiskit/circuit/library/fourier_checking.py +97 -0
- qiskit/circuit/library/generalized_gates/__init__.py +30 -0
- qiskit/circuit/library/generalized_gates/diagonal.py +164 -0
- qiskit/circuit/library/generalized_gates/gms.py +121 -0
- qiskit/circuit/library/generalized_gates/gr.py +215 -0
- qiskit/circuit/library/generalized_gates/isometry.py +573 -0
- qiskit/circuit/library/generalized_gates/linear_function.py +302 -0
- qiskit/circuit/library/generalized_gates/mcg_up_to_diagonal.py +138 -0
- qiskit/circuit/library/generalized_gates/mcmt.py +254 -0
- qiskit/circuit/library/generalized_gates/pauli.py +85 -0
- qiskit/circuit/library/generalized_gates/permutation.py +190 -0
- qiskit/circuit/library/generalized_gates/rv.py +93 -0
- qiskit/circuit/library/generalized_gates/uc.py +304 -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 +198 -0
- qiskit/circuit/library/graph_state.py +86 -0
- qiskit/circuit/library/grover_operator.py +311 -0
- qiskit/circuit/library/hamiltonian_gate.py +146 -0
- qiskit/circuit/library/hidden_linear_function.py +98 -0
- qiskit/circuit/library/iqp.py +96 -0
- qiskit/circuit/library/n_local/__init__.py +31 -0
- qiskit/circuit/library/n_local/efficient_su2.py +162 -0
- qiskit/circuit/library/n_local/excitation_preserving.py +176 -0
- qiskit/circuit/library/n_local/n_local.py +1044 -0
- qiskit/circuit/library/n_local/pauli_two_design.py +131 -0
- qiskit/circuit/library/n_local/qaoa_ansatz.py +288 -0
- qiskit/circuit/library/n_local/real_amplitudes.py +189 -0
- qiskit/circuit/library/n_local/two_local.py +334 -0
- qiskit/circuit/library/overlap.py +111 -0
- qiskit/circuit/library/pauli_evolution.py +180 -0
- qiskit/circuit/library/phase_estimation.py +99 -0
- qiskit/circuit/library/phase_oracle.py +153 -0
- qiskit/circuit/library/quantum_volume.py +114 -0
- qiskit/circuit/library/standard_gates/__init__.py +116 -0
- qiskit/circuit/library/standard_gates/dcx.py +71 -0
- qiskit/circuit/library/standard_gates/ecr.py +114 -0
- qiskit/circuit/library/standard_gates/equivalence_library.py +1677 -0
- qiskit/circuit/library/standard_gates/global_phase.py +63 -0
- qiskit/circuit/library/standard_gates/h.py +224 -0
- qiskit/circuit/library/standard_gates/i.py +60 -0
- qiskit/circuit/library/standard_gates/iswap.py +129 -0
- qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py +390 -0
- qiskit/circuit/library/standard_gates/p.py +364 -0
- qiskit/circuit/library/standard_gates/r.py +101 -0
- qiskit/circuit/library/standard_gates/rx.py +246 -0
- qiskit/circuit/library/standard_gates/rxx.py +128 -0
- qiskit/circuit/library/standard_gates/ry.py +241 -0
- qiskit/circuit/library/standard_gates/ryy.py +128 -0
- qiskit/circuit/library/standard_gates/rz.py +261 -0
- qiskit/circuit/library/standard_gates/rzx.py +174 -0
- qiskit/circuit/library/standard_gates/rzz.py +141 -0
- qiskit/circuit/library/standard_gates/s.py +303 -0
- qiskit/circuit/library/standard_gates/swap.py +246 -0
- qiskit/circuit/library/standard_gates/sx.py +268 -0
- qiskit/circuit/library/standard_gates/t.py +150 -0
- qiskit/circuit/library/standard_gates/u.py +338 -0
- qiskit/circuit/library/standard_gates/u1.py +383 -0
- qiskit/circuit/library/standard_gates/u2.py +132 -0
- qiskit/circuit/library/standard_gates/u3.py +358 -0
- qiskit/circuit/library/standard_gates/x.py +1370 -0
- qiskit/circuit/library/standard_gates/xx_minus_yy.py +179 -0
- qiskit/circuit/library/standard_gates/xx_plus_yy.py +180 -0
- qiskit/circuit/library/standard_gates/y.py +221 -0
- qiskit/circuit/library/standard_gates/z.py +294 -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 +33 -0
- qiskit/circuit/library/templates/clifford/clifford_2_2.py +34 -0
- qiskit/circuit/library/templates/clifford/clifford_2_3.py +32 -0
- qiskit/circuit/library/templates/clifford/clifford_2_4.py +33 -0
- qiskit/circuit/library/templates/clifford/clifford_3_1.py +34 -0
- qiskit/circuit/library/templates/clifford/clifford_4_1.py +37 -0
- qiskit/circuit/library/templates/clifford/clifford_4_2.py +36 -0
- qiskit/circuit/library/templates/clifford/clifford_4_3.py +37 -0
- qiskit/circuit/library/templates/clifford/clifford_4_4.py +36 -0
- qiskit/circuit/library/templates/clifford/clifford_5_1.py +39 -0
- qiskit/circuit/library/templates/clifford/clifford_6_1.py +39 -0
- qiskit/circuit/library/templates/clifford/clifford_6_2.py +39 -0
- qiskit/circuit/library/templates/clifford/clifford_6_3.py +39 -0
- qiskit/circuit/library/templates/clifford/clifford_6_4.py +37 -0
- qiskit/circuit/library/templates/clifford/clifford_6_5.py +39 -0
- qiskit/circuit/library/templates/clifford/clifford_8_1.py +41 -0
- qiskit/circuit/library/templates/clifford/clifford_8_2.py +41 -0
- qiskit/circuit/library/templates/clifford/clifford_8_3.py +40 -0
- qiskit/circuit/library/templates/nct/__init__.py +67 -0
- qiskit/circuit/library/templates/nct/template_nct_2a_1.py +32 -0
- qiskit/circuit/library/templates/nct/template_nct_2a_2.py +33 -0
- qiskit/circuit/library/templates/nct/template_nct_2a_3.py +35 -0
- qiskit/circuit/library/templates/nct/template_nct_4a_1.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_4a_2.py +39 -0
- qiskit/circuit/library/templates/nct/template_nct_4a_3.py +37 -0
- qiskit/circuit/library/templates/nct/template_nct_4b_1.py +39 -0
- qiskit/circuit/library/templates/nct/template_nct_4b_2.py +37 -0
- qiskit/circuit/library/templates/nct/template_nct_5a_1.py +38 -0
- qiskit/circuit/library/templates/nct/template_nct_5a_2.py +38 -0
- qiskit/circuit/library/templates/nct/template_nct_5a_3.py +38 -0
- qiskit/circuit/library/templates/nct/template_nct_5a_4.py +37 -0
- qiskit/circuit/library/templates/nct/template_nct_6a_1.py +38 -0
- qiskit/circuit/library/templates/nct/template_nct_6a_2.py +39 -0
- qiskit/circuit/library/templates/nct/template_nct_6a_3.py +39 -0
- qiskit/circuit/library/templates/nct/template_nct_6a_4.py +39 -0
- qiskit/circuit/library/templates/nct/template_nct_6b_1.py +39 -0
- qiskit/circuit/library/templates/nct/template_nct_6b_2.py +39 -0
- qiskit/circuit/library/templates/nct/template_nct_6c_1.py +39 -0
- qiskit/circuit/library/templates/nct/template_nct_7a_1.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_7b_1.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_7c_1.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_7d_1.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_7e_1.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_9a_1.py +43 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_1.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_10.py +42 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_11.py +42 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_12.py +42 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_2.py +42 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_3.py +42 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_4.py +42 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_5.py +42 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_6.py +42 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_7.py +42 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_8.py +42 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_9.py +42 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_1.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_10.py +42 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_2.py +42 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_3.py +42 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_4.py +42 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_5.py +42 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_6.py +42 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_7.py +42 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_8.py +42 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_9.py +42 -0
- qiskit/circuit/library/templates/rzx/__init__.py +25 -0
- qiskit/circuit/library/templates/rzx/rzx_cy.py +46 -0
- qiskit/circuit/library/templates/rzx/rzx_xz.py +53 -0
- qiskit/circuit/library/templates/rzx/rzx_yz.py +43 -0
- qiskit/circuit/library/templates/rzx/rzx_zz1.py +67 -0
- qiskit/circuit/library/templates/rzx/rzx_zz2.py +58 -0
- qiskit/circuit/library/templates/rzx/rzx_zz3.py +57 -0
- qiskit/circuit/measure.py +41 -0
- qiskit/circuit/operation.py +62 -0
- qiskit/circuit/parameter.py +160 -0
- qiskit/circuit/parameterexpression.py +515 -0
- qiskit/circuit/parametertable.py +263 -0
- qiskit/circuit/parametervector.py +114 -0
- qiskit/circuit/qpy_serialization.py +28 -0
- qiskit/circuit/quantumcircuit.py +6074 -0
- qiskit/circuit/quantumcircuitdata.py +138 -0
- qiskit/circuit/quantumregister.py +90 -0
- qiskit/circuit/random/__init__.py +15 -0
- qiskit/circuit/random/utils.py +209 -0
- qiskit/circuit/register.py +256 -0
- qiskit/circuit/reset.py +31 -0
- qiskit/circuit/singleton.py +604 -0
- qiskit/circuit/store.py +87 -0
- qiskit/circuit/tools/__init__.py +16 -0
- qiskit/circuit/tools/pi_check.py +190 -0
- qiskit/compiler/__init__.py +33 -0
- qiskit/compiler/assembler.py +597 -0
- qiskit/compiler/scheduler.py +107 -0
- qiskit/compiler/sequencer.py +69 -0
- qiskit/compiler/transpiler.py +613 -0
- qiskit/converters/__init__.py +59 -0
- qiskit/converters/circuit_to_dag.py +96 -0
- qiskit/converters/circuit_to_dagdependency.py +51 -0
- qiskit/converters/circuit_to_gate.py +109 -0
- qiskit/converters/circuit_to_instruction.py +131 -0
- qiskit/converters/dag_to_circuit.py +77 -0
- qiskit/converters/dag_to_dagdependency.py +55 -0
- qiskit/converters/dagdependency_to_circuit.py +42 -0
- qiskit/converters/dagdependency_to_dag.py +49 -0
- qiskit/dagcircuit/__init__.py +44 -0
- qiskit/dagcircuit/collect_blocks.py +386 -0
- qiskit/dagcircuit/dagcircuit.py +2105 -0
- qiskit/dagcircuit/dagdependency.py +626 -0
- qiskit/dagcircuit/dagdepnode.py +157 -0
- qiskit/dagcircuit/dagnode.py +322 -0
- qiskit/dagcircuit/exceptions.py +42 -0
- qiskit/exceptions.py +97 -0
- qiskit/execute_function.py +354 -0
- qiskit/extensions/__init__.py +70 -0
- qiskit/extensions/exceptions.py +31 -0
- qiskit/extensions/quantum_initializer/__init__.py +26 -0
- qiskit/extensions/quantum_initializer/squ.py +163 -0
- qiskit/extensions/simulator/__init__.py +15 -0
- qiskit/extensions/simulator/snapshot.py +70 -0
- qiskit/namespace.py +76 -0
- qiskit/passmanager/__init__.py +242 -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 +336 -0
- qiskit/passmanager/passmanager.py +317 -0
- qiskit/primitives/__init__.py +62 -0
- qiskit/primitives/backend_estimator.py +473 -0
- qiskit/primitives/backend_sampler.py +209 -0
- qiskit/primitives/base/__init__.py +20 -0
- qiskit/primitives/base/base_estimator.py +256 -0
- qiskit/primitives/base/base_primitive.py +74 -0
- qiskit/primitives/base/base_result.py +87 -0
- qiskit/primitives/base/base_sampler.py +202 -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/estimator.py +158 -0
- qiskit/primitives/primitive_job.py +73 -0
- qiskit/primitives/sampler.py +155 -0
- qiskit/primitives/utils.py +216 -0
- qiskit/providers/__init__.py +773 -0
- qiskit/providers/backend.py +653 -0
- qiskit/providers/backend_compat.py +347 -0
- qiskit/providers/basicaer/__init__.py +73 -0
- qiskit/providers/basicaer/basicaerjob.py +65 -0
- qiskit/providers/basicaer/basicaerprovider.py +127 -0
- qiskit/providers/basicaer/basicaertools.py +186 -0
- qiskit/providers/basicaer/exceptions.py +30 -0
- qiskit/providers/basicaer/qasm_simulator.py +678 -0
- qiskit/providers/basicaer/statevector_simulator.py +121 -0
- qiskit/providers/basicaer/unitary_simulator.py +395 -0
- qiskit/providers/exceptions.py +45 -0
- qiskit/providers/fake_provider/__init__.py +267 -0
- qiskit/providers/fake_provider/backends/__init__.py +110 -0
- qiskit/providers/fake_provider/backends/almaden/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/almaden/conf_almaden.json +1 -0
- qiskit/providers/fake_provider/backends/almaden/fake_almaden.py +58 -0
- qiskit/providers/fake_provider/backends/almaden/props_almaden.json +1 -0
- qiskit/providers/fake_provider/backends/armonk/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/armonk/conf_armonk.json +1 -0
- qiskit/providers/fake_provider/backends/armonk/defs_armonk.json +1 -0
- qiskit/providers/fake_provider/backends/armonk/fake_armonk.py +48 -0
- qiskit/providers/fake_provider/backends/armonk/props_armonk.json +1 -0
- qiskit/providers/fake_provider/backends/athens/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/athens/conf_athens.json +1 -0
- qiskit/providers/fake_provider/backends/athens/defs_athens.json +1 -0
- qiskit/providers/fake_provider/backends/athens/fake_athens.py +38 -0
- qiskit/providers/fake_provider/backends/athens/props_athens.json +1 -0
- qiskit/providers/fake_provider/backends/auckland/__init__.py +15 -0
- qiskit/providers/fake_provider/backends/auckland/conf_auckland.json +1 -0
- qiskit/providers/fake_provider/backends/auckland/defs_auckland.json +1 -0
- qiskit/providers/fake_provider/backends/auckland/fake_auckland.py +29 -0
- qiskit/providers/fake_provider/backends/auckland/props_auckland.json +1 -0
- qiskit/providers/fake_provider/backends/belem/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/belem/conf_belem.json +1 -0
- qiskit/providers/fake_provider/backends/belem/defs_belem.json +1 -0
- qiskit/providers/fake_provider/backends/belem/fake_belem.py +38 -0
- qiskit/providers/fake_provider/backends/belem/props_belem.json +1 -0
- qiskit/providers/fake_provider/backends/boeblingen/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/boeblingen/conf_boeblingen.json +1 -0
- qiskit/providers/fake_provider/backends/boeblingen/defs_boeblingen.json +1 -0
- qiskit/providers/fake_provider/backends/boeblingen/fake_boeblingen.py +60 -0
- qiskit/providers/fake_provider/backends/boeblingen/props_boeblingen.json +1 -0
- qiskit/providers/fake_provider/backends/bogota/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/bogota/conf_bogota.json +1 -0
- qiskit/providers/fake_provider/backends/bogota/defs_bogota.json +1 -0
- qiskit/providers/fake_provider/backends/bogota/fake_bogota.py +38 -0
- qiskit/providers/fake_provider/backends/bogota/props_bogota.json +1 -0
- qiskit/providers/fake_provider/backends/brooklyn/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/brooklyn/conf_brooklyn.json +1 -0
- qiskit/providers/fake_provider/backends/brooklyn/defs_brooklyn.json +1 -0
- qiskit/providers/fake_provider/backends/brooklyn/fake_brooklyn.py +38 -0
- qiskit/providers/fake_provider/backends/brooklyn/props_brooklyn.json +1 -0
- qiskit/providers/fake_provider/backends/burlington/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/burlington/conf_burlington.json +1 -0
- qiskit/providers/fake_provider/backends/burlington/fake_burlington.py +50 -0
- qiskit/providers/fake_provider/backends/burlington/props_burlington.json +1 -0
- qiskit/providers/fake_provider/backends/cairo/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/cairo/conf_cairo.json +1 -0
- qiskit/providers/fake_provider/backends/cairo/defs_cairo.json +1 -0
- qiskit/providers/fake_provider/backends/cairo/fake_cairo.py +38 -0
- qiskit/providers/fake_provider/backends/cairo/props_cairo.json +1 -0
- qiskit/providers/fake_provider/backends/cambridge/__init__.py +17 -0
- qiskit/providers/fake_provider/backends/cambridge/conf_cambridge.json +1 -0
- qiskit/providers/fake_provider/backends/cambridge/fake_cambridge.py +72 -0
- qiskit/providers/fake_provider/backends/cambridge/props_cambridge.json +1 -0
- qiskit/providers/fake_provider/backends/cambridge/props_cambridge_alt.json +1 -0
- qiskit/providers/fake_provider/backends/casablanca/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/casablanca/conf_casablanca.json +1 -0
- qiskit/providers/fake_provider/backends/casablanca/defs_casablanca.json +1 -0
- qiskit/providers/fake_provider/backends/casablanca/fake_casablanca.py +38 -0
- qiskit/providers/fake_provider/backends/casablanca/props_casablanca.json +1 -0
- qiskit/providers/fake_provider/backends/essex/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/essex/conf_essex.json +1 -0
- qiskit/providers/fake_provider/backends/essex/fake_essex.py +54 -0
- qiskit/providers/fake_provider/backends/essex/props_essex.json +1 -0
- qiskit/providers/fake_provider/backends/geneva/__init__.py +15 -0
- qiskit/providers/fake_provider/backends/geneva/conf_geneva.json +1 -0
- qiskit/providers/fake_provider/backends/geneva/defs_geneva.json +1 -0
- qiskit/providers/fake_provider/backends/geneva/fake_geneva.py +29 -0
- qiskit/providers/fake_provider/backends/geneva/props_geneva.json +1 -0
- qiskit/providers/fake_provider/backends/guadalupe/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/guadalupe/conf_guadalupe.json +1 -0
- qiskit/providers/fake_provider/backends/guadalupe/defs_guadalupe.json +1 -0
- qiskit/providers/fake_provider/backends/guadalupe/fake_guadalupe.py +39 -0
- qiskit/providers/fake_provider/backends/guadalupe/props_guadalupe.json +1 -0
- qiskit/providers/fake_provider/backends/hanoi/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/hanoi/conf_hanoi.json +1 -0
- qiskit/providers/fake_provider/backends/hanoi/defs_hanoi.json +1 -0
- qiskit/providers/fake_provider/backends/hanoi/fake_hanoi.py +38 -0
- qiskit/providers/fake_provider/backends/hanoi/props_hanoi.json +1 -0
- qiskit/providers/fake_provider/backends/jakarta/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/jakarta/conf_jakarta.json +1 -0
- qiskit/providers/fake_provider/backends/jakarta/defs_jakarta.json +1 -0
- qiskit/providers/fake_provider/backends/jakarta/fake_jakarta.py +38 -0
- qiskit/providers/fake_provider/backends/jakarta/props_jakarta.json +1 -0
- qiskit/providers/fake_provider/backends/johannesburg/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/johannesburg/conf_johannesburg.json +1 -0
- qiskit/providers/fake_provider/backends/johannesburg/fake_johannesburg.py +58 -0
- qiskit/providers/fake_provider/backends/johannesburg/props_johannesburg.json +1 -0
- qiskit/providers/fake_provider/backends/kolkata/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/kolkata/conf_kolkata.json +1 -0
- qiskit/providers/fake_provider/backends/kolkata/defs_kolkata.json +1 -0
- qiskit/providers/fake_provider/backends/kolkata/fake_kolkata.py +38 -0
- qiskit/providers/fake_provider/backends/kolkata/props_kolkata.json +1 -0
- qiskit/providers/fake_provider/backends/lagos/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/lagos/conf_lagos.json +1 -0
- qiskit/providers/fake_provider/backends/lagos/defs_lagos.json +1 -0
- qiskit/providers/fake_provider/backends/lagos/fake_lagos.py +38 -0
- qiskit/providers/fake_provider/backends/lagos/props_lagos.json +1 -0
- qiskit/providers/fake_provider/backends/lima/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/lima/conf_lima.json +1 -0
- qiskit/providers/fake_provider/backends/lima/defs_lima.json +1 -0
- qiskit/providers/fake_provider/backends/lima/fake_lima.py +38 -0
- qiskit/providers/fake_provider/backends/lima/props_lima.json +1 -0
- qiskit/providers/fake_provider/backends/london/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/london/conf_london.json +1 -0
- qiskit/providers/fake_provider/backends/london/fake_london.py +54 -0
- qiskit/providers/fake_provider/backends/london/props_london.json +1 -0
- qiskit/providers/fake_provider/backends/manhattan/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/manhattan/conf_manhattan.json +1 -0
- qiskit/providers/fake_provider/backends/manhattan/defs_manhattan.json +1 -0
- qiskit/providers/fake_provider/backends/manhattan/fake_manhattan.py +38 -0
- qiskit/providers/fake_provider/backends/manhattan/props_manhattan.json +1 -0
- qiskit/providers/fake_provider/backends/manila/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/manila/conf_manila.json +1 -0
- qiskit/providers/fake_provider/backends/manila/defs_manila.json +1 -0
- qiskit/providers/fake_provider/backends/manila/fake_manila.py +38 -0
- qiskit/providers/fake_provider/backends/manila/props_manila.json +1 -0
- qiskit/providers/fake_provider/backends/melbourne/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/melbourne/conf_melbourne.json +1 -0
- qiskit/providers/fake_provider/backends/melbourne/fake_melbourne.py +91 -0
- qiskit/providers/fake_provider/backends/melbourne/props_melbourne.json +1 -0
- qiskit/providers/fake_provider/backends/montreal/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/montreal/conf_montreal.json +1 -0
- qiskit/providers/fake_provider/backends/montreal/defs_montreal.json +1 -0
- qiskit/providers/fake_provider/backends/montreal/fake_montreal.py +38 -0
- qiskit/providers/fake_provider/backends/montreal/props_montreal.json +1 -0
- qiskit/providers/fake_provider/backends/mumbai/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/mumbai/conf_mumbai.json +1 -0
- qiskit/providers/fake_provider/backends/mumbai/defs_mumbai.json +1 -0
- qiskit/providers/fake_provider/backends/mumbai/fake_mumbai.py +38 -0
- qiskit/providers/fake_provider/backends/mumbai/props_mumbai.json +1 -0
- qiskit/providers/fake_provider/backends/nairobi/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/nairobi/conf_nairobi.json +1 -0
- qiskit/providers/fake_provider/backends/nairobi/defs_nairobi.json +1 -0
- qiskit/providers/fake_provider/backends/nairobi/fake_nairobi.py +38 -0
- qiskit/providers/fake_provider/backends/nairobi/props_nairobi.json +1 -0
- qiskit/providers/fake_provider/backends/oslo/__init__.py +15 -0
- qiskit/providers/fake_provider/backends/oslo/conf_oslo.json +1 -0
- qiskit/providers/fake_provider/backends/oslo/defs_oslo.json +1 -0
- qiskit/providers/fake_provider/backends/oslo/fake_oslo.py +29 -0
- qiskit/providers/fake_provider/backends/oslo/props_oslo.json +1 -0
- qiskit/providers/fake_provider/backends/ourense/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/ourense/conf_ourense.json +1 -0
- qiskit/providers/fake_provider/backends/ourense/fake_ourense.py +50 -0
- qiskit/providers/fake_provider/backends/ourense/props_ourense.json +1 -0
- qiskit/providers/fake_provider/backends/paris/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/paris/conf_paris.json +1 -0
- qiskit/providers/fake_provider/backends/paris/defs_paris.json +1 -0
- qiskit/providers/fake_provider/backends/paris/fake_paris.py +64 -0
- qiskit/providers/fake_provider/backends/paris/props_paris.json +1 -0
- qiskit/providers/fake_provider/backends/perth/__init__.py +15 -0
- qiskit/providers/fake_provider/backends/perth/conf_perth.json +1 -0
- qiskit/providers/fake_provider/backends/perth/defs_perth.json +1 -0
- qiskit/providers/fake_provider/backends/perth/fake_perth.py +29 -0
- qiskit/providers/fake_provider/backends/perth/props_perth.json +1 -0
- qiskit/providers/fake_provider/backends/poughkeepsie/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/poughkeepsie/conf_poughkeepsie.json +1 -0
- qiskit/providers/fake_provider/backends/poughkeepsie/defs_poughkeepsie.json +1 -0
- qiskit/providers/fake_provider/backends/poughkeepsie/fake_poughkeepsie.py +124 -0
- qiskit/providers/fake_provider/backends/poughkeepsie/props_poughkeepsie.json +1 -0
- qiskit/providers/fake_provider/backends/prague/__init__.py +15 -0
- qiskit/providers/fake_provider/backends/prague/conf_prague.json +1 -0
- qiskit/providers/fake_provider/backends/prague/fake_prague.py +28 -0
- qiskit/providers/fake_provider/backends/prague/props_prague.json +1 -0
- qiskit/providers/fake_provider/backends/quito/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/quito/conf_quito.json +1 -0
- qiskit/providers/fake_provider/backends/quito/defs_quito.json +1 -0
- qiskit/providers/fake_provider/backends/quito/fake_quito.py +38 -0
- qiskit/providers/fake_provider/backends/quito/props_quito.json +1 -0
- qiskit/providers/fake_provider/backends/rochester/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/rochester/conf_rochester.json +1 -0
- qiskit/providers/fake_provider/backends/rochester/fake_rochester.py +36 -0
- qiskit/providers/fake_provider/backends/rochester/props_rochester.json +1 -0
- qiskit/providers/fake_provider/backends/rome/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/rome/conf_rome.json +1 -0
- qiskit/providers/fake_provider/backends/rome/defs_rome.json +1 -0
- qiskit/providers/fake_provider/backends/rome/fake_rome.py +38 -0
- qiskit/providers/fake_provider/backends/rome/props_rome.json +1 -0
- qiskit/providers/fake_provider/backends/rueschlikon/__init__.py +15 -0
- qiskit/providers/fake_provider/backends/rueschlikon/fake_rueschlikon.py +74 -0
- qiskit/providers/fake_provider/backends/santiago/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/santiago/conf_santiago.json +1 -0
- qiskit/providers/fake_provider/backends/santiago/defs_santiago.json +1 -0
- qiskit/providers/fake_provider/backends/santiago/fake_santiago.py +38 -0
- qiskit/providers/fake_provider/backends/santiago/props_santiago.json +1 -0
- qiskit/providers/fake_provider/backends/sherbrooke/__init__.py +17 -0
- qiskit/providers/fake_provider/backends/sherbrooke/conf_sherbrooke.json +1 -0
- qiskit/providers/fake_provider/backends/sherbrooke/defs_sherbrooke.json +1 -0
- qiskit/providers/fake_provider/backends/sherbrooke/fake_sherbrooke.py +28 -0
- qiskit/providers/fake_provider/backends/sherbrooke/props_sherbrooke.json +1 -0
- qiskit/providers/fake_provider/backends/singapore/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/singapore/conf_singapore.json +1 -0
- qiskit/providers/fake_provider/backends/singapore/fake_singapore.py +58 -0
- qiskit/providers/fake_provider/backends/singapore/props_singapore.json +1 -0
- qiskit/providers/fake_provider/backends/sydney/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/sydney/conf_sydney.json +1 -0
- qiskit/providers/fake_provider/backends/sydney/defs_sydney.json +1 -0
- qiskit/providers/fake_provider/backends/sydney/fake_sydney.py +38 -0
- qiskit/providers/fake_provider/backends/sydney/props_sydney.json +1 -0
- qiskit/providers/fake_provider/backends/tenerife/__init__.py +15 -0
- qiskit/providers/fake_provider/backends/tenerife/fake_tenerife.py +64 -0
- qiskit/providers/fake_provider/backends/tenerife/props_tenerife.json +1 -0
- qiskit/providers/fake_provider/backends/tokyo/__init__.py +15 -0
- qiskit/providers/fake_provider/backends/tokyo/fake_tokyo.py +137 -0
- qiskit/providers/fake_provider/backends/tokyo/props_tokyo.json +1 -0
- qiskit/providers/fake_provider/backends/toronto/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/toronto/conf_toronto.json +1 -0
- qiskit/providers/fake_provider/backends/toronto/defs_toronto.json +1 -0
- qiskit/providers/fake_provider/backends/toronto/fake_toronto.py +38 -0
- qiskit/providers/fake_provider/backends/toronto/props_toronto.json +1 -0
- qiskit/providers/fake_provider/backends/valencia/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/valencia/conf_valencia.json +1 -0
- qiskit/providers/fake_provider/backends/valencia/defs_valencia.json +1 -0
- qiskit/providers/fake_provider/backends/valencia/fake_valencia.py +38 -0
- qiskit/providers/fake_provider/backends/valencia/props_valencia.json +1 -0
- qiskit/providers/fake_provider/backends/vigo/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/vigo/conf_vigo.json +1 -0
- qiskit/providers/fake_provider/backends/vigo/fake_vigo.py +50 -0
- qiskit/providers/fake_provider/backends/vigo/props_vigo.json +1 -0
- qiskit/providers/fake_provider/backends/washington/__init__.py +18 -0
- qiskit/providers/fake_provider/backends/washington/conf_washington.json +1 -0
- qiskit/providers/fake_provider/backends/washington/defs_washington.json +1 -0
- qiskit/providers/fake_provider/backends/washington/fake_washington.py +38 -0
- qiskit/providers/fake_provider/backends/washington/props_washington.json +1 -0
- qiskit/providers/fake_provider/backends/yorktown/__init__.py +16 -0
- qiskit/providers/fake_provider/backends/yorktown/conf_yorktown.json +1 -0
- qiskit/providers/fake_provider/backends/yorktown/fake_yorktown.py +54 -0
- qiskit/providers/fake_provider/backends/yorktown/props_yorktown.json +1 -0
- qiskit/providers/fake_provider/fake_1q.py +91 -0
- qiskit/providers/fake_provider/fake_backend.py +572 -0
- qiskit/providers/fake_provider/fake_backend_v2.py +217 -0
- qiskit/providers/fake_provider/fake_job.py +81 -0
- qiskit/providers/fake_provider/fake_mumbai_v2.py +637 -0
- qiskit/providers/fake_provider/fake_openpulse_2q.py +342 -0
- qiskit/providers/fake_provider/fake_openpulse_3q.py +332 -0
- qiskit/providers/fake_provider/fake_provider.py +214 -0
- qiskit/providers/fake_provider/fake_pulse_backend.py +43 -0
- qiskit/providers/fake_provider/fake_qasm_backend.py +72 -0
- qiskit/providers/fake_provider/fake_qasm_simulator.py +48 -0
- qiskit/providers/fake_provider/fake_qobj.py +44 -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/configurable_backend.py +360 -0
- qiskit/providers/fake_provider/utils/json_decoder.py +109 -0
- qiskit/providers/job.py +142 -0
- qiskit/providers/jobstatus.py +30 -0
- qiskit/providers/models/__init__.py +52 -0
- qiskit/providers/models/backendconfiguration.py +994 -0
- qiskit/providers/models/backendproperties.py +490 -0
- qiskit/providers/models/backendstatus.py +94 -0
- qiskit/providers/models/jobstatus.py +66 -0
- qiskit/providers/models/pulsedefaults.py +304 -0
- qiskit/providers/options.py +273 -0
- qiskit/providers/provider.py +79 -0
- qiskit/providers/providerutils.py +99 -0
- qiskit/pulse/__init__.py +170 -0
- qiskit/pulse/builder.py +2733 -0
- qiskit/pulse/calibration_entries.py +357 -0
- qiskit/pulse/channels.py +221 -0
- qiskit/pulse/configuration.py +244 -0
- qiskit/pulse/exceptions.py +43 -0
- qiskit/pulse/filters.py +302 -0
- qiskit/pulse/instruction_schedule_map.py +406 -0
- qiskit/pulse/instructions/__init__.py +69 -0
- qiskit/pulse/instructions/acquire.py +150 -0
- qiskit/pulse/instructions/call.py +176 -0
- qiskit/pulse/instructions/delay.py +69 -0
- qiskit/pulse/instructions/directives.py +145 -0
- qiskit/pulse/instructions/frequency.py +132 -0
- qiskit/pulse/instructions/instruction.py +266 -0
- qiskit/pulse/instructions/phase.py +149 -0
- qiskit/pulse/instructions/play.py +96 -0
- qiskit/pulse/instructions/reference.py +99 -0
- qiskit/pulse/instructions/snapshot.py +80 -0
- qiskit/pulse/library/__init__.py +99 -0
- qiskit/pulse/library/continuous.py +430 -0
- qiskit/pulse/library/parametric_pulses.py +629 -0
- qiskit/pulse/library/pulse.py +137 -0
- qiskit/pulse/library/samplers/__init__.py +15 -0
- qiskit/pulse/library/samplers/decorators.py +299 -0
- qiskit/pulse/library/samplers/strategies.py +71 -0
- qiskit/pulse/library/symbolic_pulses.py +1962 -0
- qiskit/pulse/library/waveform.py +134 -0
- qiskit/pulse/macros.py +256 -0
- qiskit/pulse/parameter_manager.py +432 -0
- qiskit/pulse/parser.py +314 -0
- qiskit/pulse/reference_manager.py +58 -0
- qiskit/pulse/schedule.py +2002 -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 +514 -0
- qiskit/pulse/transforms/dag.py +107 -0
- qiskit/pulse/utils.py +109 -0
- qiskit/qasm/libs/qelib1.inc +266 -0
- qiskit/qasm/libs/stdgates.inc +75 -0
- qiskit/qasm2/__init__.py +658 -0
- qiskit/qasm2/exceptions.py +27 -0
- qiskit/qasm2/export.py +374 -0
- qiskit/qasm2/parse.py +403 -0
- qiskit/qasm3/__init__.py +255 -0
- qiskit/qasm3/ast.py +606 -0
- qiskit/qasm3/exceptions.py +27 -0
- qiskit/qasm3/experimental.py +30 -0
- qiskit/qasm3/exporter.py +1079 -0
- qiskit/qasm3/printer.py +545 -0
- qiskit/qobj/__init__.py +75 -0
- qiskit/qobj/common.py +71 -0
- qiskit/qobj/converters/__init__.py +18 -0
- qiskit/qobj/converters/lo_config.py +168 -0
- qiskit/qobj/converters/pulse_instruction.py +1070 -0
- qiskit/qobj/pulse_qobj.py +655 -0
- qiskit/qobj/qasm_qobj.py +656 -0
- qiskit/qobj/utils.py +37 -0
- qiskit/qpy/__init__.py +1348 -0
- qiskit/qpy/binary_io/__init__.py +36 -0
- qiskit/qpy/binary_io/circuits.py +1212 -0
- qiskit/qpy/binary_io/schedules.py +619 -0
- qiskit/qpy/binary_io/value.py +549 -0
- qiskit/qpy/common.py +305 -0
- qiskit/qpy/exceptions.py +28 -0
- qiskit/qpy/formats.py +360 -0
- qiskit/qpy/interface.py +308 -0
- qiskit/qpy/type_keys.py +544 -0
- qiskit/quantum_info/__init__.py +173 -0
- qiskit/quantum_info/analysis/__init__.py +17 -0
- qiskit/quantum_info/analysis/average.py +47 -0
- qiskit/quantum_info/analysis/distance.py +101 -0
- qiskit/quantum_info/analysis/make_observable.py +43 -0
- qiskit/quantum_info/analysis/z2_symmetries.py +483 -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 +190 -0
- qiskit/quantum_info/operators/channel/choi.py +217 -0
- qiskit/quantum_info/operators/channel/kraus.py +336 -0
- qiskit/quantum_info/operators/channel/ptm.py +203 -0
- qiskit/quantum_info/operators/channel/quantum_channel.py +350 -0
- qiskit/quantum_info/operators/channel/stinespring.py +295 -0
- qiskit/quantum_info/operators/channel/superop.py +376 -0
- qiskit/quantum_info/operators/channel/transformations.py +467 -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 +508 -0
- qiskit/quantum_info/operators/dihedral/dihedral_circuits.py +218 -0
- qiskit/quantum_info/operators/dihedral/polynomial.py +313 -0
- qiskit/quantum_info/operators/dihedral/random.py +61 -0
- qiskit/quantum_info/operators/linear_op.py +25 -0
- qiskit/quantum_info/operators/measures.py +423 -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 +533 -0
- qiskit/quantum_info/operators/operator.py +778 -0
- qiskit/quantum_info/operators/predicates.py +170 -0
- qiskit/quantum_info/operators/random.py +154 -0
- qiskit/quantum_info/operators/scalar_op.py +253 -0
- qiskit/quantum_info/operators/symplectic/__init__.py +23 -0
- qiskit/quantum_info/operators/symplectic/base_pauli.py +720 -0
- qiskit/quantum_info/operators/symplectic/clifford.py +1022 -0
- qiskit/quantum_info/operators/symplectic/clifford_circuits.py +558 -0
- qiskit/quantum_info/operators/symplectic/pauli.py +699 -0
- qiskit/quantum_info/operators/symplectic/pauli_list.py +1209 -0
- qiskit/quantum_info/operators/symplectic/pauli_utils.py +40 -0
- qiskit/quantum_info/operators/symplectic/random.py +264 -0
- qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +1156 -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/random.py +26 -0
- qiskit/quantum_info/states/__init__.py +28 -0
- qiskit/quantum_info/states/densitymatrix.py +848 -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 +638 -0
- qiskit/quantum_info/states/statevector.py +961 -0
- qiskit/quantum_info/states/utils.py +245 -0
- qiskit/quantum_info/synthesis/__init__.py +20 -0
- qiskit/quantum_info/synthesis/clifford_decompose.py +69 -0
- qiskit/quantum_info/synthesis/cnotdihedral_decompose.py +50 -0
- qiskit/quantum_info/synthesis/ion_decompose.py +55 -0
- qiskit/quantum_info/synthesis/local_invariance.py +93 -0
- qiskit/quantum_info/synthesis/one_qubit_decompose.py +284 -0
- qiskit/quantum_info/synthesis/qsd.py +269 -0
- qiskit/quantum_info/synthesis/quaternion.py +156 -0
- qiskit/quantum_info/synthesis/two_qubit_decompose.py +1567 -0
- qiskit/quantum_info/synthesis/weyl.py +98 -0
- qiskit/quantum_info/synthesis/xx_decompose/__init__.py +19 -0
- qiskit/quantum_info/synthesis/xx_decompose/circuits.py +299 -0
- qiskit/quantum_info/synthesis/xx_decompose/decomposer.py +314 -0
- qiskit/quantum_info/synthesis/xx_decompose/embodiments.py +163 -0
- qiskit/quantum_info/synthesis/xx_decompose/paths.py +412 -0
- qiskit/quantum_info/synthesis/xx_decompose/polytopes.py +264 -0
- qiskit/quantum_info/synthesis/xx_decompose/utilities.py +40 -0
- qiskit/quantum_info/synthesis/xx_decompose/weyl.py +133 -0
- qiskit/result/__init__.py +67 -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 +268 -0
- qiskit/result/mitigation/local_readout_mitigator.py +319 -0
- qiskit/result/mitigation/utils.py +161 -0
- qiskit/result/models.py +233 -0
- qiskit/result/postprocess.py +239 -0
- qiskit/result/result.py +397 -0
- qiskit/result/sampled_expval.py +75 -0
- qiskit/result/utils.py +295 -0
- qiskit/scheduler/__init__.py +31 -0
- qiskit/scheduler/config.py +35 -0
- qiskit/scheduler/lowering.py +187 -0
- qiskit/scheduler/methods/__init__.py +22 -0
- qiskit/scheduler/methods/basic.py +137 -0
- qiskit/scheduler/schedule_circuit.py +67 -0
- qiskit/scheduler/sequence.py +102 -0
- qiskit/synthesis/__init__.py +122 -0
- qiskit/synthesis/clifford/__init__.py +19 -0
- qiskit/synthesis/clifford/clifford_decompose_ag.py +176 -0
- qiskit/synthesis/clifford/clifford_decompose_bm.py +276 -0
- qiskit/synthesis/clifford/clifford_decompose_full.py +61 -0
- qiskit/synthesis/clifford/clifford_decompose_greedy.py +347 -0
- qiskit/synthesis/clifford/clifford_decompose_layers.py +443 -0
- qiskit/synthesis/cnotdihedral/__init__.py +17 -0
- qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_full.py +46 -0
- qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_general.py +140 -0
- qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_two_qubits.py +264 -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 +207 -0
- qiskit/synthesis/evolution/__init__.py +20 -0
- qiskit/synthesis/evolution/evolution_synthesis.py +46 -0
- qiskit/synthesis/evolution/lie_trotter.py +123 -0
- qiskit/synthesis/evolution/matrix_synthesis.py +47 -0
- qiskit/synthesis/evolution/product_formula.py +328 -0
- qiskit/synthesis/evolution/qdrift.py +102 -0
- qiskit/synthesis/evolution/suzuki_trotter.py +145 -0
- qiskit/synthesis/linear/__init__.py +25 -0
- qiskit/synthesis/linear/cnot_synth.py +141 -0
- qiskit/synthesis/linear/linear_circuits_utils.py +127 -0
- qiskit/synthesis/linear/linear_depth_lnn.py +275 -0
- qiskit/synthesis/linear/linear_matrix_utils.py +175 -0
- qiskit/synthesis/linear_phase/__init__.py +17 -0
- qiskit/synthesis/linear_phase/cnot_phase_synth.py +203 -0
- qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py +262 -0
- qiskit/synthesis/linear_phase/cz_depth_lnn.py +206 -0
- qiskit/synthesis/permutation/__init__.py +17 -0
- qiskit/synthesis/permutation/permutation_full.py +90 -0
- qiskit/synthesis/permutation/permutation_lnn.py +68 -0
- qiskit/synthesis/permutation/permutation_utils.py +73 -0
- qiskit/synthesis/stabilizer/__init__.py +15 -0
- qiskit/synthesis/stabilizer/stabilizer_decompose.py +188 -0
- qiskit/test/__init__.py +18 -0
- qiskit/test/_canonical.py +125 -0
- qiskit/test/base.py +331 -0
- qiskit/test/decorators.py +308 -0
- qiskit/test/ibmq_mock.py +45 -0
- qiskit/test/mock/__init__.py +40 -0
- qiskit/test/mock/backends/__init__.py +32 -0
- qiskit/test/mock/backends/almaden/__init__.py +32 -0
- qiskit/test/mock/backends/armonk/__init__.py +32 -0
- qiskit/test/mock/backends/athens/__init__.py +32 -0
- qiskit/test/mock/backends/belem/__init__.py +32 -0
- qiskit/test/mock/backends/boeblingen/__init__.py +32 -0
- qiskit/test/mock/backends/bogota/__init__.py +32 -0
- qiskit/test/mock/backends/brooklyn/__init__.py +32 -0
- qiskit/test/mock/backends/burlington/__init__.py +32 -0
- qiskit/test/mock/backends/cairo/__init__.py +32 -0
- qiskit/test/mock/backends/cambridge/__init__.py +32 -0
- qiskit/test/mock/backends/casablanca/__init__.py +32 -0
- qiskit/test/mock/backends/essex/__init__.py +32 -0
- qiskit/test/mock/backends/guadalupe/__init__.py +32 -0
- qiskit/test/mock/backends/hanoi/__init__.py +32 -0
- qiskit/test/mock/backends/jakarta/__init__.py +32 -0
- qiskit/test/mock/backends/johannesburg/__init__.py +32 -0
- qiskit/test/mock/backends/kolkata/__init__.py +32 -0
- qiskit/test/mock/backends/lagos/__init__.py +32 -0
- qiskit/test/mock/backends/lima/__init__.py +32 -0
- qiskit/test/mock/backends/london/__init__.py +32 -0
- qiskit/test/mock/backends/manhattan/__init__.py +32 -0
- qiskit/test/mock/backends/manila/__init__.py +32 -0
- qiskit/test/mock/backends/melbourne/__init__.py +32 -0
- qiskit/test/mock/backends/montreal/__init__.py +32 -0
- qiskit/test/mock/backends/mumbai/__init__.py +32 -0
- qiskit/test/mock/backends/nairobi/__init__.py +32 -0
- qiskit/test/mock/backends/ourense/__init__.py +32 -0
- qiskit/test/mock/backends/paris/__init__.py +32 -0
- qiskit/test/mock/backends/poughkeepsie/__init__.py +32 -0
- qiskit/test/mock/backends/quito/__init__.py +32 -0
- qiskit/test/mock/backends/rochester/__init__.py +32 -0
- qiskit/test/mock/backends/rome/__init__.py +32 -0
- qiskit/test/mock/backends/rueschlikon/__init__.py +32 -0
- qiskit/test/mock/backends/santiago/__init__.py +32 -0
- qiskit/test/mock/backends/singapore/__init__.py +32 -0
- qiskit/test/mock/backends/sydney/__init__.py +32 -0
- qiskit/test/mock/backends/tenerife/__init__.py +32 -0
- qiskit/test/mock/backends/tokyo/__init__.py +32 -0
- qiskit/test/mock/backends/toronto/__init__.py +32 -0
- qiskit/test/mock/backends/valencia/__init__.py +32 -0
- qiskit/test/mock/backends/vigo/__init__.py +32 -0
- qiskit/test/mock/backends/washington/__init__.py +32 -0
- qiskit/test/mock/backends/yorktown/__init__.py +32 -0
- qiskit/test/providers/__init__.py +16 -0
- qiskit/test/providers/backend.py +75 -0
- qiskit/test/providers/provider.py +59 -0
- qiskit/test/reference_circuits.py +41 -0
- qiskit/test/testing_options.py +93 -0
- qiskit/test/utils.py +87 -0
- qiskit/tools/__init__.py +44 -0
- qiskit/tools/events/__init__.py +25 -0
- qiskit/tools/events/progressbar.py +195 -0
- qiskit/tools/events/pubsub.py +158 -0
- qiskit/tools/jupyter/__init__.py +138 -0
- qiskit/tools/jupyter/backend_monitor.py +588 -0
- qiskit/tools/jupyter/backend_overview.py +322 -0
- qiskit/tools/jupyter/copyright.py +42 -0
- qiskit/tools/jupyter/job_watcher.py +167 -0
- qiskit/tools/jupyter/job_widgets.py +160 -0
- qiskit/tools/jupyter/jupyter_magics.py +190 -0
- qiskit/tools/jupyter/library.py +189 -0
- qiskit/tools/jupyter/monospace.py +29 -0
- qiskit/tools/jupyter/progressbar.py +122 -0
- qiskit/tools/jupyter/version_table.py +67 -0
- qiskit/tools/jupyter/watcher_monitor.py +74 -0
- qiskit/tools/monitor/__init__.py +16 -0
- qiskit/tools/monitor/job_monitor.py +107 -0
- qiskit/tools/monitor/overview.py +247 -0
- qiskit/tools/parallel.py +198 -0
- qiskit/tools/visualization.py +16 -0
- qiskit/transpiler/__init__.py +1287 -0
- qiskit/transpiler/basepasses.py +221 -0
- qiskit/transpiler/coupling.py +500 -0
- qiskit/transpiler/exceptions.py +55 -0
- qiskit/transpiler/fencedobjs.py +78 -0
- qiskit/transpiler/instruction_durations.py +278 -0
- qiskit/transpiler/layout.py +658 -0
- qiskit/transpiler/passes/__init__.py +296 -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 +20 -0
- qiskit/transpiler/passes/basis/basis_translator.py +697 -0
- qiskit/transpiler/passes/basis/decompose.py +98 -0
- qiskit/transpiler/passes/basis/translate_parameterized.py +177 -0
- qiskit/transpiler/passes/basis/unroll_3q_or_more.py +86 -0
- qiskit/transpiler/passes/basis/unroll_custom_definitions.py +107 -0
- qiskit/transpiler/passes/basis/unroller.py +145 -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 +98 -0
- qiskit/transpiler/passes/calibration/rx_builder.py +160 -0
- qiskit/transpiler/passes/calibration/rzx_builder.py +394 -0
- qiskit/transpiler/passes/calibration/rzx_templates.py +51 -0
- qiskit/transpiler/passes/layout/__init__.py +27 -0
- qiskit/transpiler/passes/layout/_csp_custom_solver.py +65 -0
- qiskit/transpiler/passes/layout/apply_layout.py +108 -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 +205 -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/noise_adaptive_layout.py +311 -0
- qiskit/transpiler/passes/layout/sabre_layout.py +468 -0
- qiskit/transpiler/passes/layout/sabre_pre_layout.py +217 -0
- qiskit/transpiler/passes/layout/set_layout.py +64 -0
- qiskit/transpiler/passes/layout/trivial_layout.py +66 -0
- qiskit/transpiler/passes/layout/vf2_layout.py +257 -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 +38 -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 +97 -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 +93 -0
- qiskit/transpiler/passes/optimization/commutative_cancellation.py +207 -0
- qiskit/transpiler/passes/optimization/commutative_inverse_cancellation.py +97 -0
- qiskit/transpiler/passes/optimization/consolidate_blocks.py +219 -0
- qiskit/transpiler/passes/optimization/crosstalk_adaptive_schedule.py +732 -0
- qiskit/transpiler/passes/optimization/cx_cancellation.py +55 -0
- qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposition.py +160 -0
- qiskit/transpiler/passes/optimization/hoare_opt.py +416 -0
- qiskit/transpiler/passes/optimization/inverse_cancellation.py +177 -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 +263 -0
- qiskit/transpiler/passes/optimization/optimize_1q_gates.py +384 -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 +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/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 +454 -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 +629 -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 +155 -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 +387 -0
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/pauli_2q_evolution_commutation.py +141 -0
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/swap_strategy.py +306 -0
- qiskit/transpiler/passes/routing/layout_transformation.py +118 -0
- qiskit/transpiler/passes/routing/lookahead_swap.py +384 -0
- qiskit/transpiler/passes/routing/sabre_swap.py +430 -0
- qiskit/transpiler/passes/routing/stochastic_swap.py +512 -0
- qiskit/transpiler/passes/routing/utils.py +35 -0
- qiskit/transpiler/passes/scheduling/__init__.py +27 -0
- qiskit/transpiler/passes/scheduling/alap.py +155 -0
- qiskit/transpiler/passes/scheduling/alignments/__init__.py +81 -0
- qiskit/transpiler/passes/scheduling/alignments/align_measures.py +256 -0
- qiskit/transpiler/passes/scheduling/alignments/check_durations.py +75 -0
- qiskit/transpiler/passes/scheduling/alignments/pulse_gate_validation.py +97 -0
- qiskit/transpiler/passes/scheduling/alignments/reschedule.py +241 -0
- qiskit/transpiler/passes/scheduling/asap.py +177 -0
- qiskit/transpiler/passes/scheduling/base_scheduler.py +289 -0
- qiskit/transpiler/passes/scheduling/calibration_creators.py +27 -0
- qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +285 -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 +408 -0
- qiskit/transpiler/passes/scheduling/padding/pad_delay.py +79 -0
- qiskit/transpiler/passes/scheduling/rzx_templates.py +28 -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 +89 -0
- qiskit/transpiler/passes/scheduling/scheduling/set_io_latency.py +64 -0
- qiskit/transpiler/passes/scheduling/time_unit_conversion.py +135 -0
- qiskit/transpiler/passes/synthesis/__init__.py +19 -0
- qiskit/transpiler/passes/synthesis/high_level_synthesis.py +637 -0
- qiskit/transpiler/passes/synthesis/linear_functions_synthesis.py +63 -0
- qiskit/transpiler/passes/synthesis/plugin.py +597 -0
- qiskit/transpiler/passes/synthesis/solovay_kitaev_synthesis.py +289 -0
- qiskit/transpiler/passes/synthesis/unitary_synthesis.py +895 -0
- qiskit/transpiler/passes/utils/__init__.py +34 -0
- qiskit/transpiler/passes/utils/barrier_before_final_measurements.py +95 -0
- qiskit/transpiler/passes/utils/block_to_matrix.py +47 -0
- qiskit/transpiler/passes/utils/check_gate_direction.py +87 -0
- qiskit/transpiler/passes/utils/check_map.py +94 -0
- qiskit/transpiler/passes/utils/contains_instruction.py +45 -0
- qiskit/transpiler/passes/utils/control_flow.py +61 -0
- qiskit/transpiler/passes/utils/convert_conditions_to_if_ops.py +89 -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 +347 -0
- qiskit/transpiler/passes/utils/gates_basis.py +75 -0
- qiskit/transpiler/passes/utils/merge_adjacent_barriers.py +162 -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 +617 -0
- qiskit/transpiler/passmanager_config.py +193 -0
- qiskit/transpiler/preset_passmanagers/__init__.py +280 -0
- qiskit/transpiler/preset_passmanagers/builtin_plugins.py +971 -0
- qiskit/transpiler/preset_passmanagers/common.py +651 -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 +345 -0
- qiskit/transpiler/propertyset.py +19 -0
- qiskit/transpiler/runningpassmanager.py +174 -0
- qiskit/transpiler/synthesis/__init__.py +16 -0
- qiskit/transpiler/synthesis/aqc/__init__.py +178 -0
- qiskit/transpiler/synthesis/aqc/approximate.py +116 -0
- qiskit/transpiler/synthesis/aqc/aqc.py +170 -0
- qiskit/transpiler/synthesis/aqc/aqc_plugin.py +146 -0
- qiskit/transpiler/synthesis/aqc/cnot_structures.py +299 -0
- qiskit/transpiler/synthesis/aqc/cnot_unit_circuit.py +103 -0
- qiskit/transpiler/synthesis/aqc/cnot_unit_objective.py +299 -0
- qiskit/transpiler/synthesis/aqc/elementary_operations.py +108 -0
- qiskit/transpiler/synthesis/aqc/fast_gradient/__init__.py +164 -0
- qiskit/transpiler/synthesis/aqc/fast_gradient/fast_grad_utils.py +237 -0
- qiskit/transpiler/synthesis/aqc/fast_gradient/fast_gradient.py +225 -0
- qiskit/transpiler/synthesis/aqc/fast_gradient/layer.py +370 -0
- qiskit/transpiler/synthesis/aqc/fast_gradient/pmatrix.py +312 -0
- qiskit/transpiler/synthesis/graysynth.py +114 -0
- qiskit/transpiler/target.py +1540 -0
- qiskit/transpiler/timing_constraints.py +59 -0
- qiskit/user_config.py +239 -0
- qiskit/utils/__init__.py +66 -0
- qiskit/utils/classtools.py +146 -0
- qiskit/utils/deprecation.py +489 -0
- qiskit/utils/lazy_tester.py +334 -0
- qiskit/utils/multiprocessing.py +48 -0
- qiskit/utils/optionals.py +320 -0
- qiskit/utils/units.py +143 -0
- qiskit/version.py +84 -0
- qiskit/visualization/__init__.py +289 -0
- qiskit/visualization/array.py +204 -0
- qiskit/visualization/bloch.py +741 -0
- qiskit/visualization/circuit/__init__.py +15 -0
- qiskit/visualization/circuit/_utils.py +633 -0
- qiskit/visualization/circuit/circuit_visualization.py +717 -0
- qiskit/visualization/circuit/latex.py +659 -0
- qiskit/visualization/circuit/matplotlib.py +1975 -0
- qiskit/visualization/circuit/qcstyle.py +420 -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 +1802 -0
- qiskit/visualization/circuit_visualization.py +19 -0
- qiskit/visualization/counts_visualization.py +496 -0
- qiskit/visualization/dag_visualization.py +224 -0
- qiskit/visualization/exceptions.py +21 -0
- qiskit/visualization/gate_map.py +1461 -0
- qiskit/visualization/pass_manager_visualization.py +281 -0
- qiskit/visualization/pulse_v2/__init__.py +21 -0
- qiskit/visualization/pulse_v2/core.py +905 -0
- qiskit/visualization/pulse_v2/device_info.py +146 -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 +437 -0
- qiskit/visualization/pulse_v2/generators/snapshot.py +133 -0
- qiskit/visualization/pulse_v2/generators/waveform.py +649 -0
- qiskit/visualization/pulse_v2/interface.py +452 -0
- qiskit/visualization/pulse_v2/layouts.py +395 -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 +202 -0
- qiskit/visualization/pulse_v2/stylesheet.py +322 -0
- qiskit/visualization/pulse_v2/types.py +242 -0
- qiskit/visualization/qcstyle.py +17 -0
- qiskit/visualization/state_visualization.py +1518 -0
- qiskit/visualization/timeline/__init__.py +21 -0
- qiskit/visualization/timeline/core.py +457 -0
- qiskit/visualization/timeline/drawings.py +260 -0
- qiskit/visualization/timeline/generators.py +506 -0
- qiskit/visualization/timeline/interface.py +414 -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 +193 -0
- qiskit/visualization/timeline/stylesheet.py +311 -0
- qiskit/visualization/timeline/types.py +148 -0
- qiskit/visualization/transition_visualization.py +364 -0
- qiskit/visualization/utils.py +49 -0
- qiskit-1.0.0b1.dist-info/LICENSE.txt +203 -0
- qiskit-1.0.0b1.dist-info/METADATA +430 -0
- qiskit-1.0.0b1.dist-info/RECORD +1095 -0
- qiskit-1.0.0b1.dist-info/WHEEL +6 -0
- qiskit-1.0.0b1.dist-info/entry_points.txt +49 -0
- qiskit-1.0.0b1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1540 @@
|
|
1
|
+
# This code is part of Qiskit.
|
2
|
+
#
|
3
|
+
# (C) Copyright IBM 2021
|
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
|
+
from collections import defaultdict
|
27
|
+
import datetime
|
28
|
+
import io
|
29
|
+
import logging
|
30
|
+
import inspect
|
31
|
+
|
32
|
+
import rustworkx as rx
|
33
|
+
|
34
|
+
from qiskit.circuit.parameter import Parameter
|
35
|
+
from qiskit.circuit.parameterexpression import ParameterValueType
|
36
|
+
from qiskit.circuit.gate import Gate
|
37
|
+
from qiskit.circuit.library.standard_gates import get_standard_gate_name_mapping
|
38
|
+
from qiskit.pulse.instruction_schedule_map import InstructionScheduleMap
|
39
|
+
from qiskit.pulse.calibration_entries import CalibrationEntry, ScheduleDef
|
40
|
+
from qiskit.pulse.schedule import Schedule, ScheduleBlock
|
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
|
+
from qiskit.providers.exceptions import BackendPropertyError
|
46
|
+
from qiskit.pulse.exceptions import PulseError, UnassignedDurationError
|
47
|
+
from qiskit.utils.deprecation import deprecate_arg, deprecate_func
|
48
|
+
from qiskit.exceptions import QiskitError
|
49
|
+
|
50
|
+
# import QubitProperties here to provide convenience alias for building a
|
51
|
+
# full target
|
52
|
+
from qiskit.providers.backend import QubitProperties # pylint: disable=unused-import
|
53
|
+
from qiskit.providers.models.backendproperties import BackendProperties
|
54
|
+
|
55
|
+
|
56
|
+
logger = logging.getLogger(__name__)
|
57
|
+
|
58
|
+
|
59
|
+
class InstructionProperties:
|
60
|
+
"""A representation of the properties of a gate implementation.
|
61
|
+
|
62
|
+
This class provides the optional properties that a backend can provide
|
63
|
+
about an instruction. These represent the set that the transpiler can
|
64
|
+
currently work with if present. However, if your backend provides additional
|
65
|
+
properties for instructions you should subclass this to add additional
|
66
|
+
custom attributes for those custom/additional properties by the backend.
|
67
|
+
"""
|
68
|
+
|
69
|
+
__slots__ = ("duration", "error", "_calibration")
|
70
|
+
|
71
|
+
def __init__(
|
72
|
+
self,
|
73
|
+
duration: float | None = None,
|
74
|
+
error: float | None = None,
|
75
|
+
calibration: Schedule | ScheduleBlock | CalibrationEntry | None = None,
|
76
|
+
):
|
77
|
+
"""Create a new ``InstructionProperties`` object
|
78
|
+
|
79
|
+
Args:
|
80
|
+
duration: The duration, in seconds, of the instruction on the
|
81
|
+
specified set of qubits
|
82
|
+
error: The average error rate for the instruction on the specified
|
83
|
+
set of qubits.
|
84
|
+
calibration: The pulse representation of the instruction.
|
85
|
+
"""
|
86
|
+
self._calibration: CalibrationEntry | None = None
|
87
|
+
|
88
|
+
self.duration = duration
|
89
|
+
self.error = error
|
90
|
+
self.calibration = calibration
|
91
|
+
|
92
|
+
@property
|
93
|
+
def calibration(self):
|
94
|
+
"""The pulse representation of the instruction.
|
95
|
+
|
96
|
+
.. note::
|
97
|
+
|
98
|
+
This attribute always returns a Qiskit pulse program, but it is internally
|
99
|
+
wrapped by the :class:`.CalibrationEntry` to manage unbound parameters
|
100
|
+
and to uniformly handle different data representation,
|
101
|
+
for example, un-parsed Pulse Qobj JSON that a backend provider may provide.
|
102
|
+
|
103
|
+
This value can be overridden through the property setter in following manner.
|
104
|
+
When you set either :class:`.Schedule` or :class:`.ScheduleBlock` this is
|
105
|
+
always treated as a user-defined (custom) calibration and
|
106
|
+
the transpiler may automatically attach the calibration data to the output circuit.
|
107
|
+
This calibration data may appear in the wire format as an inline calibration,
|
108
|
+
which may further update the backend standard instruction set architecture.
|
109
|
+
|
110
|
+
If you are a backend provider who provides a default calibration data
|
111
|
+
that is not needed to be attached to the transpiled quantum circuit,
|
112
|
+
you can directly set :class:`.CalibrationEntry` instance to this attribute,
|
113
|
+
in which you should set :code:`user_provided=False` when you define
|
114
|
+
calibration data for the entry. End users can still intentionally utilize
|
115
|
+
the calibration data, for example, to run pulse-level simulation of the circuit.
|
116
|
+
However, such entry doesn't appear in the wire format, and backend must
|
117
|
+
use own definition to compile the circuit down to the execution format.
|
118
|
+
|
119
|
+
"""
|
120
|
+
if self._calibration is None:
|
121
|
+
return None
|
122
|
+
return self._calibration.get_schedule()
|
123
|
+
|
124
|
+
@calibration.setter
|
125
|
+
def calibration(self, calibration: Schedule | ScheduleBlock | CalibrationEntry):
|
126
|
+
if isinstance(calibration, (Schedule, ScheduleBlock)):
|
127
|
+
new_entry = ScheduleDef()
|
128
|
+
new_entry.define(calibration, user_provided=True)
|
129
|
+
else:
|
130
|
+
new_entry = calibration
|
131
|
+
self._calibration = new_entry
|
132
|
+
|
133
|
+
def __repr__(self):
|
134
|
+
return (
|
135
|
+
f"InstructionProperties(duration={self.duration}, error={self.error}"
|
136
|
+
f", calibration={self._calibration})"
|
137
|
+
)
|
138
|
+
|
139
|
+
|
140
|
+
class Target(Mapping):
|
141
|
+
"""
|
142
|
+
The intent of the ``Target`` object is to inform Qiskit's compiler about
|
143
|
+
the constraints of a particular backend so the compiler can compile an
|
144
|
+
input circuit to something that works and is optimized for a device. It
|
145
|
+
currently contains a description of instructions on a backend and their
|
146
|
+
properties as well as some timing information. However, this exact
|
147
|
+
interface may evolve over time as the needs of the compiler change. These
|
148
|
+
changes will be done in a backwards compatible and controlled manner when
|
149
|
+
they are made (either through versioning, subclassing, or mixins) to add
|
150
|
+
on to the set of information exposed by a target.
|
151
|
+
|
152
|
+
As a basic example, let's assume backend has two qubits, supports
|
153
|
+
:class:`~qiskit.circuit.library.UGate` on both qubits and
|
154
|
+
:class:`~qiskit.circuit.library.CXGate` in both directions. To model this
|
155
|
+
you would create the target like::
|
156
|
+
|
157
|
+
from qiskit.transpiler import Target, InstructionProperties
|
158
|
+
from qiskit.circuit.library import UGate, CXGate
|
159
|
+
from qiskit.circuit import Parameter
|
160
|
+
|
161
|
+
gmap = Target()
|
162
|
+
theta = Parameter('theta')
|
163
|
+
phi = Parameter('phi')
|
164
|
+
lam = Parameter('lambda')
|
165
|
+
u_props = {
|
166
|
+
(0,): InstructionProperties(duration=5.23e-8, error=0.00038115),
|
167
|
+
(1,): InstructionProperties(duration=4.52e-8, error=0.00032115),
|
168
|
+
}
|
169
|
+
gmap.add_instruction(UGate(theta, phi, lam), u_props)
|
170
|
+
cx_props = {
|
171
|
+
(0,1): InstructionProperties(duration=5.23e-7, error=0.00098115),
|
172
|
+
(1,0): InstructionProperties(duration=4.52e-7, error=0.00132115),
|
173
|
+
}
|
174
|
+
gmap.add_instruction(CXGate(), cx_props)
|
175
|
+
|
176
|
+
Each instruction in the ``Target`` is indexed by a unique string name that uniquely
|
177
|
+
identifies that instance of an :class:`~qiskit.circuit.Instruction` object in
|
178
|
+
the Target. There is a 1:1 mapping between a name and an
|
179
|
+
:class:`~qiskit.circuit.Instruction` instance in the target and each name must
|
180
|
+
be unique. By default, the name is the :attr:`~qiskit.circuit.Instruction.name`
|
181
|
+
attribute of the instruction, but can be set to anything. This lets a single
|
182
|
+
target have multiple instances of the same instruction class with different
|
183
|
+
parameters. For example, if a backend target has two instances of an
|
184
|
+
:class:`~qiskit.circuit.library.RXGate` one is parameterized over any theta
|
185
|
+
while the other is tuned up for a theta of pi/6 you can add these by doing something
|
186
|
+
like::
|
187
|
+
|
188
|
+
import math
|
189
|
+
|
190
|
+
from qiskit.transpiler import Target, InstructionProperties
|
191
|
+
from qiskit.circuit.library import RXGate
|
192
|
+
from qiskit.circuit import Parameter
|
193
|
+
|
194
|
+
target = Target()
|
195
|
+
theta = Parameter('theta')
|
196
|
+
rx_props = {
|
197
|
+
(0,): InstructionProperties(duration=5.23e-8, error=0.00038115),
|
198
|
+
}
|
199
|
+
target.add_instruction(RXGate(theta), rx_props)
|
200
|
+
rx_30_props = {
|
201
|
+
(0,): InstructionProperties(duration=1.74e-6, error=.00012)
|
202
|
+
}
|
203
|
+
target.add_instruction(RXGate(math.pi / 6), rx_30_props, name='rx_30')
|
204
|
+
|
205
|
+
Then in the ``target`` object accessing by ``rx_30`` will get the fixed
|
206
|
+
angle :class:`~qiskit.circuit.library.RXGate` while ``rx`` will get the
|
207
|
+
parameterized :class:`~qiskit.circuit.library.RXGate`.
|
208
|
+
|
209
|
+
.. note::
|
210
|
+
|
211
|
+
This class assumes that qubit indices start at 0 and are a contiguous
|
212
|
+
set if you want a submapping the bits will need to be reindexed in
|
213
|
+
a new``Target`` object.
|
214
|
+
|
215
|
+
.. note::
|
216
|
+
|
217
|
+
This class only supports additions of gates, qargs, and qubits.
|
218
|
+
If you need to remove one of these the best option is to iterate over
|
219
|
+
an existing object and create a new subset (or use one of the methods
|
220
|
+
to do this). The object internally caches different views and these
|
221
|
+
would potentially be invalidated by removals.
|
222
|
+
"""
|
223
|
+
|
224
|
+
__slots__ = (
|
225
|
+
"num_qubits",
|
226
|
+
"_gate_map",
|
227
|
+
"_gate_name_map",
|
228
|
+
"_qarg_gate_map",
|
229
|
+
"description",
|
230
|
+
"_coupling_graph",
|
231
|
+
"_instruction_durations",
|
232
|
+
"_instruction_schedule_map",
|
233
|
+
"dt",
|
234
|
+
"granularity",
|
235
|
+
"min_length",
|
236
|
+
"pulse_alignment",
|
237
|
+
"acquire_alignment",
|
238
|
+
"_non_global_basis",
|
239
|
+
"_non_global_strict_basis",
|
240
|
+
"qubit_properties",
|
241
|
+
"_global_operations",
|
242
|
+
"concurrent_measurements",
|
243
|
+
)
|
244
|
+
|
245
|
+
@deprecate_arg(
|
246
|
+
"aquire_alignment",
|
247
|
+
new_alias="acquire_alignment",
|
248
|
+
since="0.23.0",
|
249
|
+
package_name="qiskit-terra",
|
250
|
+
)
|
251
|
+
def __init__(
|
252
|
+
self,
|
253
|
+
description=None,
|
254
|
+
num_qubits=0,
|
255
|
+
dt=None,
|
256
|
+
granularity=1,
|
257
|
+
min_length=1,
|
258
|
+
pulse_alignment=1,
|
259
|
+
acquire_alignment=1,
|
260
|
+
qubit_properties=None,
|
261
|
+
concurrent_measurements=None,
|
262
|
+
):
|
263
|
+
"""
|
264
|
+
Create a new ``Target`` object
|
265
|
+
|
266
|
+
Args:
|
267
|
+
description (str): An optional string to describe the Target.
|
268
|
+
num_qubits (int): An optional int to specify the number of qubits
|
269
|
+
the backend target has. If not set it will be implicitly set
|
270
|
+
based on the qargs when :meth:`~qiskit.Target.add_instruction`
|
271
|
+
is called. Note this must be set if the backend target is for a
|
272
|
+
noiseless simulator that doesn't have constraints on the
|
273
|
+
instructions so the transpiler knows how many qubits are
|
274
|
+
available.
|
275
|
+
dt (float): The system time resolution of input signals in seconds
|
276
|
+
granularity (int): An integer value representing minimum pulse gate
|
277
|
+
resolution in units of ``dt``. A user-defined pulse gate should
|
278
|
+
have duration of a multiple of this granularity value.
|
279
|
+
min_length (int): An integer value representing minimum pulse gate
|
280
|
+
length in units of ``dt``. A user-defined pulse gate should be
|
281
|
+
longer than this length.
|
282
|
+
pulse_alignment (int): An integer value representing a time
|
283
|
+
resolution of gate instruction starting time. Gate instruction
|
284
|
+
should start at time which is a multiple of the alignment
|
285
|
+
value.
|
286
|
+
acquire_alignment (int): An integer value representing a time
|
287
|
+
resolution of measure instruction starting time. Measure
|
288
|
+
instruction should start at time which is a multiple of the
|
289
|
+
alignment value.
|
290
|
+
qubit_properties (list): A list of :class:`~.QubitProperties`
|
291
|
+
objects defining the characteristics of each qubit on the
|
292
|
+
target device. If specified the length of this list must match
|
293
|
+
the number of qubits in the target, where the index in the list
|
294
|
+
matches the qubit number the properties are defined for. If some
|
295
|
+
qubits don't have properties available you can set that entry to
|
296
|
+
``None``
|
297
|
+
concurrent_measurements(list): A list of sets of qubits that must be
|
298
|
+
measured together. This must be provided
|
299
|
+
as a nested list like ``[[0, 1], [2, 3, 4]]``.
|
300
|
+
Raises:
|
301
|
+
ValueError: If both ``num_qubits`` and ``qubit_properties`` are both
|
302
|
+
defined and the value of ``num_qubits`` differs from the length of
|
303
|
+
``qubit_properties``.
|
304
|
+
"""
|
305
|
+
self.num_qubits = num_qubits
|
306
|
+
# A mapping of gate name -> gate instance
|
307
|
+
self._gate_name_map = {}
|
308
|
+
# A nested mapping of gate name -> qargs -> properties
|
309
|
+
self._gate_map = {}
|
310
|
+
# A mapping of number of qubits to set of op names which are global
|
311
|
+
self._global_operations = defaultdict(set)
|
312
|
+
# A mapping of qarg -> set(gate name)
|
313
|
+
self._qarg_gate_map = defaultdict(set)
|
314
|
+
self.dt = dt
|
315
|
+
self.description = description
|
316
|
+
self._coupling_graph = None
|
317
|
+
self._instruction_durations = None
|
318
|
+
self._instruction_schedule_map = None
|
319
|
+
self.granularity = granularity
|
320
|
+
self.min_length = min_length
|
321
|
+
self.pulse_alignment = pulse_alignment
|
322
|
+
self.acquire_alignment = acquire_alignment
|
323
|
+
self._non_global_basis = None
|
324
|
+
self._non_global_strict_basis = None
|
325
|
+
if qubit_properties is not None:
|
326
|
+
if not self.num_qubits:
|
327
|
+
self.num_qubits = len(qubit_properties)
|
328
|
+
else:
|
329
|
+
if self.num_qubits != len(qubit_properties):
|
330
|
+
raise ValueError(
|
331
|
+
"The value of num_qubits specified does not match the "
|
332
|
+
"length of the input qubit_properties list"
|
333
|
+
)
|
334
|
+
self.qubit_properties = qubit_properties
|
335
|
+
self.concurrent_measurements = concurrent_measurements
|
336
|
+
|
337
|
+
def add_instruction(self, instruction, properties=None, name=None):
|
338
|
+
"""Add a new instruction to the :class:`~qiskit.transpiler.Target`
|
339
|
+
|
340
|
+
As ``Target`` objects are strictly additive this is the primary method
|
341
|
+
for modifying a ``Target``. Typically, you will use this to fully populate
|
342
|
+
a ``Target`` before using it in :class:`~qiskit.providers.BackendV2`. For
|
343
|
+
example::
|
344
|
+
|
345
|
+
from qiskit.circuit.library import CXGate
|
346
|
+
from qiskit.transpiler import Target, InstructionProperties
|
347
|
+
|
348
|
+
target = Target()
|
349
|
+
cx_properties = {
|
350
|
+
(0, 1): None,
|
351
|
+
(1, 0): None,
|
352
|
+
(0, 2): None,
|
353
|
+
(2, 0): None,
|
354
|
+
(0, 3): None,
|
355
|
+
(2, 3): None,
|
356
|
+
(3, 0): None,
|
357
|
+
(3, 2): None
|
358
|
+
}
|
359
|
+
target.add_instruction(CXGate(), cx_properties)
|
360
|
+
|
361
|
+
Will add a :class:`~qiskit.circuit.library.CXGate` to the target with no
|
362
|
+
properties (duration, error, etc) with the coupling edge list:
|
363
|
+
``(0, 1), (1, 0), (0, 2), (2, 0), (0, 3), (2, 3), (3, 0), (3, 2)``. If
|
364
|
+
there are properties available for the instruction you can replace the
|
365
|
+
``None`` value in the properties dictionary with an
|
366
|
+
:class:`~qiskit.transpiler.InstructionProperties` object. This pattern
|
367
|
+
is repeated for each :class:`~qiskit.circuit.Instruction` the target
|
368
|
+
supports.
|
369
|
+
|
370
|
+
Args:
|
371
|
+
instruction (qiskit.circuit.Instruction): The operation object to add to the map. If it's
|
372
|
+
parameterized any value of the parameter can be set. Optionally for variable width
|
373
|
+
instructions (such as control flow operations such as :class:`~.ForLoop` or
|
374
|
+
:class:`~MCXGate`) you can specify the class. If the class is specified than the
|
375
|
+
``name`` argument must be specified. When a class is used the gate is treated as global
|
376
|
+
and not having any properties set.
|
377
|
+
properties (dict): A dictionary of qarg entries to an
|
378
|
+
:class:`~qiskit.transpiler.InstructionProperties` object for that
|
379
|
+
instruction implementation on the backend. Properties are optional
|
380
|
+
for any instruction implementation, if there are no
|
381
|
+
:class:`~qiskit.transpiler.InstructionProperties` available for the
|
382
|
+
backend the value can be None. If there are no constraints on the
|
383
|
+
instruction (as in a noiseless/ideal simulation) this can be set to
|
384
|
+
``{None, None}`` which will indicate it runs on all qubits (or all
|
385
|
+
available permutations of qubits for multi-qubit gates). The first
|
386
|
+
``None`` indicates it applies to all qubits and the second ``None``
|
387
|
+
indicates there are no
|
388
|
+
:class:`~qiskit.transpiler.InstructionProperties` for the
|
389
|
+
instruction. By default, if properties is not set it is equivalent to
|
390
|
+
passing ``{None: None}``.
|
391
|
+
name (str): An optional name to use for identifying the instruction. If not
|
392
|
+
specified the :attr:`~qiskit.circuit.Instruction.name` attribute
|
393
|
+
of ``gate`` will be used. All gates in the ``Target`` need unique
|
394
|
+
names. Backends can differentiate between different
|
395
|
+
parameterization of a single gate by providing a unique name for
|
396
|
+
each (e.g. `"rx30"`, `"rx60", ``"rx90"`` similar to the example in the
|
397
|
+
documentation for the :class:`~qiskit.transpiler.Target` class).
|
398
|
+
Raises:
|
399
|
+
AttributeError: If gate is already in map
|
400
|
+
TranspilerError: If an operation class is passed in for ``instruction`` and no name
|
401
|
+
is specified or ``properties`` is set.
|
402
|
+
"""
|
403
|
+
is_class = inspect.isclass(instruction)
|
404
|
+
if not is_class:
|
405
|
+
instruction_name = name or instruction.name
|
406
|
+
else:
|
407
|
+
# Invalid to have class input without a name with characters set "" is not a valid name
|
408
|
+
if not name:
|
409
|
+
raise TranspilerError(
|
410
|
+
"A name must be specified when defining a supported global operation by class"
|
411
|
+
)
|
412
|
+
if properties is not None:
|
413
|
+
raise TranspilerError(
|
414
|
+
"An instruction added globally by class can't have properties set."
|
415
|
+
)
|
416
|
+
instruction_name = name
|
417
|
+
if properties is None:
|
418
|
+
properties = {None: None}
|
419
|
+
if instruction_name in self._gate_map:
|
420
|
+
raise AttributeError("Instruction %s is already in the target" % instruction_name)
|
421
|
+
self._gate_name_map[instruction_name] = instruction
|
422
|
+
if is_class:
|
423
|
+
qargs_val = {None: None}
|
424
|
+
else:
|
425
|
+
if None in properties:
|
426
|
+
self._global_operations[instruction.num_qubits].add(instruction_name)
|
427
|
+
qargs_val = {}
|
428
|
+
for qarg in properties:
|
429
|
+
if qarg is not None and len(qarg) != instruction.num_qubits:
|
430
|
+
raise TranspilerError(
|
431
|
+
f"The number of qubits for {instruction} does not match the number "
|
432
|
+
f"of qubits in the properties dictionary: {qarg}"
|
433
|
+
)
|
434
|
+
if qarg is not None:
|
435
|
+
self.num_qubits = max(self.num_qubits, max(qarg) + 1)
|
436
|
+
qargs_val[qarg] = properties[qarg]
|
437
|
+
self._qarg_gate_map[qarg].add(instruction_name)
|
438
|
+
self._gate_map[instruction_name] = qargs_val
|
439
|
+
self._coupling_graph = None
|
440
|
+
self._instruction_durations = None
|
441
|
+
self._instruction_schedule_map = None
|
442
|
+
self._non_global_basis = None
|
443
|
+
self._non_global_strict_basis = None
|
444
|
+
|
445
|
+
def update_instruction_properties(self, instruction, qargs, properties):
|
446
|
+
"""Update the property object for an instruction qarg pair already in the Target
|
447
|
+
|
448
|
+
Args:
|
449
|
+
instruction (str): The instruction name to update
|
450
|
+
qargs (tuple): The qargs to update the properties of
|
451
|
+
properties (InstructionProperties): The properties to set for this instruction
|
452
|
+
Raises:
|
453
|
+
KeyError: If ``instruction`` or ``qarg`` are not in the target
|
454
|
+
"""
|
455
|
+
if instruction not in self._gate_map:
|
456
|
+
raise KeyError(f"Provided instruction: '{instruction}' not in this Target")
|
457
|
+
if qargs not in self._gate_map[instruction]:
|
458
|
+
raise KeyError(f"Provided qarg: '{qargs}' not in this Target for {instruction}")
|
459
|
+
self._gate_map[instruction][qargs] = properties
|
460
|
+
self._instruction_durations = None
|
461
|
+
self._instruction_schedule_map = None
|
462
|
+
|
463
|
+
def update_from_instruction_schedule_map(self, inst_map, inst_name_map=None, error_dict=None):
|
464
|
+
"""Update the target from an instruction schedule map.
|
465
|
+
|
466
|
+
If the input instruction schedule map contains new instructions not in
|
467
|
+
the target they will be added. However, if it contains additional qargs
|
468
|
+
for an existing instruction in the target it will error.
|
469
|
+
|
470
|
+
Args:
|
471
|
+
inst_map (InstructionScheduleMap): The instruction
|
472
|
+
inst_name_map (dict): An optional dictionary that maps any
|
473
|
+
instruction name in ``inst_map`` to an instruction object.
|
474
|
+
If not provided, instruction is pulled from the standard Qiskit gates,
|
475
|
+
and finally custom gate instance is created with schedule name.
|
476
|
+
error_dict (dict): A dictionary of errors of the form::
|
477
|
+
|
478
|
+
{gate_name: {qarg: error}}
|
479
|
+
|
480
|
+
for example::
|
481
|
+
|
482
|
+
{'rx': {(0, ): 1.4e-4, (1, ): 1.2e-4}}
|
483
|
+
|
484
|
+
For each entry in the ``inst_map`` if ``error_dict`` is defined
|
485
|
+
a when updating the ``Target`` the error value will be pulled from
|
486
|
+
this dictionary. If one is not found in ``error_dict`` then
|
487
|
+
``None`` will be used.
|
488
|
+
"""
|
489
|
+
get_calibration = getattr(inst_map, "_get_calibration_entry")
|
490
|
+
|
491
|
+
# Expand name mapping with custom gate name provided by user.
|
492
|
+
qiskit_inst_name_map = get_standard_gate_name_mapping()
|
493
|
+
if inst_name_map is not None:
|
494
|
+
qiskit_inst_name_map.update(inst_name_map)
|
495
|
+
|
496
|
+
for inst_name in inst_map.instructions:
|
497
|
+
# Prepare dictionary of instruction properties
|
498
|
+
out_props = {}
|
499
|
+
for qargs in inst_map.qubits_with_instruction(inst_name):
|
500
|
+
try:
|
501
|
+
qargs = tuple(qargs)
|
502
|
+
except TypeError:
|
503
|
+
qargs = (qargs,)
|
504
|
+
try:
|
505
|
+
props = self._gate_map[inst_name][qargs]
|
506
|
+
except (KeyError, TypeError):
|
507
|
+
props = None
|
508
|
+
|
509
|
+
entry = get_calibration(inst_name, qargs)
|
510
|
+
if entry.user_provided and getattr(props, "_calibration", None) != entry:
|
511
|
+
# It only copies user-provided calibration from the inst map.
|
512
|
+
# Backend defined entry must already exist in Target.
|
513
|
+
if self.dt is not None:
|
514
|
+
try:
|
515
|
+
duration = entry.get_schedule().duration * self.dt
|
516
|
+
except UnassignedDurationError:
|
517
|
+
# duration of schedule is parameterized
|
518
|
+
duration = None
|
519
|
+
else:
|
520
|
+
duration = None
|
521
|
+
props = InstructionProperties(
|
522
|
+
duration=duration,
|
523
|
+
calibration=entry,
|
524
|
+
)
|
525
|
+
else:
|
526
|
+
if props is None:
|
527
|
+
# Edge case. Calibration is backend defined, but this is not
|
528
|
+
# registered in the backend target. Ignore this entry.
|
529
|
+
continue
|
530
|
+
try:
|
531
|
+
# Update gate error if provided.
|
532
|
+
props.error = error_dict[inst_name][qargs]
|
533
|
+
except (KeyError, TypeError):
|
534
|
+
pass
|
535
|
+
out_props[qargs] = props
|
536
|
+
if not out_props:
|
537
|
+
continue
|
538
|
+
# Prepare Qiskit Gate object assigned to the entries
|
539
|
+
if inst_name not in self._gate_map:
|
540
|
+
# Entry not found: Add new instruction
|
541
|
+
if inst_name in qiskit_inst_name_map:
|
542
|
+
# Remove qargs with length that doesn't match with instruction qubit number
|
543
|
+
inst_obj = qiskit_inst_name_map[inst_name]
|
544
|
+
normalized_props = {}
|
545
|
+
for qargs, prop in out_props.items():
|
546
|
+
if len(qargs) != inst_obj.num_qubits:
|
547
|
+
continue
|
548
|
+
normalized_props[qargs] = prop
|
549
|
+
self.add_instruction(inst_obj, normalized_props, name=inst_name)
|
550
|
+
else:
|
551
|
+
# Check qubit length parameter name uniformity.
|
552
|
+
qlen = set()
|
553
|
+
param_names = set()
|
554
|
+
for qargs in inst_map.qubits_with_instruction(inst_name):
|
555
|
+
if isinstance(qargs, int):
|
556
|
+
qargs = (qargs,)
|
557
|
+
qlen.add(len(qargs))
|
558
|
+
cal = getattr(out_props[tuple(qargs)], "_calibration")
|
559
|
+
param_names.add(tuple(cal.get_signature().parameters.keys()))
|
560
|
+
if len(qlen) > 1 or len(param_names) > 1:
|
561
|
+
raise QiskitError(
|
562
|
+
f"Schedules for {inst_name} are defined non-uniformly for "
|
563
|
+
f"multiple qubit lengths {qlen}, "
|
564
|
+
f"or different parameter names {param_names}. "
|
565
|
+
"Provide these schedules with inst_name_map or define them with "
|
566
|
+
"different names for different gate parameters."
|
567
|
+
)
|
568
|
+
inst_obj = Gate(
|
569
|
+
name=inst_name,
|
570
|
+
num_qubits=next(iter(qlen)),
|
571
|
+
params=list(map(Parameter, next(iter(param_names)))),
|
572
|
+
)
|
573
|
+
self.add_instruction(inst_obj, out_props, name=inst_name)
|
574
|
+
else:
|
575
|
+
# Entry found: Update "existing" instructions.
|
576
|
+
for qargs, prop in out_props.items():
|
577
|
+
if qargs not in self._gate_map[inst_name]:
|
578
|
+
continue
|
579
|
+
self.update_instruction_properties(inst_name, qargs, prop)
|
580
|
+
|
581
|
+
@property
|
582
|
+
def qargs(self):
|
583
|
+
"""The set of qargs in the target."""
|
584
|
+
qargs = set(self._qarg_gate_map)
|
585
|
+
if len(qargs) == 1 and next(iter(qargs)) is None:
|
586
|
+
return None
|
587
|
+
return qargs
|
588
|
+
|
589
|
+
def qargs_for_operation_name(self, operation):
|
590
|
+
"""Get the qargs for a given operation name
|
591
|
+
|
592
|
+
Args:
|
593
|
+
operation (str): The operation name to get qargs for
|
594
|
+
Returns:
|
595
|
+
set: The set of qargs the gate instance applies to.
|
596
|
+
"""
|
597
|
+
if None in self._gate_map[operation]:
|
598
|
+
return None
|
599
|
+
return self._gate_map[operation].keys()
|
600
|
+
|
601
|
+
def durations(self):
|
602
|
+
"""Get an InstructionDurations object from the target
|
603
|
+
|
604
|
+
Returns:
|
605
|
+
InstructionDurations: The instruction duration represented in the
|
606
|
+
target
|
607
|
+
"""
|
608
|
+
if self._instruction_durations is not None:
|
609
|
+
return self._instruction_durations
|
610
|
+
out_durations = []
|
611
|
+
for instruction, props_map in self._gate_map.items():
|
612
|
+
for qarg, properties in props_map.items():
|
613
|
+
if properties is not None and properties.duration is not None:
|
614
|
+
out_durations.append((instruction, list(qarg), properties.duration, "s"))
|
615
|
+
self._instruction_durations = InstructionDurations(out_durations, dt=self.dt)
|
616
|
+
return self._instruction_durations
|
617
|
+
|
618
|
+
def timing_constraints(self):
|
619
|
+
"""Get an :class:`~qiskit.transpiler.TimingConstraints` object from the target
|
620
|
+
|
621
|
+
Returns:
|
622
|
+
TimingConstraints: The timing constraints represented in the ``Target``
|
623
|
+
"""
|
624
|
+
return TimingConstraints(
|
625
|
+
self.granularity, self.min_length, self.pulse_alignment, self.acquire_alignment
|
626
|
+
)
|
627
|
+
|
628
|
+
def instruction_schedule_map(self):
|
629
|
+
"""Return an :class:`~qiskit.pulse.InstructionScheduleMap` for the
|
630
|
+
instructions in the target with a pulse schedule defined.
|
631
|
+
|
632
|
+
Returns:
|
633
|
+
InstructionScheduleMap: The instruction schedule map for the
|
634
|
+
instructions in this target with a pulse schedule defined.
|
635
|
+
"""
|
636
|
+
if self._instruction_schedule_map is not None:
|
637
|
+
return self._instruction_schedule_map
|
638
|
+
out_inst_schedule_map = InstructionScheduleMap()
|
639
|
+
for instruction, qargs in self._gate_map.items():
|
640
|
+
for qarg, properties in qargs.items():
|
641
|
+
# Directly getting CalibrationEntry not to invoke .get_schedule().
|
642
|
+
# This keeps PulseQobjDef un-parsed.
|
643
|
+
cal_entry = getattr(properties, "_calibration", None)
|
644
|
+
if cal_entry is not None:
|
645
|
+
# Use fast-path to add entries to the inst map.
|
646
|
+
out_inst_schedule_map._add(instruction, qarg, cal_entry)
|
647
|
+
self._instruction_schedule_map = out_inst_schedule_map
|
648
|
+
return out_inst_schedule_map
|
649
|
+
|
650
|
+
def operation_from_name(self, instruction):
|
651
|
+
"""Get the operation class object for a given name
|
652
|
+
|
653
|
+
Args:
|
654
|
+
instruction (str): The instruction name to get the
|
655
|
+
:class:`~qiskit.circuit.Instruction` instance for
|
656
|
+
Returns:
|
657
|
+
qiskit.circuit.Instruction: The Instruction instance corresponding to the
|
658
|
+
name. This also can also be the class for globally defined variable with
|
659
|
+
operations.
|
660
|
+
"""
|
661
|
+
return self._gate_name_map[instruction]
|
662
|
+
|
663
|
+
def operations_for_qargs(self, qargs):
|
664
|
+
"""Get the operation class object for a specified qargs tuple
|
665
|
+
|
666
|
+
Args:
|
667
|
+
qargs (tuple): A qargs tuple of the qubits to get the gates that apply
|
668
|
+
to it. For example, ``(0,)`` will return the set of all
|
669
|
+
instructions that apply to qubit 0. If set to ``None`` this will
|
670
|
+
return any globally defined operations in the target.
|
671
|
+
Returns:
|
672
|
+
list: The list of :class:`~qiskit.circuit.Instruction` instances
|
673
|
+
that apply to the specified qarg. This may also be a class if
|
674
|
+
a variable width operation is globally defined.
|
675
|
+
|
676
|
+
Raises:
|
677
|
+
KeyError: If qargs is not in target
|
678
|
+
"""
|
679
|
+
if qargs is not None and any(x not in range(0, self.num_qubits) for x in qargs):
|
680
|
+
raise KeyError(f"{qargs} not in target.")
|
681
|
+
res = [self._gate_name_map[x] for x in self._qarg_gate_map[qargs]]
|
682
|
+
if qargs is not None:
|
683
|
+
res += self._global_operations.get(len(qargs), [])
|
684
|
+
for op in self._gate_name_map.values():
|
685
|
+
if inspect.isclass(op):
|
686
|
+
res.append(op)
|
687
|
+
if not res:
|
688
|
+
raise KeyError(f"{qargs} not in target.")
|
689
|
+
return list(res)
|
690
|
+
|
691
|
+
def operation_names_for_qargs(self, qargs):
|
692
|
+
"""Get the operation names for a specified qargs tuple
|
693
|
+
|
694
|
+
Args:
|
695
|
+
qargs (tuple): A ``qargs`` tuple of the qubits to get the gates that apply
|
696
|
+
to it. For example, ``(0,)`` will return the set of all
|
697
|
+
instructions that apply to qubit 0. If set to ``None`` this will
|
698
|
+
return the names for any globally defined operations in the target.
|
699
|
+
Returns:
|
700
|
+
set: The set of operation names that apply to the specified ``qargs``.
|
701
|
+
|
702
|
+
Raises:
|
703
|
+
KeyError: If ``qargs`` is not in target
|
704
|
+
"""
|
705
|
+
if qargs is not None and any(x not in range(0, self.num_qubits) for x in qargs):
|
706
|
+
raise KeyError(f"{qargs} not in target.")
|
707
|
+
res = self._qarg_gate_map.get(qargs, set())
|
708
|
+
if qargs is not None:
|
709
|
+
res.update(self._global_operations.get(len(qargs), set()))
|
710
|
+
for name, op in self._gate_name_map.items():
|
711
|
+
if inspect.isclass(op):
|
712
|
+
res.add(name)
|
713
|
+
if not res:
|
714
|
+
raise KeyError(f"{qargs} not in target.")
|
715
|
+
return res
|
716
|
+
|
717
|
+
def instruction_supported(
|
718
|
+
self, operation_name=None, qargs=None, operation_class=None, parameters=None
|
719
|
+
):
|
720
|
+
"""Return whether the instruction (operation + qubits) is supported by the target
|
721
|
+
|
722
|
+
Args:
|
723
|
+
operation_name (str): The name of the operation for the instruction. Either
|
724
|
+
this or ``operation_class`` must be specified, if both are specified
|
725
|
+
``operation_class`` will take priority and this argument will be ignored.
|
726
|
+
qargs (tuple): The tuple of qubit indices for the instruction. If this is
|
727
|
+
not specified then this method will return ``True`` if the specified
|
728
|
+
operation is supported on any qubits. The typical application will
|
729
|
+
always have this set (otherwise it's the same as just checking if the
|
730
|
+
target contains the operation). Normally you would not set this argument
|
731
|
+
if you wanted to check more generally that the target supports an operation
|
732
|
+
with the ``parameters`` on any qubits.
|
733
|
+
operation_class (Type[qiskit.circuit.Instruction]): The operation class to check whether
|
734
|
+
the target supports a particular operation by class rather
|
735
|
+
than by name. This lookup is more expensive as it needs to
|
736
|
+
iterate over all operations in the target instead of just a
|
737
|
+
single lookup. If this is specified it will supersede the
|
738
|
+
``operation_name`` argument. The typical use case for this
|
739
|
+
operation is to check whether a specific variant of an operation
|
740
|
+
is supported on the backend. For example, if you wanted to
|
741
|
+
check whether a :class:`~.RXGate` was supported on a specific
|
742
|
+
qubit with a fixed angle. That fixed angle variant will
|
743
|
+
typically have a name different from the object's
|
744
|
+
:attr:`~.Instruction.name` attribute (``"rx"``) in the target.
|
745
|
+
This can be used to check if any instances of the class are
|
746
|
+
available in such a case.
|
747
|
+
parameters (list): A list of parameters to check if the target
|
748
|
+
supports them on the specified qubits. If the instruction
|
749
|
+
supports the parameter values specified in the list on the
|
750
|
+
operation and qargs specified this will return ``True`` but
|
751
|
+
if the parameters are not supported on the specified
|
752
|
+
instruction it will return ``False``. If this argument is not
|
753
|
+
specified this method will return ``True`` if the instruction
|
754
|
+
is supported independent of the instruction parameters. If
|
755
|
+
specified with any :class:`~.Parameter` objects in the list,
|
756
|
+
that entry will be treated as supporting any value, however parameter names
|
757
|
+
will not be checked (for example if an operation in the target
|
758
|
+
is listed as parameterized with ``"theta"`` and ``"phi"`` is
|
759
|
+
passed into this function that will return ``True``). For
|
760
|
+
example, if called with::
|
761
|
+
|
762
|
+
parameters = [Parameter("theta")]
|
763
|
+
target.instruction_supported("rx", (0,), parameters=parameters)
|
764
|
+
|
765
|
+
will return ``True`` if an :class:`~.RXGate` is supported on qubit 0
|
766
|
+
that will accept any parameter. If you need to check for a fixed numeric
|
767
|
+
value parameter this argument is typically paired with the ``operation_class``
|
768
|
+
argument. For example::
|
769
|
+
|
770
|
+
target.instruction_supported("rx", (0,), RXGate, parameters=[pi / 4])
|
771
|
+
|
772
|
+
will return ``True`` if an RXGate(pi/4) exists on qubit 0.
|
773
|
+
|
774
|
+
Returns:
|
775
|
+
bool: Returns ``True`` if the instruction is supported and ``False`` if it isn't.
|
776
|
+
|
777
|
+
"""
|
778
|
+
|
779
|
+
def check_obj_params(parameters, obj):
|
780
|
+
for index, param in enumerate(parameters):
|
781
|
+
if isinstance(param, Parameter) and not isinstance(obj.params[index], Parameter):
|
782
|
+
return False
|
783
|
+
if param != obj.params[index] and not isinstance(obj.params[index], Parameter):
|
784
|
+
return False
|
785
|
+
return True
|
786
|
+
|
787
|
+
# Case a list if passed in by mistake
|
788
|
+
if qargs is not None:
|
789
|
+
qargs = tuple(qargs)
|
790
|
+
if operation_class is not None:
|
791
|
+
for op_name, obj in self._gate_name_map.items():
|
792
|
+
if inspect.isclass(obj):
|
793
|
+
if obj != operation_class:
|
794
|
+
continue
|
795
|
+
# If no qargs operation class is supported
|
796
|
+
if qargs is None:
|
797
|
+
return True
|
798
|
+
# If qargs set then validate no duplicates and all indices are valid on device
|
799
|
+
elif all(qarg <= self.num_qubits for qarg in qargs) and len(set(qargs)) == len(
|
800
|
+
qargs
|
801
|
+
):
|
802
|
+
return True
|
803
|
+
else:
|
804
|
+
return False
|
805
|
+
|
806
|
+
if isinstance(obj, operation_class):
|
807
|
+
if parameters is not None:
|
808
|
+
if len(parameters) != len(obj.params):
|
809
|
+
continue
|
810
|
+
if not check_obj_params(parameters, obj):
|
811
|
+
continue
|
812
|
+
if qargs is None:
|
813
|
+
return True
|
814
|
+
if qargs in self._gate_map[op_name]:
|
815
|
+
return True
|
816
|
+
if self._gate_map[op_name] is None or None in self._gate_map[op_name]:
|
817
|
+
return self._gate_name_map[op_name].num_qubits == len(qargs) and all(
|
818
|
+
x < self.num_qubits for x in qargs
|
819
|
+
)
|
820
|
+
return False
|
821
|
+
if operation_name in self._gate_map:
|
822
|
+
if parameters is not None:
|
823
|
+
obj = self._gate_name_map[operation_name]
|
824
|
+
if inspect.isclass(obj):
|
825
|
+
# The parameters argument was set and the operation_name specified is
|
826
|
+
# defined as a globally supported class in the target. This means
|
827
|
+
# there is no available validation (including whether the specified
|
828
|
+
# operation supports parameters), the returned value will not factor
|
829
|
+
# in the argument `parameters`,
|
830
|
+
|
831
|
+
# If no qargs a operation class is supported
|
832
|
+
if qargs is None:
|
833
|
+
return True
|
834
|
+
# If qargs set then validate no duplicates and all indices are valid on device
|
835
|
+
elif all(qarg <= self.num_qubits for qarg in qargs) and len(set(qargs)) == len(
|
836
|
+
qargs
|
837
|
+
):
|
838
|
+
return True
|
839
|
+
else:
|
840
|
+
return False
|
841
|
+
if len(parameters) != len(obj.params):
|
842
|
+
return False
|
843
|
+
for index, param in enumerate(parameters):
|
844
|
+
matching_param = False
|
845
|
+
if isinstance(obj.params[index], Parameter):
|
846
|
+
matching_param = True
|
847
|
+
elif param == obj.params[index]:
|
848
|
+
matching_param = True
|
849
|
+
if not matching_param:
|
850
|
+
return False
|
851
|
+
return True
|
852
|
+
if qargs is None:
|
853
|
+
return True
|
854
|
+
if qargs in self._gate_map[operation_name]:
|
855
|
+
return True
|
856
|
+
if self._gate_map[operation_name] is None or None in self._gate_map[operation_name]:
|
857
|
+
obj = self._gate_name_map[operation_name]
|
858
|
+
if inspect.isclass(obj):
|
859
|
+
if qargs is None:
|
860
|
+
return True
|
861
|
+
# If qargs set then validate no duplicates and all indices are valid on device
|
862
|
+
elif all(qarg <= self.num_qubits for qarg in qargs) and len(set(qargs)) == len(
|
863
|
+
qargs
|
864
|
+
):
|
865
|
+
return True
|
866
|
+
else:
|
867
|
+
return False
|
868
|
+
else:
|
869
|
+
return self._gate_name_map[operation_name].num_qubits == len(qargs) and all(
|
870
|
+
x < self.num_qubits for x in qargs
|
871
|
+
)
|
872
|
+
return False
|
873
|
+
|
874
|
+
def has_calibration(
|
875
|
+
self,
|
876
|
+
operation_name: str,
|
877
|
+
qargs: tuple[int, ...],
|
878
|
+
) -> bool:
|
879
|
+
"""Return whether the instruction (operation + qubits) defines a calibration.
|
880
|
+
|
881
|
+
Args:
|
882
|
+
operation_name: The name of the operation for the instruction.
|
883
|
+
qargs: The tuple of qubit indices for the instruction.
|
884
|
+
|
885
|
+
Returns:
|
886
|
+
Returns ``True`` if the calibration is supported and ``False`` if it isn't.
|
887
|
+
"""
|
888
|
+
qargs = tuple(qargs)
|
889
|
+
if operation_name not in self._gate_map:
|
890
|
+
return False
|
891
|
+
if qargs not in self._gate_map[operation_name]:
|
892
|
+
return False
|
893
|
+
return getattr(self._gate_map[operation_name][qargs], "_calibration") is not None
|
894
|
+
|
895
|
+
def get_calibration(
|
896
|
+
self,
|
897
|
+
operation_name: str,
|
898
|
+
qargs: tuple[int, ...],
|
899
|
+
*args: ParameterValueType,
|
900
|
+
**kwargs: ParameterValueType,
|
901
|
+
) -> Schedule | ScheduleBlock:
|
902
|
+
"""Get calibrated pulse schedule for the instruction.
|
903
|
+
|
904
|
+
If calibration is templated with parameters, one can also provide those values
|
905
|
+
to build a schedule with assigned parameters.
|
906
|
+
|
907
|
+
Args:
|
908
|
+
operation_name: The name of the operation for the instruction.
|
909
|
+
qargs: The tuple of qubit indices for the instruction.
|
910
|
+
args: Parameter values to build schedule if any.
|
911
|
+
kwargs: Parameter values with name to build schedule if any.
|
912
|
+
|
913
|
+
Returns:
|
914
|
+
Calibrated pulse schedule of corresponding instruction.
|
915
|
+
"""
|
916
|
+
if not self.has_calibration(operation_name, qargs):
|
917
|
+
raise KeyError(
|
918
|
+
f"Calibration of instruction {operation_name} for qubit {qargs} is not defined."
|
919
|
+
)
|
920
|
+
cal_entry = getattr(self._gate_map[operation_name][qargs], "_calibration")
|
921
|
+
return cal_entry.get_schedule(*args, **kwargs)
|
922
|
+
|
923
|
+
@property
|
924
|
+
def operation_names(self):
|
925
|
+
"""Get the operation names in the target."""
|
926
|
+
return self._gate_map.keys()
|
927
|
+
|
928
|
+
@property
|
929
|
+
def operations(self):
|
930
|
+
"""Get the operation class objects in the target."""
|
931
|
+
return list(self._gate_name_map.values())
|
932
|
+
|
933
|
+
@property
|
934
|
+
def instructions(self):
|
935
|
+
"""Get the list of tuples ``(:class:`~qiskit.circuit.Instruction`, (qargs))``
|
936
|
+
for the target
|
937
|
+
|
938
|
+
For globally defined variable width operations the tuple will be of the form
|
939
|
+
``(class, None)`` where class is the actual operation class that
|
940
|
+
is globally defined.
|
941
|
+
"""
|
942
|
+
return [
|
943
|
+
(self._gate_name_map[op], qarg) for op in self._gate_map for qarg in self._gate_map[op]
|
944
|
+
]
|
945
|
+
|
946
|
+
def instruction_properties(self, index):
|
947
|
+
"""Get the instruction properties for a specific instruction tuple
|
948
|
+
|
949
|
+
This method is to be used in conjunction with the
|
950
|
+
:attr:`~qiskit.transpiler.Target.instructions` attribute of a
|
951
|
+
:class:`~qiskit.transpiler.Target` object. You can use this method to quickly
|
952
|
+
get the instruction properties for an element of
|
953
|
+
:attr:`~qiskit.transpiler.Target.instructions` by using the index in that list.
|
954
|
+
However, if you're not working with :attr:`~qiskit.transpiler.Target.instructions`
|
955
|
+
directly it is likely more efficient to access the target directly via the name
|
956
|
+
and qubits to get the instruction properties. For example, if
|
957
|
+
:attr:`~qiskit.transpiler.Target.instructions` returned::
|
958
|
+
|
959
|
+
[(XGate(), (0,)), (XGate(), (1,))]
|
960
|
+
|
961
|
+
you could get the properties of the ``XGate`` on qubit 1 with::
|
962
|
+
|
963
|
+
props = target.instruction_properties(1)
|
964
|
+
|
965
|
+
but just accessing it directly via the name would be more efficient::
|
966
|
+
|
967
|
+
props = target['x'][(1,)]
|
968
|
+
|
969
|
+
(assuming the ``XGate``'s canonical name in the target is ``'x'``)
|
970
|
+
This is especially true for larger targets as this will scale worse with the number
|
971
|
+
of instruction tuples in a target.
|
972
|
+
|
973
|
+
Args:
|
974
|
+
index (int): The index of the instruction tuple from the
|
975
|
+
:attr:`~qiskit.transpiler.Target.instructions` attribute. For, example
|
976
|
+
if you want the properties from the third element in
|
977
|
+
:attr:`~qiskit.transpiler.Target.instructions` you would set this to be ``2``.
|
978
|
+
Returns:
|
979
|
+
InstructionProperties: The instruction properties for the specified instruction tuple
|
980
|
+
"""
|
981
|
+
instruction_properties = [
|
982
|
+
inst_props for op in self._gate_map for _, inst_props in self._gate_map[op].items()
|
983
|
+
]
|
984
|
+
return instruction_properties[index]
|
985
|
+
|
986
|
+
def _build_coupling_graph(self):
|
987
|
+
self._coupling_graph = rx.PyDiGraph(multigraph=False)
|
988
|
+
self._coupling_graph.add_nodes_from([{} for _ in range(self.num_qubits)])
|
989
|
+
for gate, qarg_map in self._gate_map.items():
|
990
|
+
if qarg_map is None:
|
991
|
+
if self._gate_name_map[gate].num_qubits == 2:
|
992
|
+
self._coupling_graph = None
|
993
|
+
return
|
994
|
+
continue
|
995
|
+
for qarg, properties in qarg_map.items():
|
996
|
+
if qarg is None:
|
997
|
+
if self._gate_name_map[gate].num_qubits == 2:
|
998
|
+
self._coupling_graph = None
|
999
|
+
return
|
1000
|
+
continue
|
1001
|
+
if len(qarg) == 1:
|
1002
|
+
self._coupling_graph[qarg[0]] = properties
|
1003
|
+
elif len(qarg) == 2:
|
1004
|
+
try:
|
1005
|
+
edge_data = self._coupling_graph.get_edge_data(*qarg)
|
1006
|
+
edge_data[gate] = properties
|
1007
|
+
except rx.NoEdgeBetweenNodes:
|
1008
|
+
self._coupling_graph.add_edge(*qarg, {gate: properties})
|
1009
|
+
if self._coupling_graph.num_edges() == 0 and any(x is None for x in self._qarg_gate_map):
|
1010
|
+
self._coupling_graph = None
|
1011
|
+
|
1012
|
+
def build_coupling_map(self, two_q_gate=None, filter_idle_qubits=False):
|
1013
|
+
"""Get a :class:`~qiskit.transpiler.CouplingMap` from this target.
|
1014
|
+
|
1015
|
+
If there is a mix of two qubit operations that have a connectivity
|
1016
|
+
constraint and those that are globally defined this will also return
|
1017
|
+
``None`` because the globally connectivity means there is no constraint
|
1018
|
+
on the target. If you wish to see the constraints of the two qubit
|
1019
|
+
operations that have constraints you should use the ``two_q_gate``
|
1020
|
+
argument to limit the output to the gates which have a constraint.
|
1021
|
+
|
1022
|
+
Args:
|
1023
|
+
two_q_gate (str): An optional gate name for a two qubit gate in
|
1024
|
+
the ``Target`` to generate the coupling map for. If specified the
|
1025
|
+
output coupling map will only have edges between qubits where
|
1026
|
+
this gate is present.
|
1027
|
+
filter_idle_qubits (bool): If set to ``True`` the output :class:`~.CouplingMap`
|
1028
|
+
will remove any qubits that don't have any operations defined in the
|
1029
|
+
target. Note that using this argument will result in an output
|
1030
|
+
:class:`~.CouplingMap` object which has holes in its indices
|
1031
|
+
which might differ from the assumptions of the class. The typical use
|
1032
|
+
case of this argument is to be paired with
|
1033
|
+
:meth:`.CouplingMap.connected_components` which will handle the holes
|
1034
|
+
as expected.
|
1035
|
+
Returns:
|
1036
|
+
CouplingMap: The :class:`~qiskit.transpiler.CouplingMap` object
|
1037
|
+
for this target. If there are no connectivity constraints in
|
1038
|
+
the target this will return ``None``.
|
1039
|
+
|
1040
|
+
Raises:
|
1041
|
+
ValueError: If a non-two qubit gate is passed in for ``two_q_gate``.
|
1042
|
+
IndexError: If an Instruction not in the ``Target`` is passed in for
|
1043
|
+
``two_q_gate``.
|
1044
|
+
"""
|
1045
|
+
if self.qargs is None:
|
1046
|
+
return None
|
1047
|
+
if None not in self.qargs and any(len(x) > 2 for x in self.qargs):
|
1048
|
+
logger.warning(
|
1049
|
+
"This Target object contains multiqubit gates that "
|
1050
|
+
"operate on > 2 qubits. This will not be reflected in "
|
1051
|
+
"the output coupling map."
|
1052
|
+
)
|
1053
|
+
|
1054
|
+
if two_q_gate is not None:
|
1055
|
+
coupling_graph = rx.PyDiGraph(multigraph=False)
|
1056
|
+
coupling_graph.add_nodes_from([None] * self.num_qubits)
|
1057
|
+
for qargs, properties in self._gate_map[two_q_gate].items():
|
1058
|
+
if len(qargs) != 2:
|
1059
|
+
raise ValueError(
|
1060
|
+
"Specified two_q_gate: %s is not a 2 qubit instruction" % two_q_gate
|
1061
|
+
)
|
1062
|
+
coupling_graph.add_edge(*qargs, {two_q_gate: properties})
|
1063
|
+
cmap = CouplingMap()
|
1064
|
+
cmap.graph = coupling_graph
|
1065
|
+
return cmap
|
1066
|
+
if self._coupling_graph is None:
|
1067
|
+
self._build_coupling_graph()
|
1068
|
+
# if there is no connectivity constraints in the coupling graph treat it as not
|
1069
|
+
# existing and return
|
1070
|
+
if self._coupling_graph is not None:
|
1071
|
+
cmap = CouplingMap()
|
1072
|
+
if filter_idle_qubits:
|
1073
|
+
cmap.graph = self._filter_coupling_graph()
|
1074
|
+
else:
|
1075
|
+
cmap.graph = self._coupling_graph.copy()
|
1076
|
+
return cmap
|
1077
|
+
else:
|
1078
|
+
return None
|
1079
|
+
|
1080
|
+
def _filter_coupling_graph(self):
|
1081
|
+
has_operations = set(itertools.chain.from_iterable(x for x in self.qargs if x is not None))
|
1082
|
+
graph = self._coupling_graph.copy()
|
1083
|
+
to_remove = set(graph.node_indices()).difference(has_operations)
|
1084
|
+
if to_remove:
|
1085
|
+
graph.remove_nodes_from(list(to_remove))
|
1086
|
+
return graph
|
1087
|
+
|
1088
|
+
@property
|
1089
|
+
def physical_qubits(self):
|
1090
|
+
"""Returns a sorted list of physical_qubits"""
|
1091
|
+
return list(range(self.num_qubits))
|
1092
|
+
|
1093
|
+
def get_non_global_operation_names(self, strict_direction=False):
|
1094
|
+
"""Return the non-global operation names for the target
|
1095
|
+
|
1096
|
+
The non-global operations are those in the target which don't apply
|
1097
|
+
on all qubits (for single qubit operations) or all multi-qubit qargs
|
1098
|
+
(for multi-qubit operations).
|
1099
|
+
|
1100
|
+
Args:
|
1101
|
+
strict_direction (bool): If set to ``True`` the multi-qubit
|
1102
|
+
operations considered as non-global respect the strict
|
1103
|
+
direction (or order of qubits in the qargs is significant). For
|
1104
|
+
example, if ``cx`` is defined on ``(0, 1)`` and ``ecr`` is
|
1105
|
+
defined over ``(1, 0)`` by default neither would be considered
|
1106
|
+
non-global, but if ``strict_direction`` is set ``True`` both
|
1107
|
+
``cx`` and ``ecr`` would be returned.
|
1108
|
+
|
1109
|
+
Returns:
|
1110
|
+
List[str]: A list of operation names for operations that aren't global in this target
|
1111
|
+
"""
|
1112
|
+
if strict_direction:
|
1113
|
+
if self._non_global_strict_basis is not None:
|
1114
|
+
return self._non_global_strict_basis
|
1115
|
+
search_set = self._qarg_gate_map.keys()
|
1116
|
+
else:
|
1117
|
+
if self._non_global_basis is not None:
|
1118
|
+
return self._non_global_basis
|
1119
|
+
|
1120
|
+
search_set = {
|
1121
|
+
frozenset(qarg)
|
1122
|
+
for qarg in self._qarg_gate_map
|
1123
|
+
if qarg is not None and len(qarg) != 1
|
1124
|
+
}
|
1125
|
+
incomplete_basis_gates = []
|
1126
|
+
size_dict = defaultdict(int)
|
1127
|
+
size_dict[1] = self.num_qubits
|
1128
|
+
for qarg in search_set:
|
1129
|
+
if qarg is None or len(qarg) == 1:
|
1130
|
+
continue
|
1131
|
+
size_dict[len(qarg)] += 1
|
1132
|
+
for inst, qargs in self._gate_map.items():
|
1133
|
+
qarg_sample = next(iter(qargs))
|
1134
|
+
if qarg_sample is None:
|
1135
|
+
continue
|
1136
|
+
if not strict_direction:
|
1137
|
+
qargs = {frozenset(qarg) for qarg in qargs}
|
1138
|
+
if len(qargs) != size_dict[len(qarg_sample)]:
|
1139
|
+
incomplete_basis_gates.append(inst)
|
1140
|
+
if strict_direction:
|
1141
|
+
self._non_global_strict_basis = incomplete_basis_gates
|
1142
|
+
else:
|
1143
|
+
self._non_global_basis = incomplete_basis_gates
|
1144
|
+
return incomplete_basis_gates
|
1145
|
+
|
1146
|
+
@property
|
1147
|
+
@deprecate_func(
|
1148
|
+
additional_msg="Use the property ``acquire_alignment`` instead.",
|
1149
|
+
since="0.24.0",
|
1150
|
+
is_property=True,
|
1151
|
+
package_name="qiskit-terra",
|
1152
|
+
)
|
1153
|
+
def aquire_alignment(self):
|
1154
|
+
"""Alias of deprecated name. This will be removed."""
|
1155
|
+
return self.acquire_alignment
|
1156
|
+
|
1157
|
+
@aquire_alignment.setter
|
1158
|
+
@deprecate_func(
|
1159
|
+
additional_msg="Use the property ``acquire_alignment`` instead.",
|
1160
|
+
since="0.24.0",
|
1161
|
+
is_property=True,
|
1162
|
+
package_name="qiskit-terra",
|
1163
|
+
)
|
1164
|
+
def aquire_alignment(self, new_value: int):
|
1165
|
+
"""Alias of deprecated name. This will be removed."""
|
1166
|
+
self.acquire_alignment = new_value
|
1167
|
+
|
1168
|
+
def __iter__(self):
|
1169
|
+
return iter(self._gate_map)
|
1170
|
+
|
1171
|
+
def __getitem__(self, key):
|
1172
|
+
return self._gate_map[key]
|
1173
|
+
|
1174
|
+
def __len__(self):
|
1175
|
+
return len(self._gate_map)
|
1176
|
+
|
1177
|
+
def __contains__(self, item):
|
1178
|
+
return item in self._gate_map
|
1179
|
+
|
1180
|
+
def keys(self):
|
1181
|
+
return self._gate_map.keys()
|
1182
|
+
|
1183
|
+
def values(self):
|
1184
|
+
return self._gate_map.values()
|
1185
|
+
|
1186
|
+
def items(self):
|
1187
|
+
return self._gate_map.items()
|
1188
|
+
|
1189
|
+
def __str__(self):
|
1190
|
+
output = io.StringIO()
|
1191
|
+
if self.description is not None:
|
1192
|
+
output.write(f"Target: {self.description}\n")
|
1193
|
+
else:
|
1194
|
+
output.write("Target\n")
|
1195
|
+
output.write(f"Number of qubits: {self.num_qubits}\n")
|
1196
|
+
output.write("Instructions:\n")
|
1197
|
+
for inst, qarg_props in self._gate_map.items():
|
1198
|
+
output.write(f"\t{inst}\n")
|
1199
|
+
for qarg, props in qarg_props.items():
|
1200
|
+
if qarg is None:
|
1201
|
+
continue
|
1202
|
+
if props is None:
|
1203
|
+
output.write(f"\t\t{qarg}\n")
|
1204
|
+
continue
|
1205
|
+
prop_str_pieces = [f"\t\t{qarg}:\n"]
|
1206
|
+
duration = getattr(props, "duration", None)
|
1207
|
+
if duration is not None:
|
1208
|
+
prop_str_pieces.append(f"\t\t\tDuration: {duration} sec.\n")
|
1209
|
+
error = getattr(props, "error", None)
|
1210
|
+
if error is not None:
|
1211
|
+
prop_str_pieces.append(f"\t\t\tError Rate: {error}\n")
|
1212
|
+
schedule = getattr(props, "_calibration", None)
|
1213
|
+
if schedule is not None:
|
1214
|
+
prop_str_pieces.append("\t\t\tWith pulse schedule calibration\n")
|
1215
|
+
extra_props = getattr(props, "properties", None)
|
1216
|
+
if extra_props is not None:
|
1217
|
+
extra_props_pieces = [
|
1218
|
+
f"\t\t\t\t{key}: {value}\n" for key, value in extra_props.items()
|
1219
|
+
]
|
1220
|
+
extra_props_str = "".join(extra_props_pieces)
|
1221
|
+
prop_str_pieces.append(f"\t\t\tExtra properties:\n{extra_props_str}\n")
|
1222
|
+
output.write("".join(prop_str_pieces))
|
1223
|
+
return output.getvalue()
|
1224
|
+
|
1225
|
+
@classmethod
|
1226
|
+
def from_configuration(
|
1227
|
+
cls,
|
1228
|
+
basis_gates: list[str],
|
1229
|
+
num_qubits: int | None = None,
|
1230
|
+
coupling_map: CouplingMap | None = None,
|
1231
|
+
inst_map: InstructionScheduleMap | None = None,
|
1232
|
+
backend_properties: BackendProperties | None = None,
|
1233
|
+
instruction_durations: InstructionDurations | None = None,
|
1234
|
+
concurrent_measurements: Optional[List[List[int]]] = None,
|
1235
|
+
dt: float | None = None,
|
1236
|
+
timing_constraints: TimingConstraints | None = None,
|
1237
|
+
custom_name_mapping: dict[str, Any] | None = None,
|
1238
|
+
) -> Target:
|
1239
|
+
"""Create a target object from the individual global configuration
|
1240
|
+
|
1241
|
+
Prior to the creation of the :class:`~.Target` class, the constraints
|
1242
|
+
of a backend were represented by a collection of different objects
|
1243
|
+
which combined represent a subset of the information contained in
|
1244
|
+
the :class:`~.Target`. This function provides a simple interface
|
1245
|
+
to convert those separate objects to a :class:`~.Target`.
|
1246
|
+
|
1247
|
+
This constructor will use the input from ``basis_gates``, ``num_qubits``,
|
1248
|
+
and ``coupling_map`` to build a base model of the backend and the
|
1249
|
+
``instruction_durations``, ``backend_properties``, and ``inst_map`` inputs
|
1250
|
+
are then queried (in that order) based on that model to look up the properties
|
1251
|
+
of each instruction and qubit. If there is an inconsistency between the inputs
|
1252
|
+
any extra or conflicting information present in ``instruction_durations``,
|
1253
|
+
``backend_properties``, or ``inst_map`` will be ignored.
|
1254
|
+
|
1255
|
+
Args:
|
1256
|
+
basis_gates: The list of basis gate names for the backend. For the
|
1257
|
+
target to be created these names must either be in the output
|
1258
|
+
from :func:`~.get_standard_gate_name_mapping` or present in the
|
1259
|
+
specified ``custom_name_mapping`` argument.
|
1260
|
+
num_qubits: The number of qubits supported on the backend.
|
1261
|
+
coupling_map: The coupling map representing connectivity constraints
|
1262
|
+
on the backend. If specified all gates from ``basis_gates`` will
|
1263
|
+
be supported on all qubits (or pairs of qubits).
|
1264
|
+
inst_map: The instruction schedule map representing the pulse
|
1265
|
+
:class:`~.Schedule` definitions for each instruction. If this
|
1266
|
+
is specified ``coupling_map`` must be specified. The
|
1267
|
+
``coupling_map`` is used as the source of truth for connectivity
|
1268
|
+
and if ``inst_map`` is used the schedule is looked up based
|
1269
|
+
on the instructions from the pair of ``basis_gates`` and
|
1270
|
+
``coupling_map``. If you want to define a custom gate for
|
1271
|
+
a particular qubit or qubit pair, you can manually build :class:`.Target`.
|
1272
|
+
backend_properties: The :class:`~.BackendProperties` object which is
|
1273
|
+
used for instruction properties and qubit properties.
|
1274
|
+
If specified and instruction properties are intended to be used
|
1275
|
+
then the ``coupling_map`` argument must be specified. This is
|
1276
|
+
only used to lookup error rates and durations (unless
|
1277
|
+
``instruction_durations`` is specified which would take
|
1278
|
+
precedence) for instructions specified via ``coupling_map`` and
|
1279
|
+
``basis_gates``.
|
1280
|
+
instruction_durations: Optional instruction durations for instructions. If specified
|
1281
|
+
it will take priority for setting the ``duration`` field in the
|
1282
|
+
:class:`~InstructionProperties` objects for the instructions in the target.
|
1283
|
+
concurrent_measurements(list): A list of sets of qubits that must be
|
1284
|
+
measured together. This must be provided
|
1285
|
+
as a nested list like ``[[0, 1], [2, 3, 4]]``.
|
1286
|
+
dt: The system time resolution of input signals in seconds
|
1287
|
+
timing_constraints: Optional timing constraints to include in the
|
1288
|
+
:class:`~.Target`
|
1289
|
+
custom_name_mapping: An optional dictionary that maps custom gate/operation names in
|
1290
|
+
``basis_gates`` to an :class:`~.Operation` object representing that
|
1291
|
+
gate/operation. By default, most standard gates names are mapped to the
|
1292
|
+
standard gate object from :mod:`qiskit.circuit.library` this only needs
|
1293
|
+
to be specified if the input ``basis_gates`` defines gates in names outside
|
1294
|
+
that set.
|
1295
|
+
|
1296
|
+
Returns:
|
1297
|
+
Target: the target built from the input configuration
|
1298
|
+
|
1299
|
+
Raises:
|
1300
|
+
TranspilerError: If the input basis gates contain > 2 qubits and ``coupling_map`` is
|
1301
|
+
specified.
|
1302
|
+
KeyError: If no mapping is available for a specified ``basis_gate``.
|
1303
|
+
"""
|
1304
|
+
granularity = 1
|
1305
|
+
min_length = 1
|
1306
|
+
pulse_alignment = 1
|
1307
|
+
acquire_alignment = 1
|
1308
|
+
if timing_constraints is not None:
|
1309
|
+
granularity = timing_constraints.granularity
|
1310
|
+
min_length = timing_constraints.min_length
|
1311
|
+
pulse_alignment = timing_constraints.pulse_alignment
|
1312
|
+
acquire_alignment = timing_constraints.acquire_alignment
|
1313
|
+
|
1314
|
+
qubit_properties = None
|
1315
|
+
if backend_properties is not None:
|
1316
|
+
# pylint: disable=cyclic-import
|
1317
|
+
from qiskit.providers.backend_compat import qubit_props_list_from_props
|
1318
|
+
|
1319
|
+
qubit_properties = qubit_props_list_from_props(properties=backend_properties)
|
1320
|
+
|
1321
|
+
target = cls(
|
1322
|
+
num_qubits=num_qubits,
|
1323
|
+
dt=dt,
|
1324
|
+
granularity=granularity,
|
1325
|
+
min_length=min_length,
|
1326
|
+
pulse_alignment=pulse_alignment,
|
1327
|
+
acquire_alignment=acquire_alignment,
|
1328
|
+
qubit_properties=qubit_properties,
|
1329
|
+
concurrent_measurements=concurrent_measurements,
|
1330
|
+
)
|
1331
|
+
name_mapping = get_standard_gate_name_mapping()
|
1332
|
+
if custom_name_mapping is not None:
|
1333
|
+
name_mapping.update(custom_name_mapping)
|
1334
|
+
|
1335
|
+
# While BackendProperties can also contain coupling information we
|
1336
|
+
# rely solely on CouplingMap to determine connectivity. This is because
|
1337
|
+
# in legacy transpiler usage (and implicitly in the BackendV1 data model)
|
1338
|
+
# the coupling map is used to define connectivity constraints and
|
1339
|
+
# the properties is only used for error rate and duration population.
|
1340
|
+
# If coupling map is not specified we ignore the backend_properties
|
1341
|
+
if coupling_map is None:
|
1342
|
+
for gate in basis_gates:
|
1343
|
+
if gate not in name_mapping:
|
1344
|
+
raise KeyError(
|
1345
|
+
f"The specified basis gate: {gate} is not present in the standard gate "
|
1346
|
+
"names or a provided custom_name_mapping"
|
1347
|
+
)
|
1348
|
+
target.add_instruction(name_mapping[gate], name=gate)
|
1349
|
+
else:
|
1350
|
+
one_qubit_gates = []
|
1351
|
+
two_qubit_gates = []
|
1352
|
+
global_ideal_variable_width_gates = [] # pylint: disable=invalid-name
|
1353
|
+
if num_qubits is None:
|
1354
|
+
num_qubits = len(coupling_map.graph)
|
1355
|
+
for gate in basis_gates:
|
1356
|
+
if gate not in name_mapping:
|
1357
|
+
raise KeyError(
|
1358
|
+
f"The specified basis gate: {gate} is not present in the standard gate "
|
1359
|
+
"names or a provided custom_name_mapping"
|
1360
|
+
)
|
1361
|
+
gate_obj = name_mapping[gate]
|
1362
|
+
if gate_obj.num_qubits == 1:
|
1363
|
+
one_qubit_gates.append(gate)
|
1364
|
+
elif gate_obj.num_qubits == 2:
|
1365
|
+
two_qubit_gates.append(gate)
|
1366
|
+
elif inspect.isclass(gate_obj):
|
1367
|
+
global_ideal_variable_width_gates.append(gate)
|
1368
|
+
else:
|
1369
|
+
raise TranspilerError(
|
1370
|
+
f"The specified basis gate: {gate} has {gate_obj.num_qubits} "
|
1371
|
+
"qubits. This constructor method only supports fixed width operations "
|
1372
|
+
"with <= 2 qubits (because connectivity is defined on a CouplingMap)."
|
1373
|
+
)
|
1374
|
+
for gate in one_qubit_gates:
|
1375
|
+
gate_properties: dict[tuple, InstructionProperties] = {}
|
1376
|
+
for qubit in range(num_qubits):
|
1377
|
+
error = None
|
1378
|
+
duration = None
|
1379
|
+
calibration = None
|
1380
|
+
if backend_properties is not None:
|
1381
|
+
if duration is None:
|
1382
|
+
try:
|
1383
|
+
duration = backend_properties.gate_length(gate, qubit)
|
1384
|
+
except BackendPropertyError:
|
1385
|
+
duration = None
|
1386
|
+
try:
|
1387
|
+
error = backend_properties.gate_error(gate, qubit)
|
1388
|
+
except BackendPropertyError:
|
1389
|
+
error = None
|
1390
|
+
if inst_map is not None:
|
1391
|
+
try:
|
1392
|
+
calibration = inst_map._get_calibration_entry(gate, qubit)
|
1393
|
+
# If we have dt defined and there is a custom calibration which is user
|
1394
|
+
# generate use that custom pulse schedule for the duration. If it is
|
1395
|
+
# not user generated than we assume it's the same duration as what is
|
1396
|
+
# defined in the backend properties
|
1397
|
+
if dt and calibration.user_provided:
|
1398
|
+
duration = calibration.get_schedule().duration * dt
|
1399
|
+
except PulseError:
|
1400
|
+
calibration = None
|
1401
|
+
# Durations if specified manually should override model objects
|
1402
|
+
if instruction_durations is not None:
|
1403
|
+
try:
|
1404
|
+
duration = instruction_durations.get(gate, qubit, unit="s")
|
1405
|
+
except TranspilerError:
|
1406
|
+
duration = None
|
1407
|
+
|
1408
|
+
if error is None and duration is None and calibration is None:
|
1409
|
+
gate_properties[(qubit,)] = None
|
1410
|
+
else:
|
1411
|
+
gate_properties[(qubit,)] = InstructionProperties(
|
1412
|
+
duration=duration, error=error, calibration=calibration
|
1413
|
+
)
|
1414
|
+
target.add_instruction(name_mapping[gate], properties=gate_properties, name=gate)
|
1415
|
+
edges = list(coupling_map.get_edges())
|
1416
|
+
for gate in two_qubit_gates:
|
1417
|
+
gate_properties = {}
|
1418
|
+
for edge in edges:
|
1419
|
+
error = None
|
1420
|
+
duration = None
|
1421
|
+
calibration = None
|
1422
|
+
if backend_properties is not None:
|
1423
|
+
if duration is None:
|
1424
|
+
try:
|
1425
|
+
duration = backend_properties.gate_length(gate, edge)
|
1426
|
+
except BackendPropertyError:
|
1427
|
+
duration = None
|
1428
|
+
try:
|
1429
|
+
error = backend_properties.gate_error(gate, edge)
|
1430
|
+
except BackendPropertyError:
|
1431
|
+
error = None
|
1432
|
+
if inst_map is not None:
|
1433
|
+
try:
|
1434
|
+
calibration = inst_map._get_calibration_entry(gate, edge)
|
1435
|
+
# If we have dt defined and there is a custom calibration which is user
|
1436
|
+
# generate use that custom pulse schedule for the duration. If it is
|
1437
|
+
# not user generated than we assume it's the same duration as what is
|
1438
|
+
# defined in the backend properties
|
1439
|
+
if dt and calibration.user_provided:
|
1440
|
+
duration = calibration.get_schedule().duration * dt
|
1441
|
+
except PulseError:
|
1442
|
+
calibration = None
|
1443
|
+
# Durations if specified manually should override model objects
|
1444
|
+
if instruction_durations is not None:
|
1445
|
+
try:
|
1446
|
+
duration = instruction_durations.get(gate, edge, unit="s")
|
1447
|
+
except TranspilerError:
|
1448
|
+
duration = None
|
1449
|
+
|
1450
|
+
if error is None and duration is None and calibration is None:
|
1451
|
+
gate_properties[edge] = None
|
1452
|
+
else:
|
1453
|
+
gate_properties[edge] = InstructionProperties(
|
1454
|
+
duration=duration, error=error, calibration=calibration
|
1455
|
+
)
|
1456
|
+
target.add_instruction(name_mapping[gate], properties=gate_properties, name=gate)
|
1457
|
+
for gate in global_ideal_variable_width_gates:
|
1458
|
+
target.add_instruction(name_mapping[gate], name=gate)
|
1459
|
+
return target
|
1460
|
+
|
1461
|
+
|
1462
|
+
def target_to_backend_properties(target: Target):
|
1463
|
+
"""Convert a :class:`~.Target` object into a legacy :class:`~.BackendProperties`"""
|
1464
|
+
|
1465
|
+
properties_dict: dict[str, Any] = {
|
1466
|
+
"backend_name": "",
|
1467
|
+
"backend_version": "",
|
1468
|
+
"last_update_date": None,
|
1469
|
+
"general": [],
|
1470
|
+
}
|
1471
|
+
gates = []
|
1472
|
+
qubits = []
|
1473
|
+
for gate, qargs_list in target.items():
|
1474
|
+
if gate != "measure":
|
1475
|
+
for qargs, props in qargs_list.items():
|
1476
|
+
property_list = []
|
1477
|
+
if getattr(props, "duration", None) is not None:
|
1478
|
+
property_list.append(
|
1479
|
+
{
|
1480
|
+
"date": datetime.datetime.now(datetime.timezone.utc),
|
1481
|
+
"name": "gate_length",
|
1482
|
+
"unit": "s",
|
1483
|
+
"value": props.duration,
|
1484
|
+
}
|
1485
|
+
)
|
1486
|
+
if getattr(props, "error", None) is not None:
|
1487
|
+
property_list.append(
|
1488
|
+
{
|
1489
|
+
"date": datetime.datetime.now(datetime.timezone.utc),
|
1490
|
+
"name": "gate_error",
|
1491
|
+
"unit": "",
|
1492
|
+
"value": props.error,
|
1493
|
+
}
|
1494
|
+
)
|
1495
|
+
if property_list:
|
1496
|
+
gates.append(
|
1497
|
+
{
|
1498
|
+
"gate": gate,
|
1499
|
+
"qubits": list(qargs),
|
1500
|
+
"parameters": property_list,
|
1501
|
+
"name": gate + "_".join([str(x) for x in qargs]),
|
1502
|
+
}
|
1503
|
+
)
|
1504
|
+
else:
|
1505
|
+
qubit_props: dict[int, Any] = {x: None for x in range(target.num_qubits)}
|
1506
|
+
for qargs, props in qargs_list.items():
|
1507
|
+
if qargs is None:
|
1508
|
+
continue
|
1509
|
+
qubit = qargs[0]
|
1510
|
+
props_list = []
|
1511
|
+
if getattr(props, "error", None) is not None:
|
1512
|
+
props_list.append(
|
1513
|
+
{
|
1514
|
+
"date": datetime.datetime.now(datetime.timezone.utc),
|
1515
|
+
"name": "readout_error",
|
1516
|
+
"unit": "",
|
1517
|
+
"value": props.error,
|
1518
|
+
}
|
1519
|
+
)
|
1520
|
+
if getattr(props, "duration", None) is not None:
|
1521
|
+
props_list.append(
|
1522
|
+
{
|
1523
|
+
"date": datetime.datetime.now(datetime.timezone.utc),
|
1524
|
+
"name": "readout_length",
|
1525
|
+
"unit": "s",
|
1526
|
+
"value": props.duration,
|
1527
|
+
}
|
1528
|
+
)
|
1529
|
+
if not props_list:
|
1530
|
+
qubit_props = {}
|
1531
|
+
break
|
1532
|
+
qubit_props[qubit] = props_list
|
1533
|
+
if qubit_props and all(x is not None for x in qubit_props.values()):
|
1534
|
+
qubits = [qubit_props[i] for i in range(target.num_qubits)]
|
1535
|
+
if gates or qubits:
|
1536
|
+
properties_dict["gates"] = gates
|
1537
|
+
properties_dict["qubits"] = qubits
|
1538
|
+
return BackendProperties.from_dict(properties_dict)
|
1539
|
+
else:
|
1540
|
+
return None
|