qiskit 1.0.2__cp38-abi3-win32.whl → 1.1.0__cp38-abi3-win32.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.
Files changed (263) hide show
  1. qiskit/VERSION.txt +1 -1
  2. qiskit/__init__.py +27 -16
  3. qiskit/_accelerate.pyd +0 -0
  4. qiskit/_numpy_compat.py +73 -0
  5. qiskit/assembler/__init__.py +5 -10
  6. qiskit/assembler/disassemble.py +5 -6
  7. qiskit/circuit/__init__.py +1061 -232
  8. qiskit/circuit/_classical_resource_map.py +10 -6
  9. qiskit/circuit/_utils.py +18 -8
  10. qiskit/circuit/annotated_operation.py +21 -0
  11. qiskit/circuit/barrier.py +10 -13
  12. qiskit/circuit/bit.py +0 -1
  13. qiskit/circuit/classical/__init__.py +2 -2
  14. qiskit/circuit/classical/expr/__init__.py +39 -5
  15. qiskit/circuit/classical/expr/constructors.py +84 -1
  16. qiskit/circuit/classical/expr/expr.py +83 -13
  17. qiskit/circuit/classical/expr/visitors.py +83 -0
  18. qiskit/circuit/classical/types/__init__.py +5 -4
  19. qiskit/circuit/classicalfunction/__init__.py +1 -0
  20. qiskit/circuit/commutation_checker.py +86 -51
  21. qiskit/circuit/controlflow/_builder_utils.py +9 -1
  22. qiskit/circuit/controlflow/break_loop.py +8 -22
  23. qiskit/circuit/controlflow/builder.py +116 -1
  24. qiskit/circuit/controlflow/continue_loop.py +8 -22
  25. qiskit/circuit/controlflow/control_flow.py +47 -8
  26. qiskit/circuit/controlflow/for_loop.py +8 -23
  27. qiskit/circuit/controlflow/if_else.py +13 -27
  28. qiskit/circuit/controlflow/switch_case.py +14 -21
  29. qiskit/circuit/controlflow/while_loop.py +9 -23
  30. qiskit/circuit/controlledgate.py +2 -2
  31. qiskit/circuit/delay.py +7 -5
  32. qiskit/circuit/gate.py +20 -7
  33. qiskit/circuit/instruction.py +31 -30
  34. qiskit/circuit/instructionset.py +9 -22
  35. qiskit/circuit/library/__init__.py +3 -13
  36. qiskit/circuit/library/arithmetic/integer_comparator.py +2 -2
  37. qiskit/circuit/library/arithmetic/quadratic_form.py +3 -2
  38. qiskit/circuit/library/blueprintcircuit.py +29 -7
  39. qiskit/circuit/library/data_preparation/state_preparation.py +6 -5
  40. qiskit/circuit/library/generalized_gates/diagonal.py +5 -4
  41. qiskit/circuit/library/generalized_gates/isometry.py +51 -254
  42. qiskit/circuit/library/generalized_gates/pauli.py +2 -2
  43. qiskit/circuit/library/generalized_gates/permutation.py +4 -1
  44. qiskit/circuit/library/generalized_gates/rv.py +15 -11
  45. qiskit/circuit/library/generalized_gates/uc.py +2 -98
  46. qiskit/circuit/library/generalized_gates/unitary.py +9 -4
  47. qiskit/circuit/library/hamiltonian_gate.py +11 -5
  48. qiskit/circuit/library/n_local/efficient_su2.py +5 -5
  49. qiskit/circuit/library/n_local/n_local.py +100 -49
  50. qiskit/circuit/library/n_local/two_local.py +3 -59
  51. qiskit/circuit/library/overlap.py +3 -3
  52. qiskit/circuit/library/phase_oracle.py +1 -1
  53. qiskit/circuit/library/quantum_volume.py +39 -38
  54. qiskit/circuit/library/standard_gates/equivalence_library.py +50 -0
  55. qiskit/circuit/library/standard_gates/global_phase.py +4 -2
  56. qiskit/circuit/library/standard_gates/i.py +1 -2
  57. qiskit/circuit/library/standard_gates/iswap.py +1 -2
  58. qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py +11 -5
  59. qiskit/circuit/library/standard_gates/p.py +31 -15
  60. qiskit/circuit/library/standard_gates/r.py +4 -3
  61. qiskit/circuit/library/standard_gates/rx.py +7 -4
  62. qiskit/circuit/library/standard_gates/rxx.py +4 -3
  63. qiskit/circuit/library/standard_gates/ry.py +7 -4
  64. qiskit/circuit/library/standard_gates/ryy.py +4 -3
  65. qiskit/circuit/library/standard_gates/rz.py +7 -4
  66. qiskit/circuit/library/standard_gates/rzx.py +4 -3
  67. qiskit/circuit/library/standard_gates/rzz.py +4 -3
  68. qiskit/circuit/library/standard_gates/s.py +4 -8
  69. qiskit/circuit/library/standard_gates/t.py +2 -4
  70. qiskit/circuit/library/standard_gates/u.py +16 -11
  71. qiskit/circuit/library/standard_gates/u1.py +6 -2
  72. qiskit/circuit/library/standard_gates/u2.py +4 -2
  73. qiskit/circuit/library/standard_gates/u3.py +9 -5
  74. qiskit/circuit/library/standard_gates/x.py +22 -11
  75. qiskit/circuit/library/standard_gates/xx_minus_yy.py +4 -3
  76. qiskit/circuit/library/standard_gates/xx_plus_yy.py +7 -5
  77. qiskit/circuit/library/standard_gates/z.py +1 -2
  78. qiskit/circuit/measure.py +4 -1
  79. qiskit/circuit/operation.py +13 -8
  80. qiskit/circuit/parameter.py +11 -6
  81. qiskit/circuit/quantumcircuit.py +1910 -260
  82. qiskit/circuit/quantumcircuitdata.py +2 -2
  83. qiskit/circuit/reset.py +5 -2
  84. qiskit/circuit/store.py +95 -0
  85. qiskit/compiler/assembler.py +22 -22
  86. qiskit/compiler/transpiler.py +63 -112
  87. qiskit/converters/__init__.py +17 -2
  88. qiskit/converters/circuit_to_dag.py +7 -0
  89. qiskit/converters/circuit_to_dagdependency_v2.py +47 -0
  90. qiskit/converters/circuit_to_gate.py +2 -0
  91. qiskit/converters/circuit_to_instruction.py +22 -0
  92. qiskit/converters/dag_to_circuit.py +4 -0
  93. qiskit/converters/dag_to_dagdependency_v2.py +44 -0
  94. qiskit/dagcircuit/collect_blocks.py +15 -10
  95. qiskit/dagcircuit/dagcircuit.py +434 -124
  96. qiskit/dagcircuit/dagdependency.py +19 -12
  97. qiskit/dagcircuit/dagdependency_v2.py +641 -0
  98. qiskit/dagcircuit/dagdepnode.py +19 -16
  99. qiskit/dagcircuit/dagnode.py +14 -4
  100. qiskit/passmanager/passmanager.py +11 -11
  101. qiskit/primitives/__init__.py +22 -12
  102. qiskit/primitives/backend_estimator.py +3 -5
  103. qiskit/primitives/backend_estimator_v2.py +410 -0
  104. qiskit/primitives/backend_sampler_v2.py +287 -0
  105. qiskit/primitives/base/base_estimator.py +4 -9
  106. qiskit/primitives/base/base_sampler.py +2 -2
  107. qiskit/primitives/containers/__init__.py +6 -4
  108. qiskit/primitives/containers/bit_array.py +293 -2
  109. qiskit/primitives/containers/data_bin.py +123 -50
  110. qiskit/primitives/containers/estimator_pub.py +10 -3
  111. qiskit/primitives/containers/observables_array.py +2 -2
  112. qiskit/primitives/containers/pub_result.py +1 -1
  113. qiskit/primitives/containers/sampler_pub.py +19 -3
  114. qiskit/primitives/containers/sampler_pub_result.py +74 -0
  115. qiskit/primitives/containers/shape.py +4 -4
  116. qiskit/primitives/statevector_estimator.py +4 -4
  117. qiskit/primitives/statevector_sampler.py +7 -12
  118. qiskit/providers/__init__.py +65 -34
  119. qiskit/providers/backend.py +2 -2
  120. qiskit/providers/backend_compat.py +8 -10
  121. qiskit/providers/basic_provider/__init__.py +2 -23
  122. qiskit/providers/basic_provider/basic_provider_tools.py +67 -31
  123. qiskit/providers/basic_provider/basic_simulator.py +81 -21
  124. qiskit/providers/fake_provider/__init__.py +1 -1
  125. qiskit/providers/fake_provider/fake_1q.py +1 -1
  126. qiskit/providers/fake_provider/fake_backend.py +3 -408
  127. qiskit/providers/fake_provider/generic_backend_v2.py +26 -14
  128. qiskit/providers/models/__init__.py +2 -2
  129. qiskit/providers/provider.py +16 -0
  130. qiskit/pulse/builder.py +4 -1
  131. qiskit/pulse/parameter_manager.py +60 -4
  132. qiskit/pulse/schedule.py +29 -13
  133. qiskit/pulse/utils.py +61 -20
  134. qiskit/qasm2/__init__.py +1 -5
  135. qiskit/qasm2/parse.py +1 -4
  136. qiskit/qasm3/__init__.py +42 -5
  137. qiskit/qasm3/ast.py +19 -0
  138. qiskit/qasm3/exporter.py +178 -106
  139. qiskit/qasm3/printer.py +27 -5
  140. qiskit/qobj/converters/pulse_instruction.py +6 -6
  141. qiskit/qpy/__init__.py +299 -67
  142. qiskit/qpy/binary_io/circuits.py +216 -47
  143. qiskit/qpy/binary_io/schedules.py +42 -36
  144. qiskit/qpy/binary_io/value.py +201 -22
  145. qiskit/qpy/common.py +1 -1
  146. qiskit/qpy/exceptions.py +20 -0
  147. qiskit/qpy/formats.py +29 -0
  148. qiskit/qpy/type_keys.py +21 -0
  149. qiskit/quantum_info/analysis/distance.py +3 -3
  150. qiskit/quantum_info/analysis/make_observable.py +2 -1
  151. qiskit/quantum_info/analysis/z2_symmetries.py +2 -1
  152. qiskit/quantum_info/operators/channel/chi.py +9 -8
  153. qiskit/quantum_info/operators/channel/choi.py +10 -9
  154. qiskit/quantum_info/operators/channel/kraus.py +2 -1
  155. qiskit/quantum_info/operators/channel/ptm.py +10 -9
  156. qiskit/quantum_info/operators/channel/quantum_channel.py +2 -1
  157. qiskit/quantum_info/operators/channel/stinespring.py +2 -1
  158. qiskit/quantum_info/operators/channel/superop.py +12 -11
  159. qiskit/quantum_info/operators/channel/transformations.py +12 -11
  160. qiskit/quantum_info/operators/dihedral/dihedral.py +5 -4
  161. qiskit/quantum_info/operators/operator.py +43 -30
  162. qiskit/quantum_info/operators/scalar_op.py +10 -9
  163. qiskit/quantum_info/operators/symplectic/base_pauli.py +70 -59
  164. qiskit/quantum_info/operators/symplectic/clifford.py +36 -9
  165. qiskit/quantum_info/operators/symplectic/pauli.py +53 -6
  166. qiskit/quantum_info/operators/symplectic/pauli_list.py +36 -14
  167. qiskit/quantum_info/operators/symplectic/random.py +3 -2
  168. qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +61 -36
  169. qiskit/quantum_info/states/densitymatrix.py +13 -13
  170. qiskit/quantum_info/states/stabilizerstate.py +3 -3
  171. qiskit/quantum_info/states/statevector.py +14 -13
  172. qiskit/quantum_info/states/utils.py +5 -3
  173. qiskit/result/__init__.py +6 -0
  174. qiskit/result/mitigation/correlated_readout_mitigator.py +3 -2
  175. qiskit/result/mitigation/local_readout_mitigator.py +2 -1
  176. qiskit/result/mitigation/utils.py +3 -2
  177. qiskit/scheduler/__init__.py +10 -1
  178. qiskit/scheduler/methods/__init__.py +1 -8
  179. qiskit/synthesis/__init__.py +3 -6
  180. qiskit/synthesis/discrete_basis/commutator_decompose.py +2 -2
  181. qiskit/synthesis/evolution/lie_trotter.py +7 -14
  182. qiskit/synthesis/evolution/qdrift.py +3 -4
  183. qiskit/synthesis/linear/cnot_synth.py +1 -3
  184. qiskit/synthesis/linear/linear_circuits_utils.py +1 -1
  185. qiskit/synthesis/linear_phase/cz_depth_lnn.py +4 -18
  186. qiskit/synthesis/permutation/__init__.py +1 -0
  187. qiskit/synthesis/permutation/permutation_reverse_lnn.py +90 -0
  188. qiskit/synthesis/qft/qft_decompose_lnn.py +2 -6
  189. qiskit/synthesis/two_qubit/two_qubit_decompose.py +165 -954
  190. qiskit/synthesis/two_qubit/xx_decompose/circuits.py +13 -12
  191. qiskit/synthesis/two_qubit/xx_decompose/decomposer.py +7 -1
  192. qiskit/synthesis/unitary/aqc/__init__.py +1 -1
  193. qiskit/synthesis/unitary/aqc/cnot_structures.py +2 -1
  194. qiskit/synthesis/unitary/aqc/fast_gradient/fast_gradient.py +2 -1
  195. qiskit/synthesis/unitary/qsd.py +3 -2
  196. qiskit/transpiler/__init__.py +7 -3
  197. qiskit/transpiler/layout.py +140 -61
  198. qiskit/transpiler/passes/__init__.py +10 -2
  199. qiskit/transpiler/passes/basis/basis_translator.py +9 -4
  200. qiskit/transpiler/passes/basis/unroll_3q_or_more.py +1 -1
  201. qiskit/transpiler/passes/basis/unroll_custom_definitions.py +1 -1
  202. qiskit/transpiler/passes/calibration/rzx_builder.py +2 -1
  203. qiskit/transpiler/passes/layout/apply_layout.py +8 -3
  204. qiskit/transpiler/passes/layout/sabre_layout.py +15 -3
  205. qiskit/transpiler/passes/layout/set_layout.py +1 -1
  206. qiskit/transpiler/passes/optimization/__init__.py +2 -0
  207. qiskit/transpiler/passes/optimization/commutation_analysis.py +2 -2
  208. qiskit/transpiler/passes/optimization/commutative_cancellation.py +1 -1
  209. qiskit/transpiler/passes/optimization/consolidate_blocks.py +1 -1
  210. qiskit/transpiler/passes/optimization/cx_cancellation.py +10 -0
  211. qiskit/transpiler/passes/optimization/elide_permutations.py +114 -0
  212. qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +9 -3
  213. qiskit/transpiler/passes/optimization/optimize_annotated.py +248 -12
  214. qiskit/transpiler/passes/optimization/remove_final_reset.py +37 -0
  215. qiskit/transpiler/passes/optimization/template_matching/forward_match.py +1 -3
  216. qiskit/transpiler/passes/routing/__init__.py +1 -0
  217. qiskit/transpiler/passes/routing/basic_swap.py +13 -2
  218. qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py +8 -1
  219. qiskit/transpiler/passes/routing/lookahead_swap.py +7 -1
  220. qiskit/transpiler/passes/routing/sabre_swap.py +10 -6
  221. qiskit/transpiler/passes/routing/star_prerouting.py +417 -0
  222. qiskit/transpiler/passes/routing/stochastic_swap.py +24 -8
  223. qiskit/transpiler/passes/scheduling/__init__.py +1 -1
  224. qiskit/transpiler/passes/scheduling/alap.py +1 -2
  225. qiskit/transpiler/passes/scheduling/alignments/align_measures.py +1 -2
  226. qiskit/transpiler/passes/scheduling/alignments/check_durations.py +9 -6
  227. qiskit/transpiler/passes/scheduling/alignments/pulse_gate_validation.py +8 -0
  228. qiskit/transpiler/passes/scheduling/alignments/reschedule.py +13 -4
  229. qiskit/transpiler/passes/scheduling/asap.py +1 -2
  230. qiskit/transpiler/passes/scheduling/base_scheduler.py +21 -2
  231. qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +26 -4
  232. qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +24 -2
  233. qiskit/transpiler/passes/scheduling/time_unit_conversion.py +28 -4
  234. qiskit/transpiler/passes/synthesis/aqc_plugin.py +2 -2
  235. qiskit/transpiler/passes/synthesis/high_level_synthesis.py +120 -13
  236. qiskit/transpiler/passes/synthesis/unitary_synthesis.py +162 -55
  237. qiskit/transpiler/passes/utils/gates_basis.py +3 -3
  238. qiskit/transpiler/passmanager.py +44 -1
  239. qiskit/transpiler/preset_passmanagers/__init__.py +3 -3
  240. qiskit/transpiler/preset_passmanagers/builtin_plugins.py +34 -16
  241. qiskit/transpiler/preset_passmanagers/common.py +4 -6
  242. qiskit/transpiler/preset_passmanagers/plugin.py +9 -1
  243. qiskit/utils/__init__.py +3 -2
  244. qiskit/utils/optionals.py +6 -2
  245. qiskit/utils/parallel.py +24 -15
  246. qiskit/visualization/array.py +1 -1
  247. qiskit/visualization/bloch.py +2 -3
  248. qiskit/visualization/circuit/matplotlib.py +44 -14
  249. qiskit/visualization/circuit/text.py +38 -18
  250. qiskit/visualization/counts_visualization.py +3 -6
  251. qiskit/visualization/dag_visualization.py +6 -7
  252. qiskit/visualization/gate_map.py +9 -1
  253. qiskit/visualization/pulse_v2/interface.py +8 -3
  254. qiskit/visualization/state_visualization.py +3 -2
  255. qiskit/visualization/timeline/interface.py +18 -8
  256. {qiskit-1.0.2.dist-info → qiskit-1.1.0.dist-info}/METADATA +12 -8
  257. {qiskit-1.0.2.dist-info → qiskit-1.1.0.dist-info}/RECORD +261 -251
  258. {qiskit-1.0.2.dist-info → qiskit-1.1.0.dist-info}/WHEEL +1 -1
  259. qiskit/_qasm2.pyd +0 -0
  260. qiskit/_qasm3.pyd +0 -0
  261. {qiskit-1.0.2.dist-info → qiskit-1.1.0.dist-info}/LICENSE.txt +0 -0
  262. {qiskit-1.0.2.dist-info → qiskit-1.1.0.dist-info}/entry_points.txt +0 -0
  263. {qiskit-1.0.2.dist-info → qiskit-1.1.0.dist-info}/top_level.txt +0 -0
@@ -17,13 +17,13 @@ Providers Interface (:mod:`qiskit.providers`)
17
17
 
18
18
  .. currentmodule:: qiskit.providers
19
19
 
20
- This module contains the classes used to build external providers for Terra. A
21
- provider is anything that provides an external service to Terra. The typical
20
+ This module contains the classes used to build external providers for Qiskit. A
21
+ provider is anything that provides an external service to Qiskit. The typical
22
22
  example of this is a Backend provider which provides
23
23
  :class:`~qiskit.providers.Backend` objects which can be used for executing
24
24
  :class:`~qiskit.circuit.QuantumCircuit` and/or :class:`~qiskit.pulse.Schedule`
25
25
  objects. This module contains the abstract classes which are used to define the
26
- interface between a provider and terra.
26
+ interface between a provider and Qiskit.
27
27
 
28
28
  Version Support
29
29
  ===============
@@ -36,17 +36,17 @@ backwards compatible between versions.
36
36
  Version Changes
37
37
  ----------------
38
38
 
39
- Each minor version release of qiskit-terra **may** increment the version of any
40
- providers interface a single version number. It will be an aggregate of all
39
+ Each minor version release of ``qiskit`` **may** increment the version of any
40
+ backend interface a single version number. It will be an aggregate of all
41
41
  the interface changes for that release on that interface.
42
42
 
43
43
  Version Support Policy
44
44
  ----------------------
45
45
 
46
46
  To enable providers to have time to adjust to changes in this interface
47
- Terra will support multiple versions of each class at once. Given the
47
+ Qiskit will support multiple versions of each class at once. Given the
48
48
  nature of one version per release the version deprecation policy is a bit
49
- more conservative than the standard deprecation policy. Terra will support a
49
+ more conservative than the standard deprecation policy. Qiskit will support a
50
50
  provider interface version for a minimum of 3 minor releases or the first
51
51
  release after 6 months from the release that introduced a version, whichever is
52
52
  longer, prior to a potential deprecation. After that the standard deprecation
@@ -57,17 +57,17 @@ the release of 0.19.0 we release 0.20.0, 0.21.0, and 0.22.0, then 7 months after
57
57
  0.19.0 we release 0.23.0. In 0.23.0 we can deprecate BackendV2, and it needs to
58
58
  still be supported and can't be removed until the deprecation policy completes.
59
59
 
60
- It's worth pointing out that Terra's version support policy doesn't mean
60
+ It's worth pointing out that Qiskit's version support policy doesn't mean
61
61
  providers themselves will have the same support story, they can (and arguably
62
62
  should) update to newer versions as soon as they can, the support window is
63
- just for Terra's supported versions. Part of this lengthy window prior to
63
+ just for Qiskit's supported versions. Part of this lengthy window prior to
64
64
  deprecation is to give providers enough time to do their own deprecation of a
65
65
  potential end user impacting change in a user facing part of the interface
66
66
  prior to bumping their version. For example, let's say we changed the signature
67
67
  to ``Backend.run()`` in ``BackendV34`` in a backwards incompatible way. Before
68
68
  Aer could update its :class:`~qiskit_aer.AerSimulator` class
69
69
  to be based on version 34 they'd need to deprecate the old signature prior to switching
70
- over. The changeover for Aer is not guaranteed to be lockstep with Terra so we
70
+ over. The changeover for Aer is not guaranteed to be lockstep with Qiskit, so we
71
71
  need to ensure there is a sufficient amount of time for Aer to complete its
72
72
  deprecation cycle prior to removing version 33 (ie making version 34
73
73
  mandatory/the minimum version).
@@ -131,12 +131,12 @@ Exceptions
131
131
  .. autoexception:: JobTimeoutError
132
132
  .. autoexception:: BackendConfigurationError
133
133
 
134
- ======================
135
- Writing a New Provider
136
- ======================
134
+ Writing a New Backend
135
+ =====================
137
136
 
138
137
  If you have a quantum device or simulator that you would like to integrate with
139
- Qiskit you will need to write a provider. A provider will provide Terra with a
138
+ Qiskit you will need to write a backend. A provider is a collection of backends
139
+ and will provide Qiskit with a
140
140
  method to get available :class:`~qiskit.providers.BackendV2` objects. The
141
141
  :class:`~qiskit.providers.BackendV2` object provides both information describing
142
142
  a backend and its operation for the :mod:`~qiskit.transpiler` so that circuits
@@ -149,8 +149,7 @@ executing circuits on devices in a standard
149
149
  fashion regardless of how the backend is implemented. At a high level the basic
150
150
  steps for writing a provider are:
151
151
 
152
- * Implement a :class:`~qiskit.providers.ProviderV1` subclass that handles
153
- access to the backend(s).
152
+ * Implement a ``Provider`` class that handles access to the backend(s).
154
153
  * Implement a :class:`~qiskit.providers.BackendV2` subclass and its
155
154
  :meth:`~qiskit.providers.BackendV2.run` method.
156
155
 
@@ -164,7 +163,7 @@ For a simple example of a provider, see the
164
163
  `qiskit-aqt-provider <https://github.com/Qiskit-Partners/qiskit-aqt-provider>`__
165
164
 
166
165
  Provider
167
- ========
166
+ --------
168
167
 
169
168
  A provider class serves a single purpose: to get backend objects that enable
170
169
  executing circuits on a device or simulator. The expectation is that any
@@ -173,12 +172,11 @@ of a provider object. The provider object will then provide a list of backends,
173
172
  and methods to filter and acquire backends (using the provided credentials if
174
173
  required). An example provider class looks like::
175
174
 
176
- from qiskit.providers import ProviderV1 as Provider
177
175
  from qiskit.providers.providerutils import filter_backends
178
176
 
179
177
  from .backend import MyBackend
180
178
 
181
- class MyProvider(Provider):
179
+ class MyProvider:
182
180
 
183
181
  def __init__(self, token=None):
184
182
  super().__init__()
@@ -196,7 +194,7 @@ authentication (if required) are present in the class and that the backends
196
194
  method matches the required interface. The rest is up to the specific provider on how to implement.
197
195
 
198
196
  Backend
199
- =======
197
+ -------
200
198
 
201
199
  The backend classes are the core to the provider. These classes are what
202
200
  provide the interface between Qiskit and the hardware or simulator that will
@@ -277,8 +275,8 @@ example would be something like::
277
275
  return MyJob(self. job_handle, job_json, circuit)
278
276
 
279
277
 
280
- Transpiler Interface
281
- --------------------
278
+ Backend's Transpiler Interface
279
+ ------------------------------
282
280
 
283
281
  The key piece of the :class:`~qiskit.providers.Backend` object is how it describes itself to the
284
282
  compiler. This is handled with the :class:`~qiskit.transpiler.Target` class which defines
@@ -454,8 +452,45 @@ This way if these two compilation steps are **required** for running or providin
454
452
  efficient output on ``Mybackend`` the transpiler will be able to perform these
455
453
  custom steps without any manual user input.
456
454
 
457
- Run Method
458
- ----------
455
+ .. _providers-guide-real-time-variables:
456
+
457
+ Real-time variables
458
+ ^^^^^^^^^^^^^^^^^^^
459
+
460
+ The transpiler will automatically handle real-time typed classical variables (see
461
+ :mod:`qiskit.circuit.classical`) and treat the :class:`.Store` instruction as a built-in
462
+ "directive", similar to :class:`.Barrier`. No special handling from backends is necessary to permit
463
+ this.
464
+
465
+ If your backend is *unable* to handle classical variables and storage, we recommend that you comment
466
+ on this in your documentation, and insert a check into your :meth:`~.BackendV2.run` method (see
467
+ :ref:`providers-guide-backend-run`) to eagerly reject circuits containing them. You can examine
468
+ :attr:`.QuantumCircuit.num_vars` for the presence of variables at the top level. If you accept
469
+ :ref:`control-flow operations <circuit-control-flow-repr>`, you might need to recursively search the
470
+ internal :attr:`~.ControlFlowOp.blocks` of each for scope-local variables with
471
+ :attr:`.QuantumCircuit.num_declared_vars`.
472
+
473
+ For example, a function to check for the presence of any manual storage locations, or manual stores
474
+ to memory::
475
+
476
+ from qiskit.circuit import Store, ControlFlowOp, QuantumCircuit
477
+
478
+ def has_realtime_logic(circuit: QuantumCircuit) -> bool:
479
+ if circuit.num_vars:
480
+ return True
481
+ for instruction in circuit.data:
482
+ if isinstance(instruction.operation, Store):
483
+ return True
484
+ elif isinstance(instruction.operation, ControlFlowOp):
485
+ for block in instruction.operation.blocks:
486
+ if has_realtime_logic(block):
487
+ return True
488
+ return False
489
+
490
+ .. _providers-guide-backend-run:
491
+
492
+ Backend.run Method
493
+ ------------------
459
494
 
460
495
  Of key importance is the :meth:`~qiskit.providers.BackendV2.run` method, which
461
496
  is used to actually submit circuits to a device or simulator. The run method
@@ -485,8 +520,8 @@ An example run method would be something like::
485
520
  job_handle = submit_to_backend(job_jsonb)
486
521
  return MyJob(self. job_handle, job_json, circuit)
487
522
 
488
- Options
489
- -------
523
+ Backend Options
524
+ ---------------
490
525
 
491
526
  There are often several options for a backend that control how a circuit is run.
492
527
  The typical example of this is something like the number of ``shots`` which is
@@ -516,7 +551,7 @@ for a full list of validation options.
516
551
 
517
552
 
518
553
  Job
519
- ===
554
+ ---
520
555
 
521
556
  The output from the :obj:`~qiskit.providers.BackendV2.run` method is a :class:`~qiskit.providers.JobV1`
522
557
  object. Each provider is expected to implement a custom job subclass that
@@ -613,7 +648,7 @@ and for a sync job::
613
648
  return JobStatus.DONE
614
649
 
615
650
  Primitives
616
- ==========
651
+ ----------
617
652
 
618
653
  While not directly part of the provider interface, the :mod:`qiskit.primitives`
619
654
  module is tightly coupled with providers. Specifically the primitive
@@ -641,12 +676,8 @@ implementations. Also the built-in implementations: :class:`~.Sampler`,
641
676
  :class:`~.Estimator`, :class:`~.BackendSampler`, and :class:`~.BackendEstimator`
642
677
  can serve as references/models on how to implement these as well.
643
678
 
644
- ======================================
645
- Migrating between Backend API Versions
646
- ======================================
647
-
648
- BackendV1 -> BackendV2
649
- ======================
679
+ Migrating from BackendV1 to BackendV2
680
+ =====================================
650
681
 
651
682
  The :obj:`~BackendV2` class re-defined user access for most properties of a
652
683
  backend to make them work with native Qiskit data structures and have flatter
@@ -40,8 +40,8 @@ class Backend:
40
40
  class BackendV1(Backend, ABC):
41
41
  """Abstract class for Backends
42
42
 
43
- This abstract class is to be used for all Backend objects created by a
44
- provider. There are several classes of information contained in a Backend.
43
+ This abstract class is to be used for Backend objects.
44
+ There are several classes of information contained in a Backend.
45
45
  The first are the attributes of the class itself. These should be used to
46
46
  defined the immutable characteristics of the backend. The ``options``
47
47
  attribute of the backend is used to contain the dynamic user configurable
@@ -1,6 +1,6 @@
1
1
  # This code is part of Qiskit.
2
2
  #
3
- # (C) Copyright IBM 2020.
3
+ # (C) Copyright IBM 2020, 2024.
4
4
  #
5
5
  # This code is licensed under the Apache License, Version 2.0. You may
6
6
  # obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -57,7 +57,7 @@ def convert_to_target(
57
57
  A ``Target`` instance.
58
58
  """
59
59
 
60
- # importing pacakges where they are needed, to avoid cyclic-import.
60
+ # importing packages where they are needed, to avoid cyclic-import.
61
61
  # pylint: disable=cyclic-import
62
62
  from qiskit.transpiler.target import (
63
63
  Target,
@@ -82,7 +82,7 @@ def convert_to_target(
82
82
  "switch_case": SwitchCaseOp,
83
83
  }
84
84
 
85
- in_data = {"num_qubits": configuration.n_qubits}
85
+ in_data = {"num_qubits": configuration.num_qubits}
86
86
 
87
87
  # Parse global configuration properties
88
88
  if hasattr(configuration, "dt"):
@@ -97,7 +97,6 @@ def convert_to_target(
97
97
  all_instructions = set.union(
98
98
  basis_gates, set(required), supported_instructions.intersection(CONTROL_FLOW_OP_NAMES)
99
99
  )
100
-
101
100
  inst_name_map = {} # type: Dict[str, Instruction]
102
101
 
103
102
  faulty_ops = set()
@@ -244,10 +243,8 @@ def convert_to_target(
244
243
 
245
244
  for name in inst_sched_map.instructions:
246
245
  for qubits in inst_sched_map.qubits_with_instruction(name):
247
-
248
246
  if not isinstance(qubits, tuple):
249
247
  qubits = (qubits,)
250
-
251
248
  if (
252
249
  name not in all_instructions
253
250
  or name not in prop_name_map
@@ -267,17 +264,18 @@ def convert_to_target(
267
264
  continue
268
265
 
269
266
  entry = inst_sched_map._get_calibration_entry(name, qubits)
270
-
271
267
  try:
272
268
  prop_name_map[name][qubits].calibration = entry
273
269
  except AttributeError:
270
+ # if instruction properties are "None", add entry
271
+ prop_name_map[name].update({qubits: InstructionProperties(None, None, entry)})
274
272
  logger.info(
275
273
  "The PulseDefaults payload received contains an instruction %s on "
276
- "qubits %s which is not present in the configuration or properties payload.",
274
+ "qubits %s which is not present in the configuration or properties payload."
275
+ "A new properties entry will be added to include the new calibration data.",
277
276
  name,
278
277
  qubits,
279
278
  )
280
-
281
279
  # Add parsed properties to target
282
280
  target = Target(**in_data)
283
281
  for inst_name in all_instructions:
@@ -384,7 +382,7 @@ class BackendV2Converter(BackendV2):
384
382
  super().__init__(
385
383
  provider=backend.provider,
386
384
  name=backend.name(),
387
- description=self._config.description,
385
+ description=getattr(self._config, "description", None),
388
386
  online_date=getattr(self._config, "online_date", None),
389
387
  backend_version=self._config.backend_version,
390
388
  )
@@ -27,36 +27,15 @@ via the `BasicProvider` provider, e.g.:
27
27
  backend = BasicProvider().get_backend('basic_simulator')
28
28
 
29
29
 
30
- Simulators
31
- ==========
30
+ Classes
31
+ =======
32
32
 
33
33
  .. autosummary::
34
34
  :toctree: ../stubs/
35
35
 
36
36
  BasicSimulator
37
-
38
- Provider
39
- ========
40
-
41
- .. autosummary::
42
- :toctree: ../stubs/
43
-
44
37
  BasicProvider
45
-
46
- Job Class
47
- =========
48
-
49
- .. autosummary::
50
- :toctree: ../stubs/
51
-
52
38
  BasicProviderJob
53
-
54
- Exceptions
55
- ==========
56
-
57
- .. autosummary::
58
- :toctree: ../stubs/
59
-
60
39
  BasicProviderError
61
40
  """
62
41
 
@@ -23,7 +23,30 @@ import qiskit.circuit.library.standard_gates as gates
23
23
  from qiskit.exceptions import QiskitError
24
24
 
25
25
  # Single qubit gates supported by ``single_gate_params``.
26
- SINGLE_QUBIT_GATES = ("U", "u", "h", "p", "u1", "u2", "u3", "rz", "sx", "x")
26
+ SINGLE_QUBIT_GATES = {
27
+ "U": gates.UGate,
28
+ "u": gates.UGate,
29
+ "u1": gates.U1Gate,
30
+ "u2": gates.U2Gate,
31
+ "u3": gates.U3Gate,
32
+ "h": gates.HGate,
33
+ "p": gates.PhaseGate,
34
+ "s": gates.SGate,
35
+ "sdg": gates.SdgGate,
36
+ "sx": gates.SXGate,
37
+ "sxdg": gates.SXdgGate,
38
+ "t": gates.TGate,
39
+ "tdg": gates.TdgGate,
40
+ "x": gates.XGate,
41
+ "y": gates.YGate,
42
+ "z": gates.ZGate,
43
+ "id": gates.IGate,
44
+ "i": gates.IGate,
45
+ "r": gates.RGate,
46
+ "rx": gates.RXGate,
47
+ "ry": gates.RYGate,
48
+ "rz": gates.RZGate,
49
+ }
27
50
 
28
51
 
29
52
  def single_gate_matrix(gate: str, params: list[float] | None = None) -> np.ndarray:
@@ -40,42 +63,55 @@ def single_gate_matrix(gate: str, params: list[float] | None = None) -> np.ndarr
40
63
  """
41
64
  if params is None:
42
65
  params = []
43
-
44
- if gate == "U":
45
- gc = gates.UGate
46
- elif gate == "u3":
47
- gc = gates.U3Gate
48
- elif gate == "h":
49
- gc = gates.HGate
50
- elif gate == "u":
51
- gc = gates.UGate
52
- elif gate == "p":
53
- gc = gates.PhaseGate
54
- elif gate == "u2":
55
- gc = gates.U2Gate
56
- elif gate == "u1":
57
- gc = gates.U1Gate
58
- elif gate == "rz":
59
- gc = gates.RZGate
60
- elif gate == "id":
61
- gc = gates.IGate
62
- elif gate == "sx":
63
- gc = gates.SXGate
64
- elif gate == "x":
65
- gc = gates.XGate
66
+ if gate in SINGLE_QUBIT_GATES:
67
+ gc = SINGLE_QUBIT_GATES[gate]
66
68
  else:
67
69
  raise QiskitError("Gate is not a valid basis gate for this simulator: %s" % gate)
68
70
 
69
71
  return gc(*params).to_matrix()
70
72
 
71
73
 
72
- # Cache CX matrix as no parameters.
73
- _CX_MATRIX = gates.CXGate().to_matrix()
74
-
75
-
76
- def cx_gate_matrix() -> np.ndarray:
77
- """Get the matrix for a controlled-NOT gate."""
78
- return _CX_MATRIX
74
+ # Two qubit gates WITHOUT parameters: name -> matrix
75
+ TWO_QUBIT_GATES = {
76
+ "CX": gates.CXGate().to_matrix(),
77
+ "cx": gates.CXGate().to_matrix(),
78
+ "ecr": gates.ECRGate().to_matrix(),
79
+ "cy": gates.CYGate().to_matrix(),
80
+ "cz": gates.CZGate().to_matrix(),
81
+ "swap": gates.SwapGate().to_matrix(),
82
+ "iswap": gates.iSwapGate().to_matrix(),
83
+ "ch": gates.CHGate().to_matrix(),
84
+ "cs": gates.CSGate().to_matrix(),
85
+ "csdg": gates.CSdgGate().to_matrix(),
86
+ "csx": gates.CSXGate().to_matrix(),
87
+ "dcx": gates.DCXGate().to_matrix(),
88
+ }
89
+
90
+ # Two qubit gates WITH parameters: name -> class
91
+ TWO_QUBIT_GATES_WITH_PARAMETERS = {
92
+ "cp": gates.CPhaseGate,
93
+ "crx": gates.CRXGate,
94
+ "cry": gates.CRYGate,
95
+ "crz": gates.CRZGate,
96
+ "cu": gates.CUGate,
97
+ "cu1": gates.CU1Gate,
98
+ "cu3": gates.CU3Gate,
99
+ "rxx": gates.RXXGate,
100
+ "ryy": gates.RYYGate,
101
+ "rzz": gates.RZZGate,
102
+ "rzx": gates.RZXGate,
103
+ "xx_minus_yy": gates.XXMinusYYGate,
104
+ "xx_plus_yy": gates.XXPlusYYGate,
105
+ }
106
+
107
+
108
+ # Three qubit gates: name -> matrix
109
+ THREE_QUBIT_GATES = {
110
+ "ccx": gates.CCXGate().to_matrix(),
111
+ "ccz": gates.CCZGate().to_matrix(),
112
+ "rccx": gates.RCCXGate().to_matrix(),
113
+ "cswap": gates.CSwapGate().to_matrix(),
114
+ }
79
115
 
80
116
 
81
117
  def einsum_matmul_index(gate_indices: list[int], number_of_qubits: int) -> str:
@@ -29,6 +29,7 @@ field, which is a result of measurements for each shot.
29
29
 
30
30
  from __future__ import annotations
31
31
 
32
+ import math
32
33
  import uuid
33
34
  import time
34
35
  import logging
@@ -39,7 +40,7 @@ import numpy as np
39
40
 
40
41
  from qiskit.circuit import QuantumCircuit
41
42
  from qiskit.circuit.library import UnitaryGate
42
- from qiskit.circuit.library.standard_gates import get_standard_gate_name_mapping
43
+ from qiskit.circuit.library.standard_gates import get_standard_gate_name_mapping, GlobalPhaseGate
43
44
  from qiskit.providers import Provider
44
45
  from qiskit.providers.backend import BackendV2
45
46
  from qiskit.providers.models import BackendConfiguration
@@ -50,8 +51,12 @@ from qiskit.transpiler import Target
50
51
 
51
52
  from .basic_provider_job import BasicProviderJob
52
53
  from .basic_provider_tools import single_gate_matrix
53
- from .basic_provider_tools import SINGLE_QUBIT_GATES
54
- from .basic_provider_tools import cx_gate_matrix
54
+ from .basic_provider_tools import (
55
+ SINGLE_QUBIT_GATES,
56
+ TWO_QUBIT_GATES,
57
+ TWO_QUBIT_GATES_WITH_PARAMETERS,
58
+ THREE_QUBIT_GATES,
59
+ )
55
60
  from .basic_provider_tools import einsum_vecmul_index
56
61
  from .exceptions import BasicProviderError
57
62
 
@@ -137,21 +142,59 @@ class BasicSimulator(BackendV2):
137
142
  num_qubits=None,
138
143
  )
139
144
  basis_gates = [
145
+ "ccx",
146
+ "ccz",
147
+ "ch",
148
+ "cp",
149
+ "crx",
150
+ "cry",
151
+ "crz",
152
+ "cs",
153
+ "csdg",
154
+ "cswap",
155
+ "csx",
156
+ "cu",
157
+ "cu1",
158
+ "cu3",
159
+ "cx",
160
+ "cy",
161
+ "cz",
162
+ "dcx",
163
+ "delay",
164
+ "ecr",
165
+ "global_phase",
140
166
  "h",
141
- "u",
167
+ "id",
168
+ "iswap",
169
+ "measure",
142
170
  "p",
171
+ "r",
172
+ "rccx",
173
+ "reset",
174
+ "rx",
175
+ "rxx",
176
+ "ry",
177
+ "ryy",
178
+ "rz",
179
+ "rzx",
180
+ "rzz",
181
+ "s",
182
+ "sdg",
183
+ "swap",
184
+ "sx",
185
+ "sxdg",
186
+ "t",
187
+ "tdg",
188
+ "u",
143
189
  "u1",
144
190
  "u2",
145
191
  "u3",
146
- "rz",
147
- "sx",
148
- "x",
149
- "cx",
150
- "id",
151
192
  "unitary",
152
- "measure",
153
- "delay",
154
- "reset",
193
+ "x",
194
+ "xx_minus_yy",
195
+ "xx_plus_yy",
196
+ "y",
197
+ "z",
155
198
  ]
156
199
  inst_mapping = get_standard_gate_name_mapping()
157
200
  for name in basis_gates:
@@ -331,9 +374,9 @@ class BasicSimulator(BackendV2):
331
374
 
332
375
  # update quantum state
333
376
  if outcome == "0":
334
- update_diag = [[1 / np.sqrt(probability), 0], [0, 0]]
377
+ update_diag = [[1 / math.sqrt(probability), 0], [0, 0]]
335
378
  else:
336
- update_diag = [[0, 0], [0, 1 / np.sqrt(probability)]]
379
+ update_diag = [[0, 0], [0, 1 / math.sqrt(probability)]]
337
380
  # update classical state
338
381
  self._add_unitary(update_diag, [qubit])
339
382
 
@@ -351,10 +394,10 @@ class BasicSimulator(BackendV2):
351
394
  outcome, probability = self._get_measure_outcome(qubit)
352
395
  # update quantum state
353
396
  if outcome == "0":
354
- update = [[1 / np.sqrt(probability), 0], [0, 0]]
397
+ update = [[1 / math.sqrt(probability), 0], [0, 0]]
355
398
  self._add_unitary(update, [qubit])
356
399
  else:
357
- update = [[0, 1 / np.sqrt(probability)], [0, 0]]
400
+ update = [[0, 1 / math.sqrt(probability)], [0, 0]]
358
401
  self._add_unitary(update, [qubit])
359
402
 
360
403
  def _validate_initial_statevector(self) -> None:
@@ -478,7 +521,7 @@ class BasicSimulator(BackendV2):
478
521
  Example::
479
522
 
480
523
  backend_options = {
481
- "initial_statevector": np.array([1, 0, 0, 1j]) / np.sqrt(2),
524
+ "initial_statevector": np.array([1, 0, 0, 1j]) / math.sqrt(2),
482
525
  }
483
526
  """
484
527
  # TODO: replace assemble with new run flow
@@ -616,24 +659,41 @@ class BasicSimulator(BackendV2):
616
659
  value >>= 1
617
660
  if value != int(operation.conditional.val, 16):
618
661
  continue
619
- # Check if single gate
620
662
  if operation.name == "unitary":
621
663
  qubits = operation.qubits
622
664
  gate = operation.params[0]
623
665
  self._add_unitary(gate, qubits)
666
+ elif operation.name in ("id", "u0", "delay"):
667
+ pass
668
+ elif operation.name == "global_phase":
669
+ params = getattr(operation, "params", None)
670
+ gate = GlobalPhaseGate(*params).to_matrix()
671
+ self._add_unitary(gate, [])
672
+ # Check if single qubit gate
624
673
  elif operation.name in SINGLE_QUBIT_GATES:
625
674
  params = getattr(operation, "params", None)
626
675
  qubit = operation.qubits[0]
627
676
  gate = single_gate_matrix(operation.name, params)
628
677
  self._add_unitary(gate, [qubit])
629
- # Check if CX gate
678
+ elif operation.name in TWO_QUBIT_GATES_WITH_PARAMETERS:
679
+ params = getattr(operation, "params", None)
680
+ qubit0 = operation.qubits[0]
681
+ qubit1 = operation.qubits[1]
682
+ gate = TWO_QUBIT_GATES_WITH_PARAMETERS[operation.name](*params).to_matrix()
683
+ self._add_unitary(gate, [qubit0, qubit1])
630
684
  elif operation.name in ("id", "u0"):
631
685
  pass
632
- elif operation.name in ("CX", "cx"):
686
+ elif operation.name in TWO_QUBIT_GATES:
633
687
  qubit0 = operation.qubits[0]
634
688
  qubit1 = operation.qubits[1]
635
- gate = cx_gate_matrix()
689
+ gate = TWO_QUBIT_GATES[operation.name]
636
690
  self._add_unitary(gate, [qubit0, qubit1])
691
+ elif operation.name in THREE_QUBIT_GATES:
692
+ qubit0 = operation.qubits[0]
693
+ qubit1 = operation.qubits[1]
694
+ qubit2 = operation.qubits[2]
695
+ gate = THREE_QUBIT_GATES[operation.name]
696
+ self._add_unitary(gate, [qubit0, qubit1, qubit2])
637
697
  # Check if reset
638
698
  elif operation.name == "reset":
639
699
  qubit = operation.qubits[0]
@@ -24,7 +24,7 @@ The fake provider module in Qiskit contains fake (simulated) backend classes
24
24
  useful for testing the transpiler and other backend-facing functionality.
25
25
 
26
26
  Example Usage
27
- =============
27
+ -------------
28
28
 
29
29
  Here is an example of using a simulated backend for transpilation and running.
30
30
 
@@ -32,7 +32,7 @@ class Fake1Q(FakeBackend):
32
32
  configuration = BackendProperties(
33
33
  backend_name="fake_1q",
34
34
  backend_version="0.0.0",
35
- n_qubits=1,
35
+ num_qubits=1,
36
36
  basis_gates=["u1", "u2", "u3", "cx"],
37
37
  simulator=False,
38
38
  local=True,