qiskit 1.3.0__cp39-abi3-win32.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (836) hide show
  1. qiskit/VERSION.txt +1 -0
  2. qiskit/__init__.py +146 -0
  3. qiskit/_accelerate.pyd +0 -0
  4. qiskit/_numpy_compat.py +73 -0
  5. qiskit/assembler/__init__.py +42 -0
  6. qiskit/assembler/assemble_circuits.py +451 -0
  7. qiskit/assembler/assemble_schedules.py +367 -0
  8. qiskit/assembler/disassemble.py +310 -0
  9. qiskit/assembler/run_config.py +77 -0
  10. qiskit/circuit/__init__.py +1313 -0
  11. qiskit/circuit/_classical_resource_map.py +148 -0
  12. qiskit/circuit/_standard_gates_commutations.py +3849 -0
  13. qiskit/circuit/_utils.py +167 -0
  14. qiskit/circuit/add_control.py +274 -0
  15. qiskit/circuit/annotated_operation.py +279 -0
  16. qiskit/circuit/barrier.py +50 -0
  17. qiskit/circuit/bit.py +94 -0
  18. qiskit/circuit/classical/__init__.py +41 -0
  19. qiskit/circuit/classical/expr/__init__.py +238 -0
  20. qiskit/circuit/classical/expr/constructors.py +556 -0
  21. qiskit/circuit/classical/expr/expr.py +397 -0
  22. qiskit/circuit/classical/expr/visitors.py +300 -0
  23. qiskit/circuit/classical/types/__init__.py +109 -0
  24. qiskit/circuit/classical/types/ordering.py +222 -0
  25. qiskit/circuit/classical/types/types.py +117 -0
  26. qiskit/circuit/classicalfunction/__init__.py +140 -0
  27. qiskit/circuit/classicalfunction/boolean_expression.py +129 -0
  28. qiskit/circuit/classicalfunction/classical_element.py +54 -0
  29. qiskit/circuit/classicalfunction/classical_function_visitor.py +155 -0
  30. qiskit/circuit/classicalfunction/classicalfunction.py +173 -0
  31. qiskit/circuit/classicalfunction/exceptions.py +35 -0
  32. qiskit/circuit/classicalfunction/types.py +18 -0
  33. qiskit/circuit/classicalfunction/utils.py +91 -0
  34. qiskit/circuit/classicalregister.py +57 -0
  35. qiskit/circuit/commutation_checker.py +106 -0
  36. qiskit/circuit/commutation_library.py +20 -0
  37. qiskit/circuit/controlflow/__init__.py +28 -0
  38. qiskit/circuit/controlflow/_builder_utils.py +207 -0
  39. qiskit/circuit/controlflow/break_loop.py +56 -0
  40. qiskit/circuit/controlflow/builder.py +691 -0
  41. qiskit/circuit/controlflow/continue_loop.py +58 -0
  42. qiskit/circuit/controlflow/control_flow.py +84 -0
  43. qiskit/circuit/controlflow/for_loop.py +217 -0
  44. qiskit/circuit/controlflow/if_else.py +511 -0
  45. qiskit/circuit/controlflow/switch_case.py +417 -0
  46. qiskit/circuit/controlflow/while_loop.py +171 -0
  47. qiskit/circuit/controlledgate.py +274 -0
  48. qiskit/circuit/delay.py +123 -0
  49. qiskit/circuit/duration.py +95 -0
  50. qiskit/circuit/equivalence.py +94 -0
  51. qiskit/circuit/equivalence_library.py +18 -0
  52. qiskit/circuit/exceptions.py +19 -0
  53. qiskit/circuit/gate.py +263 -0
  54. qiskit/circuit/instruction.py +697 -0
  55. qiskit/circuit/instructionset.py +179 -0
  56. qiskit/circuit/library/__init__.py +668 -0
  57. qiskit/circuit/library/arithmetic/__init__.py +34 -0
  58. qiskit/circuit/library/arithmetic/adders/__init__.py +18 -0
  59. qiskit/circuit/library/arithmetic/adders/adder.py +210 -0
  60. qiskit/circuit/library/arithmetic/adders/cdkm_ripple_carry_adder.py +123 -0
  61. qiskit/circuit/library/arithmetic/adders/draper_qft_adder.py +129 -0
  62. qiskit/circuit/library/arithmetic/adders/vbe_ripple_carry_adder.py +95 -0
  63. qiskit/circuit/library/arithmetic/exact_reciprocal.py +88 -0
  64. qiskit/circuit/library/arithmetic/functional_pauli_rotations.py +114 -0
  65. qiskit/circuit/library/arithmetic/integer_comparator.py +243 -0
  66. qiskit/circuit/library/arithmetic/linear_amplitude_function.py +196 -0
  67. qiskit/circuit/library/arithmetic/linear_pauli_rotations.py +189 -0
  68. qiskit/circuit/library/arithmetic/multipliers/__init__.py +17 -0
  69. qiskit/circuit/library/arithmetic/multipliers/hrs_cumulative_multiplier.py +145 -0
  70. qiskit/circuit/library/arithmetic/multipliers/multiplier.py +192 -0
  71. qiskit/circuit/library/arithmetic/multipliers/rg_qft_multiplier.py +108 -0
  72. qiskit/circuit/library/arithmetic/piecewise_chebyshev.py +353 -0
  73. qiskit/circuit/library/arithmetic/piecewise_linear_pauli_rotations.py +277 -0
  74. qiskit/circuit/library/arithmetic/piecewise_polynomial_pauli_rotations.py +317 -0
  75. qiskit/circuit/library/arithmetic/polynomial_pauli_rotations.py +335 -0
  76. qiskit/circuit/library/arithmetic/quadratic_form.py +198 -0
  77. qiskit/circuit/library/arithmetic/weighted_adder.py +337 -0
  78. qiskit/circuit/library/basis_change/__init__.py +15 -0
  79. qiskit/circuit/library/basis_change/qft.py +313 -0
  80. qiskit/circuit/library/blueprintcircuit.py +280 -0
  81. qiskit/circuit/library/boolean_logic/__init__.py +18 -0
  82. qiskit/circuit/library/boolean_logic/inner_product.py +155 -0
  83. qiskit/circuit/library/boolean_logic/quantum_and.py +200 -0
  84. qiskit/circuit/library/boolean_logic/quantum_or.py +202 -0
  85. qiskit/circuit/library/boolean_logic/quantum_xor.py +165 -0
  86. qiskit/circuit/library/data_preparation/__init__.py +57 -0
  87. qiskit/circuit/library/data_preparation/_z_feature_map.py +115 -0
  88. qiskit/circuit/library/data_preparation/_zz_feature_map.py +150 -0
  89. qiskit/circuit/library/data_preparation/initializer.py +107 -0
  90. qiskit/circuit/library/data_preparation/pauli_feature_map.py +656 -0
  91. qiskit/circuit/library/data_preparation/state_preparation.py +336 -0
  92. qiskit/circuit/library/fourier_checking.py +158 -0
  93. qiskit/circuit/library/generalized_gates/__init__.py +30 -0
  94. qiskit/circuit/library/generalized_gates/diagonal.py +159 -0
  95. qiskit/circuit/library/generalized_gates/gms.py +174 -0
  96. qiskit/circuit/library/generalized_gates/gr.py +215 -0
  97. qiskit/circuit/library/generalized_gates/isometry.py +370 -0
  98. qiskit/circuit/library/generalized_gates/linear_function.py +318 -0
  99. qiskit/circuit/library/generalized_gates/mcg_up_to_diagonal.py +143 -0
  100. qiskit/circuit/library/generalized_gates/mcmt.py +316 -0
  101. qiskit/circuit/library/generalized_gates/pauli.py +85 -0
  102. qiskit/circuit/library/generalized_gates/permutation.py +194 -0
  103. qiskit/circuit/library/generalized_gates/rv.py +96 -0
  104. qiskit/circuit/library/generalized_gates/uc.py +213 -0
  105. qiskit/circuit/library/generalized_gates/uc_pauli_rot.py +164 -0
  106. qiskit/circuit/library/generalized_gates/ucrx.py +32 -0
  107. qiskit/circuit/library/generalized_gates/ucry.py +32 -0
  108. qiskit/circuit/library/generalized_gates/ucrz.py +32 -0
  109. qiskit/circuit/library/generalized_gates/unitary.py +215 -0
  110. qiskit/circuit/library/graph_state.py +169 -0
  111. qiskit/circuit/library/grover_operator.py +579 -0
  112. qiskit/circuit/library/hamiltonian_gate.py +142 -0
  113. qiskit/circuit/library/hidden_linear_function.py +161 -0
  114. qiskit/circuit/library/iqp.py +175 -0
  115. qiskit/circuit/library/n_local/__init__.py +45 -0
  116. qiskit/circuit/library/n_local/efficient_su2.py +277 -0
  117. qiskit/circuit/library/n_local/evolved_operator_ansatz.py +515 -0
  118. qiskit/circuit/library/n_local/excitation_preserving.py +297 -0
  119. qiskit/circuit/library/n_local/n_local.py +1472 -0
  120. qiskit/circuit/library/n_local/pauli_two_design.py +243 -0
  121. qiskit/circuit/library/n_local/qaoa_ansatz.py +366 -0
  122. qiskit/circuit/library/n_local/real_amplitudes.py +306 -0
  123. qiskit/circuit/library/n_local/two_local.py +289 -0
  124. qiskit/circuit/library/overlap.py +182 -0
  125. qiskit/circuit/library/pauli_evolution.py +186 -0
  126. qiskit/circuit/library/phase_estimation.py +175 -0
  127. qiskit/circuit/library/phase_oracle.py +153 -0
  128. qiskit/circuit/library/quantum_volume.py +167 -0
  129. qiskit/circuit/library/standard_gates/__init__.py +142 -0
  130. qiskit/circuit/library/standard_gates/dcx.py +78 -0
  131. qiskit/circuit/library/standard_gates/ecr.py +130 -0
  132. qiskit/circuit/library/standard_gates/equivalence_library.py +1800 -0
  133. qiskit/circuit/library/standard_gates/global_phase.py +85 -0
  134. qiskit/circuit/library/standard_gates/h.py +258 -0
  135. qiskit/circuit/library/standard_gates/i.py +76 -0
  136. qiskit/circuit/library/standard_gates/iswap.py +134 -0
  137. qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py +405 -0
  138. qiskit/circuit/library/standard_gates/p.py +441 -0
  139. qiskit/circuit/library/standard_gates/r.py +117 -0
  140. qiskit/circuit/library/standard_gates/rx.py +303 -0
  141. qiskit/circuit/library/standard_gates/rxx.py +183 -0
  142. qiskit/circuit/library/standard_gates/ry.py +298 -0
  143. qiskit/circuit/library/standard_gates/ryy.py +183 -0
  144. qiskit/circuit/library/standard_gates/rz.py +319 -0
  145. qiskit/circuit/library/standard_gates/rzx.py +229 -0
  146. qiskit/circuit/library/standard_gates/rzz.py +196 -0
  147. qiskit/circuit/library/standard_gates/s.py +428 -0
  148. qiskit/circuit/library/standard_gates/swap.py +288 -0
  149. qiskit/circuit/library/standard_gates/sx.py +315 -0
  150. qiskit/circuit/library/standard_gates/t.py +179 -0
  151. qiskit/circuit/library/standard_gates/u.py +403 -0
  152. qiskit/circuit/library/standard_gates/u1.py +501 -0
  153. qiskit/circuit/library/standard_gates/u2.py +149 -0
  154. qiskit/circuit/library/standard_gates/u3.py +436 -0
  155. qiskit/circuit/library/standard_gates/x.py +1529 -0
  156. qiskit/circuit/library/standard_gates/xx_minus_yy.py +235 -0
  157. qiskit/circuit/library/standard_gates/xx_plus_yy.py +239 -0
  158. qiskit/circuit/library/standard_gates/y.py +262 -0
  159. qiskit/circuit/library/standard_gates/z.py +348 -0
  160. qiskit/circuit/library/templates/__init__.py +92 -0
  161. qiskit/circuit/library/templates/clifford/__init__.py +33 -0
  162. qiskit/circuit/library/templates/clifford/clifford_2_1.py +34 -0
  163. qiskit/circuit/library/templates/clifford/clifford_2_2.py +35 -0
  164. qiskit/circuit/library/templates/clifford/clifford_2_3.py +34 -0
  165. qiskit/circuit/library/templates/clifford/clifford_2_4.py +34 -0
  166. qiskit/circuit/library/templates/clifford/clifford_3_1.py +35 -0
  167. qiskit/circuit/library/templates/clifford/clifford_4_1.py +38 -0
  168. qiskit/circuit/library/templates/clifford/clifford_4_2.py +37 -0
  169. qiskit/circuit/library/templates/clifford/clifford_4_3.py +38 -0
  170. qiskit/circuit/library/templates/clifford/clifford_4_4.py +37 -0
  171. qiskit/circuit/library/templates/clifford/clifford_5_1.py +40 -0
  172. qiskit/circuit/library/templates/clifford/clifford_6_1.py +40 -0
  173. qiskit/circuit/library/templates/clifford/clifford_6_2.py +40 -0
  174. qiskit/circuit/library/templates/clifford/clifford_6_3.py +40 -0
  175. qiskit/circuit/library/templates/clifford/clifford_6_4.py +38 -0
  176. qiskit/circuit/library/templates/clifford/clifford_6_5.py +40 -0
  177. qiskit/circuit/library/templates/clifford/clifford_8_1.py +42 -0
  178. qiskit/circuit/library/templates/clifford/clifford_8_2.py +42 -0
  179. qiskit/circuit/library/templates/clifford/clifford_8_3.py +41 -0
  180. qiskit/circuit/library/templates/nct/__init__.py +67 -0
  181. qiskit/circuit/library/templates/nct/template_nct_2a_1.py +34 -0
  182. qiskit/circuit/library/templates/nct/template_nct_2a_2.py +35 -0
  183. qiskit/circuit/library/templates/nct/template_nct_2a_3.py +37 -0
  184. qiskit/circuit/library/templates/nct/template_nct_4a_1.py +43 -0
  185. qiskit/circuit/library/templates/nct/template_nct_4a_2.py +41 -0
  186. qiskit/circuit/library/templates/nct/template_nct_4a_3.py +39 -0
  187. qiskit/circuit/library/templates/nct/template_nct_4b_1.py +41 -0
  188. qiskit/circuit/library/templates/nct/template_nct_4b_2.py +39 -0
  189. qiskit/circuit/library/templates/nct/template_nct_5a_1.py +40 -0
  190. qiskit/circuit/library/templates/nct/template_nct_5a_2.py +40 -0
  191. qiskit/circuit/library/templates/nct/template_nct_5a_3.py +40 -0
  192. qiskit/circuit/library/templates/nct/template_nct_5a_4.py +39 -0
  193. qiskit/circuit/library/templates/nct/template_nct_6a_1.py +40 -0
  194. qiskit/circuit/library/templates/nct/template_nct_6a_2.py +41 -0
  195. qiskit/circuit/library/templates/nct/template_nct_6a_3.py +41 -0
  196. qiskit/circuit/library/templates/nct/template_nct_6a_4.py +41 -0
  197. qiskit/circuit/library/templates/nct/template_nct_6b_1.py +41 -0
  198. qiskit/circuit/library/templates/nct/template_nct_6b_2.py +41 -0
  199. qiskit/circuit/library/templates/nct/template_nct_6c_1.py +41 -0
  200. qiskit/circuit/library/templates/nct/template_nct_7a_1.py +43 -0
  201. qiskit/circuit/library/templates/nct/template_nct_7b_1.py +43 -0
  202. qiskit/circuit/library/templates/nct/template_nct_7c_1.py +43 -0
  203. qiskit/circuit/library/templates/nct/template_nct_7d_1.py +43 -0
  204. qiskit/circuit/library/templates/nct/template_nct_7e_1.py +43 -0
  205. qiskit/circuit/library/templates/nct/template_nct_9a_1.py +45 -0
  206. qiskit/circuit/library/templates/nct/template_nct_9c_1.py +43 -0
  207. qiskit/circuit/library/templates/nct/template_nct_9c_10.py +44 -0
  208. qiskit/circuit/library/templates/nct/template_nct_9c_11.py +44 -0
  209. qiskit/circuit/library/templates/nct/template_nct_9c_12.py +44 -0
  210. qiskit/circuit/library/templates/nct/template_nct_9c_2.py +44 -0
  211. qiskit/circuit/library/templates/nct/template_nct_9c_3.py +44 -0
  212. qiskit/circuit/library/templates/nct/template_nct_9c_4.py +44 -0
  213. qiskit/circuit/library/templates/nct/template_nct_9c_5.py +44 -0
  214. qiskit/circuit/library/templates/nct/template_nct_9c_6.py +44 -0
  215. qiskit/circuit/library/templates/nct/template_nct_9c_7.py +44 -0
  216. qiskit/circuit/library/templates/nct/template_nct_9c_8.py +44 -0
  217. qiskit/circuit/library/templates/nct/template_nct_9c_9.py +44 -0
  218. qiskit/circuit/library/templates/nct/template_nct_9d_1.py +43 -0
  219. qiskit/circuit/library/templates/nct/template_nct_9d_10.py +44 -0
  220. qiskit/circuit/library/templates/nct/template_nct_9d_2.py +44 -0
  221. qiskit/circuit/library/templates/nct/template_nct_9d_3.py +44 -0
  222. qiskit/circuit/library/templates/nct/template_nct_9d_4.py +44 -0
  223. qiskit/circuit/library/templates/nct/template_nct_9d_5.py +44 -0
  224. qiskit/circuit/library/templates/nct/template_nct_9d_6.py +44 -0
  225. qiskit/circuit/library/templates/nct/template_nct_9d_7.py +44 -0
  226. qiskit/circuit/library/templates/nct/template_nct_9d_8.py +44 -0
  227. qiskit/circuit/library/templates/nct/template_nct_9d_9.py +44 -0
  228. qiskit/circuit/library/templates/rzx/__init__.py +25 -0
  229. qiskit/circuit/library/templates/rzx/rzx_cy.py +47 -0
  230. qiskit/circuit/library/templates/rzx/rzx_xz.py +54 -0
  231. qiskit/circuit/library/templates/rzx/rzx_yz.py +45 -0
  232. qiskit/circuit/library/templates/rzx/rzx_zz1.py +69 -0
  233. qiskit/circuit/library/templates/rzx/rzx_zz2.py +59 -0
  234. qiskit/circuit/library/templates/rzx/rzx_zz3.py +59 -0
  235. qiskit/circuit/measure.py +44 -0
  236. qiskit/circuit/operation.py +67 -0
  237. qiskit/circuit/parameter.py +178 -0
  238. qiskit/circuit/parameterexpression.py +692 -0
  239. qiskit/circuit/parametertable.py +119 -0
  240. qiskit/circuit/parametervector.py +120 -0
  241. qiskit/circuit/quantumcircuit.py +6829 -0
  242. qiskit/circuit/quantumcircuitdata.py +136 -0
  243. qiskit/circuit/quantumregister.py +75 -0
  244. qiskit/circuit/random/__init__.py +15 -0
  245. qiskit/circuit/random/utils.py +358 -0
  246. qiskit/circuit/register.py +233 -0
  247. qiskit/circuit/reset.py +34 -0
  248. qiskit/circuit/singleton.py +606 -0
  249. qiskit/circuit/store.py +97 -0
  250. qiskit/circuit/tools/__init__.py +16 -0
  251. qiskit/circuit/tools/pi_check.py +190 -0
  252. qiskit/circuit/twirling.py +145 -0
  253. qiskit/compiler/__init__.py +33 -0
  254. qiskit/compiler/assembler.py +681 -0
  255. qiskit/compiler/scheduler.py +109 -0
  256. qiskit/compiler/sequencer.py +71 -0
  257. qiskit/compiler/transpiler.py +533 -0
  258. qiskit/converters/__init__.py +74 -0
  259. qiskit/converters/circuit_to_dag.py +78 -0
  260. qiskit/converters/circuit_to_dagdependency.py +51 -0
  261. qiskit/converters/circuit_to_dagdependency_v2.py +47 -0
  262. qiskit/converters/circuit_to_gate.py +107 -0
  263. qiskit/converters/circuit_to_instruction.py +155 -0
  264. qiskit/converters/dag_to_circuit.py +79 -0
  265. qiskit/converters/dag_to_dagdependency.py +55 -0
  266. qiskit/converters/dag_to_dagdependency_v2.py +44 -0
  267. qiskit/converters/dagdependency_to_circuit.py +46 -0
  268. qiskit/converters/dagdependency_to_dag.py +54 -0
  269. qiskit/dagcircuit/__init__.py +44 -0
  270. qiskit/dagcircuit/collect_blocks.py +391 -0
  271. qiskit/dagcircuit/dagcircuit.py +24 -0
  272. qiskit/dagcircuit/dagdependency.py +646 -0
  273. qiskit/dagcircuit/dagdependency_v2.py +641 -0
  274. qiskit/dagcircuit/dagdepnode.py +160 -0
  275. qiskit/dagcircuit/dagnode.py +176 -0
  276. qiskit/dagcircuit/exceptions.py +42 -0
  277. qiskit/exceptions.py +153 -0
  278. qiskit/passmanager/__init__.py +240 -0
  279. qiskit/passmanager/base_tasks.py +230 -0
  280. qiskit/passmanager/compilation_status.py +74 -0
  281. qiskit/passmanager/exceptions.py +19 -0
  282. qiskit/passmanager/flow_controllers.py +116 -0
  283. qiskit/passmanager/passmanager.py +333 -0
  284. qiskit/primitives/__init__.py +481 -0
  285. qiskit/primitives/backend_estimator.py +486 -0
  286. qiskit/primitives/backend_estimator_v2.py +434 -0
  287. qiskit/primitives/backend_sampler.py +222 -0
  288. qiskit/primitives/backend_sampler_v2.py +339 -0
  289. qiskit/primitives/base/__init__.py +20 -0
  290. qiskit/primitives/base/base_estimator.py +252 -0
  291. qiskit/primitives/base/base_primitive.py +45 -0
  292. qiskit/primitives/base/base_primitive_job.py +78 -0
  293. qiskit/primitives/base/base_result.py +65 -0
  294. qiskit/primitives/base/base_sampler.py +204 -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/containers/__init__.py +26 -0
  299. qiskit/primitives/containers/bindings_array.py +389 -0
  300. qiskit/primitives/containers/bit_array.py +741 -0
  301. qiskit/primitives/containers/data_bin.py +173 -0
  302. qiskit/primitives/containers/estimator_pub.py +222 -0
  303. qiskit/primitives/containers/object_array.py +94 -0
  304. qiskit/primitives/containers/observables_array.py +279 -0
  305. qiskit/primitives/containers/primitive_result.py +53 -0
  306. qiskit/primitives/containers/pub_result.py +51 -0
  307. qiskit/primitives/containers/sampler_pub.py +193 -0
  308. qiskit/primitives/containers/sampler_pub_result.py +74 -0
  309. qiskit/primitives/containers/shape.py +129 -0
  310. qiskit/primitives/estimator.py +172 -0
  311. qiskit/primitives/primitive_job.py +81 -0
  312. qiskit/primitives/sampler.py +162 -0
  313. qiskit/primitives/statevector_estimator.py +174 -0
  314. qiskit/primitives/statevector_sampler.py +292 -0
  315. qiskit/primitives/utils.py +247 -0
  316. qiskit/providers/__init__.py +803 -0
  317. qiskit/providers/backend.py +667 -0
  318. qiskit/providers/backend_compat.py +472 -0
  319. qiskit/providers/basic_provider/__init__.py +45 -0
  320. qiskit/providers/basic_provider/basic_provider.py +101 -0
  321. qiskit/providers/basic_provider/basic_provider_job.py +65 -0
  322. qiskit/providers/basic_provider/basic_provider_tools.py +218 -0
  323. qiskit/providers/basic_provider/basic_simulator.py +821 -0
  324. qiskit/providers/basic_provider/exceptions.py +30 -0
  325. qiskit/providers/exceptions.py +45 -0
  326. qiskit/providers/fake_provider/__init__.py +105 -0
  327. qiskit/providers/fake_provider/backends_v1/__init__.py +22 -0
  328. qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/__init__.py +18 -0
  329. qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/conf_washington.json +1 -0
  330. qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/defs_washington.json +1 -0
  331. qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/fake_127q_pulse_v1.py +37 -0
  332. qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/props_washington.json +1 -0
  333. qiskit/providers/fake_provider/backends_v1/fake_20q/__init__.py +18 -0
  334. qiskit/providers/fake_provider/backends_v1/fake_20q/conf_singapore.json +1 -0
  335. qiskit/providers/fake_provider/backends_v1/fake_20q/fake_20q.py +43 -0
  336. qiskit/providers/fake_provider/backends_v1/fake_20q/props_singapore.json +1 -0
  337. qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/__init__.py +18 -0
  338. qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/conf_hanoi.json +1 -0
  339. qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/defs_hanoi.json +1 -0
  340. qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/fake_27q_pulse_v1.py +50 -0
  341. qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/props_hanoi.json +1 -0
  342. qiskit/providers/fake_provider/backends_v1/fake_5q/__init__.py +18 -0
  343. qiskit/providers/fake_provider/backends_v1/fake_5q/conf_yorktown.json +1 -0
  344. qiskit/providers/fake_provider/backends_v1/fake_5q/fake_5q_v1.py +41 -0
  345. qiskit/providers/fake_provider/backends_v1/fake_5q/props_yorktown.json +1 -0
  346. qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/__init__.py +18 -0
  347. qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/conf_nairobi.json +1 -0
  348. qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/defs_nairobi.json +1 -0
  349. qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/fake_7q_pulse_v1.py +44 -0
  350. qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/props_nairobi.json +1 -0
  351. qiskit/providers/fake_provider/fake_1q.py +91 -0
  352. qiskit/providers/fake_provider/fake_backend.py +165 -0
  353. qiskit/providers/fake_provider/fake_openpulse_2q.py +391 -0
  354. qiskit/providers/fake_provider/fake_openpulse_3q.py +340 -0
  355. qiskit/providers/fake_provider/fake_pulse_backend.py +49 -0
  356. qiskit/providers/fake_provider/fake_qasm_backend.py +77 -0
  357. qiskit/providers/fake_provider/generic_backend_v2.py +1035 -0
  358. qiskit/providers/fake_provider/utils/__init__.py +15 -0
  359. qiskit/providers/fake_provider/utils/backend_converter.py +150 -0
  360. qiskit/providers/fake_provider/utils/json_decoder.py +109 -0
  361. qiskit/providers/job.py +147 -0
  362. qiskit/providers/jobstatus.py +30 -0
  363. qiskit/providers/models/__init__.py +89 -0
  364. qiskit/providers/models/backendconfiguration.py +1040 -0
  365. qiskit/providers/models/backendproperties.py +517 -0
  366. qiskit/providers/models/backendstatus.py +94 -0
  367. qiskit/providers/models/jobstatus.py +66 -0
  368. qiskit/providers/models/pulsedefaults.py +305 -0
  369. qiskit/providers/options.py +273 -0
  370. qiskit/providers/provider.py +95 -0
  371. qiskit/providers/providerutils.py +110 -0
  372. qiskit/pulse/__init__.py +158 -0
  373. qiskit/pulse/builder.py +2254 -0
  374. qiskit/pulse/calibration_entries.py +381 -0
  375. qiskit/pulse/channels.py +227 -0
  376. qiskit/pulse/configuration.py +245 -0
  377. qiskit/pulse/exceptions.py +45 -0
  378. qiskit/pulse/filters.py +309 -0
  379. qiskit/pulse/instruction_schedule_map.py +424 -0
  380. qiskit/pulse/instructions/__init__.py +67 -0
  381. qiskit/pulse/instructions/acquire.py +150 -0
  382. qiskit/pulse/instructions/delay.py +71 -0
  383. qiskit/pulse/instructions/directives.py +154 -0
  384. qiskit/pulse/instructions/frequency.py +135 -0
  385. qiskit/pulse/instructions/instruction.py +270 -0
  386. qiskit/pulse/instructions/phase.py +152 -0
  387. qiskit/pulse/instructions/play.py +99 -0
  388. qiskit/pulse/instructions/reference.py +100 -0
  389. qiskit/pulse/instructions/snapshot.py +82 -0
  390. qiskit/pulse/library/__init__.py +97 -0
  391. qiskit/pulse/library/continuous.py +430 -0
  392. qiskit/pulse/library/pulse.py +148 -0
  393. qiskit/pulse/library/samplers/__init__.py +15 -0
  394. qiskit/pulse/library/samplers/decorators.py +295 -0
  395. qiskit/pulse/library/samplers/strategies.py +71 -0
  396. qiskit/pulse/library/symbolic_pulses.py +1988 -0
  397. qiskit/pulse/library/waveform.py +136 -0
  398. qiskit/pulse/macros.py +262 -0
  399. qiskit/pulse/parameter_manager.py +445 -0
  400. qiskit/pulse/parser.py +314 -0
  401. qiskit/pulse/reference_manager.py +58 -0
  402. qiskit/pulse/schedule.py +1854 -0
  403. qiskit/pulse/transforms/__init__.py +106 -0
  404. qiskit/pulse/transforms/alignments.py +406 -0
  405. qiskit/pulse/transforms/base_transforms.py +71 -0
  406. qiskit/pulse/transforms/canonicalization.py +498 -0
  407. qiskit/pulse/transforms/dag.py +122 -0
  408. qiskit/pulse/utils.py +149 -0
  409. qiskit/qasm/libs/dummy/stdgates.inc +75 -0
  410. qiskit/qasm/libs/qelib1.inc +266 -0
  411. qiskit/qasm/libs/stdgates.inc +82 -0
  412. qiskit/qasm2/__init__.py +654 -0
  413. qiskit/qasm2/exceptions.py +27 -0
  414. qiskit/qasm2/export.py +372 -0
  415. qiskit/qasm2/parse.py +452 -0
  416. qiskit/qasm3/__init__.py +367 -0
  417. qiskit/qasm3/ast.py +738 -0
  418. qiskit/qasm3/exceptions.py +27 -0
  419. qiskit/qasm3/experimental.py +70 -0
  420. qiskit/qasm3/exporter.py +1299 -0
  421. qiskit/qasm3/printer.py +577 -0
  422. qiskit/qobj/__init__.py +75 -0
  423. qiskit/qobj/common.py +81 -0
  424. qiskit/qobj/converters/__init__.py +18 -0
  425. qiskit/qobj/converters/lo_config.py +177 -0
  426. qiskit/qobj/converters/pulse_instruction.py +897 -0
  427. qiskit/qobj/pulse_qobj.py +709 -0
  428. qiskit/qobj/qasm_qobj.py +708 -0
  429. qiskit/qobj/utils.py +46 -0
  430. qiskit/qpy/__init__.py +1822 -0
  431. qiskit/qpy/binary_io/__init__.py +36 -0
  432. qiskit/qpy/binary_io/circuits.py +1475 -0
  433. qiskit/qpy/binary_io/schedules.py +635 -0
  434. qiskit/qpy/binary_io/value.py +1025 -0
  435. qiskit/qpy/common.py +350 -0
  436. qiskit/qpy/exceptions.py +53 -0
  437. qiskit/qpy/formats.py +401 -0
  438. qiskit/qpy/interface.py +377 -0
  439. qiskit/qpy/type_keys.py +572 -0
  440. qiskit/quantum_info/__init__.py +162 -0
  441. qiskit/quantum_info/analysis/__init__.py +17 -0
  442. qiskit/quantum_info/analysis/average.py +47 -0
  443. qiskit/quantum_info/analysis/distance.py +102 -0
  444. qiskit/quantum_info/analysis/make_observable.py +44 -0
  445. qiskit/quantum_info/analysis/z2_symmetries.py +484 -0
  446. qiskit/quantum_info/operators/__init__.py +28 -0
  447. qiskit/quantum_info/operators/base_operator.py +145 -0
  448. qiskit/quantum_info/operators/channel/__init__.py +29 -0
  449. qiskit/quantum_info/operators/channel/chi.py +191 -0
  450. qiskit/quantum_info/operators/channel/choi.py +218 -0
  451. qiskit/quantum_info/operators/channel/kraus.py +337 -0
  452. qiskit/quantum_info/operators/channel/ptm.py +204 -0
  453. qiskit/quantum_info/operators/channel/quantum_channel.py +348 -0
  454. qiskit/quantum_info/operators/channel/stinespring.py +296 -0
  455. qiskit/quantum_info/operators/channel/superop.py +377 -0
  456. qiskit/quantum_info/operators/channel/transformations.py +475 -0
  457. qiskit/quantum_info/operators/custom_iterator.py +48 -0
  458. qiskit/quantum_info/operators/dihedral/__init__.py +18 -0
  459. qiskit/quantum_info/operators/dihedral/dihedral.py +509 -0
  460. qiskit/quantum_info/operators/dihedral/dihedral_circuits.py +216 -0
  461. qiskit/quantum_info/operators/dihedral/polynomial.py +313 -0
  462. qiskit/quantum_info/operators/dihedral/random.py +64 -0
  463. qiskit/quantum_info/operators/linear_op.py +25 -0
  464. qiskit/quantum_info/operators/measures.py +418 -0
  465. qiskit/quantum_info/operators/mixins/__init__.py +52 -0
  466. qiskit/quantum_info/operators/mixins/adjoint.py +52 -0
  467. qiskit/quantum_info/operators/mixins/group.py +171 -0
  468. qiskit/quantum_info/operators/mixins/linear.py +84 -0
  469. qiskit/quantum_info/operators/mixins/multiply.py +62 -0
  470. qiskit/quantum_info/operators/mixins/tolerances.py +72 -0
  471. qiskit/quantum_info/operators/op_shape.py +525 -0
  472. qiskit/quantum_info/operators/operator.py +865 -0
  473. qiskit/quantum_info/operators/operator_utils.py +76 -0
  474. qiskit/quantum_info/operators/predicates.py +183 -0
  475. qiskit/quantum_info/operators/random.py +154 -0
  476. qiskit/quantum_info/operators/scalar_op.py +254 -0
  477. qiskit/quantum_info/operators/symplectic/__init__.py +23 -0
  478. qiskit/quantum_info/operators/symplectic/base_pauli.py +719 -0
  479. qiskit/quantum_info/operators/symplectic/clifford.py +1030 -0
  480. qiskit/quantum_info/operators/symplectic/clifford_circuits.py +558 -0
  481. qiskit/quantum_info/operators/symplectic/pauli.py +753 -0
  482. qiskit/quantum_info/operators/symplectic/pauli_list.py +1230 -0
  483. qiskit/quantum_info/operators/symplectic/pauli_utils.py +40 -0
  484. qiskit/quantum_info/operators/symplectic/random.py +117 -0
  485. qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +1196 -0
  486. qiskit/quantum_info/operators/utils/__init__.py +20 -0
  487. qiskit/quantum_info/operators/utils/anti_commutator.py +36 -0
  488. qiskit/quantum_info/operators/utils/commutator.py +36 -0
  489. qiskit/quantum_info/operators/utils/double_commutator.py +76 -0
  490. qiskit/quantum_info/quaternion.py +156 -0
  491. qiskit/quantum_info/random.py +26 -0
  492. qiskit/quantum_info/states/__init__.py +28 -0
  493. qiskit/quantum_info/states/densitymatrix.py +845 -0
  494. qiskit/quantum_info/states/measures.py +288 -0
  495. qiskit/quantum_info/states/quantum_state.py +503 -0
  496. qiskit/quantum_info/states/random.py +157 -0
  497. qiskit/quantum_info/states/stabilizerstate.py +773 -0
  498. qiskit/quantum_info/states/statevector.py +958 -0
  499. qiskit/quantum_info/states/utils.py +247 -0
  500. qiskit/result/__init__.py +73 -0
  501. qiskit/result/counts.py +189 -0
  502. qiskit/result/distributions/__init__.py +17 -0
  503. qiskit/result/distributions/probability.py +100 -0
  504. qiskit/result/distributions/quasi.py +154 -0
  505. qiskit/result/exceptions.py +40 -0
  506. qiskit/result/mitigation/__init__.py +13 -0
  507. qiskit/result/mitigation/base_readout_mitigator.py +79 -0
  508. qiskit/result/mitigation/correlated_readout_mitigator.py +277 -0
  509. qiskit/result/mitigation/local_readout_mitigator.py +328 -0
  510. qiskit/result/mitigation/utils.py +217 -0
  511. qiskit/result/models.py +234 -0
  512. qiskit/result/postprocess.py +239 -0
  513. qiskit/result/result.py +392 -0
  514. qiskit/result/sampled_expval.py +75 -0
  515. qiskit/result/utils.py +295 -0
  516. qiskit/scheduler/__init__.py +40 -0
  517. qiskit/scheduler/config.py +37 -0
  518. qiskit/scheduler/lowering.py +187 -0
  519. qiskit/scheduler/methods/__init__.py +15 -0
  520. qiskit/scheduler/methods/basic.py +140 -0
  521. qiskit/scheduler/schedule_circuit.py +69 -0
  522. qiskit/scheduler/sequence.py +104 -0
  523. qiskit/synthesis/__init__.py +220 -0
  524. qiskit/synthesis/arithmetic/__init__.py +16 -0
  525. qiskit/synthesis/arithmetic/adders/__init__.py +17 -0
  526. qiskit/synthesis/arithmetic/adders/cdkm_ripple_carry_adder.py +154 -0
  527. qiskit/synthesis/arithmetic/adders/draper_qft_adder.py +103 -0
  528. qiskit/synthesis/arithmetic/adders/vbe_ripple_carry_adder.py +161 -0
  529. qiskit/synthesis/arithmetic/multipliers/__init__.py +16 -0
  530. qiskit/synthesis/arithmetic/multipliers/hrs_cumulative_multiplier.py +102 -0
  531. qiskit/synthesis/arithmetic/multipliers/rg_qft_multiplier.py +99 -0
  532. qiskit/synthesis/clifford/__init__.py +19 -0
  533. qiskit/synthesis/clifford/clifford_decompose_ag.py +178 -0
  534. qiskit/synthesis/clifford/clifford_decompose_bm.py +46 -0
  535. qiskit/synthesis/clifford/clifford_decompose_full.py +64 -0
  536. qiskit/synthesis/clifford/clifford_decompose_greedy.py +58 -0
  537. qiskit/synthesis/clifford/clifford_decompose_layers.py +447 -0
  538. qiskit/synthesis/cnotdihedral/__init__.py +17 -0
  539. qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_full.py +52 -0
  540. qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_general.py +141 -0
  541. qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_two_qubits.py +266 -0
  542. qiskit/synthesis/discrete_basis/__init__.py +16 -0
  543. qiskit/synthesis/discrete_basis/commutator_decompose.py +241 -0
  544. qiskit/synthesis/discrete_basis/gate_sequence.py +415 -0
  545. qiskit/synthesis/discrete_basis/generate_basis_approximations.py +163 -0
  546. qiskit/synthesis/discrete_basis/solovay_kitaev.py +217 -0
  547. qiskit/synthesis/evolution/__init__.py +21 -0
  548. qiskit/synthesis/evolution/evolution_synthesis.py +48 -0
  549. qiskit/synthesis/evolution/lie_trotter.py +117 -0
  550. qiskit/synthesis/evolution/matrix_synthesis.py +47 -0
  551. qiskit/synthesis/evolution/pauli_network.py +80 -0
  552. qiskit/synthesis/evolution/product_formula.py +311 -0
  553. qiskit/synthesis/evolution/qdrift.py +138 -0
  554. qiskit/synthesis/evolution/suzuki_trotter.py +215 -0
  555. qiskit/synthesis/linear/__init__.py +26 -0
  556. qiskit/synthesis/linear/cnot_synth.py +69 -0
  557. qiskit/synthesis/linear/linear_circuits_utils.py +128 -0
  558. qiskit/synthesis/linear/linear_depth_lnn.py +276 -0
  559. qiskit/synthesis/linear/linear_matrix_utils.py +27 -0
  560. qiskit/synthesis/linear_phase/__init__.py +17 -0
  561. qiskit/synthesis/linear_phase/cnot_phase_synth.py +206 -0
  562. qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py +262 -0
  563. qiskit/synthesis/linear_phase/cz_depth_lnn.py +58 -0
  564. qiskit/synthesis/multi_controlled/__init__.py +24 -0
  565. qiskit/synthesis/multi_controlled/mcmt_vchain.py +52 -0
  566. qiskit/synthesis/multi_controlled/mcx_synthesis.py +356 -0
  567. qiskit/synthesis/one_qubit/__init__.py +15 -0
  568. qiskit/synthesis/one_qubit/one_qubit_decompose.py +288 -0
  569. qiskit/synthesis/permutation/__init__.py +18 -0
  570. qiskit/synthesis/permutation/permutation_full.py +78 -0
  571. qiskit/synthesis/permutation/permutation_lnn.py +54 -0
  572. qiskit/synthesis/permutation/permutation_reverse_lnn.py +93 -0
  573. qiskit/synthesis/permutation/permutation_utils.py +16 -0
  574. qiskit/synthesis/qft/__init__.py +16 -0
  575. qiskit/synthesis/qft/qft_decompose_full.py +97 -0
  576. qiskit/synthesis/qft/qft_decompose_lnn.py +79 -0
  577. qiskit/synthesis/stabilizer/__init__.py +16 -0
  578. qiskit/synthesis/stabilizer/stabilizer_circuit.py +149 -0
  579. qiskit/synthesis/stabilizer/stabilizer_decompose.py +194 -0
  580. qiskit/synthesis/two_qubit/__init__.py +19 -0
  581. qiskit/synthesis/two_qubit/local_invariance.py +63 -0
  582. qiskit/synthesis/two_qubit/two_qubit_decompose.py +700 -0
  583. qiskit/synthesis/two_qubit/xx_decompose/__init__.py +19 -0
  584. qiskit/synthesis/two_qubit/xx_decompose/circuits.py +300 -0
  585. qiskit/synthesis/two_qubit/xx_decompose/decomposer.py +324 -0
  586. qiskit/synthesis/two_qubit/xx_decompose/embodiments.py +163 -0
  587. qiskit/synthesis/two_qubit/xx_decompose/paths.py +412 -0
  588. qiskit/synthesis/two_qubit/xx_decompose/polytopes.py +262 -0
  589. qiskit/synthesis/two_qubit/xx_decompose/utilities.py +40 -0
  590. qiskit/synthesis/two_qubit/xx_decompose/weyl.py +133 -0
  591. qiskit/synthesis/unitary/__init__.py +13 -0
  592. qiskit/synthesis/unitary/aqc/__init__.py +177 -0
  593. qiskit/synthesis/unitary/aqc/approximate.py +116 -0
  594. qiskit/synthesis/unitary/aqc/aqc.py +175 -0
  595. qiskit/synthesis/unitary/aqc/cnot_structures.py +300 -0
  596. qiskit/synthesis/unitary/aqc/cnot_unit_circuit.py +103 -0
  597. qiskit/synthesis/unitary/aqc/cnot_unit_objective.py +299 -0
  598. qiskit/synthesis/unitary/aqc/elementary_operations.py +108 -0
  599. qiskit/synthesis/unitary/aqc/fast_gradient/__init__.py +164 -0
  600. qiskit/synthesis/unitary/aqc/fast_gradient/fast_grad_utils.py +237 -0
  601. qiskit/synthesis/unitary/aqc/fast_gradient/fast_gradient.py +226 -0
  602. qiskit/synthesis/unitary/aqc/fast_gradient/layer.py +370 -0
  603. qiskit/synthesis/unitary/aqc/fast_gradient/pmatrix.py +312 -0
  604. qiskit/synthesis/unitary/qsd.py +288 -0
  605. qiskit/transpiler/__init__.py +1290 -0
  606. qiskit/transpiler/basepasses.py +221 -0
  607. qiskit/transpiler/coupling.py +500 -0
  608. qiskit/transpiler/exceptions.py +59 -0
  609. qiskit/transpiler/instruction_durations.py +281 -0
  610. qiskit/transpiler/layout.py +737 -0
  611. qiskit/transpiler/passes/__init__.py +312 -0
  612. qiskit/transpiler/passes/analysis/__init__.py +23 -0
  613. qiskit/transpiler/passes/analysis/count_ops.py +30 -0
  614. qiskit/transpiler/passes/analysis/count_ops_longest_path.py +26 -0
  615. qiskit/transpiler/passes/analysis/dag_longest_path.py +24 -0
  616. qiskit/transpiler/passes/analysis/depth.py +33 -0
  617. qiskit/transpiler/passes/analysis/num_qubits.py +26 -0
  618. qiskit/transpiler/passes/analysis/num_tensor_factors.py +26 -0
  619. qiskit/transpiler/passes/analysis/resource_estimation.py +41 -0
  620. qiskit/transpiler/passes/analysis/size.py +36 -0
  621. qiskit/transpiler/passes/analysis/width.py +27 -0
  622. qiskit/transpiler/passes/basis/__init__.py +19 -0
  623. qiskit/transpiler/passes/basis/basis_translator.py +137 -0
  624. qiskit/transpiler/passes/basis/decompose.py +131 -0
  625. qiskit/transpiler/passes/basis/translate_parameterized.py +175 -0
  626. qiskit/transpiler/passes/basis/unroll_3q_or_more.py +88 -0
  627. qiskit/transpiler/passes/basis/unroll_custom_definitions.py +109 -0
  628. qiskit/transpiler/passes/calibration/__init__.py +17 -0
  629. qiskit/transpiler/passes/calibration/base_builder.py +79 -0
  630. qiskit/transpiler/passes/calibration/builders.py +20 -0
  631. qiskit/transpiler/passes/calibration/exceptions.py +22 -0
  632. qiskit/transpiler/passes/calibration/pulse_gate.py +100 -0
  633. qiskit/transpiler/passes/calibration/rx_builder.py +164 -0
  634. qiskit/transpiler/passes/calibration/rzx_builder.py +411 -0
  635. qiskit/transpiler/passes/calibration/rzx_templates.py +51 -0
  636. qiskit/transpiler/passes/layout/__init__.py +26 -0
  637. qiskit/transpiler/passes/layout/_csp_custom_solver.py +65 -0
  638. qiskit/transpiler/passes/layout/apply_layout.py +123 -0
  639. qiskit/transpiler/passes/layout/csp_layout.py +132 -0
  640. qiskit/transpiler/passes/layout/dense_layout.py +202 -0
  641. qiskit/transpiler/passes/layout/disjoint_utils.py +219 -0
  642. qiskit/transpiler/passes/layout/enlarge_with_ancilla.py +49 -0
  643. qiskit/transpiler/passes/layout/full_ancilla_allocation.py +117 -0
  644. qiskit/transpiler/passes/layout/layout_2q_distance.py +77 -0
  645. qiskit/transpiler/passes/layout/sabre_layout.py +487 -0
  646. qiskit/transpiler/passes/layout/sabre_pre_layout.py +225 -0
  647. qiskit/transpiler/passes/layout/set_layout.py +69 -0
  648. qiskit/transpiler/passes/layout/trivial_layout.py +66 -0
  649. qiskit/transpiler/passes/layout/vf2_layout.py +263 -0
  650. qiskit/transpiler/passes/layout/vf2_post_layout.py +419 -0
  651. qiskit/transpiler/passes/layout/vf2_utils.py +260 -0
  652. qiskit/transpiler/passes/optimization/__init__.py +43 -0
  653. qiskit/transpiler/passes/optimization/_gate_extension.py +80 -0
  654. qiskit/transpiler/passes/optimization/collect_1q_runs.py +31 -0
  655. qiskit/transpiler/passes/optimization/collect_2q_blocks.py +35 -0
  656. qiskit/transpiler/passes/optimization/collect_and_collapse.py +115 -0
  657. qiskit/transpiler/passes/optimization/collect_cliffords.py +104 -0
  658. qiskit/transpiler/passes/optimization/collect_linear_functions.py +80 -0
  659. qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py +227 -0
  660. qiskit/transpiler/passes/optimization/commutation_analysis.py +44 -0
  661. qiskit/transpiler/passes/optimization/commutative_cancellation.py +82 -0
  662. qiskit/transpiler/passes/optimization/commutative_inverse_cancellation.py +140 -0
  663. qiskit/transpiler/passes/optimization/consolidate_blocks.py +149 -0
  664. qiskit/transpiler/passes/optimization/cx_cancellation.py +65 -0
  665. qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposition.py +162 -0
  666. qiskit/transpiler/passes/optimization/elide_permutations.py +91 -0
  667. qiskit/transpiler/passes/optimization/hoare_opt.py +420 -0
  668. qiskit/transpiler/passes/optimization/inverse_cancellation.py +95 -0
  669. qiskit/transpiler/passes/optimization/normalize_rx_angle.py +149 -0
  670. qiskit/transpiler/passes/optimization/optimize_1q_commutation.py +268 -0
  671. qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +254 -0
  672. qiskit/transpiler/passes/optimization/optimize_1q_gates.py +384 -0
  673. qiskit/transpiler/passes/optimization/optimize_annotated.py +448 -0
  674. qiskit/transpiler/passes/optimization/optimize_cliffords.py +89 -0
  675. qiskit/transpiler/passes/optimization/optimize_swap_before_measure.py +71 -0
  676. qiskit/transpiler/passes/optimization/remove_diagonal_gates_before_measure.py +41 -0
  677. qiskit/transpiler/passes/optimization/remove_final_reset.py +37 -0
  678. qiskit/transpiler/passes/optimization/remove_identity_equiv.py +69 -0
  679. qiskit/transpiler/passes/optimization/remove_reset_in_zero_state.py +37 -0
  680. qiskit/transpiler/passes/optimization/reset_after_measure_simplification.py +47 -0
  681. qiskit/transpiler/passes/optimization/split_2q_unitaries.py +40 -0
  682. qiskit/transpiler/passes/optimization/template_matching/__init__.py +19 -0
  683. qiskit/transpiler/passes/optimization/template_matching/backward_match.py +749 -0
  684. qiskit/transpiler/passes/optimization/template_matching/forward_match.py +452 -0
  685. qiskit/transpiler/passes/optimization/template_matching/maximal_matches.py +77 -0
  686. qiskit/transpiler/passes/optimization/template_matching/template_matching.py +370 -0
  687. qiskit/transpiler/passes/optimization/template_matching/template_substitution.py +638 -0
  688. qiskit/transpiler/passes/optimization/template_optimization.py +158 -0
  689. qiskit/transpiler/passes/routing/__init__.py +22 -0
  690. qiskit/transpiler/passes/routing/algorithms/__init__.py +33 -0
  691. qiskit/transpiler/passes/routing/algorithms/token_swapper.py +105 -0
  692. qiskit/transpiler/passes/routing/algorithms/types.py +46 -0
  693. qiskit/transpiler/passes/routing/algorithms/util.py +103 -0
  694. qiskit/transpiler/passes/routing/basic_swap.py +166 -0
  695. qiskit/transpiler/passes/routing/commuting_2q_gate_routing/__init__.py +25 -0
  696. qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_block.py +60 -0
  697. qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py +395 -0
  698. qiskit/transpiler/passes/routing/commuting_2q_gate_routing/pauli_2q_evolution_commutation.py +145 -0
  699. qiskit/transpiler/passes/routing/commuting_2q_gate_routing/swap_strategy.py +306 -0
  700. qiskit/transpiler/passes/routing/layout_transformation.py +119 -0
  701. qiskit/transpiler/passes/routing/lookahead_swap.py +390 -0
  702. qiskit/transpiler/passes/routing/sabre_swap.py +447 -0
  703. qiskit/transpiler/passes/routing/star_prerouting.py +392 -0
  704. qiskit/transpiler/passes/routing/stochastic_swap.py +532 -0
  705. qiskit/transpiler/passes/routing/utils.py +35 -0
  706. qiskit/transpiler/passes/scheduling/__init__.py +27 -0
  707. qiskit/transpiler/passes/scheduling/alap.py +153 -0
  708. qiskit/transpiler/passes/scheduling/alignments/__init__.py +81 -0
  709. qiskit/transpiler/passes/scheduling/alignments/align_measures.py +255 -0
  710. qiskit/transpiler/passes/scheduling/alignments/check_durations.py +78 -0
  711. qiskit/transpiler/passes/scheduling/alignments/pulse_gate_validation.py +107 -0
  712. qiskit/transpiler/passes/scheduling/alignments/reschedule.py +250 -0
  713. qiskit/transpiler/passes/scheduling/asap.py +175 -0
  714. qiskit/transpiler/passes/scheduling/base_scheduler.py +310 -0
  715. qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +312 -0
  716. qiskit/transpiler/passes/scheduling/padding/__init__.py +16 -0
  717. qiskit/transpiler/passes/scheduling/padding/base_padding.py +256 -0
  718. qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +452 -0
  719. qiskit/transpiler/passes/scheduling/padding/pad_delay.py +82 -0
  720. qiskit/transpiler/passes/scheduling/scheduling/__init__.py +17 -0
  721. qiskit/transpiler/passes/scheduling/scheduling/alap.py +127 -0
  722. qiskit/transpiler/passes/scheduling/scheduling/asap.py +131 -0
  723. qiskit/transpiler/passes/scheduling/scheduling/base_scheduler.py +94 -0
  724. qiskit/transpiler/passes/scheduling/scheduling/set_io_latency.py +64 -0
  725. qiskit/transpiler/passes/scheduling/time_unit_conversion.py +165 -0
  726. qiskit/transpiler/passes/synthesis/__init__.py +20 -0
  727. qiskit/transpiler/passes/synthesis/aqc_plugin.py +153 -0
  728. qiskit/transpiler/passes/synthesis/high_level_synthesis.py +854 -0
  729. qiskit/transpiler/passes/synthesis/hls_plugins.py +1559 -0
  730. qiskit/transpiler/passes/synthesis/linear_functions_synthesis.py +41 -0
  731. qiskit/transpiler/passes/synthesis/plugin.py +734 -0
  732. qiskit/transpiler/passes/synthesis/solovay_kitaev_synthesis.py +297 -0
  733. qiskit/transpiler/passes/synthesis/unitary_synthesis.py +1076 -0
  734. qiskit/transpiler/passes/utils/__init__.py +33 -0
  735. qiskit/transpiler/passes/utils/barrier_before_final_measurements.py +41 -0
  736. qiskit/transpiler/passes/utils/check_gate_direction.py +52 -0
  737. qiskit/transpiler/passes/utils/check_map.py +78 -0
  738. qiskit/transpiler/passes/utils/contains_instruction.py +45 -0
  739. qiskit/transpiler/passes/utils/control_flow.py +65 -0
  740. qiskit/transpiler/passes/utils/convert_conditions_to_if_ops.py +93 -0
  741. qiskit/transpiler/passes/utils/dag_fixed_point.py +36 -0
  742. qiskit/transpiler/passes/utils/error.py +69 -0
  743. qiskit/transpiler/passes/utils/filter_op_nodes.py +65 -0
  744. qiskit/transpiler/passes/utils/fixed_point.py +48 -0
  745. qiskit/transpiler/passes/utils/gate_direction.py +86 -0
  746. qiskit/transpiler/passes/utils/gates_basis.py +51 -0
  747. qiskit/transpiler/passes/utils/merge_adjacent_barriers.py +163 -0
  748. qiskit/transpiler/passes/utils/minimum_point.py +118 -0
  749. qiskit/transpiler/passes/utils/remove_barriers.py +49 -0
  750. qiskit/transpiler/passes/utils/remove_final_measurements.py +114 -0
  751. qiskit/transpiler/passes/utils/unroll_forloops.py +81 -0
  752. qiskit/transpiler/passmanager.py +490 -0
  753. qiskit/transpiler/passmanager_config.py +216 -0
  754. qiskit/transpiler/preset_passmanagers/__init__.py +73 -0
  755. qiskit/transpiler/preset_passmanagers/builtin_plugins.py +1045 -0
  756. qiskit/transpiler/preset_passmanagers/common.py +649 -0
  757. qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py +626 -0
  758. qiskit/transpiler/preset_passmanagers/level0.py +113 -0
  759. qiskit/transpiler/preset_passmanagers/level1.py +120 -0
  760. qiskit/transpiler/preset_passmanagers/level2.py +119 -0
  761. qiskit/transpiler/preset_passmanagers/level3.py +119 -0
  762. qiskit/transpiler/preset_passmanagers/plugin.py +353 -0
  763. qiskit/transpiler/target.py +1319 -0
  764. qiskit/transpiler/timing_constraints.py +59 -0
  765. qiskit/user_config.py +262 -0
  766. qiskit/utils/__init__.py +89 -0
  767. qiskit/utils/classtools.py +146 -0
  768. qiskit/utils/deprecate_pulse.py +119 -0
  769. qiskit/utils/deprecation.py +490 -0
  770. qiskit/utils/lazy_tester.py +363 -0
  771. qiskit/utils/multiprocessing.py +56 -0
  772. qiskit/utils/optionals.py +347 -0
  773. qiskit/utils/parallel.py +191 -0
  774. qiskit/utils/units.py +143 -0
  775. qiskit/version.py +84 -0
  776. qiskit/visualization/__init__.py +288 -0
  777. qiskit/visualization/array.py +204 -0
  778. qiskit/visualization/bloch.py +778 -0
  779. qiskit/visualization/circuit/__init__.py +15 -0
  780. qiskit/visualization/circuit/_utils.py +675 -0
  781. qiskit/visualization/circuit/circuit_visualization.py +727 -0
  782. qiskit/visualization/circuit/latex.py +661 -0
  783. qiskit/visualization/circuit/matplotlib.py +2029 -0
  784. qiskit/visualization/circuit/qcstyle.py +278 -0
  785. qiskit/visualization/circuit/styles/__init__.py +13 -0
  786. qiskit/visualization/circuit/styles/bw.json +202 -0
  787. qiskit/visualization/circuit/styles/clifford.json +202 -0
  788. qiskit/visualization/circuit/styles/iqp-dark.json +214 -0
  789. qiskit/visualization/circuit/styles/iqp.json +214 -0
  790. qiskit/visualization/circuit/styles/textbook.json +202 -0
  791. qiskit/visualization/circuit/text.py +1844 -0
  792. qiskit/visualization/circuit_visualization.py +19 -0
  793. qiskit/visualization/counts_visualization.py +481 -0
  794. qiskit/visualization/dag_visualization.py +316 -0
  795. qiskit/visualization/exceptions.py +21 -0
  796. qiskit/visualization/gate_map.py +1485 -0
  797. qiskit/visualization/library.py +37 -0
  798. qiskit/visualization/pass_manager_visualization.py +308 -0
  799. qiskit/visualization/pulse_v2/__init__.py +21 -0
  800. qiskit/visualization/pulse_v2/core.py +901 -0
  801. qiskit/visualization/pulse_v2/device_info.py +173 -0
  802. qiskit/visualization/pulse_v2/drawings.py +253 -0
  803. qiskit/visualization/pulse_v2/events.py +254 -0
  804. qiskit/visualization/pulse_v2/generators/__init__.py +40 -0
  805. qiskit/visualization/pulse_v2/generators/barrier.py +76 -0
  806. qiskit/visualization/pulse_v2/generators/chart.py +208 -0
  807. qiskit/visualization/pulse_v2/generators/frame.py +436 -0
  808. qiskit/visualization/pulse_v2/generators/snapshot.py +133 -0
  809. qiskit/visualization/pulse_v2/generators/waveform.py +645 -0
  810. qiskit/visualization/pulse_v2/interface.py +458 -0
  811. qiskit/visualization/pulse_v2/layouts.py +387 -0
  812. qiskit/visualization/pulse_v2/plotters/__init__.py +17 -0
  813. qiskit/visualization/pulse_v2/plotters/base_plotter.py +53 -0
  814. qiskit/visualization/pulse_v2/plotters/matplotlib.py +201 -0
  815. qiskit/visualization/pulse_v2/stylesheet.py +312 -0
  816. qiskit/visualization/pulse_v2/types.py +242 -0
  817. qiskit/visualization/state_visualization.py +1518 -0
  818. qiskit/visualization/timeline/__init__.py +21 -0
  819. qiskit/visualization/timeline/core.py +480 -0
  820. qiskit/visualization/timeline/drawings.py +260 -0
  821. qiskit/visualization/timeline/generators.py +506 -0
  822. qiskit/visualization/timeline/interface.py +436 -0
  823. qiskit/visualization/timeline/layouts.py +115 -0
  824. qiskit/visualization/timeline/plotters/__init__.py +16 -0
  825. qiskit/visualization/timeline/plotters/base_plotter.py +58 -0
  826. qiskit/visualization/timeline/plotters/matplotlib.py +192 -0
  827. qiskit/visualization/timeline/stylesheet.py +301 -0
  828. qiskit/visualization/timeline/types.py +148 -0
  829. qiskit/visualization/transition_visualization.py +369 -0
  830. qiskit/visualization/utils.py +49 -0
  831. qiskit-1.3.0.dist-info/LICENSE.txt +203 -0
  832. qiskit-1.3.0.dist-info/METADATA +222 -0
  833. qiskit-1.3.0.dist-info/RECORD +836 -0
  834. qiskit-1.3.0.dist-info/WHEEL +5 -0
  835. qiskit-1.3.0.dist-info/entry_points.txt +76 -0
  836. qiskit-1.3.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1559 @@
1
+ # This code is part of Qiskit.
2
+ #
3
+ # (C) Copyright IBM 2022, 2023.
4
+ #
5
+ # This code is licensed under the Apache License, Version 2.0. You may
6
+ # obtain a copy of this license in the LICENSE.txt file in the root directory
7
+ # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8
+ #
9
+ # Any modifications or derivative works of this code must retain this
10
+ # copyright notice, and modified files need to carry a notice indicating
11
+ # that they have been altered from the originals.
12
+
13
+
14
+ """
15
+
16
+ High Level Synthesis Plugins
17
+ -----------------------------
18
+
19
+ Clifford Synthesis
20
+ ''''''''''''''''''
21
+
22
+ .. list-table:: Plugins for :class:`qiskit.quantum_info.Clifford` (key = ``"clifford"``)
23
+ :header-rows: 1
24
+
25
+ * - Plugin name
26
+ - Plugin class
27
+ - Targeted connectivity
28
+ - Description
29
+ * - ``"ag"``
30
+ - :class:`~.AGSynthesisClifford`
31
+ - all-to-all
32
+ - greedily optimizes CX-count
33
+ * - ``"bm"``
34
+ - :class:`~.BMSynthesisClifford`
35
+ - all-to-all
36
+ - optimal count for `n=2,3`; used in ``"default"`` for `n=2,3`
37
+ * - ``"greedy"``
38
+ - :class:`~.GreedySynthesisClifford`
39
+ - all-to-all
40
+ - greedily optimizes CX-count; used in ``"default"`` for `n>=4`
41
+ * - ``"layers"``
42
+ - :class:`~.LayerSynthesisClifford`
43
+ - all-to-all
44
+ -
45
+ * - ``"lnn"``
46
+ - :class:`~.LayerLnnSynthesisClifford`
47
+ - linear
48
+ - many CX-gates but guarantees CX-depth of at most `7*n+2`
49
+ * - ``"default"``
50
+ - :class:`~.DefaultSynthesisClifford`
51
+ - all-to-all
52
+ - usually best for optimizing CX-count (and optimal CX-count for `n=2,3`)
53
+
54
+ .. autosummary::
55
+ :toctree: ../stubs/
56
+
57
+ AGSynthesisClifford
58
+ BMSynthesisClifford
59
+ GreedySynthesisClifford
60
+ LayerSynthesisClifford
61
+ LayerLnnSynthesisClifford
62
+ DefaultSynthesisClifford
63
+
64
+
65
+ Linear Function Synthesis
66
+ '''''''''''''''''''''''''
67
+
68
+ .. list-table:: Plugins for :class:`.LinearFunction` (key = ``"linear"``)
69
+ :header-rows: 1
70
+
71
+ * - Plugin name
72
+ - Plugin class
73
+ - Targeted connectivity
74
+ - Description
75
+ * - ``"kms"``
76
+ - :class:`~.KMSSynthesisLinearFunction`
77
+ - linear
78
+ - many CX-gates but guarantees CX-depth of at most `5*n`
79
+ * - ``"pmh"``
80
+ - :class:`~.PMHSynthesisLinearFunction`
81
+ - all-to-all
82
+ - greedily optimizes CX-count; used in ``"default"``
83
+ * - ``"default"``
84
+ - :class:`~.DefaultSynthesisLinearFunction`
85
+ - all-to-all
86
+ - best for optimizing CX-count
87
+
88
+ .. autosummary::
89
+ :toctree: ../stubs/
90
+
91
+ KMSSynthesisLinearFunction
92
+ PMHSynthesisLinearFunction
93
+ DefaultSynthesisLinearFunction
94
+
95
+
96
+ Permutation Synthesis
97
+ '''''''''''''''''''''
98
+
99
+ .. list-table:: Plugins for :class:`.PermutationGate` (key = ``"permutation"``)
100
+ :header-rows: 1
101
+
102
+ * - Plugin name
103
+ - Plugin class
104
+ - Targeted connectivity
105
+ - Description
106
+ * - ``"basic"``
107
+ - :class:`~.BasicSynthesisPermutation`
108
+ - all-to-all
109
+ - optimal SWAP-count; used in ``"default"``
110
+ * - ``"acg"``
111
+ - :class:`~.ACGSynthesisPermutation`
112
+ - all-to-all
113
+ - guarantees SWAP-depth of at most `2`
114
+ * - ``"kms"``
115
+ - :class:`~.KMSSynthesisPermutation`
116
+ - linear
117
+ - many SWAP-gates, but guarantees SWAP-depth of at most `n`
118
+ * - ``"token_swapper"``
119
+ - :class:`~.TokenSwapperSynthesisPermutation`
120
+ - any
121
+ - greedily optimizes SWAP-count for arbitrary connectivity
122
+ * - ``"default"``
123
+ - :class:`~.BasicSynthesisPermutation`
124
+ - all-to-all
125
+ - best for optimizing SWAP-count
126
+
127
+ .. autosummary::
128
+ :toctree: ../stubs/
129
+
130
+ BasicSynthesisPermutation
131
+ ACGSynthesisPermutation
132
+ KMSSynthesisPermutation
133
+ TokenSwapperSynthesisPermutation
134
+
135
+
136
+ QFT Synthesis
137
+ '''''''''''''
138
+
139
+ .. list-table:: Plugins for :class:`.QFTGate` (key = ``"qft"``)
140
+ :header-rows: 1
141
+
142
+ * - Plugin name
143
+ - Plugin class
144
+ - Targeted connectivity
145
+ * - ``"full"``
146
+ - :class:`~.QFTSynthesisFull`
147
+ - all-to-all
148
+ * - ``"line"``
149
+ - :class:`~.QFTSynthesisLine`
150
+ - linear
151
+ * - ``"default"``
152
+ - :class:`~.QFTSynthesisFull`
153
+ - all-to-all
154
+
155
+ .. autosummary::
156
+ :toctree: ../stubs/
157
+
158
+ QFTSynthesisFull
159
+ QFTSynthesisLine
160
+
161
+
162
+ MCX Synthesis
163
+ '''''''''''''
164
+
165
+ The following table lists synthesis plugins available for an :class:`.MCXGate` gate
166
+ with `k` control qubits. If the available number of clean/dirty auxiliary qubits is
167
+ not sufficient, the corresponding synthesis method will return `None`.
168
+
169
+ .. list-table:: Plugins for :class:`.MCXGate` (key = ``"mcx"``)
170
+ :header-rows: 1
171
+
172
+ * - Plugin name
173
+ - Plugin class
174
+ - Number of clean ancillas
175
+ - Number of dirty ancillas
176
+ - Description
177
+ * - ``"gray_code"``
178
+ - :class:`~.MCXSynthesisGrayCode`
179
+ - `0`
180
+ - `0`
181
+ - exponentially many CX gates; use only for small values of `k`
182
+ * - ``"noaux_v24"``
183
+ - :class:`~.MCXSynthesisNoAuxV24`
184
+ - `0`
185
+ - `0`
186
+ - quadratic number of CX gates; use instead of ``"gray_code"`` for large values of `k`
187
+ * - ``"n_clean_m15"``
188
+ - :class:`~.MCXSynthesisNCleanM15`
189
+ - `k-2`
190
+ - `0`
191
+ - at most `6*k-6` CX gates
192
+ * - ``"n_dirty_i15"``
193
+ - :class:`~.MCXSynthesisNDirtyI15`
194
+ - `0`
195
+ - `k-2`
196
+ - at most `8*k-6` CX gates
197
+ * - ``"1_clean_b95"``
198
+ - :class:`~.MCXSynthesis1CleanB95`
199
+ - `1`
200
+ - `0`
201
+ - at most `16*k-8` CX gates
202
+ * - ``"default"``
203
+ - :class:`~.MCXSynthesisDefault`
204
+ - any
205
+ - any
206
+ - chooses the best algorithm based on the ancillas available
207
+
208
+ .. autosummary::
209
+ :toctree: ../stubs/
210
+
211
+ MCXSynthesisGrayCode
212
+ MCXSynthesisNoAuxV24
213
+ MCXSynthesisNCleanM15
214
+ MCXSynthesisNDirtyI15
215
+ MCXSynthesis1CleanB95
216
+ MCXSynthesisDefault
217
+
218
+
219
+ MCMT Synthesis
220
+ ''''''''''''''
221
+
222
+ .. list-table:: Plugins for :class:`.MCMTGate` (key = ``"mcmt"``)
223
+ :header-rows: 1
224
+
225
+ * - Plugin name
226
+ - Plugin class
227
+ - Number of clean ancillas
228
+ - Number of dirty ancillas
229
+ - Description
230
+ * - ``"vchain"``
231
+ - :class:`.MCMTSynthesisVChain`
232
+ - `k-1`
233
+ - `0`
234
+ - uses a linear number of Toffoli gates
235
+ * - ``"noaux"``
236
+ - :class:`~.MCMTSynthesisNoAux`
237
+ - `0`
238
+ - `0`
239
+ - uses Qiskit's standard control mechanism
240
+ * - ``"default"``
241
+ - :class:`~.MCMTSynthesisDefault`
242
+ - any
243
+ - any
244
+ - chooses the best algorithm based on the ancillas available
245
+
246
+ .. autosummary::
247
+ :toctree: ../stubs/
248
+
249
+ MCMTSynthesisVChain
250
+ MCMTSynthesisNoAux
251
+ MCMTSynthesisDefault
252
+
253
+
254
+ Pauli Evolution Synthesis
255
+ '''''''''''''''''''''''''
256
+
257
+ .. list-table:: Plugins for :class:`.PauliEvolutionGate` (key = ``"PauliEvolution"``)
258
+ :header-rows: 1
259
+
260
+ * - Plugin name
261
+ - Plugin class
262
+ - Description
263
+ - Targeted connectivity
264
+ * - ``"rustiq"``
265
+ - :class:`~.PauliEvolutionSynthesisRustiq`
266
+ - use the synthesis method from `Rustiq circuit synthesis library
267
+ <https://github.com/smartiel/rustiq-core>`_
268
+ - all-to-all
269
+ * - ``"default"``
270
+ - :class:`~.PauliEvolutionSynthesisDefault`
271
+ - use a diagonalizing Clifford per Pauli term
272
+ - all-to-all
273
+
274
+ .. autosummary::
275
+ :toctree: ../stubs/
276
+
277
+ PauliEvolutionSynthesisDefault
278
+ PauliEvolutionSynthesisRustiq
279
+
280
+
281
+ Modular Adder Synthesis
282
+ '''''''''''''''''''''''
283
+
284
+ .. list-table:: Plugins for :class:`.ModularAdderGate` (key = ``"ModularAdder"``)
285
+ :header-rows: 1
286
+
287
+ * - Plugin name
288
+ - Plugin class
289
+ - Number of clean ancillas
290
+ - Description
291
+ * - ``"ripple_cdkm"``
292
+ - :class:`.ModularAdderSynthesisC04`
293
+ - 1
294
+ - a ripple-carry adder
295
+ * - ``"ripple_vbe"``
296
+ - :class:`.ModularAdderSynthesisV95`
297
+ - :math:`n-1`, for :math:`n`-bit numbers
298
+ - a ripple-carry adder
299
+ * - ``"qft"``
300
+ - :class:`.ModularAdderSynthesisD00`
301
+ - 0
302
+ - a QFT-based adder
303
+
304
+ .. autosummary::
305
+ :toctree: ../stubs/
306
+
307
+ ModularAdderSynthesisC04
308
+ ModularAdderSynthesisD00
309
+ ModularAdderSynthesisV95
310
+
311
+ Half Adder Synthesis
312
+ ''''''''''''''''''''
313
+
314
+ .. list-table:: Plugins for :class:`.HalfAdderGate` (key = ``"HalfAdder"``)
315
+ :header-rows: 1
316
+
317
+ * - Plugin name
318
+ - Plugin class
319
+ - Number of clean ancillas
320
+ - Description
321
+ * - ``"ripple_cdkm"``
322
+ - :class:`.HalfAdderSynthesisC04`
323
+ - 1
324
+ - a ripple-carry adder
325
+ * - ``"ripple_vbe"``
326
+ - :class:`.HalfAdderSynthesisV95`
327
+ - :math:`n-1`, for :math:`n`-bit numbers
328
+ - a ripple-carry adder
329
+ * - ``"qft"``
330
+ - :class:`.HalfAdderSynthesisD00`
331
+ - 0
332
+ - a QFT-based adder
333
+
334
+ .. autosummary::
335
+ :toctree: ../stubs/
336
+
337
+ HalfAdderSynthesisC04
338
+ HalfAdderSynthesisD00
339
+ HalfAdderSynthesisV95
340
+
341
+ Full Adder Synthesis
342
+ ''''''''''''''''''''
343
+
344
+ .. list-table:: Plugins for :class:`.FullAdderGate` (key = ``"FullAdder"``)
345
+ :header-rows: 1
346
+
347
+ * - Plugin name
348
+ - Plugin class
349
+ - Number of clean ancillas
350
+ - Description
351
+ * - ``"ripple_cdkm"``
352
+ - :class:`.FullAdderSynthesisC04`
353
+ - 0
354
+ - a ripple-carry adder
355
+ * - ``"ripple_vbe"``
356
+ - :class:`.FullAdderSynthesisV95`
357
+ - :math:`n-1`, for :math:`n`-bit numbers
358
+ - a ripple-carry adder
359
+
360
+ .. autosummary::
361
+ :toctree: ../stubs/
362
+
363
+ FullAdderSynthesisC04
364
+ FullAdderSynthesisV95
365
+
366
+
367
+ Multiplier Synthesis
368
+ ''''''''''''''''''''
369
+
370
+ .. list-table:: Plugins for :class:`.MultiplierGate` (key = ``"Multiplier"``)
371
+ :header-rows: 1
372
+
373
+ * - Plugin name
374
+ - Plugin class
375
+ - Number of clean ancillas
376
+ - Description
377
+ * - ``"cumulative"``
378
+ - :class:`.MultiplierSynthesisH18`
379
+ - depending on the :class:`.HalfAdderGate` used
380
+ - a cumulative adder based on controlled adders
381
+ * - ``"qft"``
382
+ - :class:`.MultiplierSynthesisR17`
383
+ - 0
384
+ - a QFT-based multiplier
385
+
386
+ .. autosummary::
387
+ :toctree: ../stubs/
388
+
389
+ MultiplierSynthesisH18
390
+ MultiplierSynthesisR17
391
+
392
+ """
393
+
394
+ from __future__ import annotations
395
+
396
+ import warnings
397
+ import numpy as np
398
+ import rustworkx as rx
399
+
400
+ from qiskit.circuit.quantumcircuit import QuantumCircuit
401
+ from qiskit.circuit.library import (
402
+ LinearFunction,
403
+ QFTGate,
404
+ MCXGate,
405
+ C3XGate,
406
+ C4XGate,
407
+ PauliEvolutionGate,
408
+ ModularAdderGate,
409
+ HalfAdderGate,
410
+ FullAdderGate,
411
+ MultiplierGate,
412
+ )
413
+ from qiskit.transpiler.exceptions import TranspilerError
414
+ from qiskit.transpiler.coupling import CouplingMap
415
+
416
+ from qiskit.synthesis.clifford import (
417
+ synth_clifford_full,
418
+ synth_clifford_layers,
419
+ synth_clifford_depth_lnn,
420
+ synth_clifford_greedy,
421
+ synth_clifford_ag,
422
+ synth_clifford_bm,
423
+ )
424
+ from qiskit.synthesis.linear import (
425
+ synth_cnot_count_full_pmh,
426
+ synth_cnot_depth_line_kms,
427
+ calc_inverse_matrix,
428
+ )
429
+ from qiskit.synthesis.linear.linear_circuits_utils import transpose_cx_circ
430
+ from qiskit.synthesis.permutation import (
431
+ synth_permutation_basic,
432
+ synth_permutation_acg,
433
+ synth_permutation_depth_lnn_kms,
434
+ )
435
+ from qiskit.synthesis.qft import (
436
+ synth_qft_full,
437
+ synth_qft_line,
438
+ )
439
+ from qiskit.synthesis.multi_controlled import (
440
+ synth_mcx_n_dirty_i15,
441
+ synth_mcx_n_clean_m15,
442
+ synth_mcx_1_clean_b95,
443
+ synth_mcx_gray_code,
444
+ synth_mcx_noaux_v24,
445
+ synth_mcmt_vchain,
446
+ )
447
+ from qiskit.synthesis.evolution import ProductFormula, synth_pauli_network_rustiq
448
+ from qiskit.synthesis.arithmetic import (
449
+ adder_ripple_c04,
450
+ adder_qft_d00,
451
+ adder_ripple_v95,
452
+ multiplier_qft_r17,
453
+ multiplier_cumulative_h18,
454
+ )
455
+ from qiskit.transpiler.passes.routing.algorithms import ApproximateTokenSwapper
456
+ from .plugin import HighLevelSynthesisPlugin
457
+
458
+
459
+ class DefaultSynthesisClifford(HighLevelSynthesisPlugin):
460
+ """The default clifford synthesis plugin.
461
+
462
+ For N <= 3 qubits this is the optimal CX cost decomposition by Bravyi, Maslov.
463
+ For N > 3 qubits this is done using the general non-optimal greedy compilation
464
+ routine from reference by Bravyi, Hu, Maslov, Shaydulin.
465
+
466
+ This plugin name is :``clifford.default`` which can be used as the key on
467
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
468
+ """
469
+
470
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
471
+ """Run synthesis for the given Clifford."""
472
+ decomposition = synth_clifford_full(high_level_object)
473
+ return decomposition
474
+
475
+
476
+ class AGSynthesisClifford(HighLevelSynthesisPlugin):
477
+ """Clifford synthesis plugin based on the Aaronson-Gottesman method.
478
+
479
+ This plugin name is :``clifford.ag`` which can be used as the key on
480
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
481
+ """
482
+
483
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
484
+ """Run synthesis for the given Clifford."""
485
+ decomposition = synth_clifford_ag(high_level_object)
486
+ return decomposition
487
+
488
+
489
+ class BMSynthesisClifford(HighLevelSynthesisPlugin):
490
+ """Clifford synthesis plugin based on the Bravyi-Maslov method.
491
+
492
+ The method only works on Cliffords with at most 3 qubits, for which it
493
+ constructs the optimal CX cost decomposition.
494
+
495
+ This plugin name is :``clifford.bm`` which can be used as the key on
496
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
497
+ """
498
+
499
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
500
+ """Run synthesis for the given Clifford."""
501
+ if high_level_object.num_qubits <= 3:
502
+ decomposition = synth_clifford_bm(high_level_object)
503
+ else:
504
+ decomposition = None
505
+ return decomposition
506
+
507
+
508
+ class GreedySynthesisClifford(HighLevelSynthesisPlugin):
509
+ """Clifford synthesis plugin based on the greedy synthesis
510
+ Bravyi-Hu-Maslov-Shaydulin method.
511
+
512
+ This plugin name is :``clifford.greedy`` which can be used as the key on
513
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
514
+ """
515
+
516
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
517
+ """Run synthesis for the given Clifford."""
518
+ decomposition = synth_clifford_greedy(high_level_object)
519
+ return decomposition
520
+
521
+
522
+ class LayerSynthesisClifford(HighLevelSynthesisPlugin):
523
+ """Clifford synthesis plugin based on the Bravyi-Maslov method
524
+ to synthesize Cliffords into layers.
525
+
526
+ This plugin name is :``clifford.layers`` which can be used as the key on
527
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
528
+ """
529
+
530
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
531
+ """Run synthesis for the given Clifford."""
532
+ decomposition = synth_clifford_layers(high_level_object)
533
+ return decomposition
534
+
535
+
536
+ class LayerLnnSynthesisClifford(HighLevelSynthesisPlugin):
537
+ """Clifford synthesis plugin based on the Bravyi-Maslov method
538
+ to synthesize Cliffords into layers, with each layer synthesized
539
+ adhering to LNN connectivity.
540
+
541
+ This plugin name is :``clifford.lnn`` which can be used as the key on
542
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
543
+ """
544
+
545
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
546
+ """Run synthesis for the given Clifford."""
547
+ decomposition = synth_clifford_depth_lnn(high_level_object)
548
+ return decomposition
549
+
550
+
551
+ class DefaultSynthesisLinearFunction(HighLevelSynthesisPlugin):
552
+ """The default linear function synthesis plugin.
553
+
554
+ This plugin name is :``linear_function.default`` which can be used as the key on
555
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
556
+ """
557
+
558
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
559
+ """Run synthesis for the given LinearFunction."""
560
+ decomposition = synth_cnot_count_full_pmh(high_level_object.linear)
561
+ return decomposition
562
+
563
+
564
+ class KMSSynthesisLinearFunction(HighLevelSynthesisPlugin):
565
+ """Linear function synthesis plugin based on the Kutin-Moulton-Smithline method.
566
+
567
+ This plugin name is :``linear_function.kms`` which can be used as the key on
568
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
569
+
570
+ The plugin supports the following plugin-specific options:
571
+
572
+ * use_inverted: Indicates whether to run the algorithm on the inverse matrix
573
+ and to invert the synthesized circuit.
574
+ In certain cases this provides a better decomposition than the direct approach.
575
+ * use_transposed: Indicates whether to run the algorithm on the transposed matrix
576
+ and to invert the order of CX gates in the synthesized circuit.
577
+ In certain cases this provides a better decomposition than the direct approach.
578
+
579
+ """
580
+
581
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
582
+ """Run synthesis for the given LinearFunction."""
583
+
584
+ if not isinstance(high_level_object, LinearFunction):
585
+ raise TranspilerError(
586
+ "PMHSynthesisLinearFunction only accepts objects of type LinearFunction"
587
+ )
588
+
589
+ use_inverted = options.get("use_inverted", False)
590
+ use_transposed = options.get("use_transposed", False)
591
+
592
+ mat = high_level_object.linear.astype(bool, copy=False)
593
+
594
+ if use_transposed:
595
+ mat = np.transpose(mat)
596
+ if use_inverted:
597
+ mat = calc_inverse_matrix(mat)
598
+
599
+ decomposition = synth_cnot_depth_line_kms(mat)
600
+
601
+ if use_transposed:
602
+ decomposition = transpose_cx_circ(decomposition)
603
+ if use_inverted:
604
+ decomposition = decomposition.inverse()
605
+
606
+ return decomposition
607
+
608
+
609
+ class PMHSynthesisLinearFunction(HighLevelSynthesisPlugin):
610
+ """Linear function synthesis plugin based on the Patel-Markov-Hayes method.
611
+
612
+ This plugin name is :``linear_function.pmh`` which can be used as the key on
613
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
614
+
615
+ The plugin supports the following plugin-specific options:
616
+
617
+ * section size: The size of each section used in the Patel–Markov–Hayes algorithm [1].
618
+ * use_inverted: Indicates whether to run the algorithm on the inverse matrix
619
+ and to invert the synthesized circuit.
620
+ In certain cases this provides a better decomposition than the direct approach.
621
+ * use_transposed: Indicates whether to run the algorithm on the transposed matrix
622
+ and to invert the order of CX gates in the synthesized circuit.
623
+ In certain cases this provides a better decomposition than the direct approach.
624
+
625
+ References:
626
+ 1. Patel, Ketan N., Igor L. Markov, and John P. Hayes,
627
+ *Optimal synthesis of linear reversible circuits*,
628
+ Quantum Information & Computation 8.3 (2008): 282-294.
629
+ `arXiv:quant-ph/0302002 [quant-ph] <https://arxiv.org/abs/quant-ph/0302002>`_
630
+ """
631
+
632
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
633
+ """Run synthesis for the given LinearFunction."""
634
+
635
+ if not isinstance(high_level_object, LinearFunction):
636
+ raise TranspilerError(
637
+ "PMHSynthesisLinearFunction only accepts objects of type LinearFunction"
638
+ )
639
+
640
+ section_size = options.get("section_size", 2)
641
+ use_inverted = options.get("use_inverted", False)
642
+ use_transposed = options.get("use_transposed", False)
643
+
644
+ mat = high_level_object.linear.astype(bool, copy=False)
645
+
646
+ if use_transposed:
647
+ mat = np.transpose(mat)
648
+ if use_inverted:
649
+ mat = calc_inverse_matrix(mat)
650
+
651
+ decomposition = synth_cnot_count_full_pmh(mat, section_size=section_size)
652
+
653
+ if use_transposed:
654
+ decomposition = transpose_cx_circ(decomposition)
655
+ if use_inverted:
656
+ decomposition = decomposition.inverse()
657
+
658
+ return decomposition
659
+
660
+
661
+ class KMSSynthesisPermutation(HighLevelSynthesisPlugin):
662
+ """The permutation synthesis plugin based on the Kutin, Moulton, Smithline method.
663
+
664
+ This plugin name is :``permutation.kms`` which can be used as the key on
665
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
666
+ """
667
+
668
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
669
+ """Run synthesis for the given Permutation."""
670
+ decomposition = synth_permutation_depth_lnn_kms(high_level_object.pattern)
671
+ return decomposition
672
+
673
+
674
+ class BasicSynthesisPermutation(HighLevelSynthesisPlugin):
675
+ """The permutation synthesis plugin based on sorting.
676
+
677
+ This plugin name is :``permutation.basic`` which can be used as the key on
678
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
679
+ """
680
+
681
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
682
+ """Run synthesis for the given Permutation."""
683
+ decomposition = synth_permutation_basic(high_level_object.pattern)
684
+ return decomposition
685
+
686
+
687
+ class ACGSynthesisPermutation(HighLevelSynthesisPlugin):
688
+ """The permutation synthesis plugin based on the Alon, Chung, Graham method.
689
+
690
+ This plugin name is :``permutation.acg`` which can be used as the key on
691
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
692
+ """
693
+
694
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
695
+ """Run synthesis for the given Permutation."""
696
+ decomposition = synth_permutation_acg(high_level_object.pattern)
697
+ return decomposition
698
+
699
+
700
+ class QFTSynthesisFull(HighLevelSynthesisPlugin):
701
+ """Synthesis plugin for QFT gates using all-to-all connectivity.
702
+
703
+ This plugin name is :``qft.full`` which can be used as the key on
704
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
705
+
706
+ Note that the plugin mechanism is not applied if the gate is called ``qft`` but
707
+ is not an instance of ``QFTGate``. This allows users to create custom gates with
708
+ name ``qft``.
709
+
710
+ The plugin supports the following additional options:
711
+
712
+ * reverse_qubits (bool): Whether to synthesize the "QFT" operation (if ``False``,
713
+ which is the default) or the "QFT-with-reversal" operation (if ``True``).
714
+ Some implementation of the ``QFTGate`` include a layer of swap gates at the end
715
+ of the synthesized circuit, which can in principle be dropped if the ``QFTGate``
716
+ itself is the last gate in the circuit.
717
+ * approximation_degree (int): The degree of approximation (0 for no approximation).
718
+ It is possible to implement the QFT approximately by ignoring
719
+ controlled-phase rotations with the angle beneath a threshold. This is discussed
720
+ in more detail in [1] or [2].
721
+ * insert_barriers (bool): If True, barriers are inserted as visualization improvement.
722
+ * inverse (bool): If True, the inverse Fourier transform is constructed.
723
+ * name (str): The name of the circuit.
724
+
725
+ References:
726
+ 1. Adriano Barenco, Artur Ekert, Kalle-Antti Suominen, and Päivi Törmä,
727
+ *Approximate Quantum Fourier Transform and Decoherence*,
728
+ Physical Review A (1996).
729
+ `arXiv:quant-ph/9601018 [quant-ph] <https://arxiv.org/abs/quant-ph/9601018>`_
730
+ 2. Donny Cheung,
731
+ *Improved Bounds for the Approximate QFT* (2004),
732
+ `arXiv:quant-ph/0403071 [quant-ph] <https://https://arxiv.org/abs/quant-ph/0403071>`_
733
+ """
734
+
735
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
736
+ """Run synthesis for the given QFTGate."""
737
+
738
+ # Even though the gate is called "qft", it's not a QFTGate,
739
+ # and we should not synthesize it using the plugin.
740
+ if not isinstance(high_level_object, QFTGate):
741
+ return None
742
+
743
+ reverse_qubits = options.get("reverse_qubits", False)
744
+ approximation_degree = options.get("approximation_degree", 0)
745
+ insert_barriers = options.get("insert_barriers", False)
746
+ inverse = options.get("inverse", False)
747
+ name = options.get("name", None)
748
+
749
+ decomposition = synth_qft_full(
750
+ num_qubits=high_level_object.num_qubits,
751
+ do_swaps=not reverse_qubits,
752
+ approximation_degree=approximation_degree,
753
+ insert_barriers=insert_barriers,
754
+ inverse=inverse,
755
+ name=name,
756
+ )
757
+ return decomposition
758
+
759
+
760
+ class QFTSynthesisLine(HighLevelSynthesisPlugin):
761
+ """Synthesis plugin for QFT gates using linear connectivity.
762
+
763
+ This plugin name is :``qft.line`` which can be used as the key on
764
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
765
+
766
+ Note that the plugin mechanism is not applied if the gate is called ``qft`` but
767
+ is not an instance of ``QFTGate``. This allows users to create custom gates with
768
+ name ``qft``.
769
+
770
+ The plugin supports the following additional options:
771
+
772
+ * reverse_qubits (bool): Whether to synthesize the "QFT" operation (if ``False``,
773
+ which is the default) or the "QFT-with-reversal" operation (if ``True``).
774
+ Some implementation of the ``QFTGate`` include a layer of swap gates at the end
775
+ of the synthesized circuit, which can in principle be dropped if the ``QFTGate``
776
+ itself is the last gate in the circuit.
777
+ * approximation_degree (int): the degree of approximation (0 for no approximation).
778
+ It is possible to implement the QFT approximately by ignoring
779
+ controlled-phase rotations with the angle beneath a threshold. This is discussed
780
+ in more detail in [1] or [2].
781
+
782
+ References:
783
+ 1. Adriano Barenco, Artur Ekert, Kalle-Antti Suominen, and Päivi Törmä,
784
+ *Approximate Quantum Fourier Transform and Decoherence*,
785
+ Physical Review A (1996).
786
+ `arXiv:quant-ph/9601018 [quant-ph] <https://arxiv.org/abs/quant-ph/9601018>`_
787
+ 2. Donny Cheung,
788
+ *Improved Bounds for the Approximate QFT* (2004),
789
+ `arXiv:quant-ph/0403071 [quant-ph] <https://https://arxiv.org/abs/quant-ph/0403071>`_
790
+ """
791
+
792
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
793
+ """Run synthesis for the given QFTGate."""
794
+
795
+ # Even though the gate is called "qft", it's not a QFTGate,
796
+ # and we should not synthesize it using the plugin.
797
+ if not isinstance(high_level_object, QFTGate):
798
+ return None
799
+
800
+ reverse_qubits = options.get("reverse_qubits", False)
801
+ approximation_degree = options.get("approximation_degree", 0)
802
+
803
+ decomposition = synth_qft_line(
804
+ num_qubits=high_level_object.num_qubits,
805
+ do_swaps=not reverse_qubits,
806
+ approximation_degree=approximation_degree,
807
+ )
808
+ return decomposition
809
+
810
+
811
+ class TokenSwapperSynthesisPermutation(HighLevelSynthesisPlugin):
812
+ """The permutation synthesis plugin based on the token swapper algorithm.
813
+
814
+ This plugin name is :``permutation.token_swapper`` which can be used as the key on
815
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
816
+
817
+ In more detail, this plugin is used to synthesize objects of type `PermutationGate`.
818
+ When synthesis succeeds, the plugin outputs a quantum circuit consisting only of swap
819
+ gates. When synthesis does not succeed, the plugin outputs `None`.
820
+
821
+ If either `coupling_map` or `qubits` is None, then the synthesized circuit
822
+ is not required to adhere to connectivity constraints, as is the case
823
+ when the synthesis is done before layout/routing.
824
+
825
+ On the other hand, if both `coupling_map` and `qubits` are specified, the synthesized
826
+ circuit is supposed to adhere to connectivity constraints. At the moment, the
827
+ plugin only creates swap gates between qubits in `qubits`, i.e. it does not use
828
+ any other qubits in the coupling map (if such synthesis is not possible, the
829
+ plugin outputs `None`).
830
+
831
+ The plugin supports the following plugin-specific options:
832
+
833
+ * trials: The number of trials for the token swapper to perform the mapping. The
834
+ circuit with the smallest number of SWAPs is returned.
835
+ * seed: The argument to the token swapper specifying the seed for random trials.
836
+ * parallel_threshold: The argument to the token swapper specifying the number of nodes
837
+ in the graph beyond which the algorithm will use parallel processing.
838
+
839
+ For more details on the token swapper algorithm, see to the paper:
840
+ `arXiv:1902.09102 <https://arxiv.org/abs/1902.09102>`__.
841
+ """
842
+
843
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
844
+ """Run synthesis for the given Permutation."""
845
+
846
+ trials = options.get("trials", 5)
847
+ seed = options.get("seed", 0)
848
+ parallel_threshold = options.get("parallel_threshold", 50)
849
+
850
+ pattern = high_level_object.pattern
851
+ pattern_as_dict = {j: i for i, j in enumerate(pattern)}
852
+
853
+ # When the plugin is called from the HighLevelSynthesis transpiler pass,
854
+ # the coupling map already takes target into account.
855
+ if coupling_map is None or qubits is None:
856
+ # The abstract synthesis uses a fully connected coupling map, allowing
857
+ # arbitrary connections between qubits.
858
+ used_coupling_map = CouplingMap.from_full(len(pattern))
859
+ else:
860
+ # The concrete synthesis uses the coupling map restricted to the set of
861
+ # qubits over which the permutation gate is defined. If we allow using other
862
+ # qubits in the coupling map, replacing the node in the DAGCircuit that
863
+ # defines this PermutationGate by the DAG corresponding to the constructed
864
+ # decomposition becomes problematic. Note that we allow the reduced
865
+ # coupling map to be disconnected.
866
+ used_coupling_map = coupling_map.reduce(qubits, check_if_connected=False)
867
+
868
+ graph = used_coupling_map.graph.to_undirected()
869
+ swapper = ApproximateTokenSwapper(graph, seed=seed)
870
+
871
+ try:
872
+ swapper_result = swapper.map(
873
+ pattern_as_dict, trials, parallel_threshold=parallel_threshold
874
+ )
875
+ except rx.InvalidMapping:
876
+ swapper_result = None
877
+
878
+ if swapper_result is not None:
879
+ decomposition = QuantumCircuit(len(graph.node_indices()))
880
+ for swap in swapper_result:
881
+ decomposition.swap(*swap)
882
+ return decomposition
883
+
884
+ return None
885
+
886
+
887
+ class MCXSynthesisNDirtyI15(HighLevelSynthesisPlugin):
888
+ r"""Synthesis plugin for a multi-controlled X gate based on the paper
889
+ by Iten et al. (2016).
890
+
891
+ See [1] for details.
892
+
893
+ This plugin name is :``mcx.n_dirty_i15`` which can be used as the key on
894
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
895
+
896
+ For a multi-controlled X gate with :math:`k\ge 3` control qubits this synthesis
897
+ method requires :math:`k - 2` additional dirty auxiliary qubits. The synthesized
898
+ circuit consists of :math:`2 * k - 1` qubits and at most :math:`8 * k - 6` CX gates.
899
+
900
+ The plugin supports the following plugin-specific options:
901
+
902
+ * num_clean_ancillas: The number of clean auxiliary qubits available.
903
+ * num_dirty_ancillas: The number of dirty auxiliary qubits available.
904
+ * relative_phase: When set to ``True``, the method applies the optimized multi-controlled
905
+ X gate up to a relative phase, in a way that, by lemma 8 of [1], the relative
906
+ phases of the ``action part`` cancel out with the phases of the ``reset part``.
907
+ * action_only: when set to ``True``, the method applies only the ``action part``
908
+ of lemma 8 of [1].
909
+
910
+ References:
911
+ 1. Iten et. al., *Quantum Circuits for Isometries*, Phys. Rev. A 93, 032318 (2016),
912
+ `arXiv:1501.06911 <http://arxiv.org/abs/1501.06911>`_
913
+ """
914
+
915
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
916
+ """Run synthesis for the given MCX gate."""
917
+
918
+ if not isinstance(high_level_object, (MCXGate, C3XGate, C4XGate)):
919
+ # Unfortunately we occasionally have custom instructions called "mcx"
920
+ # which get wrongly caught by the plugin interface. A simple solution is
921
+ # to return None in this case, since HLS would proceed to examine
922
+ # their definition as it should.
923
+ return None
924
+
925
+ num_ctrl_qubits = high_level_object.num_ctrl_qubits
926
+ num_clean_ancillas = options.get("num_clean_ancillas", 0)
927
+ num_dirty_ancillas = options.get("num_dirty_ancillas", 0)
928
+ relative_phase = options.get("relative_phase", False)
929
+ action_only = options.get("actions_only", False)
930
+
931
+ if num_ctrl_qubits >= 3 and num_dirty_ancillas + num_clean_ancillas < num_ctrl_qubits - 2:
932
+ # This synthesis method is not applicable as there are not enough ancilla qubits
933
+ return None
934
+
935
+ decomposition = synth_mcx_n_dirty_i15(num_ctrl_qubits, relative_phase, action_only)
936
+ return decomposition
937
+
938
+
939
+ class MCXSynthesisNCleanM15(HighLevelSynthesisPlugin):
940
+ r"""Synthesis plugin for a multi-controlled X gate based on the paper by
941
+ Maslov (2016).
942
+
943
+ See [1] for details.
944
+
945
+ This plugin name is :``mcx.n_clean_m15`` which can be used as the key on
946
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
947
+
948
+ For a multi-controlled X gate with :math:`k\ge 3` control qubits this synthesis
949
+ method requires :math:`k - 2` additional clean auxiliary qubits. The synthesized
950
+ circuit consists of :math:`2 * k - 1` qubits and at most :math:`6 * k - 6` CX gates.
951
+
952
+ The plugin supports the following plugin-specific options:
953
+
954
+ * num_clean_ancillas: The number of clean auxiliary qubits available.
955
+
956
+ References:
957
+ 1. Maslov., Phys. Rev. A 93, 022311 (2016),
958
+ `arXiv:1508.03273 <https://arxiv.org/pdf/1508.03273>`_
959
+ """
960
+
961
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
962
+ """Run synthesis for the given MCX gate."""
963
+
964
+ if not isinstance(high_level_object, (MCXGate, C3XGate, C4XGate)):
965
+ # Unfortunately we occasionally have custom instructions called "mcx"
966
+ # which get wrongly caught by the plugin interface. A simple solution is
967
+ # to return None in this case, since HLS would proceed to examine
968
+ # their definition as it should.
969
+ return None
970
+
971
+ num_ctrl_qubits = high_level_object.num_ctrl_qubits
972
+ num_clean_ancillas = options.get("num_clean_ancillas", 0)
973
+
974
+ if num_ctrl_qubits >= 3 and num_clean_ancillas < num_ctrl_qubits - 2:
975
+ # This synthesis method is not applicable as there are not enough ancilla qubits
976
+ return None
977
+
978
+ decomposition = synth_mcx_n_clean_m15(num_ctrl_qubits)
979
+ return decomposition
980
+
981
+
982
+ class MCXSynthesis1CleanB95(HighLevelSynthesisPlugin):
983
+ r"""Synthesis plugin for a multi-controlled X gate based on the paper by
984
+ Barenco et al. (1995).
985
+
986
+ See [1] for details.
987
+
988
+ This plugin name is :``mcx.1_clean_b95`` which can be used as the key on
989
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
990
+
991
+ For a multi-controlled X gate with :math:`k\ge 5` control qubits this synthesis
992
+ method requires a single additional clean auxiliary qubit. The synthesized
993
+ circuit consists of :math:`k + 2` qubits and at most :math:`16 * k - 8` CX gates.
994
+
995
+ The plugin supports the following plugin-specific options:
996
+
997
+ * num_clean_ancillas: The number of clean auxiliary qubits available.
998
+
999
+ References:
1000
+ 1. Barenco et. al., Phys.Rev. A52 3457 (1995),
1001
+ `arXiv:quant-ph/9503016 <https://arxiv.org/abs/quant-ph/9503016>`_
1002
+ """
1003
+
1004
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1005
+ """Run synthesis for the given MCX gate."""
1006
+
1007
+ if not isinstance(high_level_object, (MCXGate, C3XGate, C4XGate)):
1008
+ # Unfortunately we occasionally have custom instructions called "mcx"
1009
+ # which get wrongly caught by the plugin interface. A simple solution is
1010
+ # to return None in this case, since HLS would proceed to examine
1011
+ # their definition as it should.
1012
+ return None
1013
+
1014
+ num_ctrl_qubits = high_level_object.num_ctrl_qubits
1015
+
1016
+ if num_ctrl_qubits <= 2:
1017
+ # The method requires at least 3 control qubits
1018
+ return None
1019
+
1020
+ num_clean_ancillas = options.get("num_clean_ancillas", 0)
1021
+
1022
+ if num_ctrl_qubits >= 5 and num_clean_ancillas == 0:
1023
+ # This synthesis method is not applicable as there are not enough ancilla qubits
1024
+ return None
1025
+
1026
+ decomposition = synth_mcx_1_clean_b95(num_ctrl_qubits)
1027
+ return decomposition
1028
+
1029
+
1030
+ class MCXSynthesisGrayCode(HighLevelSynthesisPlugin):
1031
+ r"""Synthesis plugin for a multi-controlled X gate based on the Gray code.
1032
+
1033
+ This plugin name is :``mcx.gray_code`` which can be used as the key on
1034
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
1035
+
1036
+ For a multi-controlled X gate with :math:`k` control qubits this synthesis
1037
+ method requires no additional clean auxiliary qubits. The synthesized
1038
+ circuit consists of :math:`k + 1` qubits.
1039
+
1040
+ It is not recommended to use this method for large values of :math:`k + 1`
1041
+ as it produces exponentially many gates.
1042
+ """
1043
+
1044
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1045
+ """Run synthesis for the given MCX gate."""
1046
+
1047
+ if not isinstance(high_level_object, (MCXGate, C3XGate, C4XGate)):
1048
+ # Unfortunately we occasionally have custom instructions called "mcx"
1049
+ # which get wrongly caught by the plugin interface. A simple solution is
1050
+ # to return None in this case, since HLS would proceed to examine
1051
+ # their definition as it should.
1052
+ return None
1053
+
1054
+ num_ctrl_qubits = high_level_object.num_ctrl_qubits
1055
+ decomposition = synth_mcx_gray_code(num_ctrl_qubits)
1056
+ return decomposition
1057
+
1058
+
1059
+ class MCXSynthesisNoAuxV24(HighLevelSynthesisPlugin):
1060
+ r"""Synthesis plugin for a multi-controlled X gate based on the
1061
+ implementation for MCPhaseGate, which is in turn based on the
1062
+ paper by Vale et al. (2024).
1063
+
1064
+ See [1] for details.
1065
+
1066
+ This plugin name is :``mcx.noaux_v24`` which can be used as the key on
1067
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
1068
+
1069
+ For a multi-controlled X gate with :math:`k` control qubits this synthesis
1070
+ method requires no additional clean auxiliary qubits. The synthesized
1071
+ circuit consists of :math:`k + 1` qubits.
1072
+
1073
+ References:
1074
+ 1. Vale et. al., *Circuit Decomposition of Multicontrolled Special Unitary
1075
+ Single-Qubit Gates*, IEEE TCAD 43(3) (2024),
1076
+ `arXiv:2302.06377 <https://arxiv.org/abs/2302.06377>`_
1077
+ """
1078
+
1079
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1080
+ """Run synthesis for the given MCX gate."""
1081
+
1082
+ if not isinstance(high_level_object, (MCXGate, C3XGate, C4XGate)):
1083
+ # Unfortunately we occasionally have custom instructions called "mcx"
1084
+ # which get wrongly caught by the plugin interface. A simple solution is
1085
+ # to return None in this case, since HLS would proceed to examine
1086
+ # their definition as it should.
1087
+ return None
1088
+
1089
+ num_ctrl_qubits = high_level_object.num_ctrl_qubits
1090
+ decomposition = synth_mcx_noaux_v24(num_ctrl_qubits)
1091
+ return decomposition
1092
+
1093
+
1094
+ class MCXSynthesisDefault(HighLevelSynthesisPlugin):
1095
+ r"""The default synthesis plugin for a multi-controlled X gate.
1096
+
1097
+ This plugin name is :``mcx.default`` which can be used as the key on
1098
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
1099
+ """
1100
+
1101
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1102
+ """Run synthesis for the given MCX gate."""
1103
+
1104
+ if not isinstance(high_level_object, (MCXGate, C3XGate, C4XGate)):
1105
+ # Unfortunately we occasionally have custom instructions called "mcx"
1106
+ # which get wrongly caught by the plugin interface. A simple solution is
1107
+ # to return None in this case, since HLS would proceed to examine
1108
+ # their definition as it should.
1109
+ return None
1110
+
1111
+ # Iteratively run other synthesis methods available
1112
+
1113
+ if (
1114
+ decomposition := MCXSynthesisNCleanM15().run(
1115
+ high_level_object, coupling_map, target, qubits, **options
1116
+ )
1117
+ ) is not None:
1118
+ return decomposition
1119
+
1120
+ if (
1121
+ decomposition := MCXSynthesisNDirtyI15().run(
1122
+ high_level_object, coupling_map, target, qubits, **options
1123
+ )
1124
+ ) is not None:
1125
+ return decomposition
1126
+
1127
+ if (
1128
+ decomposition := MCXSynthesis1CleanB95().run(
1129
+ high_level_object, coupling_map, target, qubits, **options
1130
+ )
1131
+ ) is not None:
1132
+ return decomposition
1133
+
1134
+ return MCXSynthesisNoAuxV24().run(
1135
+ high_level_object, coupling_map, target, qubits, **options
1136
+ )
1137
+
1138
+
1139
+ class MCMTSynthesisDefault(HighLevelSynthesisPlugin):
1140
+ """A default decomposition for MCMT gates."""
1141
+
1142
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1143
+ # first try to use the V-chain synthesis if enough auxiliary qubits are available
1144
+ if (
1145
+ decomposition := MCMTSynthesisVChain().run(
1146
+ high_level_object, coupling_map, target, qubits, **options
1147
+ )
1148
+ ) is not None:
1149
+ return decomposition
1150
+
1151
+ return MCMTSynthesisNoAux().run(high_level_object, coupling_map, target, qubits, **options)
1152
+
1153
+
1154
+ class MCMTSynthesisNoAux(HighLevelSynthesisPlugin):
1155
+ """A V-chain based synthesis for ``MCMTGate``."""
1156
+
1157
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1158
+ base_gate = high_level_object.base_gate
1159
+ ctrl_state = options.get("ctrl_state", None)
1160
+
1161
+ if high_level_object.num_target_qubits == 1:
1162
+ # no broadcasting needed (makes for better circuit diagrams)
1163
+ circuit = QuantumCircuit(high_level_object.num_qubits)
1164
+ circuit.append(
1165
+ base_gate.control(high_level_object.num_ctrl_qubits, ctrl_state=ctrl_state),
1166
+ circuit.qubits,
1167
+ )
1168
+
1169
+ else:
1170
+ base = QuantumCircuit(high_level_object.num_target_qubits, name=high_level_object.label)
1171
+ for i in range(high_level_object.num_target_qubits):
1172
+ base.append(base_gate, [i], [])
1173
+
1174
+ circuit = base.control(high_level_object.num_ctrl_qubits, ctrl_state=ctrl_state)
1175
+
1176
+ return circuit.decompose()
1177
+
1178
+
1179
+ class MCMTSynthesisVChain(HighLevelSynthesisPlugin):
1180
+ """A V-chain based synthesis for ``MCMTGate``."""
1181
+
1182
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1183
+ if options.get("num_clean_ancillas", 0) < high_level_object.num_ctrl_qubits - 1:
1184
+ return None # insufficient number of auxiliary qubits
1185
+
1186
+ ctrl_state = options.get("ctrl_state", None)
1187
+
1188
+ return synth_mcmt_vchain(
1189
+ high_level_object.base_gate,
1190
+ high_level_object.num_ctrl_qubits,
1191
+ high_level_object.num_target_qubits,
1192
+ ctrl_state,
1193
+ )
1194
+
1195
+
1196
+ class ModularAdderSynthesisDefault(HighLevelSynthesisPlugin):
1197
+ """The default modular adder (no carry in, no carry out qubit) synthesis.
1198
+
1199
+ This plugin name is:``ModularAdder.default`` which can be used as the key on
1200
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
1201
+
1202
+ If at least one clean auxiliary qubit is available, the :class:`ModularAdderSynthesisC04`
1203
+ is used, otherwise :class:`ModularAdderSynthesisD00`.
1204
+
1205
+ The plugin supports the following plugin-specific options:
1206
+
1207
+ * ``num_clean_ancillas``: The number of clean auxiliary qubits available.
1208
+
1209
+ """
1210
+
1211
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1212
+ if not isinstance(high_level_object, ModularAdderGate):
1213
+ return None
1214
+
1215
+ if options.get("num_clean_ancillas", 0) >= 1:
1216
+ return adder_ripple_c04(high_level_object.num_state_qubits, kind="fixed")
1217
+
1218
+ return adder_qft_d00(high_level_object.num_state_qubits, kind="fixed")
1219
+
1220
+
1221
+ class ModularAdderSynthesisC04(HighLevelSynthesisPlugin):
1222
+ r"""A ripple-carry adder, modulo :math:`2^n`.
1223
+
1224
+ This plugin name is:``ModularAdder.ripple_c04`` which can be used as the key on
1225
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
1226
+
1227
+ This plugin requires at least one clean auxiliary qubit.
1228
+
1229
+ The plugin supports the following plugin-specific options:
1230
+
1231
+ * ``num_clean_ancillas``: The number of clean auxiliary qubits available.
1232
+
1233
+ """
1234
+
1235
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1236
+ if not isinstance(high_level_object, ModularAdderGate):
1237
+ return None
1238
+
1239
+ # unless we implement the full adder, this implementation needs an ancilla qubit
1240
+ if options.get("num_clean_ancillas", 0) < 1:
1241
+ return None
1242
+
1243
+ return adder_ripple_c04(high_level_object.num_state_qubits, kind="fixed")
1244
+
1245
+
1246
+ class ModularAdderSynthesisV95(HighLevelSynthesisPlugin):
1247
+ r"""A ripple-carry adder, modulo :math:`2^n`.
1248
+
1249
+ This plugin name is:``ModularAdder.ripple_v95`` which can be used as the key on
1250
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
1251
+
1252
+ For an adder on 2 registers with :math:`n` qubits each, this plugin requires at
1253
+ least :math:`n-1` clean auxiliary qubit.
1254
+
1255
+ The plugin supports the following plugin-specific options:
1256
+
1257
+ * ``num_clean_ancillas``: The number of clean auxiliary qubits available.
1258
+
1259
+ """
1260
+
1261
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1262
+ if not isinstance(high_level_object, ModularAdderGate):
1263
+ return None
1264
+
1265
+ num_state_qubits = high_level_object.num_state_qubits
1266
+
1267
+ # for more than 1 state qubit, we need an ancilla
1268
+ if num_state_qubits > 1 > options.get("num_clean_ancillas", 1):
1269
+ return None
1270
+
1271
+ return adder_ripple_v95(num_state_qubits, kind="fixed")
1272
+
1273
+
1274
+ class ModularAdderSynthesisD00(HighLevelSynthesisPlugin):
1275
+ r"""A QFT-based adder, modulo :math:`2^n`.
1276
+
1277
+ This plugin name is:``ModularAdder.qft_d00`` which can be used as the key on
1278
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
1279
+ """
1280
+
1281
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1282
+ if not isinstance(high_level_object, ModularAdderGate):
1283
+ return None
1284
+
1285
+ return adder_qft_d00(high_level_object.num_state_qubits, kind="fixed")
1286
+
1287
+
1288
+ class HalfAdderSynthesisDefault(HighLevelSynthesisPlugin):
1289
+ r"""The default half-adder (no carry in, but a carry out qubit) synthesis.
1290
+
1291
+ If we have an auxiliary qubit available, the Cuccaro ripple-carry adder uses
1292
+ :math:`O(n)` CX gates and 1 auxiliary qubit, whereas the Vedral ripple-carry uses more CX
1293
+ and :math:`n-1` auxiliary qubits. The QFT-based adder uses no auxiliary qubits, but
1294
+ :math:`O(n^2)`, hence it is only used if no auxiliary qubits are available.
1295
+
1296
+ This plugin name is:``HalfAdder.default`` which can be used as the key on
1297
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
1298
+
1299
+ If at least one clean auxiliary qubit is available, the :class:`HalfAdderSynthesisC04`
1300
+ is used, otherwise :class:`HalfAdderSynthesisD00`.
1301
+
1302
+ The plugin supports the following plugin-specific options:
1303
+
1304
+ * ``num_clean_ancillas``: The number of clean auxiliary qubits available.
1305
+
1306
+ """
1307
+
1308
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1309
+ if not isinstance(high_level_object, HalfAdderGate):
1310
+ return None
1311
+
1312
+ if options.get("num_clean_ancillas", 0) >= 1:
1313
+ return adder_ripple_c04(high_level_object.num_state_qubits, kind="half")
1314
+
1315
+ return adder_qft_d00(high_level_object.num_state_qubits, kind="half")
1316
+
1317
+
1318
+ class HalfAdderSynthesisC04(HighLevelSynthesisPlugin):
1319
+ """A ripple-carry adder with a carry-out bit.
1320
+
1321
+ This plugin name is:``HalfAdder.ripple_c04`` which can be used as the key on
1322
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
1323
+
1324
+ This plugin requires at least one clean auxiliary qubit.
1325
+
1326
+ The plugin supports the following plugin-specific options:
1327
+
1328
+ * ``num_clean_ancillas``: The number of clean auxiliary qubits available.
1329
+
1330
+ """
1331
+
1332
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1333
+ if not isinstance(high_level_object, HalfAdderGate):
1334
+ return None
1335
+
1336
+ # unless we implement the full adder, this implementation needs an ancilla qubit
1337
+ if options.get("num_clean_ancillas", 0) < 1:
1338
+ return None
1339
+
1340
+ return adder_ripple_c04(high_level_object.num_state_qubits, kind="half")
1341
+
1342
+
1343
+ class HalfAdderSynthesisV95(HighLevelSynthesisPlugin):
1344
+ """A ripple-carry adder with a carry-out bit.
1345
+
1346
+ This plugin name is:``HalfAdder.ripple_v95`` which can be used as the key on
1347
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
1348
+
1349
+ For an adder on 2 registers with :math:`n` qubits each, this plugin requires at
1350
+ least :math:`n-1` clean auxiliary qubit.
1351
+
1352
+ The plugin supports the following plugin-specific options:
1353
+
1354
+ * ``num_clean_ancillas``: The number of clean auxiliary qubits available.
1355
+ """
1356
+
1357
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1358
+ if not isinstance(high_level_object, HalfAdderGate):
1359
+ return None
1360
+
1361
+ num_state_qubits = high_level_object.num_state_qubits
1362
+
1363
+ # for more than 1 state qubit, we need an ancilla
1364
+ if num_state_qubits > 1 > options.get("num_clean_ancillas", 1):
1365
+ return None
1366
+
1367
+ return adder_ripple_v95(num_state_qubits, kind="half")
1368
+
1369
+
1370
+ class HalfAdderSynthesisD00(HighLevelSynthesisPlugin):
1371
+ """A QFT-based adder with a carry-in and a carry-out bit.
1372
+
1373
+ This plugin name is:``HalfAdder.qft_d00`` which can be used as the key on
1374
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
1375
+ """
1376
+
1377
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1378
+ if not isinstance(high_level_object, HalfAdderGate):
1379
+ return None
1380
+
1381
+ return adder_qft_d00(high_level_object.num_state_qubits, kind="half")
1382
+
1383
+
1384
+ class FullAdderSynthesisC04(HighLevelSynthesisPlugin):
1385
+ """A ripple-carry adder with a carry-in and a carry-out bit.
1386
+
1387
+ This plugin name is:``FullAdder.ripple_c04`` which can be used as the key on
1388
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
1389
+
1390
+ This plugin requires at least one clean auxiliary qubit.
1391
+
1392
+ The plugin supports the following plugin-specific options:
1393
+
1394
+ * ``num_clean_ancillas``: The number of clean auxiliary qubits available.
1395
+
1396
+ """
1397
+
1398
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1399
+ if not isinstance(high_level_object, FullAdderGate):
1400
+ return None
1401
+
1402
+ return adder_ripple_c04(high_level_object.num_state_qubits, kind="full")
1403
+
1404
+
1405
+ class FullAdderSynthesisV95(HighLevelSynthesisPlugin):
1406
+ """A ripple-carry adder with a carry-in and a carry-out bit.
1407
+
1408
+ This plugin name is:``FullAdder.ripple_v95`` which can be used as the key on
1409
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
1410
+
1411
+ For an adder on 2 registers with :math:`n` qubits each, this plugin requires at
1412
+ least :math:`n-1` clean auxiliary qubit.
1413
+
1414
+ The plugin supports the following plugin-specific options:
1415
+
1416
+ * ``num_clean_ancillas``: The number of clean auxiliary qubits available.
1417
+ """
1418
+
1419
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1420
+ if not isinstance(high_level_object, FullAdderGate):
1421
+ return None
1422
+
1423
+ num_state_qubits = high_level_object.num_state_qubits
1424
+
1425
+ # for more than 1 state qubit, we need an ancilla
1426
+ if num_state_qubits > 1 > options.get("num_clean_ancillas", 1):
1427
+ return None
1428
+
1429
+ return adder_ripple_v95(num_state_qubits, kind="full")
1430
+
1431
+
1432
+ class MultiplierSynthesisH18(HighLevelSynthesisPlugin):
1433
+ """A cumulative multiplier based on controlled adders.
1434
+
1435
+ This plugin name is:``Multiplier.cumulative_h18`` which can be used as the key on
1436
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
1437
+ """
1438
+
1439
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1440
+ if not isinstance(high_level_object, MultiplierGate):
1441
+ return None
1442
+
1443
+ return multiplier_cumulative_h18(
1444
+ high_level_object.num_state_qubits, high_level_object.num_result_qubits
1445
+ )
1446
+
1447
+
1448
+ class MultiplierSynthesisR17(HighLevelSynthesisPlugin):
1449
+ """A QFT-based multiplier.
1450
+
1451
+ This plugin name is:``Multiplier.qft_r17`` which can be used as the key on
1452
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
1453
+ """
1454
+
1455
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1456
+ if not isinstance(high_level_object, MultiplierGate):
1457
+ return None
1458
+
1459
+ return multiplier_qft_r17(
1460
+ high_level_object.num_state_qubits, high_level_object.num_result_qubits
1461
+ )
1462
+
1463
+
1464
+ class PauliEvolutionSynthesisDefault(HighLevelSynthesisPlugin):
1465
+ """Synthesize a :class:`.PauliEvolutionGate` using the default synthesis algorithm.
1466
+
1467
+ This plugin name is:``PauliEvolution.default`` which can be used as the key on
1468
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
1469
+
1470
+ The following plugin option can be set:
1471
+
1472
+ * preserve_order: If ``False``, allow re-ordering the Pauli terms in the Hamiltonian to
1473
+ reduce the circuit depth of the decomposition.
1474
+
1475
+ """
1476
+
1477
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1478
+ if not isinstance(high_level_object, PauliEvolutionGate):
1479
+ # Don't do anything if a gate is called "evolution" but is not an
1480
+ # actual PauliEvolutionGate
1481
+ return None
1482
+
1483
+ algo = high_level_object.synthesis
1484
+
1485
+ if "preserve_order" in options and isinstance(algo, ProductFormula):
1486
+ algo.preserve_order = options["preserve_order"]
1487
+
1488
+ return algo.synthesize(high_level_object)
1489
+
1490
+
1491
+ class PauliEvolutionSynthesisRustiq(HighLevelSynthesisPlugin):
1492
+ """Synthesize a :class:`.PauliEvolutionGate` using Rustiq.
1493
+
1494
+ This plugin name is :``PauliEvolution.rustiq`` which can be used as the key on
1495
+ an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
1496
+
1497
+ The Rustiq synthesis algorithm is described in [1], and is implemented in
1498
+ Rust-based quantum circuit synthesis library available at
1499
+ https://github.com/smartiel/rustiq-core.
1500
+
1501
+ On large circuits the plugin may take a significant runtime.
1502
+
1503
+ The plugin supports the following additional options:
1504
+
1505
+ * optimize_count (bool): if `True` the synthesis algorithm will try to optimize
1506
+ the 2-qubit gate count; and if `False` then the 2-qubit depth.
1507
+ * preserve_order (bool): whether the order of paulis should be preserved, up to
1508
+ commutativity.
1509
+ * upto_clifford (bool): if `True`, the final Clifford operator is not synthesized.
1510
+ * upto_phase (bool): if `True`, the global phase of the returned circuit may
1511
+ differ from the global phase of the given pauli network.
1512
+ * resynth_clifford_method (int): describes the strategy to synthesize the final
1513
+ Clifford operator. Allowed values are `0` (naive approach), `1` (qiskit
1514
+ greedy synthesis), `2` (rustiq isometry synthesis).
1515
+
1516
+ References:
1517
+ 1. Timothée Goubault de Brugière and Simon Martiel,
1518
+ *Faster and shorter synthesis of Hamiltonian simulation circuits*,
1519
+ `arXiv:2404.03280 [quant-ph] <https://arxiv.org/abs/2404.03280>`_
1520
+
1521
+ """
1522
+
1523
+ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
1524
+ if not isinstance(high_level_object, PauliEvolutionGate):
1525
+ # Don't do anything if a gate is called "evolution" but is not an
1526
+ # actual PauliEvolutionGate
1527
+ return None
1528
+
1529
+ algo = high_level_object.synthesis
1530
+
1531
+ if not isinstance(algo, ProductFormula):
1532
+ warnings.warn(
1533
+ "Cannot apply Rustiq if the evolution synthesis does not implement ``expand``. ",
1534
+ stacklevel=2,
1535
+ category=RuntimeWarning,
1536
+ )
1537
+ return None
1538
+
1539
+ if "preserve_order" in options:
1540
+ algo.preserve_order = options["preserve_order"]
1541
+
1542
+ num_qubits = high_level_object.num_qubits
1543
+ pauli_network = algo.expand(high_level_object)
1544
+
1545
+ optimize_count = options.get("optimize_count", True)
1546
+ preserve_order = options.get("preserve_order", True)
1547
+ upto_clifford = options.get("upto_clifford", False)
1548
+ upto_phase = options.get("upto_phase", False)
1549
+ resynth_clifford_method = options.get("resynth_clifford_method", 1)
1550
+
1551
+ return synth_pauli_network_rustiq(
1552
+ num_qubits=num_qubits,
1553
+ pauli_network=pauli_network,
1554
+ optimize_count=optimize_count,
1555
+ preserve_order=preserve_order,
1556
+ upto_clifford=upto_clifford,
1557
+ upto_phase=upto_phase,
1558
+ resynth_clifford_method=resynth_clifford_method,
1559
+ )