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.
Files changed (1095) hide show
  1. qiskit/VERSION.txt +1 -0
  2. qiskit/__init__.py +195 -0
  3. qiskit/_accelerate.abi3.so +0 -0
  4. qiskit/_qasm2.abi3.so +0 -0
  5. qiskit/assembler/__init__.py +47 -0
  6. qiskit/assembler/assemble_circuits.py +408 -0
  7. qiskit/assembler/assemble_schedules.py +372 -0
  8. qiskit/assembler/disassemble.py +318 -0
  9. qiskit/assembler/run_config.py +77 -0
  10. qiskit/circuit/__init__.py +425 -0
  11. qiskit/circuit/_classical_resource_map.py +144 -0
  12. qiskit/circuit/_utils.py +170 -0
  13. qiskit/circuit/add_control.py +274 -0
  14. qiskit/circuit/annotated_operation.py +188 -0
  15. qiskit/circuit/barrier.py +51 -0
  16. qiskit/circuit/bit.py +142 -0
  17. qiskit/circuit/classical/__init__.py +41 -0
  18. qiskit/circuit/classical/expr/__init__.py +218 -0
  19. qiskit/circuit/classical/expr/constructors.py +473 -0
  20. qiskit/circuit/classical/expr/expr.py +356 -0
  21. qiskit/circuit/classical/expr/visitors.py +280 -0
  22. qiskit/circuit/classical/types/__init__.py +108 -0
  23. qiskit/circuit/classical/types/ordering.py +222 -0
  24. qiskit/circuit/classical/types/types.py +117 -0
  25. qiskit/circuit/classicalfunction/__init__.py +131 -0
  26. qiskit/circuit/classicalfunction/boolean_expression.py +129 -0
  27. qiskit/circuit/classicalfunction/classical_element.py +54 -0
  28. qiskit/circuit/classicalfunction/classical_function_visitor.py +155 -0
  29. qiskit/circuit/classicalfunction/classicalfunction.py +173 -0
  30. qiskit/circuit/classicalfunction/exceptions.py +35 -0
  31. qiskit/circuit/classicalfunction/types.py +18 -0
  32. qiskit/circuit/classicalfunction/utils.py +91 -0
  33. qiskit/circuit/classicalregister.py +71 -0
  34. qiskit/circuit/commutation_checker.py +176 -0
  35. qiskit/circuit/controlflow/__init__.py +27 -0
  36. qiskit/circuit/controlflow/_builder_utils.py +199 -0
  37. qiskit/circuit/controlflow/break_loop.py +70 -0
  38. qiskit/circuit/controlflow/builder.py +651 -0
  39. qiskit/circuit/controlflow/continue_loop.py +72 -0
  40. qiskit/circuit/controlflow/control_flow.py +52 -0
  41. qiskit/circuit/controlflow/for_loop.py +232 -0
  42. qiskit/circuit/controlflow/if_else.py +517 -0
  43. qiskit/circuit/controlflow/switch_case.py +424 -0
  44. qiskit/circuit/controlflow/while_loop.py +177 -0
  45. qiskit/circuit/controlledgate.py +271 -0
  46. qiskit/circuit/delay.py +104 -0
  47. qiskit/circuit/duration.py +88 -0
  48. qiskit/circuit/equivalence.py +291 -0
  49. qiskit/circuit/equivalence_library.py +18 -0
  50. qiskit/circuit/exceptions.py +19 -0
  51. qiskit/circuit/gate.py +245 -0
  52. qiskit/circuit/instruction.py +655 -0
  53. qiskit/circuit/instructionset.py +191 -0
  54. qiskit/circuit/library/__init__.py +581 -0
  55. qiskit/circuit/library/arithmetic/__init__.py +27 -0
  56. qiskit/circuit/library/arithmetic/adders/__init__.py +17 -0
  57. qiskit/circuit/library/arithmetic/adders/adder.py +58 -0
  58. qiskit/circuit/library/arithmetic/adders/cdkm_ripple_carry_adder.py +159 -0
  59. qiskit/circuit/library/arithmetic/adders/draper_qft_adder.py +116 -0
  60. qiskit/circuit/library/arithmetic/adders/vbe_ripple_carry_adder.py +165 -0
  61. qiskit/circuit/library/arithmetic/exact_reciprocal.py +88 -0
  62. qiskit/circuit/library/arithmetic/functional_pauli_rotations.py +114 -0
  63. qiskit/circuit/library/arithmetic/integer_comparator.py +243 -0
  64. qiskit/circuit/library/arithmetic/linear_amplitude_function.py +196 -0
  65. qiskit/circuit/library/arithmetic/linear_pauli_rotations.py +189 -0
  66. qiskit/circuit/library/arithmetic/multipliers/__init__.py +16 -0
  67. qiskit/circuit/library/arithmetic/multipliers/hrs_cumulative_multiplier.py +138 -0
  68. qiskit/circuit/library/arithmetic/multipliers/multiplier.py +101 -0
  69. qiskit/circuit/library/arithmetic/multipliers/rg_qft_multiplier.py +101 -0
  70. qiskit/circuit/library/arithmetic/piecewise_chebyshev.py +353 -0
  71. qiskit/circuit/library/arithmetic/piecewise_linear_pauli_rotations.py +277 -0
  72. qiskit/circuit/library/arithmetic/piecewise_polynomial_pauli_rotations.py +317 -0
  73. qiskit/circuit/library/arithmetic/polynomial_pauli_rotations.py +335 -0
  74. qiskit/circuit/library/arithmetic/quadratic_form.py +197 -0
  75. qiskit/circuit/library/arithmetic/weighted_adder.py +337 -0
  76. qiskit/circuit/library/basis_change/__init__.py +15 -0
  77. qiskit/circuit/library/basis_change/qft.py +289 -0
  78. qiskit/circuit/library/blueprintcircuit.py +186 -0
  79. qiskit/circuit/library/boolean_logic/__init__.py +18 -0
  80. qiskit/circuit/library/boolean_logic/inner_product.py +78 -0
  81. qiskit/circuit/library/boolean_logic/quantum_and.py +97 -0
  82. qiskit/circuit/library/boolean_logic/quantum_or.py +98 -0
  83. qiskit/circuit/library/boolean_logic/quantum_xor.py +71 -0
  84. qiskit/circuit/library/data_preparation/__init__.py +47 -0
  85. qiskit/circuit/library/data_preparation/initializer.py +96 -0
  86. qiskit/circuit/library/data_preparation/pauli_feature_map.py +296 -0
  87. qiskit/circuit/library/data_preparation/state_preparation.py +526 -0
  88. qiskit/circuit/library/data_preparation/z_feature_map.py +104 -0
  89. qiskit/circuit/library/data_preparation/zz_feature_map.py +114 -0
  90. qiskit/circuit/library/evolved_operator_ansatz.py +245 -0
  91. qiskit/circuit/library/fourier_checking.py +97 -0
  92. qiskit/circuit/library/generalized_gates/__init__.py +30 -0
  93. qiskit/circuit/library/generalized_gates/diagonal.py +164 -0
  94. qiskit/circuit/library/generalized_gates/gms.py +121 -0
  95. qiskit/circuit/library/generalized_gates/gr.py +215 -0
  96. qiskit/circuit/library/generalized_gates/isometry.py +573 -0
  97. qiskit/circuit/library/generalized_gates/linear_function.py +302 -0
  98. qiskit/circuit/library/generalized_gates/mcg_up_to_diagonal.py +138 -0
  99. qiskit/circuit/library/generalized_gates/mcmt.py +254 -0
  100. qiskit/circuit/library/generalized_gates/pauli.py +85 -0
  101. qiskit/circuit/library/generalized_gates/permutation.py +190 -0
  102. qiskit/circuit/library/generalized_gates/rv.py +93 -0
  103. qiskit/circuit/library/generalized_gates/uc.py +304 -0
  104. qiskit/circuit/library/generalized_gates/uc_pauli_rot.py +164 -0
  105. qiskit/circuit/library/generalized_gates/ucrx.py +32 -0
  106. qiskit/circuit/library/generalized_gates/ucry.py +32 -0
  107. qiskit/circuit/library/generalized_gates/ucrz.py +32 -0
  108. qiskit/circuit/library/generalized_gates/unitary.py +198 -0
  109. qiskit/circuit/library/graph_state.py +86 -0
  110. qiskit/circuit/library/grover_operator.py +311 -0
  111. qiskit/circuit/library/hamiltonian_gate.py +146 -0
  112. qiskit/circuit/library/hidden_linear_function.py +98 -0
  113. qiskit/circuit/library/iqp.py +96 -0
  114. qiskit/circuit/library/n_local/__init__.py +31 -0
  115. qiskit/circuit/library/n_local/efficient_su2.py +162 -0
  116. qiskit/circuit/library/n_local/excitation_preserving.py +176 -0
  117. qiskit/circuit/library/n_local/n_local.py +1044 -0
  118. qiskit/circuit/library/n_local/pauli_two_design.py +131 -0
  119. qiskit/circuit/library/n_local/qaoa_ansatz.py +288 -0
  120. qiskit/circuit/library/n_local/real_amplitudes.py +189 -0
  121. qiskit/circuit/library/n_local/two_local.py +334 -0
  122. qiskit/circuit/library/overlap.py +111 -0
  123. qiskit/circuit/library/pauli_evolution.py +180 -0
  124. qiskit/circuit/library/phase_estimation.py +99 -0
  125. qiskit/circuit/library/phase_oracle.py +153 -0
  126. qiskit/circuit/library/quantum_volume.py +114 -0
  127. qiskit/circuit/library/standard_gates/__init__.py +116 -0
  128. qiskit/circuit/library/standard_gates/dcx.py +71 -0
  129. qiskit/circuit/library/standard_gates/ecr.py +114 -0
  130. qiskit/circuit/library/standard_gates/equivalence_library.py +1677 -0
  131. qiskit/circuit/library/standard_gates/global_phase.py +63 -0
  132. qiskit/circuit/library/standard_gates/h.py +224 -0
  133. qiskit/circuit/library/standard_gates/i.py +60 -0
  134. qiskit/circuit/library/standard_gates/iswap.py +129 -0
  135. qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py +390 -0
  136. qiskit/circuit/library/standard_gates/p.py +364 -0
  137. qiskit/circuit/library/standard_gates/r.py +101 -0
  138. qiskit/circuit/library/standard_gates/rx.py +246 -0
  139. qiskit/circuit/library/standard_gates/rxx.py +128 -0
  140. qiskit/circuit/library/standard_gates/ry.py +241 -0
  141. qiskit/circuit/library/standard_gates/ryy.py +128 -0
  142. qiskit/circuit/library/standard_gates/rz.py +261 -0
  143. qiskit/circuit/library/standard_gates/rzx.py +174 -0
  144. qiskit/circuit/library/standard_gates/rzz.py +141 -0
  145. qiskit/circuit/library/standard_gates/s.py +303 -0
  146. qiskit/circuit/library/standard_gates/swap.py +246 -0
  147. qiskit/circuit/library/standard_gates/sx.py +268 -0
  148. qiskit/circuit/library/standard_gates/t.py +150 -0
  149. qiskit/circuit/library/standard_gates/u.py +338 -0
  150. qiskit/circuit/library/standard_gates/u1.py +383 -0
  151. qiskit/circuit/library/standard_gates/u2.py +132 -0
  152. qiskit/circuit/library/standard_gates/u3.py +358 -0
  153. qiskit/circuit/library/standard_gates/x.py +1370 -0
  154. qiskit/circuit/library/standard_gates/xx_minus_yy.py +179 -0
  155. qiskit/circuit/library/standard_gates/xx_plus_yy.py +180 -0
  156. qiskit/circuit/library/standard_gates/y.py +221 -0
  157. qiskit/circuit/library/standard_gates/z.py +294 -0
  158. qiskit/circuit/library/templates/__init__.py +92 -0
  159. qiskit/circuit/library/templates/clifford/__init__.py +33 -0
  160. qiskit/circuit/library/templates/clifford/clifford_2_1.py +33 -0
  161. qiskit/circuit/library/templates/clifford/clifford_2_2.py +34 -0
  162. qiskit/circuit/library/templates/clifford/clifford_2_3.py +32 -0
  163. qiskit/circuit/library/templates/clifford/clifford_2_4.py +33 -0
  164. qiskit/circuit/library/templates/clifford/clifford_3_1.py +34 -0
  165. qiskit/circuit/library/templates/clifford/clifford_4_1.py +37 -0
  166. qiskit/circuit/library/templates/clifford/clifford_4_2.py +36 -0
  167. qiskit/circuit/library/templates/clifford/clifford_4_3.py +37 -0
  168. qiskit/circuit/library/templates/clifford/clifford_4_4.py +36 -0
  169. qiskit/circuit/library/templates/clifford/clifford_5_1.py +39 -0
  170. qiskit/circuit/library/templates/clifford/clifford_6_1.py +39 -0
  171. qiskit/circuit/library/templates/clifford/clifford_6_2.py +39 -0
  172. qiskit/circuit/library/templates/clifford/clifford_6_3.py +39 -0
  173. qiskit/circuit/library/templates/clifford/clifford_6_4.py +37 -0
  174. qiskit/circuit/library/templates/clifford/clifford_6_5.py +39 -0
  175. qiskit/circuit/library/templates/clifford/clifford_8_1.py +41 -0
  176. qiskit/circuit/library/templates/clifford/clifford_8_2.py +41 -0
  177. qiskit/circuit/library/templates/clifford/clifford_8_3.py +40 -0
  178. qiskit/circuit/library/templates/nct/__init__.py +67 -0
  179. qiskit/circuit/library/templates/nct/template_nct_2a_1.py +32 -0
  180. qiskit/circuit/library/templates/nct/template_nct_2a_2.py +33 -0
  181. qiskit/circuit/library/templates/nct/template_nct_2a_3.py +35 -0
  182. qiskit/circuit/library/templates/nct/template_nct_4a_1.py +41 -0
  183. qiskit/circuit/library/templates/nct/template_nct_4a_2.py +39 -0
  184. qiskit/circuit/library/templates/nct/template_nct_4a_3.py +37 -0
  185. qiskit/circuit/library/templates/nct/template_nct_4b_1.py +39 -0
  186. qiskit/circuit/library/templates/nct/template_nct_4b_2.py +37 -0
  187. qiskit/circuit/library/templates/nct/template_nct_5a_1.py +38 -0
  188. qiskit/circuit/library/templates/nct/template_nct_5a_2.py +38 -0
  189. qiskit/circuit/library/templates/nct/template_nct_5a_3.py +38 -0
  190. qiskit/circuit/library/templates/nct/template_nct_5a_4.py +37 -0
  191. qiskit/circuit/library/templates/nct/template_nct_6a_1.py +38 -0
  192. qiskit/circuit/library/templates/nct/template_nct_6a_2.py +39 -0
  193. qiskit/circuit/library/templates/nct/template_nct_6a_3.py +39 -0
  194. qiskit/circuit/library/templates/nct/template_nct_6a_4.py +39 -0
  195. qiskit/circuit/library/templates/nct/template_nct_6b_1.py +39 -0
  196. qiskit/circuit/library/templates/nct/template_nct_6b_2.py +39 -0
  197. qiskit/circuit/library/templates/nct/template_nct_6c_1.py +39 -0
  198. qiskit/circuit/library/templates/nct/template_nct_7a_1.py +41 -0
  199. qiskit/circuit/library/templates/nct/template_nct_7b_1.py +41 -0
  200. qiskit/circuit/library/templates/nct/template_nct_7c_1.py +41 -0
  201. qiskit/circuit/library/templates/nct/template_nct_7d_1.py +41 -0
  202. qiskit/circuit/library/templates/nct/template_nct_7e_1.py +41 -0
  203. qiskit/circuit/library/templates/nct/template_nct_9a_1.py +43 -0
  204. qiskit/circuit/library/templates/nct/template_nct_9c_1.py +41 -0
  205. qiskit/circuit/library/templates/nct/template_nct_9c_10.py +42 -0
  206. qiskit/circuit/library/templates/nct/template_nct_9c_11.py +42 -0
  207. qiskit/circuit/library/templates/nct/template_nct_9c_12.py +42 -0
  208. qiskit/circuit/library/templates/nct/template_nct_9c_2.py +42 -0
  209. qiskit/circuit/library/templates/nct/template_nct_9c_3.py +42 -0
  210. qiskit/circuit/library/templates/nct/template_nct_9c_4.py +42 -0
  211. qiskit/circuit/library/templates/nct/template_nct_9c_5.py +42 -0
  212. qiskit/circuit/library/templates/nct/template_nct_9c_6.py +42 -0
  213. qiskit/circuit/library/templates/nct/template_nct_9c_7.py +42 -0
  214. qiskit/circuit/library/templates/nct/template_nct_9c_8.py +42 -0
  215. qiskit/circuit/library/templates/nct/template_nct_9c_9.py +42 -0
  216. qiskit/circuit/library/templates/nct/template_nct_9d_1.py +41 -0
  217. qiskit/circuit/library/templates/nct/template_nct_9d_10.py +42 -0
  218. qiskit/circuit/library/templates/nct/template_nct_9d_2.py +42 -0
  219. qiskit/circuit/library/templates/nct/template_nct_9d_3.py +42 -0
  220. qiskit/circuit/library/templates/nct/template_nct_9d_4.py +42 -0
  221. qiskit/circuit/library/templates/nct/template_nct_9d_5.py +42 -0
  222. qiskit/circuit/library/templates/nct/template_nct_9d_6.py +42 -0
  223. qiskit/circuit/library/templates/nct/template_nct_9d_7.py +42 -0
  224. qiskit/circuit/library/templates/nct/template_nct_9d_8.py +42 -0
  225. qiskit/circuit/library/templates/nct/template_nct_9d_9.py +42 -0
  226. qiskit/circuit/library/templates/rzx/__init__.py +25 -0
  227. qiskit/circuit/library/templates/rzx/rzx_cy.py +46 -0
  228. qiskit/circuit/library/templates/rzx/rzx_xz.py +53 -0
  229. qiskit/circuit/library/templates/rzx/rzx_yz.py +43 -0
  230. qiskit/circuit/library/templates/rzx/rzx_zz1.py +67 -0
  231. qiskit/circuit/library/templates/rzx/rzx_zz2.py +58 -0
  232. qiskit/circuit/library/templates/rzx/rzx_zz3.py +57 -0
  233. qiskit/circuit/measure.py +41 -0
  234. qiskit/circuit/operation.py +62 -0
  235. qiskit/circuit/parameter.py +160 -0
  236. qiskit/circuit/parameterexpression.py +515 -0
  237. qiskit/circuit/parametertable.py +263 -0
  238. qiskit/circuit/parametervector.py +114 -0
  239. qiskit/circuit/qpy_serialization.py +28 -0
  240. qiskit/circuit/quantumcircuit.py +6074 -0
  241. qiskit/circuit/quantumcircuitdata.py +138 -0
  242. qiskit/circuit/quantumregister.py +90 -0
  243. qiskit/circuit/random/__init__.py +15 -0
  244. qiskit/circuit/random/utils.py +209 -0
  245. qiskit/circuit/register.py +256 -0
  246. qiskit/circuit/reset.py +31 -0
  247. qiskit/circuit/singleton.py +604 -0
  248. qiskit/circuit/store.py +87 -0
  249. qiskit/circuit/tools/__init__.py +16 -0
  250. qiskit/circuit/tools/pi_check.py +190 -0
  251. qiskit/compiler/__init__.py +33 -0
  252. qiskit/compiler/assembler.py +597 -0
  253. qiskit/compiler/scheduler.py +107 -0
  254. qiskit/compiler/sequencer.py +69 -0
  255. qiskit/compiler/transpiler.py +613 -0
  256. qiskit/converters/__init__.py +59 -0
  257. qiskit/converters/circuit_to_dag.py +96 -0
  258. qiskit/converters/circuit_to_dagdependency.py +51 -0
  259. qiskit/converters/circuit_to_gate.py +109 -0
  260. qiskit/converters/circuit_to_instruction.py +131 -0
  261. qiskit/converters/dag_to_circuit.py +77 -0
  262. qiskit/converters/dag_to_dagdependency.py +55 -0
  263. qiskit/converters/dagdependency_to_circuit.py +42 -0
  264. qiskit/converters/dagdependency_to_dag.py +49 -0
  265. qiskit/dagcircuit/__init__.py +44 -0
  266. qiskit/dagcircuit/collect_blocks.py +386 -0
  267. qiskit/dagcircuit/dagcircuit.py +2105 -0
  268. qiskit/dagcircuit/dagdependency.py +626 -0
  269. qiskit/dagcircuit/dagdepnode.py +157 -0
  270. qiskit/dagcircuit/dagnode.py +322 -0
  271. qiskit/dagcircuit/exceptions.py +42 -0
  272. qiskit/exceptions.py +97 -0
  273. qiskit/execute_function.py +354 -0
  274. qiskit/extensions/__init__.py +70 -0
  275. qiskit/extensions/exceptions.py +31 -0
  276. qiskit/extensions/quantum_initializer/__init__.py +26 -0
  277. qiskit/extensions/quantum_initializer/squ.py +163 -0
  278. qiskit/extensions/simulator/__init__.py +15 -0
  279. qiskit/extensions/simulator/snapshot.py +70 -0
  280. qiskit/namespace.py +76 -0
  281. qiskit/passmanager/__init__.py +242 -0
  282. qiskit/passmanager/base_tasks.py +230 -0
  283. qiskit/passmanager/compilation_status.py +74 -0
  284. qiskit/passmanager/exceptions.py +19 -0
  285. qiskit/passmanager/flow_controllers.py +336 -0
  286. qiskit/passmanager/passmanager.py +317 -0
  287. qiskit/primitives/__init__.py +62 -0
  288. qiskit/primitives/backend_estimator.py +473 -0
  289. qiskit/primitives/backend_sampler.py +209 -0
  290. qiskit/primitives/base/__init__.py +20 -0
  291. qiskit/primitives/base/base_estimator.py +256 -0
  292. qiskit/primitives/base/base_primitive.py +74 -0
  293. qiskit/primitives/base/base_result.py +87 -0
  294. qiskit/primitives/base/base_sampler.py +202 -0
  295. qiskit/primitives/base/estimator_result.py +46 -0
  296. qiskit/primitives/base/sampler_result.py +45 -0
  297. qiskit/primitives/base/validation.py +231 -0
  298. qiskit/primitives/estimator.py +158 -0
  299. qiskit/primitives/primitive_job.py +73 -0
  300. qiskit/primitives/sampler.py +155 -0
  301. qiskit/primitives/utils.py +216 -0
  302. qiskit/providers/__init__.py +773 -0
  303. qiskit/providers/backend.py +653 -0
  304. qiskit/providers/backend_compat.py +347 -0
  305. qiskit/providers/basicaer/__init__.py +73 -0
  306. qiskit/providers/basicaer/basicaerjob.py +65 -0
  307. qiskit/providers/basicaer/basicaerprovider.py +127 -0
  308. qiskit/providers/basicaer/basicaertools.py +186 -0
  309. qiskit/providers/basicaer/exceptions.py +30 -0
  310. qiskit/providers/basicaer/qasm_simulator.py +678 -0
  311. qiskit/providers/basicaer/statevector_simulator.py +121 -0
  312. qiskit/providers/basicaer/unitary_simulator.py +395 -0
  313. qiskit/providers/exceptions.py +45 -0
  314. qiskit/providers/fake_provider/__init__.py +267 -0
  315. qiskit/providers/fake_provider/backends/__init__.py +110 -0
  316. qiskit/providers/fake_provider/backends/almaden/__init__.py +16 -0
  317. qiskit/providers/fake_provider/backends/almaden/conf_almaden.json +1 -0
  318. qiskit/providers/fake_provider/backends/almaden/fake_almaden.py +58 -0
  319. qiskit/providers/fake_provider/backends/almaden/props_almaden.json +1 -0
  320. qiskit/providers/fake_provider/backends/armonk/__init__.py +16 -0
  321. qiskit/providers/fake_provider/backends/armonk/conf_armonk.json +1 -0
  322. qiskit/providers/fake_provider/backends/armonk/defs_armonk.json +1 -0
  323. qiskit/providers/fake_provider/backends/armonk/fake_armonk.py +48 -0
  324. qiskit/providers/fake_provider/backends/armonk/props_armonk.json +1 -0
  325. qiskit/providers/fake_provider/backends/athens/__init__.py +16 -0
  326. qiskit/providers/fake_provider/backends/athens/conf_athens.json +1 -0
  327. qiskit/providers/fake_provider/backends/athens/defs_athens.json +1 -0
  328. qiskit/providers/fake_provider/backends/athens/fake_athens.py +38 -0
  329. qiskit/providers/fake_provider/backends/athens/props_athens.json +1 -0
  330. qiskit/providers/fake_provider/backends/auckland/__init__.py +15 -0
  331. qiskit/providers/fake_provider/backends/auckland/conf_auckland.json +1 -0
  332. qiskit/providers/fake_provider/backends/auckland/defs_auckland.json +1 -0
  333. qiskit/providers/fake_provider/backends/auckland/fake_auckland.py +29 -0
  334. qiskit/providers/fake_provider/backends/auckland/props_auckland.json +1 -0
  335. qiskit/providers/fake_provider/backends/belem/__init__.py +16 -0
  336. qiskit/providers/fake_provider/backends/belem/conf_belem.json +1 -0
  337. qiskit/providers/fake_provider/backends/belem/defs_belem.json +1 -0
  338. qiskit/providers/fake_provider/backends/belem/fake_belem.py +38 -0
  339. qiskit/providers/fake_provider/backends/belem/props_belem.json +1 -0
  340. qiskit/providers/fake_provider/backends/boeblingen/__init__.py +16 -0
  341. qiskit/providers/fake_provider/backends/boeblingen/conf_boeblingen.json +1 -0
  342. qiskit/providers/fake_provider/backends/boeblingen/defs_boeblingen.json +1 -0
  343. qiskit/providers/fake_provider/backends/boeblingen/fake_boeblingen.py +60 -0
  344. qiskit/providers/fake_provider/backends/boeblingen/props_boeblingen.json +1 -0
  345. qiskit/providers/fake_provider/backends/bogota/__init__.py +16 -0
  346. qiskit/providers/fake_provider/backends/bogota/conf_bogota.json +1 -0
  347. qiskit/providers/fake_provider/backends/bogota/defs_bogota.json +1 -0
  348. qiskit/providers/fake_provider/backends/bogota/fake_bogota.py +38 -0
  349. qiskit/providers/fake_provider/backends/bogota/props_bogota.json +1 -0
  350. qiskit/providers/fake_provider/backends/brooklyn/__init__.py +16 -0
  351. qiskit/providers/fake_provider/backends/brooklyn/conf_brooklyn.json +1 -0
  352. qiskit/providers/fake_provider/backends/brooklyn/defs_brooklyn.json +1 -0
  353. qiskit/providers/fake_provider/backends/brooklyn/fake_brooklyn.py +38 -0
  354. qiskit/providers/fake_provider/backends/brooklyn/props_brooklyn.json +1 -0
  355. qiskit/providers/fake_provider/backends/burlington/__init__.py +16 -0
  356. qiskit/providers/fake_provider/backends/burlington/conf_burlington.json +1 -0
  357. qiskit/providers/fake_provider/backends/burlington/fake_burlington.py +50 -0
  358. qiskit/providers/fake_provider/backends/burlington/props_burlington.json +1 -0
  359. qiskit/providers/fake_provider/backends/cairo/__init__.py +16 -0
  360. qiskit/providers/fake_provider/backends/cairo/conf_cairo.json +1 -0
  361. qiskit/providers/fake_provider/backends/cairo/defs_cairo.json +1 -0
  362. qiskit/providers/fake_provider/backends/cairo/fake_cairo.py +38 -0
  363. qiskit/providers/fake_provider/backends/cairo/props_cairo.json +1 -0
  364. qiskit/providers/fake_provider/backends/cambridge/__init__.py +17 -0
  365. qiskit/providers/fake_provider/backends/cambridge/conf_cambridge.json +1 -0
  366. qiskit/providers/fake_provider/backends/cambridge/fake_cambridge.py +72 -0
  367. qiskit/providers/fake_provider/backends/cambridge/props_cambridge.json +1 -0
  368. qiskit/providers/fake_provider/backends/cambridge/props_cambridge_alt.json +1 -0
  369. qiskit/providers/fake_provider/backends/casablanca/__init__.py +16 -0
  370. qiskit/providers/fake_provider/backends/casablanca/conf_casablanca.json +1 -0
  371. qiskit/providers/fake_provider/backends/casablanca/defs_casablanca.json +1 -0
  372. qiskit/providers/fake_provider/backends/casablanca/fake_casablanca.py +38 -0
  373. qiskit/providers/fake_provider/backends/casablanca/props_casablanca.json +1 -0
  374. qiskit/providers/fake_provider/backends/essex/__init__.py +16 -0
  375. qiskit/providers/fake_provider/backends/essex/conf_essex.json +1 -0
  376. qiskit/providers/fake_provider/backends/essex/fake_essex.py +54 -0
  377. qiskit/providers/fake_provider/backends/essex/props_essex.json +1 -0
  378. qiskit/providers/fake_provider/backends/geneva/__init__.py +15 -0
  379. qiskit/providers/fake_provider/backends/geneva/conf_geneva.json +1 -0
  380. qiskit/providers/fake_provider/backends/geneva/defs_geneva.json +1 -0
  381. qiskit/providers/fake_provider/backends/geneva/fake_geneva.py +29 -0
  382. qiskit/providers/fake_provider/backends/geneva/props_geneva.json +1 -0
  383. qiskit/providers/fake_provider/backends/guadalupe/__init__.py +16 -0
  384. qiskit/providers/fake_provider/backends/guadalupe/conf_guadalupe.json +1 -0
  385. qiskit/providers/fake_provider/backends/guadalupe/defs_guadalupe.json +1 -0
  386. qiskit/providers/fake_provider/backends/guadalupe/fake_guadalupe.py +39 -0
  387. qiskit/providers/fake_provider/backends/guadalupe/props_guadalupe.json +1 -0
  388. qiskit/providers/fake_provider/backends/hanoi/__init__.py +16 -0
  389. qiskit/providers/fake_provider/backends/hanoi/conf_hanoi.json +1 -0
  390. qiskit/providers/fake_provider/backends/hanoi/defs_hanoi.json +1 -0
  391. qiskit/providers/fake_provider/backends/hanoi/fake_hanoi.py +38 -0
  392. qiskit/providers/fake_provider/backends/hanoi/props_hanoi.json +1 -0
  393. qiskit/providers/fake_provider/backends/jakarta/__init__.py +16 -0
  394. qiskit/providers/fake_provider/backends/jakarta/conf_jakarta.json +1 -0
  395. qiskit/providers/fake_provider/backends/jakarta/defs_jakarta.json +1 -0
  396. qiskit/providers/fake_provider/backends/jakarta/fake_jakarta.py +38 -0
  397. qiskit/providers/fake_provider/backends/jakarta/props_jakarta.json +1 -0
  398. qiskit/providers/fake_provider/backends/johannesburg/__init__.py +16 -0
  399. qiskit/providers/fake_provider/backends/johannesburg/conf_johannesburg.json +1 -0
  400. qiskit/providers/fake_provider/backends/johannesburg/fake_johannesburg.py +58 -0
  401. qiskit/providers/fake_provider/backends/johannesburg/props_johannesburg.json +1 -0
  402. qiskit/providers/fake_provider/backends/kolkata/__init__.py +16 -0
  403. qiskit/providers/fake_provider/backends/kolkata/conf_kolkata.json +1 -0
  404. qiskit/providers/fake_provider/backends/kolkata/defs_kolkata.json +1 -0
  405. qiskit/providers/fake_provider/backends/kolkata/fake_kolkata.py +38 -0
  406. qiskit/providers/fake_provider/backends/kolkata/props_kolkata.json +1 -0
  407. qiskit/providers/fake_provider/backends/lagos/__init__.py +16 -0
  408. qiskit/providers/fake_provider/backends/lagos/conf_lagos.json +1 -0
  409. qiskit/providers/fake_provider/backends/lagos/defs_lagos.json +1 -0
  410. qiskit/providers/fake_provider/backends/lagos/fake_lagos.py +38 -0
  411. qiskit/providers/fake_provider/backends/lagos/props_lagos.json +1 -0
  412. qiskit/providers/fake_provider/backends/lima/__init__.py +16 -0
  413. qiskit/providers/fake_provider/backends/lima/conf_lima.json +1 -0
  414. qiskit/providers/fake_provider/backends/lima/defs_lima.json +1 -0
  415. qiskit/providers/fake_provider/backends/lima/fake_lima.py +38 -0
  416. qiskit/providers/fake_provider/backends/lima/props_lima.json +1 -0
  417. qiskit/providers/fake_provider/backends/london/__init__.py +16 -0
  418. qiskit/providers/fake_provider/backends/london/conf_london.json +1 -0
  419. qiskit/providers/fake_provider/backends/london/fake_london.py +54 -0
  420. qiskit/providers/fake_provider/backends/london/props_london.json +1 -0
  421. qiskit/providers/fake_provider/backends/manhattan/__init__.py +16 -0
  422. qiskit/providers/fake_provider/backends/manhattan/conf_manhattan.json +1 -0
  423. qiskit/providers/fake_provider/backends/manhattan/defs_manhattan.json +1 -0
  424. qiskit/providers/fake_provider/backends/manhattan/fake_manhattan.py +38 -0
  425. qiskit/providers/fake_provider/backends/manhattan/props_manhattan.json +1 -0
  426. qiskit/providers/fake_provider/backends/manila/__init__.py +16 -0
  427. qiskit/providers/fake_provider/backends/manila/conf_manila.json +1 -0
  428. qiskit/providers/fake_provider/backends/manila/defs_manila.json +1 -0
  429. qiskit/providers/fake_provider/backends/manila/fake_manila.py +38 -0
  430. qiskit/providers/fake_provider/backends/manila/props_manila.json +1 -0
  431. qiskit/providers/fake_provider/backends/melbourne/__init__.py +16 -0
  432. qiskit/providers/fake_provider/backends/melbourne/conf_melbourne.json +1 -0
  433. qiskit/providers/fake_provider/backends/melbourne/fake_melbourne.py +91 -0
  434. qiskit/providers/fake_provider/backends/melbourne/props_melbourne.json +1 -0
  435. qiskit/providers/fake_provider/backends/montreal/__init__.py +16 -0
  436. qiskit/providers/fake_provider/backends/montreal/conf_montreal.json +1 -0
  437. qiskit/providers/fake_provider/backends/montreal/defs_montreal.json +1 -0
  438. qiskit/providers/fake_provider/backends/montreal/fake_montreal.py +38 -0
  439. qiskit/providers/fake_provider/backends/montreal/props_montreal.json +1 -0
  440. qiskit/providers/fake_provider/backends/mumbai/__init__.py +16 -0
  441. qiskit/providers/fake_provider/backends/mumbai/conf_mumbai.json +1 -0
  442. qiskit/providers/fake_provider/backends/mumbai/defs_mumbai.json +1 -0
  443. qiskit/providers/fake_provider/backends/mumbai/fake_mumbai.py +38 -0
  444. qiskit/providers/fake_provider/backends/mumbai/props_mumbai.json +1 -0
  445. qiskit/providers/fake_provider/backends/nairobi/__init__.py +16 -0
  446. qiskit/providers/fake_provider/backends/nairobi/conf_nairobi.json +1 -0
  447. qiskit/providers/fake_provider/backends/nairobi/defs_nairobi.json +1 -0
  448. qiskit/providers/fake_provider/backends/nairobi/fake_nairobi.py +38 -0
  449. qiskit/providers/fake_provider/backends/nairobi/props_nairobi.json +1 -0
  450. qiskit/providers/fake_provider/backends/oslo/__init__.py +15 -0
  451. qiskit/providers/fake_provider/backends/oslo/conf_oslo.json +1 -0
  452. qiskit/providers/fake_provider/backends/oslo/defs_oslo.json +1 -0
  453. qiskit/providers/fake_provider/backends/oslo/fake_oslo.py +29 -0
  454. qiskit/providers/fake_provider/backends/oslo/props_oslo.json +1 -0
  455. qiskit/providers/fake_provider/backends/ourense/__init__.py +16 -0
  456. qiskit/providers/fake_provider/backends/ourense/conf_ourense.json +1 -0
  457. qiskit/providers/fake_provider/backends/ourense/fake_ourense.py +50 -0
  458. qiskit/providers/fake_provider/backends/ourense/props_ourense.json +1 -0
  459. qiskit/providers/fake_provider/backends/paris/__init__.py +16 -0
  460. qiskit/providers/fake_provider/backends/paris/conf_paris.json +1 -0
  461. qiskit/providers/fake_provider/backends/paris/defs_paris.json +1 -0
  462. qiskit/providers/fake_provider/backends/paris/fake_paris.py +64 -0
  463. qiskit/providers/fake_provider/backends/paris/props_paris.json +1 -0
  464. qiskit/providers/fake_provider/backends/perth/__init__.py +15 -0
  465. qiskit/providers/fake_provider/backends/perth/conf_perth.json +1 -0
  466. qiskit/providers/fake_provider/backends/perth/defs_perth.json +1 -0
  467. qiskit/providers/fake_provider/backends/perth/fake_perth.py +29 -0
  468. qiskit/providers/fake_provider/backends/perth/props_perth.json +1 -0
  469. qiskit/providers/fake_provider/backends/poughkeepsie/__init__.py +16 -0
  470. qiskit/providers/fake_provider/backends/poughkeepsie/conf_poughkeepsie.json +1 -0
  471. qiskit/providers/fake_provider/backends/poughkeepsie/defs_poughkeepsie.json +1 -0
  472. qiskit/providers/fake_provider/backends/poughkeepsie/fake_poughkeepsie.py +124 -0
  473. qiskit/providers/fake_provider/backends/poughkeepsie/props_poughkeepsie.json +1 -0
  474. qiskit/providers/fake_provider/backends/prague/__init__.py +15 -0
  475. qiskit/providers/fake_provider/backends/prague/conf_prague.json +1 -0
  476. qiskit/providers/fake_provider/backends/prague/fake_prague.py +28 -0
  477. qiskit/providers/fake_provider/backends/prague/props_prague.json +1 -0
  478. qiskit/providers/fake_provider/backends/quito/__init__.py +16 -0
  479. qiskit/providers/fake_provider/backends/quito/conf_quito.json +1 -0
  480. qiskit/providers/fake_provider/backends/quito/defs_quito.json +1 -0
  481. qiskit/providers/fake_provider/backends/quito/fake_quito.py +38 -0
  482. qiskit/providers/fake_provider/backends/quito/props_quito.json +1 -0
  483. qiskit/providers/fake_provider/backends/rochester/__init__.py +16 -0
  484. qiskit/providers/fake_provider/backends/rochester/conf_rochester.json +1 -0
  485. qiskit/providers/fake_provider/backends/rochester/fake_rochester.py +36 -0
  486. qiskit/providers/fake_provider/backends/rochester/props_rochester.json +1 -0
  487. qiskit/providers/fake_provider/backends/rome/__init__.py +16 -0
  488. qiskit/providers/fake_provider/backends/rome/conf_rome.json +1 -0
  489. qiskit/providers/fake_provider/backends/rome/defs_rome.json +1 -0
  490. qiskit/providers/fake_provider/backends/rome/fake_rome.py +38 -0
  491. qiskit/providers/fake_provider/backends/rome/props_rome.json +1 -0
  492. qiskit/providers/fake_provider/backends/rueschlikon/__init__.py +15 -0
  493. qiskit/providers/fake_provider/backends/rueschlikon/fake_rueschlikon.py +74 -0
  494. qiskit/providers/fake_provider/backends/santiago/__init__.py +16 -0
  495. qiskit/providers/fake_provider/backends/santiago/conf_santiago.json +1 -0
  496. qiskit/providers/fake_provider/backends/santiago/defs_santiago.json +1 -0
  497. qiskit/providers/fake_provider/backends/santiago/fake_santiago.py +38 -0
  498. qiskit/providers/fake_provider/backends/santiago/props_santiago.json +1 -0
  499. qiskit/providers/fake_provider/backends/sherbrooke/__init__.py +17 -0
  500. qiskit/providers/fake_provider/backends/sherbrooke/conf_sherbrooke.json +1 -0
  501. qiskit/providers/fake_provider/backends/sherbrooke/defs_sherbrooke.json +1 -0
  502. qiskit/providers/fake_provider/backends/sherbrooke/fake_sherbrooke.py +28 -0
  503. qiskit/providers/fake_provider/backends/sherbrooke/props_sherbrooke.json +1 -0
  504. qiskit/providers/fake_provider/backends/singapore/__init__.py +16 -0
  505. qiskit/providers/fake_provider/backends/singapore/conf_singapore.json +1 -0
  506. qiskit/providers/fake_provider/backends/singapore/fake_singapore.py +58 -0
  507. qiskit/providers/fake_provider/backends/singapore/props_singapore.json +1 -0
  508. qiskit/providers/fake_provider/backends/sydney/__init__.py +16 -0
  509. qiskit/providers/fake_provider/backends/sydney/conf_sydney.json +1 -0
  510. qiskit/providers/fake_provider/backends/sydney/defs_sydney.json +1 -0
  511. qiskit/providers/fake_provider/backends/sydney/fake_sydney.py +38 -0
  512. qiskit/providers/fake_provider/backends/sydney/props_sydney.json +1 -0
  513. qiskit/providers/fake_provider/backends/tenerife/__init__.py +15 -0
  514. qiskit/providers/fake_provider/backends/tenerife/fake_tenerife.py +64 -0
  515. qiskit/providers/fake_provider/backends/tenerife/props_tenerife.json +1 -0
  516. qiskit/providers/fake_provider/backends/tokyo/__init__.py +15 -0
  517. qiskit/providers/fake_provider/backends/tokyo/fake_tokyo.py +137 -0
  518. qiskit/providers/fake_provider/backends/tokyo/props_tokyo.json +1 -0
  519. qiskit/providers/fake_provider/backends/toronto/__init__.py +16 -0
  520. qiskit/providers/fake_provider/backends/toronto/conf_toronto.json +1 -0
  521. qiskit/providers/fake_provider/backends/toronto/defs_toronto.json +1 -0
  522. qiskit/providers/fake_provider/backends/toronto/fake_toronto.py +38 -0
  523. qiskit/providers/fake_provider/backends/toronto/props_toronto.json +1 -0
  524. qiskit/providers/fake_provider/backends/valencia/__init__.py +16 -0
  525. qiskit/providers/fake_provider/backends/valencia/conf_valencia.json +1 -0
  526. qiskit/providers/fake_provider/backends/valencia/defs_valencia.json +1 -0
  527. qiskit/providers/fake_provider/backends/valencia/fake_valencia.py +38 -0
  528. qiskit/providers/fake_provider/backends/valencia/props_valencia.json +1 -0
  529. qiskit/providers/fake_provider/backends/vigo/__init__.py +16 -0
  530. qiskit/providers/fake_provider/backends/vigo/conf_vigo.json +1 -0
  531. qiskit/providers/fake_provider/backends/vigo/fake_vigo.py +50 -0
  532. qiskit/providers/fake_provider/backends/vigo/props_vigo.json +1 -0
  533. qiskit/providers/fake_provider/backends/washington/__init__.py +18 -0
  534. qiskit/providers/fake_provider/backends/washington/conf_washington.json +1 -0
  535. qiskit/providers/fake_provider/backends/washington/defs_washington.json +1 -0
  536. qiskit/providers/fake_provider/backends/washington/fake_washington.py +38 -0
  537. qiskit/providers/fake_provider/backends/washington/props_washington.json +1 -0
  538. qiskit/providers/fake_provider/backends/yorktown/__init__.py +16 -0
  539. qiskit/providers/fake_provider/backends/yorktown/conf_yorktown.json +1 -0
  540. qiskit/providers/fake_provider/backends/yorktown/fake_yorktown.py +54 -0
  541. qiskit/providers/fake_provider/backends/yorktown/props_yorktown.json +1 -0
  542. qiskit/providers/fake_provider/fake_1q.py +91 -0
  543. qiskit/providers/fake_provider/fake_backend.py +572 -0
  544. qiskit/providers/fake_provider/fake_backend_v2.py +217 -0
  545. qiskit/providers/fake_provider/fake_job.py +81 -0
  546. qiskit/providers/fake_provider/fake_mumbai_v2.py +637 -0
  547. qiskit/providers/fake_provider/fake_openpulse_2q.py +342 -0
  548. qiskit/providers/fake_provider/fake_openpulse_3q.py +332 -0
  549. qiskit/providers/fake_provider/fake_provider.py +214 -0
  550. qiskit/providers/fake_provider/fake_pulse_backend.py +43 -0
  551. qiskit/providers/fake_provider/fake_qasm_backend.py +72 -0
  552. qiskit/providers/fake_provider/fake_qasm_simulator.py +48 -0
  553. qiskit/providers/fake_provider/fake_qobj.py +44 -0
  554. qiskit/providers/fake_provider/utils/__init__.py +15 -0
  555. qiskit/providers/fake_provider/utils/backend_converter.py +150 -0
  556. qiskit/providers/fake_provider/utils/configurable_backend.py +360 -0
  557. qiskit/providers/fake_provider/utils/json_decoder.py +109 -0
  558. qiskit/providers/job.py +142 -0
  559. qiskit/providers/jobstatus.py +30 -0
  560. qiskit/providers/models/__init__.py +52 -0
  561. qiskit/providers/models/backendconfiguration.py +994 -0
  562. qiskit/providers/models/backendproperties.py +490 -0
  563. qiskit/providers/models/backendstatus.py +94 -0
  564. qiskit/providers/models/jobstatus.py +66 -0
  565. qiskit/providers/models/pulsedefaults.py +304 -0
  566. qiskit/providers/options.py +273 -0
  567. qiskit/providers/provider.py +79 -0
  568. qiskit/providers/providerutils.py +99 -0
  569. qiskit/pulse/__init__.py +170 -0
  570. qiskit/pulse/builder.py +2733 -0
  571. qiskit/pulse/calibration_entries.py +357 -0
  572. qiskit/pulse/channels.py +221 -0
  573. qiskit/pulse/configuration.py +244 -0
  574. qiskit/pulse/exceptions.py +43 -0
  575. qiskit/pulse/filters.py +302 -0
  576. qiskit/pulse/instruction_schedule_map.py +406 -0
  577. qiskit/pulse/instructions/__init__.py +69 -0
  578. qiskit/pulse/instructions/acquire.py +150 -0
  579. qiskit/pulse/instructions/call.py +176 -0
  580. qiskit/pulse/instructions/delay.py +69 -0
  581. qiskit/pulse/instructions/directives.py +145 -0
  582. qiskit/pulse/instructions/frequency.py +132 -0
  583. qiskit/pulse/instructions/instruction.py +266 -0
  584. qiskit/pulse/instructions/phase.py +149 -0
  585. qiskit/pulse/instructions/play.py +96 -0
  586. qiskit/pulse/instructions/reference.py +99 -0
  587. qiskit/pulse/instructions/snapshot.py +80 -0
  588. qiskit/pulse/library/__init__.py +99 -0
  589. qiskit/pulse/library/continuous.py +430 -0
  590. qiskit/pulse/library/parametric_pulses.py +629 -0
  591. qiskit/pulse/library/pulse.py +137 -0
  592. qiskit/pulse/library/samplers/__init__.py +15 -0
  593. qiskit/pulse/library/samplers/decorators.py +299 -0
  594. qiskit/pulse/library/samplers/strategies.py +71 -0
  595. qiskit/pulse/library/symbolic_pulses.py +1962 -0
  596. qiskit/pulse/library/waveform.py +134 -0
  597. qiskit/pulse/macros.py +256 -0
  598. qiskit/pulse/parameter_manager.py +432 -0
  599. qiskit/pulse/parser.py +314 -0
  600. qiskit/pulse/reference_manager.py +58 -0
  601. qiskit/pulse/schedule.py +2002 -0
  602. qiskit/pulse/transforms/__init__.py +106 -0
  603. qiskit/pulse/transforms/alignments.py +406 -0
  604. qiskit/pulse/transforms/base_transforms.py +71 -0
  605. qiskit/pulse/transforms/canonicalization.py +514 -0
  606. qiskit/pulse/transforms/dag.py +107 -0
  607. qiskit/pulse/utils.py +109 -0
  608. qiskit/qasm/libs/qelib1.inc +266 -0
  609. qiskit/qasm/libs/stdgates.inc +75 -0
  610. qiskit/qasm2/__init__.py +658 -0
  611. qiskit/qasm2/exceptions.py +27 -0
  612. qiskit/qasm2/export.py +374 -0
  613. qiskit/qasm2/parse.py +403 -0
  614. qiskit/qasm3/__init__.py +255 -0
  615. qiskit/qasm3/ast.py +606 -0
  616. qiskit/qasm3/exceptions.py +27 -0
  617. qiskit/qasm3/experimental.py +30 -0
  618. qiskit/qasm3/exporter.py +1079 -0
  619. qiskit/qasm3/printer.py +545 -0
  620. qiskit/qobj/__init__.py +75 -0
  621. qiskit/qobj/common.py +71 -0
  622. qiskit/qobj/converters/__init__.py +18 -0
  623. qiskit/qobj/converters/lo_config.py +168 -0
  624. qiskit/qobj/converters/pulse_instruction.py +1070 -0
  625. qiskit/qobj/pulse_qobj.py +655 -0
  626. qiskit/qobj/qasm_qobj.py +656 -0
  627. qiskit/qobj/utils.py +37 -0
  628. qiskit/qpy/__init__.py +1348 -0
  629. qiskit/qpy/binary_io/__init__.py +36 -0
  630. qiskit/qpy/binary_io/circuits.py +1212 -0
  631. qiskit/qpy/binary_io/schedules.py +619 -0
  632. qiskit/qpy/binary_io/value.py +549 -0
  633. qiskit/qpy/common.py +305 -0
  634. qiskit/qpy/exceptions.py +28 -0
  635. qiskit/qpy/formats.py +360 -0
  636. qiskit/qpy/interface.py +308 -0
  637. qiskit/qpy/type_keys.py +544 -0
  638. qiskit/quantum_info/__init__.py +173 -0
  639. qiskit/quantum_info/analysis/__init__.py +17 -0
  640. qiskit/quantum_info/analysis/average.py +47 -0
  641. qiskit/quantum_info/analysis/distance.py +101 -0
  642. qiskit/quantum_info/analysis/make_observable.py +43 -0
  643. qiskit/quantum_info/analysis/z2_symmetries.py +483 -0
  644. qiskit/quantum_info/operators/__init__.py +28 -0
  645. qiskit/quantum_info/operators/base_operator.py +145 -0
  646. qiskit/quantum_info/operators/channel/__init__.py +29 -0
  647. qiskit/quantum_info/operators/channel/chi.py +190 -0
  648. qiskit/quantum_info/operators/channel/choi.py +217 -0
  649. qiskit/quantum_info/operators/channel/kraus.py +336 -0
  650. qiskit/quantum_info/operators/channel/ptm.py +203 -0
  651. qiskit/quantum_info/operators/channel/quantum_channel.py +350 -0
  652. qiskit/quantum_info/operators/channel/stinespring.py +295 -0
  653. qiskit/quantum_info/operators/channel/superop.py +376 -0
  654. qiskit/quantum_info/operators/channel/transformations.py +467 -0
  655. qiskit/quantum_info/operators/custom_iterator.py +48 -0
  656. qiskit/quantum_info/operators/dihedral/__init__.py +18 -0
  657. qiskit/quantum_info/operators/dihedral/dihedral.py +508 -0
  658. qiskit/quantum_info/operators/dihedral/dihedral_circuits.py +218 -0
  659. qiskit/quantum_info/operators/dihedral/polynomial.py +313 -0
  660. qiskit/quantum_info/operators/dihedral/random.py +61 -0
  661. qiskit/quantum_info/operators/linear_op.py +25 -0
  662. qiskit/quantum_info/operators/measures.py +423 -0
  663. qiskit/quantum_info/operators/mixins/__init__.py +52 -0
  664. qiskit/quantum_info/operators/mixins/adjoint.py +52 -0
  665. qiskit/quantum_info/operators/mixins/group.py +171 -0
  666. qiskit/quantum_info/operators/mixins/linear.py +84 -0
  667. qiskit/quantum_info/operators/mixins/multiply.py +62 -0
  668. qiskit/quantum_info/operators/mixins/tolerances.py +72 -0
  669. qiskit/quantum_info/operators/op_shape.py +533 -0
  670. qiskit/quantum_info/operators/operator.py +778 -0
  671. qiskit/quantum_info/operators/predicates.py +170 -0
  672. qiskit/quantum_info/operators/random.py +154 -0
  673. qiskit/quantum_info/operators/scalar_op.py +253 -0
  674. qiskit/quantum_info/operators/symplectic/__init__.py +23 -0
  675. qiskit/quantum_info/operators/symplectic/base_pauli.py +720 -0
  676. qiskit/quantum_info/operators/symplectic/clifford.py +1022 -0
  677. qiskit/quantum_info/operators/symplectic/clifford_circuits.py +558 -0
  678. qiskit/quantum_info/operators/symplectic/pauli.py +699 -0
  679. qiskit/quantum_info/operators/symplectic/pauli_list.py +1209 -0
  680. qiskit/quantum_info/operators/symplectic/pauli_utils.py +40 -0
  681. qiskit/quantum_info/operators/symplectic/random.py +264 -0
  682. qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +1156 -0
  683. qiskit/quantum_info/operators/utils/__init__.py +20 -0
  684. qiskit/quantum_info/operators/utils/anti_commutator.py +36 -0
  685. qiskit/quantum_info/operators/utils/commutator.py +36 -0
  686. qiskit/quantum_info/operators/utils/double_commutator.py +76 -0
  687. qiskit/quantum_info/random.py +26 -0
  688. qiskit/quantum_info/states/__init__.py +28 -0
  689. qiskit/quantum_info/states/densitymatrix.py +848 -0
  690. qiskit/quantum_info/states/measures.py +288 -0
  691. qiskit/quantum_info/states/quantum_state.py +503 -0
  692. qiskit/quantum_info/states/random.py +157 -0
  693. qiskit/quantum_info/states/stabilizerstate.py +638 -0
  694. qiskit/quantum_info/states/statevector.py +961 -0
  695. qiskit/quantum_info/states/utils.py +245 -0
  696. qiskit/quantum_info/synthesis/__init__.py +20 -0
  697. qiskit/quantum_info/synthesis/clifford_decompose.py +69 -0
  698. qiskit/quantum_info/synthesis/cnotdihedral_decompose.py +50 -0
  699. qiskit/quantum_info/synthesis/ion_decompose.py +55 -0
  700. qiskit/quantum_info/synthesis/local_invariance.py +93 -0
  701. qiskit/quantum_info/synthesis/one_qubit_decompose.py +284 -0
  702. qiskit/quantum_info/synthesis/qsd.py +269 -0
  703. qiskit/quantum_info/synthesis/quaternion.py +156 -0
  704. qiskit/quantum_info/synthesis/two_qubit_decompose.py +1567 -0
  705. qiskit/quantum_info/synthesis/weyl.py +98 -0
  706. qiskit/quantum_info/synthesis/xx_decompose/__init__.py +19 -0
  707. qiskit/quantum_info/synthesis/xx_decompose/circuits.py +299 -0
  708. qiskit/quantum_info/synthesis/xx_decompose/decomposer.py +314 -0
  709. qiskit/quantum_info/synthesis/xx_decompose/embodiments.py +163 -0
  710. qiskit/quantum_info/synthesis/xx_decompose/paths.py +412 -0
  711. qiskit/quantum_info/synthesis/xx_decompose/polytopes.py +264 -0
  712. qiskit/quantum_info/synthesis/xx_decompose/utilities.py +40 -0
  713. qiskit/quantum_info/synthesis/xx_decompose/weyl.py +133 -0
  714. qiskit/result/__init__.py +67 -0
  715. qiskit/result/counts.py +189 -0
  716. qiskit/result/distributions/__init__.py +17 -0
  717. qiskit/result/distributions/probability.py +100 -0
  718. qiskit/result/distributions/quasi.py +154 -0
  719. qiskit/result/exceptions.py +40 -0
  720. qiskit/result/mitigation/__init__.py +13 -0
  721. qiskit/result/mitigation/base_readout_mitigator.py +79 -0
  722. qiskit/result/mitigation/correlated_readout_mitigator.py +268 -0
  723. qiskit/result/mitigation/local_readout_mitigator.py +319 -0
  724. qiskit/result/mitigation/utils.py +161 -0
  725. qiskit/result/models.py +233 -0
  726. qiskit/result/postprocess.py +239 -0
  727. qiskit/result/result.py +397 -0
  728. qiskit/result/sampled_expval.py +75 -0
  729. qiskit/result/utils.py +295 -0
  730. qiskit/scheduler/__init__.py +31 -0
  731. qiskit/scheduler/config.py +35 -0
  732. qiskit/scheduler/lowering.py +187 -0
  733. qiskit/scheduler/methods/__init__.py +22 -0
  734. qiskit/scheduler/methods/basic.py +137 -0
  735. qiskit/scheduler/schedule_circuit.py +67 -0
  736. qiskit/scheduler/sequence.py +102 -0
  737. qiskit/synthesis/__init__.py +122 -0
  738. qiskit/synthesis/clifford/__init__.py +19 -0
  739. qiskit/synthesis/clifford/clifford_decompose_ag.py +176 -0
  740. qiskit/synthesis/clifford/clifford_decompose_bm.py +276 -0
  741. qiskit/synthesis/clifford/clifford_decompose_full.py +61 -0
  742. qiskit/synthesis/clifford/clifford_decompose_greedy.py +347 -0
  743. qiskit/synthesis/clifford/clifford_decompose_layers.py +443 -0
  744. qiskit/synthesis/cnotdihedral/__init__.py +17 -0
  745. qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_full.py +46 -0
  746. qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_general.py +140 -0
  747. qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_two_qubits.py +264 -0
  748. qiskit/synthesis/discrete_basis/__init__.py +16 -0
  749. qiskit/synthesis/discrete_basis/commutator_decompose.py +241 -0
  750. qiskit/synthesis/discrete_basis/gate_sequence.py +415 -0
  751. qiskit/synthesis/discrete_basis/generate_basis_approximations.py +163 -0
  752. qiskit/synthesis/discrete_basis/solovay_kitaev.py +207 -0
  753. qiskit/synthesis/evolution/__init__.py +20 -0
  754. qiskit/synthesis/evolution/evolution_synthesis.py +46 -0
  755. qiskit/synthesis/evolution/lie_trotter.py +123 -0
  756. qiskit/synthesis/evolution/matrix_synthesis.py +47 -0
  757. qiskit/synthesis/evolution/product_formula.py +328 -0
  758. qiskit/synthesis/evolution/qdrift.py +102 -0
  759. qiskit/synthesis/evolution/suzuki_trotter.py +145 -0
  760. qiskit/synthesis/linear/__init__.py +25 -0
  761. qiskit/synthesis/linear/cnot_synth.py +141 -0
  762. qiskit/synthesis/linear/linear_circuits_utils.py +127 -0
  763. qiskit/synthesis/linear/linear_depth_lnn.py +275 -0
  764. qiskit/synthesis/linear/linear_matrix_utils.py +175 -0
  765. qiskit/synthesis/linear_phase/__init__.py +17 -0
  766. qiskit/synthesis/linear_phase/cnot_phase_synth.py +203 -0
  767. qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py +262 -0
  768. qiskit/synthesis/linear_phase/cz_depth_lnn.py +206 -0
  769. qiskit/synthesis/permutation/__init__.py +17 -0
  770. qiskit/synthesis/permutation/permutation_full.py +90 -0
  771. qiskit/synthesis/permutation/permutation_lnn.py +68 -0
  772. qiskit/synthesis/permutation/permutation_utils.py +73 -0
  773. qiskit/synthesis/stabilizer/__init__.py +15 -0
  774. qiskit/synthesis/stabilizer/stabilizer_decompose.py +188 -0
  775. qiskit/test/__init__.py +18 -0
  776. qiskit/test/_canonical.py +125 -0
  777. qiskit/test/base.py +331 -0
  778. qiskit/test/decorators.py +308 -0
  779. qiskit/test/ibmq_mock.py +45 -0
  780. qiskit/test/mock/__init__.py +40 -0
  781. qiskit/test/mock/backends/__init__.py +32 -0
  782. qiskit/test/mock/backends/almaden/__init__.py +32 -0
  783. qiskit/test/mock/backends/armonk/__init__.py +32 -0
  784. qiskit/test/mock/backends/athens/__init__.py +32 -0
  785. qiskit/test/mock/backends/belem/__init__.py +32 -0
  786. qiskit/test/mock/backends/boeblingen/__init__.py +32 -0
  787. qiskit/test/mock/backends/bogota/__init__.py +32 -0
  788. qiskit/test/mock/backends/brooklyn/__init__.py +32 -0
  789. qiskit/test/mock/backends/burlington/__init__.py +32 -0
  790. qiskit/test/mock/backends/cairo/__init__.py +32 -0
  791. qiskit/test/mock/backends/cambridge/__init__.py +32 -0
  792. qiskit/test/mock/backends/casablanca/__init__.py +32 -0
  793. qiskit/test/mock/backends/essex/__init__.py +32 -0
  794. qiskit/test/mock/backends/guadalupe/__init__.py +32 -0
  795. qiskit/test/mock/backends/hanoi/__init__.py +32 -0
  796. qiskit/test/mock/backends/jakarta/__init__.py +32 -0
  797. qiskit/test/mock/backends/johannesburg/__init__.py +32 -0
  798. qiskit/test/mock/backends/kolkata/__init__.py +32 -0
  799. qiskit/test/mock/backends/lagos/__init__.py +32 -0
  800. qiskit/test/mock/backends/lima/__init__.py +32 -0
  801. qiskit/test/mock/backends/london/__init__.py +32 -0
  802. qiskit/test/mock/backends/manhattan/__init__.py +32 -0
  803. qiskit/test/mock/backends/manila/__init__.py +32 -0
  804. qiskit/test/mock/backends/melbourne/__init__.py +32 -0
  805. qiskit/test/mock/backends/montreal/__init__.py +32 -0
  806. qiskit/test/mock/backends/mumbai/__init__.py +32 -0
  807. qiskit/test/mock/backends/nairobi/__init__.py +32 -0
  808. qiskit/test/mock/backends/ourense/__init__.py +32 -0
  809. qiskit/test/mock/backends/paris/__init__.py +32 -0
  810. qiskit/test/mock/backends/poughkeepsie/__init__.py +32 -0
  811. qiskit/test/mock/backends/quito/__init__.py +32 -0
  812. qiskit/test/mock/backends/rochester/__init__.py +32 -0
  813. qiskit/test/mock/backends/rome/__init__.py +32 -0
  814. qiskit/test/mock/backends/rueschlikon/__init__.py +32 -0
  815. qiskit/test/mock/backends/santiago/__init__.py +32 -0
  816. qiskit/test/mock/backends/singapore/__init__.py +32 -0
  817. qiskit/test/mock/backends/sydney/__init__.py +32 -0
  818. qiskit/test/mock/backends/tenerife/__init__.py +32 -0
  819. qiskit/test/mock/backends/tokyo/__init__.py +32 -0
  820. qiskit/test/mock/backends/toronto/__init__.py +32 -0
  821. qiskit/test/mock/backends/valencia/__init__.py +32 -0
  822. qiskit/test/mock/backends/vigo/__init__.py +32 -0
  823. qiskit/test/mock/backends/washington/__init__.py +32 -0
  824. qiskit/test/mock/backends/yorktown/__init__.py +32 -0
  825. qiskit/test/providers/__init__.py +16 -0
  826. qiskit/test/providers/backend.py +75 -0
  827. qiskit/test/providers/provider.py +59 -0
  828. qiskit/test/reference_circuits.py +41 -0
  829. qiskit/test/testing_options.py +93 -0
  830. qiskit/test/utils.py +87 -0
  831. qiskit/tools/__init__.py +44 -0
  832. qiskit/tools/events/__init__.py +25 -0
  833. qiskit/tools/events/progressbar.py +195 -0
  834. qiskit/tools/events/pubsub.py +158 -0
  835. qiskit/tools/jupyter/__init__.py +138 -0
  836. qiskit/tools/jupyter/backend_monitor.py +588 -0
  837. qiskit/tools/jupyter/backend_overview.py +322 -0
  838. qiskit/tools/jupyter/copyright.py +42 -0
  839. qiskit/tools/jupyter/job_watcher.py +167 -0
  840. qiskit/tools/jupyter/job_widgets.py +160 -0
  841. qiskit/tools/jupyter/jupyter_magics.py +190 -0
  842. qiskit/tools/jupyter/library.py +189 -0
  843. qiskit/tools/jupyter/monospace.py +29 -0
  844. qiskit/tools/jupyter/progressbar.py +122 -0
  845. qiskit/tools/jupyter/version_table.py +67 -0
  846. qiskit/tools/jupyter/watcher_monitor.py +74 -0
  847. qiskit/tools/monitor/__init__.py +16 -0
  848. qiskit/tools/monitor/job_monitor.py +107 -0
  849. qiskit/tools/monitor/overview.py +247 -0
  850. qiskit/tools/parallel.py +198 -0
  851. qiskit/tools/visualization.py +16 -0
  852. qiskit/transpiler/__init__.py +1287 -0
  853. qiskit/transpiler/basepasses.py +221 -0
  854. qiskit/transpiler/coupling.py +500 -0
  855. qiskit/transpiler/exceptions.py +55 -0
  856. qiskit/transpiler/fencedobjs.py +78 -0
  857. qiskit/transpiler/instruction_durations.py +278 -0
  858. qiskit/transpiler/layout.py +658 -0
  859. qiskit/transpiler/passes/__init__.py +296 -0
  860. qiskit/transpiler/passes/analysis/__init__.py +23 -0
  861. qiskit/transpiler/passes/analysis/count_ops.py +30 -0
  862. qiskit/transpiler/passes/analysis/count_ops_longest_path.py +26 -0
  863. qiskit/transpiler/passes/analysis/dag_longest_path.py +24 -0
  864. qiskit/transpiler/passes/analysis/depth.py +33 -0
  865. qiskit/transpiler/passes/analysis/num_qubits.py +26 -0
  866. qiskit/transpiler/passes/analysis/num_tensor_factors.py +26 -0
  867. qiskit/transpiler/passes/analysis/resource_estimation.py +41 -0
  868. qiskit/transpiler/passes/analysis/size.py +36 -0
  869. qiskit/transpiler/passes/analysis/width.py +27 -0
  870. qiskit/transpiler/passes/basis/__init__.py +20 -0
  871. qiskit/transpiler/passes/basis/basis_translator.py +697 -0
  872. qiskit/transpiler/passes/basis/decompose.py +98 -0
  873. qiskit/transpiler/passes/basis/translate_parameterized.py +177 -0
  874. qiskit/transpiler/passes/basis/unroll_3q_or_more.py +86 -0
  875. qiskit/transpiler/passes/basis/unroll_custom_definitions.py +107 -0
  876. qiskit/transpiler/passes/basis/unroller.py +145 -0
  877. qiskit/transpiler/passes/calibration/__init__.py +17 -0
  878. qiskit/transpiler/passes/calibration/base_builder.py +79 -0
  879. qiskit/transpiler/passes/calibration/builders.py +20 -0
  880. qiskit/transpiler/passes/calibration/exceptions.py +22 -0
  881. qiskit/transpiler/passes/calibration/pulse_gate.py +98 -0
  882. qiskit/transpiler/passes/calibration/rx_builder.py +160 -0
  883. qiskit/transpiler/passes/calibration/rzx_builder.py +394 -0
  884. qiskit/transpiler/passes/calibration/rzx_templates.py +51 -0
  885. qiskit/transpiler/passes/layout/__init__.py +27 -0
  886. qiskit/transpiler/passes/layout/_csp_custom_solver.py +65 -0
  887. qiskit/transpiler/passes/layout/apply_layout.py +108 -0
  888. qiskit/transpiler/passes/layout/csp_layout.py +132 -0
  889. qiskit/transpiler/passes/layout/dense_layout.py +202 -0
  890. qiskit/transpiler/passes/layout/disjoint_utils.py +205 -0
  891. qiskit/transpiler/passes/layout/enlarge_with_ancilla.py +49 -0
  892. qiskit/transpiler/passes/layout/full_ancilla_allocation.py +117 -0
  893. qiskit/transpiler/passes/layout/layout_2q_distance.py +77 -0
  894. qiskit/transpiler/passes/layout/noise_adaptive_layout.py +311 -0
  895. qiskit/transpiler/passes/layout/sabre_layout.py +468 -0
  896. qiskit/transpiler/passes/layout/sabre_pre_layout.py +217 -0
  897. qiskit/transpiler/passes/layout/set_layout.py +64 -0
  898. qiskit/transpiler/passes/layout/trivial_layout.py +66 -0
  899. qiskit/transpiler/passes/layout/vf2_layout.py +257 -0
  900. qiskit/transpiler/passes/layout/vf2_post_layout.py +419 -0
  901. qiskit/transpiler/passes/layout/vf2_utils.py +260 -0
  902. qiskit/transpiler/passes/optimization/__init__.py +38 -0
  903. qiskit/transpiler/passes/optimization/_gate_extension.py +80 -0
  904. qiskit/transpiler/passes/optimization/collect_1q_runs.py +31 -0
  905. qiskit/transpiler/passes/optimization/collect_2q_blocks.py +35 -0
  906. qiskit/transpiler/passes/optimization/collect_and_collapse.py +115 -0
  907. qiskit/transpiler/passes/optimization/collect_cliffords.py +97 -0
  908. qiskit/transpiler/passes/optimization/collect_linear_functions.py +80 -0
  909. qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py +227 -0
  910. qiskit/transpiler/passes/optimization/commutation_analysis.py +93 -0
  911. qiskit/transpiler/passes/optimization/commutative_cancellation.py +207 -0
  912. qiskit/transpiler/passes/optimization/commutative_inverse_cancellation.py +97 -0
  913. qiskit/transpiler/passes/optimization/consolidate_blocks.py +219 -0
  914. qiskit/transpiler/passes/optimization/crosstalk_adaptive_schedule.py +732 -0
  915. qiskit/transpiler/passes/optimization/cx_cancellation.py +55 -0
  916. qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposition.py +160 -0
  917. qiskit/transpiler/passes/optimization/hoare_opt.py +416 -0
  918. qiskit/transpiler/passes/optimization/inverse_cancellation.py +177 -0
  919. qiskit/transpiler/passes/optimization/normalize_rx_angle.py +149 -0
  920. qiskit/transpiler/passes/optimization/optimize_1q_commutation.py +268 -0
  921. qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +263 -0
  922. qiskit/transpiler/passes/optimization/optimize_1q_gates.py +384 -0
  923. qiskit/transpiler/passes/optimization/optimize_cliffords.py +89 -0
  924. qiskit/transpiler/passes/optimization/optimize_swap_before_measure.py +71 -0
  925. qiskit/transpiler/passes/optimization/remove_diagonal_gates_before_measure.py +69 -0
  926. qiskit/transpiler/passes/optimization/remove_reset_in_zero_state.py +37 -0
  927. qiskit/transpiler/passes/optimization/reset_after_measure_simplification.py +47 -0
  928. qiskit/transpiler/passes/optimization/template_matching/__init__.py +19 -0
  929. qiskit/transpiler/passes/optimization/template_matching/backward_match.py +749 -0
  930. qiskit/transpiler/passes/optimization/template_matching/forward_match.py +454 -0
  931. qiskit/transpiler/passes/optimization/template_matching/maximal_matches.py +77 -0
  932. qiskit/transpiler/passes/optimization/template_matching/template_matching.py +370 -0
  933. qiskit/transpiler/passes/optimization/template_matching/template_substitution.py +629 -0
  934. qiskit/transpiler/passes/optimization/template_optimization.py +158 -0
  935. qiskit/transpiler/passes/routing/__init__.py +21 -0
  936. qiskit/transpiler/passes/routing/algorithms/__init__.py +33 -0
  937. qiskit/transpiler/passes/routing/algorithms/token_swapper.py +105 -0
  938. qiskit/transpiler/passes/routing/algorithms/types.py +46 -0
  939. qiskit/transpiler/passes/routing/algorithms/util.py +103 -0
  940. qiskit/transpiler/passes/routing/basic_swap.py +155 -0
  941. qiskit/transpiler/passes/routing/commuting_2q_gate_routing/__init__.py +25 -0
  942. qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_block.py +60 -0
  943. qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py +387 -0
  944. qiskit/transpiler/passes/routing/commuting_2q_gate_routing/pauli_2q_evolution_commutation.py +141 -0
  945. qiskit/transpiler/passes/routing/commuting_2q_gate_routing/swap_strategy.py +306 -0
  946. qiskit/transpiler/passes/routing/layout_transformation.py +118 -0
  947. qiskit/transpiler/passes/routing/lookahead_swap.py +384 -0
  948. qiskit/transpiler/passes/routing/sabre_swap.py +430 -0
  949. qiskit/transpiler/passes/routing/stochastic_swap.py +512 -0
  950. qiskit/transpiler/passes/routing/utils.py +35 -0
  951. qiskit/transpiler/passes/scheduling/__init__.py +27 -0
  952. qiskit/transpiler/passes/scheduling/alap.py +155 -0
  953. qiskit/transpiler/passes/scheduling/alignments/__init__.py +81 -0
  954. qiskit/transpiler/passes/scheduling/alignments/align_measures.py +256 -0
  955. qiskit/transpiler/passes/scheduling/alignments/check_durations.py +75 -0
  956. qiskit/transpiler/passes/scheduling/alignments/pulse_gate_validation.py +97 -0
  957. qiskit/transpiler/passes/scheduling/alignments/reschedule.py +241 -0
  958. qiskit/transpiler/passes/scheduling/asap.py +177 -0
  959. qiskit/transpiler/passes/scheduling/base_scheduler.py +289 -0
  960. qiskit/transpiler/passes/scheduling/calibration_creators.py +27 -0
  961. qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +285 -0
  962. qiskit/transpiler/passes/scheduling/padding/__init__.py +16 -0
  963. qiskit/transpiler/passes/scheduling/padding/base_padding.py +256 -0
  964. qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +408 -0
  965. qiskit/transpiler/passes/scheduling/padding/pad_delay.py +79 -0
  966. qiskit/transpiler/passes/scheduling/rzx_templates.py +28 -0
  967. qiskit/transpiler/passes/scheduling/scheduling/__init__.py +17 -0
  968. qiskit/transpiler/passes/scheduling/scheduling/alap.py +127 -0
  969. qiskit/transpiler/passes/scheduling/scheduling/asap.py +131 -0
  970. qiskit/transpiler/passes/scheduling/scheduling/base_scheduler.py +89 -0
  971. qiskit/transpiler/passes/scheduling/scheduling/set_io_latency.py +64 -0
  972. qiskit/transpiler/passes/scheduling/time_unit_conversion.py +135 -0
  973. qiskit/transpiler/passes/synthesis/__init__.py +19 -0
  974. qiskit/transpiler/passes/synthesis/high_level_synthesis.py +637 -0
  975. qiskit/transpiler/passes/synthesis/linear_functions_synthesis.py +63 -0
  976. qiskit/transpiler/passes/synthesis/plugin.py +597 -0
  977. qiskit/transpiler/passes/synthesis/solovay_kitaev_synthesis.py +289 -0
  978. qiskit/transpiler/passes/synthesis/unitary_synthesis.py +895 -0
  979. qiskit/transpiler/passes/utils/__init__.py +34 -0
  980. qiskit/transpiler/passes/utils/barrier_before_final_measurements.py +95 -0
  981. qiskit/transpiler/passes/utils/block_to_matrix.py +47 -0
  982. qiskit/transpiler/passes/utils/check_gate_direction.py +87 -0
  983. qiskit/transpiler/passes/utils/check_map.py +94 -0
  984. qiskit/transpiler/passes/utils/contains_instruction.py +45 -0
  985. qiskit/transpiler/passes/utils/control_flow.py +61 -0
  986. qiskit/transpiler/passes/utils/convert_conditions_to_if_ops.py +89 -0
  987. qiskit/transpiler/passes/utils/dag_fixed_point.py +36 -0
  988. qiskit/transpiler/passes/utils/error.py +69 -0
  989. qiskit/transpiler/passes/utils/filter_op_nodes.py +65 -0
  990. qiskit/transpiler/passes/utils/fixed_point.py +48 -0
  991. qiskit/transpiler/passes/utils/gate_direction.py +347 -0
  992. qiskit/transpiler/passes/utils/gates_basis.py +75 -0
  993. qiskit/transpiler/passes/utils/merge_adjacent_barriers.py +162 -0
  994. qiskit/transpiler/passes/utils/minimum_point.py +118 -0
  995. qiskit/transpiler/passes/utils/remove_barriers.py +49 -0
  996. qiskit/transpiler/passes/utils/remove_final_measurements.py +114 -0
  997. qiskit/transpiler/passes/utils/unroll_forloops.py +81 -0
  998. qiskit/transpiler/passmanager.py +617 -0
  999. qiskit/transpiler/passmanager_config.py +193 -0
  1000. qiskit/transpiler/preset_passmanagers/__init__.py +280 -0
  1001. qiskit/transpiler/preset_passmanagers/builtin_plugins.py +971 -0
  1002. qiskit/transpiler/preset_passmanagers/common.py +651 -0
  1003. qiskit/transpiler/preset_passmanagers/level0.py +113 -0
  1004. qiskit/transpiler/preset_passmanagers/level1.py +120 -0
  1005. qiskit/transpiler/preset_passmanagers/level2.py +119 -0
  1006. qiskit/transpiler/preset_passmanagers/level3.py +119 -0
  1007. qiskit/transpiler/preset_passmanagers/plugin.py +345 -0
  1008. qiskit/transpiler/propertyset.py +19 -0
  1009. qiskit/transpiler/runningpassmanager.py +174 -0
  1010. qiskit/transpiler/synthesis/__init__.py +16 -0
  1011. qiskit/transpiler/synthesis/aqc/__init__.py +178 -0
  1012. qiskit/transpiler/synthesis/aqc/approximate.py +116 -0
  1013. qiskit/transpiler/synthesis/aqc/aqc.py +170 -0
  1014. qiskit/transpiler/synthesis/aqc/aqc_plugin.py +146 -0
  1015. qiskit/transpiler/synthesis/aqc/cnot_structures.py +299 -0
  1016. qiskit/transpiler/synthesis/aqc/cnot_unit_circuit.py +103 -0
  1017. qiskit/transpiler/synthesis/aqc/cnot_unit_objective.py +299 -0
  1018. qiskit/transpiler/synthesis/aqc/elementary_operations.py +108 -0
  1019. qiskit/transpiler/synthesis/aqc/fast_gradient/__init__.py +164 -0
  1020. qiskit/transpiler/synthesis/aqc/fast_gradient/fast_grad_utils.py +237 -0
  1021. qiskit/transpiler/synthesis/aqc/fast_gradient/fast_gradient.py +225 -0
  1022. qiskit/transpiler/synthesis/aqc/fast_gradient/layer.py +370 -0
  1023. qiskit/transpiler/synthesis/aqc/fast_gradient/pmatrix.py +312 -0
  1024. qiskit/transpiler/synthesis/graysynth.py +114 -0
  1025. qiskit/transpiler/target.py +1540 -0
  1026. qiskit/transpiler/timing_constraints.py +59 -0
  1027. qiskit/user_config.py +239 -0
  1028. qiskit/utils/__init__.py +66 -0
  1029. qiskit/utils/classtools.py +146 -0
  1030. qiskit/utils/deprecation.py +489 -0
  1031. qiskit/utils/lazy_tester.py +334 -0
  1032. qiskit/utils/multiprocessing.py +48 -0
  1033. qiskit/utils/optionals.py +320 -0
  1034. qiskit/utils/units.py +143 -0
  1035. qiskit/version.py +84 -0
  1036. qiskit/visualization/__init__.py +289 -0
  1037. qiskit/visualization/array.py +204 -0
  1038. qiskit/visualization/bloch.py +741 -0
  1039. qiskit/visualization/circuit/__init__.py +15 -0
  1040. qiskit/visualization/circuit/_utils.py +633 -0
  1041. qiskit/visualization/circuit/circuit_visualization.py +717 -0
  1042. qiskit/visualization/circuit/latex.py +659 -0
  1043. qiskit/visualization/circuit/matplotlib.py +1975 -0
  1044. qiskit/visualization/circuit/qcstyle.py +420 -0
  1045. qiskit/visualization/circuit/styles/bw.json +202 -0
  1046. qiskit/visualization/circuit/styles/clifford.json +202 -0
  1047. qiskit/visualization/circuit/styles/iqp-dark.json +214 -0
  1048. qiskit/visualization/circuit/styles/iqp.json +214 -0
  1049. qiskit/visualization/circuit/styles/textbook.json +202 -0
  1050. qiskit/visualization/circuit/text.py +1802 -0
  1051. qiskit/visualization/circuit_visualization.py +19 -0
  1052. qiskit/visualization/counts_visualization.py +496 -0
  1053. qiskit/visualization/dag_visualization.py +224 -0
  1054. qiskit/visualization/exceptions.py +21 -0
  1055. qiskit/visualization/gate_map.py +1461 -0
  1056. qiskit/visualization/pass_manager_visualization.py +281 -0
  1057. qiskit/visualization/pulse_v2/__init__.py +21 -0
  1058. qiskit/visualization/pulse_v2/core.py +905 -0
  1059. qiskit/visualization/pulse_v2/device_info.py +146 -0
  1060. qiskit/visualization/pulse_v2/drawings.py +253 -0
  1061. qiskit/visualization/pulse_v2/events.py +254 -0
  1062. qiskit/visualization/pulse_v2/generators/__init__.py +40 -0
  1063. qiskit/visualization/pulse_v2/generators/barrier.py +76 -0
  1064. qiskit/visualization/pulse_v2/generators/chart.py +208 -0
  1065. qiskit/visualization/pulse_v2/generators/frame.py +437 -0
  1066. qiskit/visualization/pulse_v2/generators/snapshot.py +133 -0
  1067. qiskit/visualization/pulse_v2/generators/waveform.py +649 -0
  1068. qiskit/visualization/pulse_v2/interface.py +452 -0
  1069. qiskit/visualization/pulse_v2/layouts.py +395 -0
  1070. qiskit/visualization/pulse_v2/plotters/__init__.py +17 -0
  1071. qiskit/visualization/pulse_v2/plotters/base_plotter.py +53 -0
  1072. qiskit/visualization/pulse_v2/plotters/matplotlib.py +202 -0
  1073. qiskit/visualization/pulse_v2/stylesheet.py +322 -0
  1074. qiskit/visualization/pulse_v2/types.py +242 -0
  1075. qiskit/visualization/qcstyle.py +17 -0
  1076. qiskit/visualization/state_visualization.py +1518 -0
  1077. qiskit/visualization/timeline/__init__.py +21 -0
  1078. qiskit/visualization/timeline/core.py +457 -0
  1079. qiskit/visualization/timeline/drawings.py +260 -0
  1080. qiskit/visualization/timeline/generators.py +506 -0
  1081. qiskit/visualization/timeline/interface.py +414 -0
  1082. qiskit/visualization/timeline/layouts.py +115 -0
  1083. qiskit/visualization/timeline/plotters/__init__.py +16 -0
  1084. qiskit/visualization/timeline/plotters/base_plotter.py +58 -0
  1085. qiskit/visualization/timeline/plotters/matplotlib.py +193 -0
  1086. qiskit/visualization/timeline/stylesheet.py +311 -0
  1087. qiskit/visualization/timeline/types.py +148 -0
  1088. qiskit/visualization/transition_visualization.py +364 -0
  1089. qiskit/visualization/utils.py +49 -0
  1090. qiskit-1.0.0b1.dist-info/LICENSE.txt +203 -0
  1091. qiskit-1.0.0b1.dist-info/METADATA +430 -0
  1092. qiskit-1.0.0b1.dist-info/RECORD +1095 -0
  1093. qiskit-1.0.0b1.dist-info/WHEEL +6 -0
  1094. qiskit-1.0.0b1.dist-info/entry_points.txt +49 -0
  1095. qiskit-1.0.0b1.dist-info/top_level.txt +1 -0
qiskit/qpy/__init__.py ADDED
@@ -0,0 +1,1348 @@
1
+ # This code is part of Qiskit.
2
+ #
3
+ # (C) Copyright IBM 2021, 2022.
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
+ """
14
+ ###########################################################
15
+ QPY serialization (:mod:`qiskit.qpy`)
16
+ ###########################################################
17
+
18
+ .. currentmodule:: qiskit.qpy
19
+
20
+ QPY is a binary serialization format for :class:`~.QuantumCircuit` and
21
+ :class:`~.ScheduleBlock` objects that is designed to be cross-platform,
22
+ Python version agnostic, and backwards compatible moving forward. QPY should
23
+ be used if you need a mechanism to save or copy between systems a
24
+ :class:`~.QuantumCircuit` or :class:`~.ScheduleBlock` that preserves the full
25
+ Qiskit object structure (except for custom attributes defined outside of
26
+ Qiskit code). This differs from other serialization formats like
27
+ `OpenQASM <https://github.com/openqasm/openqasm>`__ (2.0 or 3.0) which has a
28
+ different abstraction model and can result in a loss of information contained
29
+ in the original circuit (or is unable to represent some aspects of the
30
+ Qiskit objects) or Python's `pickle <https://docs.python.org/3/library/pickle.html>`__
31
+ which will preserve the Qiskit object exactly but will only work for a single Qiskit
32
+ version (it is also
33
+ `potentially insecure <https://docs.python.org/3/library/pickle.html#module-pickle>`__).
34
+
35
+ *********
36
+ Using QPY
37
+ *********
38
+
39
+ Using QPY is defined to be straightforward and mirror the user API of the
40
+ serializers in Python's standard library, ``pickle`` and ``json``. There are
41
+ 2 user facing functions: :func:`qiskit.qpy.dump` and
42
+ :func:`qiskit.qpy.load` which are used to dump QPY data
43
+ to a file object and load circuits from QPY data in a file object respectively.
44
+ For example::
45
+
46
+ from qiskit.circuit import QuantumCircuit
47
+ from qiskit import qpy
48
+
49
+ qc = QuantumCircuit(2, name='Bell', metadata={'test': True})
50
+ qc.h(0)
51
+ qc.cx(0, 1)
52
+ qc.measure_all()
53
+
54
+ with open('bell.qpy', 'wb') as fd:
55
+ qpy.dump(qc, fd)
56
+
57
+ with open('bell.qpy', 'rb') as fd:
58
+ new_qc = qpy.load(fd)[0]
59
+
60
+ The :func:`qiskit.qpy.dump` function also lets you
61
+ include multiple circuits in a single QPY file::
62
+
63
+ with open('twenty_bells.qpy', 'wb') as fd:
64
+ qpy.dump([qc] * 20, fd)
65
+
66
+ and then loading that file will return a list with all the circuits
67
+
68
+ with open('twenty_bells.qpy', 'rb') as fd:
69
+ twenty_new_bells = qpy.load(fd)
70
+
71
+ API documentation
72
+ =================
73
+
74
+ .. autofunction:: load
75
+ .. autofunction:: dump
76
+
77
+ These functions will raise a custom subclass of :exc:`.QiskitError` if they encounter problems
78
+ during serialization or deserialization.
79
+
80
+ .. autoexception:: QpyError
81
+
82
+ QPY Compatibility
83
+ =================
84
+
85
+ The QPY format is designed to be backwards compatible moving forward. This means
86
+ you should be able to load a QPY with any newer Qiskit version than the one
87
+ that generated it. However, loading a QPY file with an older Qiskit version is
88
+ not supported and may not work.
89
+
90
+ For example, if you generated a QPY file using qiskit-terra 0.18.1 you could
91
+ load that QPY file with qiskit-terra 0.19.0 and a hypothetical qiskit-terra
92
+ 0.29.0. However, loading that QPY file with 0.18.0 is not supported and may not
93
+ work.
94
+
95
+ .. _qpy_format:
96
+
97
+ **********
98
+ QPY Format
99
+ **********
100
+
101
+ The QPY serialization format is a portable cross-platform binary
102
+ serialization format for :class:`~qiskit.circuit.QuantumCircuit` objects in Qiskit. The basic
103
+ file format is as follows:
104
+
105
+ A QPY file (or memory object) always starts with the following 6
106
+ byte UTF8 string: ``QISKIT`` which is immediately followed by the overall
107
+ file header. The contents of the file header as defined as a C struct are:
108
+
109
+ .. code-block:: c
110
+
111
+ struct {
112
+ uint8_t qpy_version;
113
+ uint8_t qiskit_major_version;
114
+ uint8_t qiskit_minor_version;
115
+ uint8_t qiskit_patch_version;
116
+ uint64_t num_circuits;
117
+ }
118
+
119
+
120
+ From V10 on, a new field is added to the file header struct to represent the
121
+ encoding scheme used for symbolic expressions:
122
+
123
+ .. code-block:: c
124
+
125
+ struct {
126
+ uint8_t qpy_version;
127
+ uint8_t qiskit_major_version;
128
+ uint8_t qiskit_minor_version;
129
+ uint8_t qiskit_patch_version;
130
+ uint64_t num_circuits;
131
+ char symbolic_encoding;
132
+ }
133
+
134
+ All values use network byte order [#f1]_ (big endian) for cross platform
135
+ compatibility.
136
+
137
+ The file header is immediately followed by the circuit payloads.
138
+ Each individual circuit is composed of the following parts:
139
+
140
+ ``HEADER | METADATA | REGISTERS | CUSTOM_DEFINITIONS | INSTRUCTIONS``
141
+
142
+ There is a circuit payload for each circuit (where the total number is dictated
143
+ by ``num_circuits`` in the file header). There is no padding between the
144
+ circuits in the data.
145
+
146
+ .. _qpy_version_10:
147
+
148
+ Version 10
149
+ ==========
150
+
151
+ Version 10 adds support for symengine-native serialization for objects of type
152
+ :class:`~.ParameterExpression` as well as symbolic expressions in Pulse schedule blocks. Version
153
+ 10 also adds support for new fields in the :class:`~.TranspileLayout` class added in the Qiskit
154
+ 0.45.0 release.
155
+
156
+ The symbolic_encoding field is added to the file header, and a new encoding type char
157
+ is introduced, mapped to each symbolic library as follows: ``p`` refers to sympy
158
+ encoding and ``e`` refers to symengine encoding.
159
+
160
+ FILE_HEADER
161
+ -----------
162
+
163
+ The contents of FILE_HEADER after V10 are defined as a C struct as:
164
+
165
+ .. code-block:: c
166
+
167
+ struct {
168
+ uint8_t qpy_version;
169
+ uint8_t qiskit_major_version;
170
+ uint8_t qiskit_minor_version;
171
+ uint8_t qiskit_patch_version;
172
+ uint64_t num_circuits;
173
+ char symbolic_encoding;
174
+ }
175
+
176
+ LAYOUT
177
+ ------
178
+
179
+ The ``LAYOUT`` struct is updated to have an additional ``input_qubit_count`` field.
180
+ With version 10 the ``LAYOUT`` struct is now:
181
+
182
+ .. code-block:: c
183
+
184
+ struct {
185
+ char exists;
186
+ int32_t initial_layout_size;
187
+ int32_t input_mapping_size;
188
+ int32_t final_layout_size;
189
+ uint32_t extra_registers;
190
+ int32_t input_qubit_count;
191
+ }
192
+
193
+ The rest of the layout data after the ``LAYOUT`` struct is represented as in previous versions. If
194
+ ``input qubit_count`` is < 0 that indicates that both ``_input_qubit_count``
195
+ and ``_output_qubit_list`` in the :class:`~.TranspileLayout` object are ``None``.
196
+
197
+ .. _qpy_version_9:
198
+
199
+ Version 9
200
+ =========
201
+
202
+ Version 9 adds support for classical :class:`~.expr.Expr` nodes and their associated
203
+ :class:`~.types.Type`\\ s.
204
+
205
+
206
+ EXPRESSION
207
+ ----------
208
+
209
+ An :class:`~.expr.Expr` node is represented by a stream of variable-width data. A node itself is
210
+ represented by (in order in the byte stream):
211
+
212
+ #. a one-byte type code discriminator;
213
+ #. an EXPR_TYPE object;
214
+ #. a type-code-specific additional payload;
215
+ #. a type-code-specific number of child EXPRESSION payloads (the number of these is implied by the
216
+ type code and not explicitly stored).
217
+
218
+ Each of these are described in the following table:
219
+
220
+ ====================== ========= ======================================================= ========
221
+ Qiskit class Type code Payload Children
222
+ ====================== ========= ======================================================= ========
223
+ :class:`~.expr.Var` ``x`` One EXPR_VAR. 0
224
+
225
+ :class:`~.expr.Value` ``v`` One EXPR_VALUE. 0
226
+
227
+ :class:`~.expr.Cast` ``c`` One ``_Bool`` that corresponds to the value of 1
228
+ ``implicit``.
229
+
230
+ :class:`~.expr.Unary` ``u`` One ``uint8_t`` with the same numeric value as the 1
231
+ :class:`.Unary.Op`.
232
+
233
+ :class:`~.expr.Binary` ``b`` One ``uint8_t`` with the same numeric value as the 2
234
+ :class:`.Binary.Op`.
235
+ ====================== ========= ======================================================= ========
236
+
237
+
238
+ EXPR_TYPE
239
+ ---------
240
+
241
+ A :class:`~.types.Type` is encoded by a single-byte ASCII ``char`` that encodes the kind of type,
242
+ followed by a payload that varies depending on the type. The defined codes are:
243
+
244
+ ====================== ========= =================================================================
245
+ Qiskit class Type code Payload
246
+ ====================== ========= =================================================================
247
+ :class:`~.types.Bool` ``b`` None.
248
+
249
+ :class:`~.types.Uint` ``u`` One ``uint32_t width``.
250
+ ====================== ========= =================================================================
251
+
252
+
253
+ EXPR_VAR
254
+ --------
255
+
256
+ This represents a runtime variable of a :class:`~.expr.Var` node. These are a type code, followed
257
+ by a type-code-specific payload:
258
+
259
+ =========================== ========= ============================================================
260
+ Python class Type code Payload
261
+ =========================== ========= ============================================================
262
+ :class:`.Clbit` ``C`` One ``uint32_t index`` that is the index of the
263
+ :class:`.Clbit` in the containing circuit.
264
+
265
+ :class:`.ClassicalRegister` ``R`` One ``uint16_t reg_name_size``, followed by that many bytes
266
+ of UTF-8 string data of the register name.
267
+ =========================== ========= ============================================================
268
+
269
+
270
+ EXPR_VALUE
271
+ ----------
272
+
273
+ This represents a literal object in the classical type system, such as an integer. Currently there
274
+ are very few such literals. These are encoded as a type code, followed by a type-code-specific
275
+ payload.
276
+
277
+ =========== ========= ============================================================================
278
+ Python type Type code Payload
279
+ =========== ========= ============================================================================
280
+ ``bool`` ``b`` One ``_Bool value``.
281
+
282
+ ``int`` ``i`` One ``uint8_t num_bytes``, followed by the integer encoded into that many
283
+ many bytes (network order) in a two's complement representation.
284
+ =========== ========= ============================================================================
285
+
286
+
287
+
288
+ Changes to INSTRUCTION
289
+ ----------------------
290
+
291
+ To support the use of :class:`~.expr.Expr` nodes in the fields :attr:`.IfElseOp.condition`,
292
+ :attr:`.WhileLoopOp.condition` and :attr:`.SwitchCaseOp.target`, the INSTRUCTION struct is changed
293
+ in an ABI compatible-manner to :ref:`its previous definition <qpy_instruction_v5>`. The new struct
294
+ is the C struct:
295
+
296
+ .. code-block:: c
297
+
298
+ struct {
299
+ uint16_t name_size;
300
+ uint16_t label_size;
301
+ uint16_t num_parameters;
302
+ uint32_t num_qargs;
303
+ uint32_t num_cargs;
304
+ uint8_t conditional_key;
305
+ uint16_t conditional_reg_name_size;
306
+ int64_t conditional_value;
307
+ uint32_t num_ctrl_qubits;
308
+ uint32_t ctrl_state;
309
+ }
310
+
311
+ where the only change is that a ``uint8_t conditional_key`` entry has replaced ``_Bool
312
+ has_conditional``. This new ``conditional_key`` takes the following numeric values, with these
313
+ effects:
314
+
315
+ ===== =============================================================================================
316
+ Value Effects
317
+ ===== =============================================================================================
318
+ 0 The instruction has its ``.condition`` field set to ``None``. The
319
+ ``conditional_reg_name_size`` and ``conditional_value`` fields should be ignored.
320
+
321
+ 1 The instruction has its ``.condition`` field set to a 2-tuple of either a :class:`.Clbit`
322
+ or a :class:`.ClassicalRegister`, and a integer of value ``conditional_value``. The
323
+ INSTRUCTION payload, including its trailing data is parsed exactly as it would be in QPY
324
+ versions less than 8.
325
+
326
+ 2 The instruction has its ``.condition`` field set to a :class:`~.expr.Expr` node. The
327
+ ``conditional_reg_name_size`` and ``conditional_value`` fields should be ignored. The data
328
+ following the struct is followed (as in QPY versions less than 8) by ``name_size`` bytes of
329
+ UTF-8 string data for the class name and ``label_size`` bytes of UTF-8 string data for the
330
+ label (if any). Then, there is one INSTRUCTION_PARAM, which will contain an EXPRESSION. After
331
+ that, parsing continues with the INSTRUCTION_ARG structs, as in previous versions of QPY.
332
+ ===== =============================================================================================
333
+
334
+
335
+ Changes to INSTRUCTION_PARAM
336
+ ----------------------------
337
+
338
+ A new type code ``x`` is added that defines an EXPRESSION parameter.
339
+
340
+
341
+ .. _qpy_version_8:
342
+
343
+ Version 8
344
+ =========
345
+
346
+ Version 8 adds support for handling a :class:`~.TranspileLayout` stored in the
347
+ :attr:`.QuantumCircuit.layout` attribute. In version 8 immediately following the
348
+ calibrations block at the end of the circuit payload there is now the
349
+ ``LAYOUT`` struct. This struct outlines the size of the three attributes of a
350
+ :class:`~.TranspileLayout` class.
351
+
352
+ LAYOUT
353
+ ------
354
+
355
+ .. code-block:: c
356
+
357
+ struct {
358
+ char exists;
359
+ int32_t initial_layout_size;
360
+ int32_t input_mapping_size;
361
+ int32_t final_layout_size;
362
+ uint32_t extra_registers;
363
+ }
364
+
365
+ If any of the signed values are ``-1`` this indicates the corresponding
366
+ attribute is ``None``.
367
+
368
+ Immediately following the ``LAYOUT`` struct there is a :ref:`qpy_registers` struct
369
+ for ``extra_registers`` (specifically the format introduced in :ref:`qpy_version_4`)
370
+ standalone register definitions that aren't present in the circuit. Then there
371
+ are ``initial_layout_size`` ``INITIAL_LAYOUT_BIT`` structs to define the
372
+ :attr:`.TranspileLayout.initial_layout` attribute.
373
+
374
+ INITIAL_LAYOUT_BIT
375
+ ------------------
376
+
377
+ .. code-block:: c
378
+
379
+ struct {
380
+ int32_t index;
381
+ int32_t register_size;
382
+ }
383
+
384
+ Where a value of ``-1`` indicates ``None`` (as in no register is associated
385
+ with the bit). Following each ``INITIAL_LAYOUT_BIT`` struct is ``register_size``
386
+ bytes for a ``utf8`` encoded string for the register name.
387
+
388
+ Following the initial layout there is ``input_mapping_size`` array of
389
+ ``uint32_t`` integers representing the positions of the physical bit from the
390
+ initial layout. This enables constructing a list of virtual bits where the
391
+ array index is its input mapping position.
392
+
393
+ Finally, there is an array of ``final_layout_size`` ``uint32_t`` integers. Each
394
+ element is an index in the circuit's ``qubits`` attribute which enables building
395
+ a mapping from qubit starting position to the output position at the end of the
396
+ circuit.
397
+
398
+ .. _qpy_version_7:
399
+
400
+ Version 7
401
+ =========
402
+
403
+ Version 7 adds support for :class:`.~Reference` instruction and serialization of
404
+ a :class:`.~ScheduleBlock` program while keeping its reference to subroutines::
405
+
406
+ from qiskit import pulse
407
+ from qiskit import qpy
408
+
409
+ with pulse.build() as schedule:
410
+ pulse.reference("cr45p", "q0", "q1")
411
+ pulse.reference("x", "q0")
412
+ pulse.reference("cr45p", "q0", "q1")
413
+
414
+ with open('template_ecr.qpy', 'wb') as fd:
415
+ qpy.dump(schedule, fd)
416
+
417
+ The conventional :ref:`qpy_schedule_block` data model is preserved, but in
418
+ version 7 it is immediately followed by an extra :ref:`qpy_mapping` utf8 bytes block
419
+ representing the data of the referenced subroutines.
420
+
421
+ New type key character is added to the :ref:`qpy_schedule_instructions` group
422
+ for the :class:`.~Reference` instruction.
423
+
424
+ - ``y``: :class:`~qiskit.pulse.instructions.Reference` instruction
425
+
426
+ New type key character is added to the :ref:`qpy_schedule_operands` group
427
+ for the operands of :class:`.~Reference` instruction,
428
+ which is a tuple of strings, e.g. ("cr45p", "q0", "q1").
429
+
430
+ - ``o``: string (operand string)
431
+
432
+ Note that this is the same encoding with the built-in Python string, however,
433
+ the standard value encoding in QPY uses ``s`` type character for string data,
434
+ which conflicts with the :class:`~qiskit.pulse.library.SymbolicPulse` in the scope of
435
+ pulse instruction operands. A special type character ``o`` is reserved for
436
+ the string data that appears in the pulse instruction operands.
437
+
438
+ In addition, version 7 adds two new type keys to the INSTRUCTION_PARM struct. ``"d"`` is followed
439
+ by no data and represents the literal value :data:`.CASE_DEFAULT` for switch-statement support.
440
+ ``"R"`` represents a :class:`.ClassicalRegister` or :class:`.Clbit`, and is followed by the same
441
+ format as the description of register or classical bit as used in the first element of :ref:`the
442
+ condition of an INSTRUCTION field <qpy_instructions>`.
443
+
444
+ .. _qpy_version_6:
445
+
446
+ Version 6
447
+ =========
448
+
449
+ Version 6 adds support for :class:`.~ScalableSymbolicPulse`. These objects are saved and read
450
+ like `SymbolicPulse` objects, and the class name is added to the data to correctly handle
451
+ the class selection.
452
+
453
+ `SymbolicPulse` block now starts with SYMBOLIC_PULSE_V2 header:
454
+
455
+ .. code-block:: c
456
+
457
+ struct {
458
+ uint16_t class_name_size;
459
+ uint16_t type_size;
460
+ uint16_t envelope_size;
461
+ uint16_t constraints_size;
462
+ uint16_t valid_amp_conditions_size;
463
+ _bool amp_limited;
464
+ }
465
+
466
+ The only change compared to :ref:`qpy_version_5` is the addition of `class_name_size`. The header
467
+ is then immediately followed by ``class_name_size`` utf8 bytes with the name of the class. Currently,
468
+ either `SymbolicPulse` or `ScalableSymbolicPulse` are supported. The rest of the data is then
469
+ identical to :ref:`qpy_version_5`.
470
+
471
+ .. _qpy_version_5:
472
+
473
+ Version 5
474
+ =========
475
+
476
+ Version 5 changes from :ref:`qpy_version_4` by adding support for :class:`.~ScheduleBlock`
477
+ and changing two payloads the INSTRUCTION metadata payload and the CUSTOM_INSTRUCTION block.
478
+ These now have new fields to better account for :class:`~.ControlledGate` objects in a circuit.
479
+ In addition, new payload MAP_ITEM is defined to implement the :ref:`qpy_mapping` block.
480
+
481
+ With the support of :class:`.~ScheduleBlock`, now :class:`~.QuantumCircuit` can be
482
+ serialized together with :attr:`~.QuantumCircuit.calibrations`, or
483
+ `Pulse Gates <https://docs.quantum-computing.ibm.com/build/pulse>`_.
484
+ In QPY version 5 and above, :ref:`qpy_circuit_calibrations` payload is
485
+ packed after the :ref:`qpy_instructions` block.
486
+
487
+ In QPY version 5 and above,
488
+
489
+ .. code-block:: c
490
+
491
+ struct {
492
+ char type;
493
+ }
494
+
495
+ immediately follows the file header block to represent the program type stored in the file.
496
+
497
+ - When ``type==c``, :class:`~.QuantumCircuit` payload follows
498
+ - When ``type==s``, :class:`~.ScheduleBlock` payload follows
499
+
500
+ .. note::
501
+
502
+ Different programs cannot be packed together in the same file.
503
+ You must create different files for different program types.
504
+ Multiple objects with the same type can be saved in a single file.
505
+
506
+ .. _qpy_schedule_block:
507
+
508
+ SCHEDULE_BLOCK
509
+ --------------
510
+
511
+ :class:`~.ScheduleBlock` is first supported in QPY Version 5. This allows
512
+ users to save pulse programs in the QPY binary format as follows:
513
+
514
+ .. code-block:: python
515
+
516
+ from qiskit import pulse, qpy
517
+
518
+ with pulse.build() as schedule:
519
+ pulse.play(pulse.Gaussian(160, 0.1, 40), pulse.DriveChannel(0))
520
+
521
+ with open('schedule.qpy', 'wb') as fd:
522
+ qpy.dump(qc, fd)
523
+
524
+ with open('schedule.qpy', 'rb') as fd:
525
+ new_qc = qpy.load(fd)[0]
526
+
527
+ Note that circuit and schedule block are serialized and deserialized through
528
+ the same QPY interface. Input data type is implicitly analyzed and
529
+ no extra option is required to save the schedule block.
530
+
531
+ .. _qpy_schedule_block_header:
532
+
533
+ SCHEDULE_BLOCK_HEADER
534
+ ---------------------
535
+
536
+ :class:`~.ScheduleBlock` block starts with the following header:
537
+
538
+ .. code-block:: c
539
+
540
+ struct {
541
+ uint16_t name_size;
542
+ uint64_t metadata_size;
543
+ uint16_t num_element;
544
+ }
545
+
546
+ which is immediately followed by ``name_size`` utf8 bytes of schedule name and
547
+ ``metadata_size`` utf8 bytes of the JSON serialized metadata dictionary
548
+ attached to the schedule.
549
+
550
+ .. _qpy_schedule_alignments:
551
+
552
+ SCHEDULE_BLOCK_ALIGNMENTS
553
+ -------------------------
554
+
555
+ Then, alignment context of the schedule block starts with ``char``
556
+ representing the supported context type followed by the :ref:`qpy_sequence` block representing
557
+ the parameters associated with the alignment context :attr:`AlignmentKind._context_params`.
558
+ The context type char is mapped to each alignment subclass as follows:
559
+
560
+ - ``l``: :class:`~.AlignLeft`
561
+ - ``r``: :class:`~.AlignRight`
562
+ - ``s``: :class:`~.AlignSequential`
563
+ - ``e``: :class:`~.AlignEquispaced`
564
+
565
+ Note that :class:`~.AlignFunc` context is not supported because of the callback function
566
+ stored in the context parameters.
567
+
568
+ .. _qpy_schedule_instructions:
569
+
570
+ SCHEDULE_BLOCK_INSTRUCTIONS
571
+ ---------------------------
572
+
573
+ This alignment block is further followed by ``num_element`` length of block elements which may
574
+ consist of nested schedule blocks and schedule instructions.
575
+ Each schedule instruction starts with ``char`` representing the instruction type
576
+ followed by the :ref:`qpy_sequence` block representing the instruction
577
+ :attr:`~qiskit.pulse.instructions.Instruction.operands`.
578
+ Note that the data structure of pulse :class:`~qiskit.pulse.instructions.Instruction`
579
+ is unified so that instance can be uniquely determined by the class and a tuple of operands.
580
+ The mapping of type char to the instruction subclass is defined as follows:
581
+
582
+ - ``a``: :class:`~qiskit.pulse.instructions.Acquire` instruction
583
+ - ``p``: :class:`~qiskit.pulse.instructions.Play` instruction
584
+ - ``d``: :class:`~qiskit.pulse.instructions.Delay` instruction
585
+ - ``f``: :class:`~qiskit.pulse.instructions.SetFrequency` instruction
586
+ - ``g``: :class:`~qiskit.pulse.instructions.ShiftFrequency` instruction
587
+ - ``q``: :class:`~qiskit.pulse.instructions.SetPhase` instruction
588
+ - ``r``: :class:`~qiskit.pulse.instructions.ShiftPhase` instruction
589
+ - ``b``: :class:`~qiskit.pulse.instructions.RelativeBarrier` instruction
590
+ - ``t``: :class:`~qiskit.pulse.instructions.TimeBlockade` instruction
591
+ - ``y``: :class:`~qiskit.pulse.instructions.Reference` instruction (new in version 0.7)
592
+
593
+ .. _qpy_schedule_operands:
594
+
595
+ SCHEDULE_BLOCK_OPERANDS
596
+ -----------------------
597
+
598
+ The operands of these instances can be serialized through the standard QPY value serialization
599
+ mechanism, however there are special object types that only appear in the schedule operands.
600
+ Since the operands are serialized as :ref:`qpy_sequence`, each element must be packed with the
601
+ INSTRUCTION_PARAM pack struct, where each payload starts with a header block consists of
602
+ the char ``type`` and uint64_t ``size``.
603
+ Special objects start with the following type key:
604
+
605
+ - ``c``: :class:`~qiskit.pulse.channels.Channel`
606
+ - ``w``: :class:`~qiskit.pulse.library.Waveform`
607
+ - ``s``: :class:`~qiskit.pulse.library.SymbolicPulse`
608
+ - ``o``: string (operand string, new in version 0.7)
609
+
610
+ .. _qpy_schedule_channel:
611
+
612
+ CHANNEL
613
+ -------
614
+
615
+ Channel block starts with channel subtype ``char`` that maps an object data to
616
+ :class:`~qiskit.pulse.channels.Channel` subclass. Mapping is defined as follows:
617
+
618
+ - ``d``: :class:`~qiskit.pulse.channels.DriveChannel`
619
+ - ``c``: :class:`~qiskit.pulse.channels.ControlChannel`
620
+ - ``m``: :class:`~qiskit.pulse.channels.MeasureChannel`
621
+ - ``a``: :class:`~qiskit.pulse.channels.AcquireChannel`
622
+ - ``e``: :class:`~qiskit.pulse.channels.MemorySlot`
623
+ - ``r``: :class:`~qiskit.pulse.channels.RegisterSlot`
624
+
625
+ The key is immediately followed by the channel index serialized as the INSTRUCTION_PARAM.
626
+
627
+ .. _qpy_schedule_waveform:
628
+
629
+ Waveform
630
+ --------
631
+
632
+ Waveform block starts with WAVEFORM header:
633
+
634
+ .. code-block:: c
635
+
636
+ struct {
637
+ double epsilon;
638
+ uint32_t data_size;
639
+ _bool amp_limited;
640
+ }
641
+
642
+ which is followed by ``data_size`` bytes of complex ``ndarray`` binary generated by numpy.save_.
643
+ This represents the complex IQ data points played on a quantum device.
644
+ :attr:`~qiskit.pulse.library.Waveform.name` is saved after the samples in the
645
+ INSTRUCTION_PARAM pack struct, which can be string or ``None``.
646
+
647
+ .. _numpy.save: https://numpy.org/doc/stable/reference/generated/numpy.save.html
648
+
649
+ .. _qpy_schedule_symbolic_pulse:
650
+
651
+ SymbolicPulse
652
+ -------------
653
+
654
+ SymbolicPulse block starts with SYMBOLIC_PULSE header:
655
+
656
+ .. code-block:: c
657
+
658
+ struct {
659
+ uint16_t type_size;
660
+ uint16_t envelope_size;
661
+ uint16_t constraints_size;
662
+ uint16_t valid_amp_conditions_size;
663
+ _bool amp_limited;
664
+ }
665
+
666
+ which is followed by ``type_size`` utf8 bytes of :attr:`.SymbolicPulse.pulse_type` string
667
+ that represents a class of waveform, such as "Gaussian" or "GaussianSquare".
668
+ Then, ``envelope_size``, ``constraints_size``, ``valid_amp_conditions_size`` utf8 bytes of
669
+ serialized symbolic expressions are generated for :attr:`.SymbolicPulse.envelope`,
670
+ :attr:`.SymbolicPulse.constraints`, and :attr:`.SymbolicPulse.valid_amp_conditions`, respectively.
671
+ Since string representation of these expressions are usually lengthy,
672
+ the expression binary is generated by the python zlib_ module with data compression.
673
+
674
+ To uniquely specify a pulse instance, we also need to store the associated parameters,
675
+ which consist of ``duration`` and the rest of parameters as a dictionary.
676
+ Dictionary parameters are first dumped in the :ref:`qpy_mapping` form, and then ``duration``
677
+ is dumped with the INSTRUCTION_PARAM pack struct.
678
+ Lastly, :attr:`~qiskit.pulse.library.SymbolicPulse.name` is saved also with the
679
+ INSTRUCTION_PARAM pack struct, which can be string or ``None``.
680
+
681
+ .. _zlib: https://docs.python.org/3/library/zlib.html
682
+
683
+ .. _qpy_mapping:
684
+
685
+ MAPPING
686
+ -------
687
+
688
+ The MAPPING is a representation for arbitrary mapping object. This is a fixed length
689
+ :ref:`qpy_sequence` of key-value pair represented by the MAP_ITEM payload.
690
+
691
+ A MAP_ITEM starts with a header defined as:
692
+
693
+ .. code-block:: c
694
+
695
+ struct {
696
+ uint16_t key_size;
697
+ char type;
698
+ uint16_t size;
699
+ }
700
+
701
+ which is immediately followed by the ``key_size`` utf8 bytes representing
702
+ the dictionary key in string and ``size`` utf8 bytes of arbitrary object data of
703
+ QPY serializable ``type``.
704
+
705
+ .. _qpy_circuit_calibrations:
706
+
707
+ CIRCUIT_CALIBRATIONS
708
+ --------------------
709
+
710
+ The CIRCUIT_CALIBRATIONS block is a dictionary to define pulse calibrations of the custom
711
+ instruction set. This block starts with the following CALIBRATION header:
712
+
713
+ .. code-block:: c
714
+
715
+ struct {
716
+ uint16_t num_cals;
717
+ }
718
+
719
+ which is followed by the ``num_cals`` length of calibration entries, each starts with
720
+ the CALIBRATION_DEF header:
721
+
722
+ .. code-block:: c
723
+
724
+ struct {
725
+ uint16_t name_size;
726
+ uint16_t num_qubits;
727
+ uint16_t num_params;
728
+ char type;
729
+ }
730
+
731
+ The calibration definition header is then followed by ``name_size`` utf8 bytes of
732
+ the gate name, ``num_qubits`` length of integers representing a sequence of qubits,
733
+ and ``num_params`` length of INSTRUCTION_PARAM payload for parameters
734
+ associated to the custom instruction.
735
+ The ``type`` indicates the class of pulse program which is either, in principle,
736
+ :class:`~.ScheduleBlock` or :class:`~.Schedule`. As of QPY Version 5,
737
+ only :class:`~.ScheduleBlock` payload is supported.
738
+ Finally, :ref:`qpy_schedule_block` payload is packed for each CALIBRATION_DEF entry.
739
+
740
+ .. _qpy_instruction_v5:
741
+
742
+ INSTRUCTION
743
+ -----------
744
+
745
+ The INSTRUCTION block was modified to add two new fields ``num_ctrl_qubits`` and ``ctrl_state``
746
+ which are used to model the :attr:`.ControlledGate.num_ctrl_qubits` and
747
+ :attr:`.ControlledGate.ctrl_state` attributes. The new payload packed struct
748
+ format is:
749
+
750
+ .. code-block:: c
751
+
752
+ struct {
753
+ uint16_t name_size;
754
+ uint16_t label_size;
755
+ uint16_t num_parameters;
756
+ uint32_t num_qargs;
757
+ uint32_t num_cargs;
758
+ _Bool has_conditional;
759
+ uint16_t conditional_reg_name_size;
760
+ int64_t conditional_value;
761
+ uint32_t num_ctrl_qubits;
762
+ uint32_t ctrl_state;
763
+ }
764
+
765
+ The rest of the instruction payload is the same. You can refer to
766
+ :ref:`qpy_instructions` for the details of the full payload.
767
+
768
+ CUSTOM_INSTRUCTION
769
+ ------------------
770
+
771
+ The CUSTOM_INSTRUCTION block in QPY version 5 adds a new field
772
+ ``base_gate_size`` which is used to define the size of the
773
+ :class:`qiskit.circuit.Instruction` object stored in the
774
+ :attr:`.ControlledGate.base_gate` attribute for a custom
775
+ :class:`~.ControlledGate` object. With this change the CUSTOM_INSTRUCTION
776
+ metadata block becomes:
777
+
778
+ .. code-block:: c
779
+
780
+ struct {
781
+ uint16_t name_size;
782
+ char type;
783
+ uint32_t num_qubits;
784
+ uint32_t num_clbits;
785
+ _Bool custom_definition;
786
+ uint64_t size;
787
+ uint32_t num_ctrl_qubits;
788
+ uint32_t ctrl_state;
789
+ uint64_t base_gate_size
790
+ }
791
+
792
+ Immediately following the CUSTOM_INSTRUCTION struct is the utf8 encoded name
793
+ of size ``name_size``.
794
+
795
+ If ``custom_definition`` is ``True`` that means that the immediately following
796
+ ``size`` bytes contains a QPY circuit data which can be used for the custom
797
+ definition of that gate. If ``custom_definition`` is ``False`` then the
798
+ instruction can be considered opaque (ie no definition). The ``type`` field
799
+ determines what type of object will get created with the custom definition.
800
+ If it's ``'g'`` it will be a :class:`~qiskit.circuit.Gate` object, ``'i'``
801
+ it will be a :class:`~qiskit.circuit.Instruction` object.
802
+
803
+ Following this the next ``base_gate_size`` bytes contain the ``INSTRUCTION``
804
+ payload for the :attr:`.ControlledGate.base_gate`.
805
+
806
+ Additionally an addition value for ``type`` is added ``'c'`` which is used to
807
+ indicate the custom instruction is a custom :class:`~.ControlledGate`.
808
+
809
+ .. _qpy_version_4:
810
+
811
+ Version 4
812
+ =========
813
+
814
+ Version 4 is identical to :ref:`qpy_version_3` except that it adds 2 new type strings
815
+ to the INSTRUCTION_PARAM struct, ``z`` to represent ``None`` (which is encoded as
816
+ no data), ``q`` to represent a :class:`.QuantumCircuit` (which is encoded as
817
+ a QPY circuit), ``r`` to represent a ``range`` of integers (which is encoded as
818
+ a :ref:`qpy_range_pack`), and ``t`` to represent a ``sequence`` (which is encoded as
819
+ defined by :ref:`qpy_sequence`). Additionally, version 4 changes the type of register
820
+ index mapping array from ``uint32_t`` to ``int64_t``. If the values of any of the
821
+ array elements are negative they represent a register bit that is not present in the
822
+ circuit.
823
+
824
+ The :ref:`qpy_registers` header format has also been updated to
825
+
826
+ .. code-block:: c
827
+
828
+ struct {
829
+ char type;
830
+ _Bool standalone;
831
+ uint32_t size;
832
+ uint16_t name_size;
833
+ _bool in_circuit;
834
+ }
835
+
836
+ which just adds the ``in_circuit`` field which represents whether the register is
837
+ part of the circuit or not.
838
+
839
+ .. _qpy_range_pack:
840
+
841
+ RANGE
842
+ -----
843
+
844
+ A RANGE is a representation of a ``range`` object. It is defined as:
845
+
846
+ .. code-block:: c
847
+
848
+ struct {
849
+ int64_t start;
850
+ int64_t stop;
851
+ int64_t step;
852
+ }
853
+
854
+ .. _qpy_sequence:
855
+
856
+ SEQUENCE
857
+ --------
858
+
859
+ A SEQUENCE is a representation of an arbitrary sequence object. As sequence are just fixed length
860
+ containers of arbitrary python objects their QPY can't fully represent any sequence,
861
+ but as long as the contents in a sequence are other QPY serializable types for
862
+ the INSTRUCTION_PARAM payload the ``sequence`` object can be serialized.
863
+
864
+ A sequence instruction parameter starts with a header defined as:
865
+
866
+ .. code-block:: c
867
+
868
+ struct {
869
+ uint64_t size;
870
+ }
871
+
872
+ followed by ``size`` elements that are INSTRUCTION_PARAM payloads, where each of
873
+ these define an element in the sequence. The sequence object will be typecasted
874
+ into proper type, e.g. ``tuple``, afterwards.
875
+
876
+ .. _qpy_version_3:
877
+
878
+ Version 3
879
+ =========
880
+
881
+ Version 3 of the QPY format is identical to :ref:`qpy_version_2` except that it defines
882
+ a struct format to represent a :class:`~qiskit.circuit.library.PauliEvolutionGate`
883
+ natively in QPY. To accomplish this the :ref:`qpy_custom_definition` struct now supports
884
+ a new type value ``'p'`` to represent a :class:`~qiskit.circuit.library.PauliEvolutionGate`.
885
+ Enties in the custom instructions tables have unique name generated that start with the
886
+ string ``"###PauliEvolutionGate_"`` followed by a uuid string. This gate name is reservered
887
+ in QPY and if you have a custom :class:`~qiskit.circuit.Instruction` object with a definition
888
+ set and that name prefix it will error. If it's of type ``'p'`` the data payload is defined
889
+ as follows:
890
+
891
+ .. _pauli_evo_qpy:
892
+
893
+ PAULI_EVOLUTION
894
+ ---------------
895
+
896
+ This represents the high level :class:`~qiskit.circuit.library.PauliEvolutionGate`
897
+
898
+ .. code-block:: c
899
+
900
+ struct {
901
+ uint64_t operator_count;
902
+ _Bool standalone_op;
903
+ char time_type;
904
+ uint64_t time_size;
905
+ uint64_t synthesis_size;
906
+ }
907
+
908
+ This is immediately followed by ``operator_count`` elements defined by the :ref:`qpy_pauli_sum_op`
909
+ payload. Following that we have ``time_size`` bytes representing the ``time`` attribute. If
910
+ ``standalone_op`` is ``True`` then there must only be a single operator. The
911
+ encoding of these bytes is determined by the value of ``time_type``. Possible values of
912
+ ``time_type`` are ``'f'``, ``'p'``, and ``'e'``. If ``time_type`` is ``'f'`` it's a double,
913
+ ``'p'`` defines a :class:`~qiskit.circuit.Parameter` object which is represented by a
914
+ :ref:`qpy_param_struct`, ``e`` defines a :class:`~qiskit.circuit.ParameterExpression` object
915
+ (that's not a :class:`~qiskit.circuit.Parameter`) which is represented by a :ref:`qpy_param_expr`.
916
+ Following that is ``synthesis_size`` bytes which is a utf8 encoded json payload representing
917
+ the :class:`.EvolutionSynthesis` class used by the gate.
918
+
919
+ .. _qpy_pauli_sum_op:
920
+
921
+ SPARSE_PAULI_OP_LIST_ELEM
922
+ -------------------------
923
+
924
+ This represents an instance of :class:`.SparsePauliOp`.
925
+
926
+
927
+ .. code-block:: c
928
+
929
+ struct {
930
+ uint32_t pauli_op_size;
931
+ }
932
+
933
+ which is immediately followed by ``pauli_op_size`` bytes which are .npy format [#f2]_
934
+ data which represents the :class:`~qiskit.quantum_info.SparsePauliOp`.
935
+
936
+ Version 3 of the QPY format also defines a struct format to represent a
937
+ :class:`~qiskit.circuit.ParameterVectorElement` as a distinct subclass from
938
+ a :class:`~qiskit.circuit.Parameter`. This adds a new parameter type char ``'v'``
939
+ to represent a :class:`~qiskit.circuit.ParameterVectorElement` which is now
940
+ supported as a type string value for an INSTRUCTION_PARAM. The payload for these
941
+ parameters are defined below as :ref:`qpy_param_vector`.
942
+
943
+ .. _qpy_param_vector:
944
+
945
+ PARAMETER_VECTOR_ELEMENT
946
+ ------------------------
947
+
948
+ A PARAMETER_VECTOR_ELEMENT represents a :class:`~qiskit.circuit.ParameterVectorElement`
949
+ object the data for a INSTRUCTION_PARAM. The contents of the PARAMETER_VECTOR_ELEMENT are
950
+ defined as:
951
+
952
+ .. code-block:: c
953
+
954
+ struct {
955
+ uint16_t vector_name_size;
956
+ uint64_t vector_size;
957
+ char uuid[16];
958
+ uint64_t index;
959
+ }
960
+
961
+ which is immediately followed by ``vector_name_size`` utf8 bytes representing
962
+ the parameter's vector name.
963
+
964
+ .. _qpy_param_expr_v3:
965
+
966
+
967
+ PARAMETER_EXPR
968
+ --------------
969
+
970
+ Additionally, since QPY format version v3 distinguishes between a
971
+ :class:`~qiskit.circuit.Parameter` and :class:`~qiskit.circuit.ParameterVectorElement`
972
+ the payload for a :class:`~qiskit.circuit.ParameterExpression` needs to be updated
973
+ to distinguish between the types. The following is the modified payload format
974
+ which is mostly identical to the format in Version 1 and :ref:`qpy_version_2` but just
975
+ modifies the ``map_elements`` struct to include a symbol type field.
976
+
977
+ A PARAMETER_EXPR represents a :class:`~qiskit.circuit.ParameterExpression`
978
+ object that the data for an INSTRUCTION_PARAM. The contents of a PARAMETER_EXPR
979
+ are defined as:
980
+
981
+ .. code-block:: c
982
+
983
+ struct {
984
+ uint64_t map_elements;
985
+ uint64_t expr_size;
986
+ }
987
+
988
+ Immediately following the header is ``expr_size`` bytes of utf8 data containing
989
+ the expression string, which is the sympy srepr of the expression for the
990
+ parameter expression. Following that is a symbol map which contains
991
+ ``map_elements`` elements with the format
992
+
993
+ .. code-block:: c
994
+
995
+ struct {
996
+ char symbol_type;
997
+ char type;
998
+ uint64_t size;
999
+ }
1000
+
1001
+ The ``symbol_type`` key determines the payload type of the symbol representation
1002
+ for the element. If it's ``p`` it represents a :class:`~qiskit.circuit.Parameter`
1003
+ and if it's ``v`` it represents a :class:`~qiskit.circuit.ParameterVectorElement`.
1004
+ The map element struct is immediately followed by the symbol map key payload, if
1005
+ ``symbol_type`` is ``p`` then it is followed immediately by a :ref:`qpy_param_struct`
1006
+ object (both the struct and utf8 name bytes) and if ``symbol_type`` is ``v``
1007
+ then the struct is imediately followed by :ref:`qpy_param_vector` (both the struct
1008
+ and utf8 name bytes). That is followed by ``size`` bytes for the
1009
+ data of the symbol. The data format is dependent on the value of ``type``. If
1010
+ ``type`` is ``p`` then it represents a :class:`~qiskit.circuit.Parameter` and
1011
+ size will be 0, the value will just be the same as the key. Similarly if the
1012
+ ``type`` is ``v`` then it represents a :class:`~qiskit.circuit.ParameterVectorElement`
1013
+ and size will be 0 as the value will just be the same as the key. If
1014
+ ``type`` is ``f`` then it represents a double precision float. If ``type`` is
1015
+ ``c`` it represents a double precision complex, which is represented by the
1016
+ :ref:`qpy_complex`. Finally, if type is ``i`` it represents an integer which is an
1017
+ ``int64_t``.
1018
+
1019
+ .. _qpy_version_2:
1020
+
1021
+ Version 2
1022
+ =========
1023
+
1024
+ Version 2 of the QPY format is identical to version 1 except for the HEADER
1025
+ section is slightly different. You can refer to the :ref:`qpy_version_1` section
1026
+ for the details on the rest of the payload format.
1027
+
1028
+ HEADER
1029
+ ------
1030
+
1031
+ The contents of HEADER are defined as a C struct are:
1032
+
1033
+ .. code-block:: c
1034
+
1035
+ struct {
1036
+ uint16_t name_size;
1037
+ char global_phase_type;
1038
+ uint16_t global_phase_size;
1039
+ uint32_t num_qubits;
1040
+ uint32_t num_clbits;
1041
+ uint64_t metadata_size;
1042
+ uint32_t num_registers;
1043
+ uint64_t num_instructions;
1044
+ uint64_t num_custom_gates;
1045
+ }
1046
+
1047
+ This is immediately followed by ``name_size`` bytes of utf8 data for the name
1048
+ of the circuit. Following this is immediately ``global_phase_size`` bytes
1049
+ representing the global phase. The content of that data is dictated by the
1050
+ value of ``global_phase_type``. If it's ``'f'`` the data is a float and is the
1051
+ size of a ``double``. If it's ``'p'`` defines a :class:`~qiskit.circuit.Parameter`
1052
+ object which is represented by a PARAM struct (see below), ``e`` defines a
1053
+ :class:`~qiskit.circuit.ParameterExpression` object (that's not a
1054
+ :class:`~qiskit.circuit.Parameter`) which is represented by a PARAM_EXPR struct
1055
+ (see below).
1056
+
1057
+ .. _qpy_version_1:
1058
+
1059
+ Version 1
1060
+ =========
1061
+
1062
+ HEADER
1063
+ ------
1064
+
1065
+ The contents of HEADER as defined as a C struct are:
1066
+
1067
+ .. code-block:: c
1068
+
1069
+ struct {
1070
+ uint16_t name_size;
1071
+ double global_phase;
1072
+ uint32_t num_qubits;
1073
+ uint32_t num_clbits;
1074
+ uint64_t metadata_size;
1075
+ uint32_t num_registers;
1076
+ uint64_t num_instructions;
1077
+ uint64_t num_custom_gates;
1078
+ }
1079
+
1080
+ This is immediately followed by ``name_size`` bytes of utf8 data for the name
1081
+ of the circuit.
1082
+
1083
+ METADATA
1084
+ --------
1085
+
1086
+ The METADATA field is a UTF8 encoded JSON string. After reading the HEADER
1087
+ (which is a fixed size at the start of the QPY file) and the ``name`` string
1088
+ you then read the ``metadata_size`` number of bytes and parse the JSON to get
1089
+ the metadata for the circuit.
1090
+
1091
+ .. _qpy_registers:
1092
+
1093
+ REGISTERS
1094
+ ---------
1095
+
1096
+ The contents of REGISTERS is a number of REGISTER object. If num_registers is
1097
+ > 0 then after reading METADATA you read that number of REGISTER structs defined
1098
+ as:
1099
+
1100
+ .. code-block:: c
1101
+
1102
+ struct {
1103
+ char type;
1104
+ _Bool standalone;
1105
+ uint32_t size;
1106
+ uint16_t name_size;
1107
+ }
1108
+
1109
+ ``type`` can be ``'q'`` or ``'c'``.
1110
+
1111
+ Immediately following the REGISTER struct is the utf8 encoded register name of
1112
+ size ``name_size``. After the ``name`` utf8 bytes there is then an array of
1113
+ int64_t values of size ``size`` that contains a map of the register's index to
1114
+ the circuit's qubit index. For example, array element 0's value is the index
1115
+ of the ``register[0]``'s position in the containing circuit's qubits list.
1116
+
1117
+ .. note::
1118
+
1119
+ Prior to QPY :ref:`qpy_version_4` the type of array elements was uint32_t. This was changed
1120
+ to enable negative values which represent bits in the array not present in the
1121
+ circuit
1122
+
1123
+
1124
+ The standalone boolean determines whether the register is constructed as a
1125
+ standalone register that was added to the circuit or was created from existing
1126
+ bits. A register is considered standalone if it has bits constructed solely
1127
+ as part of it, for example::
1128
+
1129
+ qr = QuantumRegister(2)
1130
+ qc = QuantumCircuit(qr)
1131
+
1132
+ the register ``qr`` would be a standalone register. While something like::
1133
+
1134
+ bits = [Qubit(), Qubit()]
1135
+ qr2 = QuantumRegister(bits=bits)
1136
+ qc = QuantumCircuit(qr2)
1137
+
1138
+ ``qr2`` would have ``standalone`` set to ``False``.
1139
+
1140
+
1141
+ .. _qpy_custom_definition:
1142
+
1143
+ CUSTOM_DEFINITIONS
1144
+ ------------------
1145
+
1146
+ This section specifies custom definitions for any of the instructions in the circuit.
1147
+
1148
+ CUSTOM_DEFINITION_HEADER contents are defined as:
1149
+
1150
+ .. code-block:: c
1151
+
1152
+ struct {
1153
+ uint64_t size;
1154
+ }
1155
+
1156
+ If size is greater than 0 that means the circuit contains custom instruction(s).
1157
+ Each custom instruction is defined with a CUSTOM_INSTRUCTION block defined as:
1158
+
1159
+ .. code-block:: c
1160
+
1161
+ struct {
1162
+ uint16_t name_size;
1163
+ char type;
1164
+ uint32_t num_qubits;
1165
+ uint32_t num_clbits;
1166
+ _Bool custom_definition;
1167
+ uint64_t size;
1168
+ }
1169
+
1170
+ Immediately following the CUSTOM_INSTRUCTION struct is the utf8 encoded name
1171
+ of size ``name_size``.
1172
+
1173
+ If ``custom_definition`` is ``True`` that means that the immediately following
1174
+ ``size`` bytes contains a QPY circuit data which can be used for the custom
1175
+ definition of that gate. If ``custom_definition`` is ``False`` then the
1176
+ instruction can be considered opaque (ie no definition). The ``type`` field
1177
+ determines what type of object will get created with the custom definition.
1178
+ If it's ``'g'`` it will be a :class:`~qiskit.circuit.Gate` object, ``'i'``
1179
+ it will be a :class:`~qiskit.circuit.Instruction` object.
1180
+
1181
+ .. _qpy_instructions:
1182
+
1183
+ INSTRUCTIONS
1184
+ ------------
1185
+
1186
+ The contents of INSTRUCTIONS is a list of INSTRUCTION metadata objects
1187
+
1188
+ .. code-block:: c
1189
+
1190
+ struct {
1191
+ uint16_t name_size;
1192
+ uint16_t label_size;
1193
+ uint16_t num_parameters;
1194
+ uint32_t num_qargs;
1195
+ uint32_t num_cargs;
1196
+ _Bool has_conditional;
1197
+ uint16_t conditional_reg_name_size;
1198
+ int64_t conditional_value;
1199
+ }
1200
+
1201
+ This metadata object is immediately followed by ``name_size`` bytes of utf8 bytes
1202
+ for the ``name``. ``name`` here is the Qiskit class name for the Instruction
1203
+ class if it's defined in Qiskit. Otherwise it falls back to the custom
1204
+ instruction name. Following the ``name`` bytes there are ``label_size`` bytes of
1205
+ utf8 data for the label if one was set on the instruction. Following the label
1206
+ bytes if ``has_conditional`` is ``True`` then there are
1207
+ ``conditional_reg_name_size`` bytes of utf8 data for the name of the conditional
1208
+ register name. In case of single classical bit conditions the register name
1209
+ utf8 data will be prefixed with a null character "\\x00" and then a utf8 string
1210
+ integer representing the classical bit index in the circuit that the condition
1211
+ is on.
1212
+
1213
+ This is immediately followed by the INSTRUCTION_ARG structs for the list of
1214
+ arguments of that instruction. These are in the order of all quantum arguments
1215
+ (there are num_qargs of these) followed by all classical arguments (num_cargs
1216
+ of these).
1217
+
1218
+ The contents of each INSTRUCTION_ARG is:
1219
+
1220
+ .. code-block:: c
1221
+
1222
+ struct {
1223
+ char type;
1224
+ uint32_t index;
1225
+ }
1226
+
1227
+ ``type`` can be ``'q'`` or ``'c'``.
1228
+
1229
+ After all arguments for an instruction the parameters are specified with
1230
+ ``num_parameters`` INSTRUCTION_PARAM structs.
1231
+
1232
+ The contents of each INSTRUCTION_PARAM is:
1233
+
1234
+ .. code-block:: c
1235
+
1236
+ struct {
1237
+ char type;
1238
+ uint64_t size;
1239
+ }
1240
+
1241
+ After each INSTRUCTION_PARAM the next ``size`` bytes are the parameter's data.
1242
+ The ``type`` field can be ``'i'``, ``'f'``, ``'p'``, ``'e'``, ``'s'``, ``'c'``
1243
+ or ``'n'`` which dictate the format. For ``'i'`` it's an integer, ``'f'`` it's
1244
+ a double, ``'s'`` if it's a string (encoded as utf8), ``'c'`` is a complex and
1245
+ the data is represented by the struct format in the :ref:`qpy_param_expr` section.
1246
+ ``'p'`` defines a :class:`~qiskit.circuit.Parameter` object which is
1247
+ represented by a :ref:`qpy_param_struct` struct, ``e`` defines a
1248
+ :class:`~qiskit.circuit.ParameterExpression` object (that's not a
1249
+ :class:`~qiskit.circuit.Parameter`) which is represented by a :ref:`qpy_param_expr`
1250
+ struct (on QPY format :ref:`qpy_version_3` the format is tweak slightly see:
1251
+ :ref:`qpy_param_expr_v3`), ``'n'`` represents an object from numpy (either an
1252
+ ``ndarray`` or a numpy type) which means the data is .npy format [#f2]_ data,
1253
+ and in QPY :ref:`qpy_version_3` ``'v'`` represents a
1254
+ :class:`~qiskit.circuit.ParameterVectorElement` which is represented by a
1255
+ :ref:`qpy_param_vector` struct.
1256
+
1257
+ .. _qpy_param_struct:
1258
+
1259
+ PARAMETER
1260
+ ---------
1261
+
1262
+ A PARAMETER represents a :class:`~qiskit.circuit.Parameter` object the data for
1263
+ a INSTRUCTION_PARAM. The contents of the PARAMETER are defined as:
1264
+
1265
+ .. code-block:: c
1266
+
1267
+ struct {
1268
+ uint16_t name_size;
1269
+ char uuid[16];
1270
+ }
1271
+
1272
+ which is immediately followed by ``name_size`` utf8 bytes representing the
1273
+ parameter name.
1274
+
1275
+ .. _qpy_param_expr:
1276
+
1277
+ PARAMETER_EXPR
1278
+ --------------
1279
+
1280
+ A PARAMETER_EXPR represents a :class:`~qiskit.circuit.ParameterExpression`
1281
+ object that the data for an INSTRUCTION_PARAM. The contents of a PARAMETER_EXPR
1282
+ are defined as:
1283
+
1284
+ The PARAMETER_EXPR data starts with a header:
1285
+
1286
+ .. code-block:: c
1287
+
1288
+ struct {
1289
+ uint64_t map_elements;
1290
+ uint64_t expr_size;
1291
+ }
1292
+
1293
+ Immediately following the header is ``expr_size`` bytes of utf8 data containing
1294
+ the expression string, which is the sympy srepr of the expression for the
1295
+ parameter expression. Follwing that is a symbol map which contains
1296
+ ``map_elements`` elements with the format
1297
+
1298
+ .. code-block:: c
1299
+
1300
+ struct {
1301
+ char type;
1302
+ uint64_t size;
1303
+ }
1304
+
1305
+ Which is followed immediately by ``PARAMETER`` object (both the struct and utf8
1306
+ name bytes) for the symbol map key. That is followed by ``size`` bytes for the
1307
+ data of the symbol. The data format is dependent on the value of ``type``. If
1308
+ ``type`` is ``p`` then it represents a :class:`~qiskit.circuit.Parameter` and
1309
+ size will be 0, the value will just be the same as the key. If
1310
+ ``type`` is ``f`` then it represents a double precision float. If ``type`` is
1311
+ ``c`` it represents a double precision complex, which is represented by :ref:`qpy_complex`.
1312
+ Finally, if type is ``i`` it represents an integer which is an ``int64_t``.
1313
+
1314
+ .. _qpy_complex:
1315
+
1316
+ COMPLEX
1317
+ -------
1318
+
1319
+ When representing a double precision complex value in QPY the following
1320
+ struct is used:
1321
+
1322
+
1323
+ .. code-block:: c
1324
+
1325
+ struct {
1326
+ double real;
1327
+ double imag;
1328
+ }
1329
+
1330
+ this matches the internal C representation of Python's complex type. [#f3]_
1331
+
1332
+
1333
+ .. [#f1] https://tools.ietf.org/html/rfc1700
1334
+ .. [#f2] https://numpy.org/doc/stable/reference/generated/numpy.lib.format.html
1335
+ .. [#f3] https://docs.python.org/3/c-api/complex.html#c.Py_complex
1336
+ """
1337
+
1338
+ from .exceptions import QpyError
1339
+ from .interface import dump, load
1340
+
1341
+ # For backward compatibility. Provide, Runtime, Experiment call these private functions.
1342
+ from .binary_io import (
1343
+ _write_instruction,
1344
+ _read_instruction,
1345
+ _write_parameter_expression,
1346
+ _read_parameter_expression,
1347
+ _read_parameter_expression_v3,
1348
+ )