qiskit 1.1.2__cp38-abi3-win32.whl → 1.2.0__cp38-abi3-win32.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (343) hide show
  1. qiskit/VERSION.txt +1 -1
  2. qiskit/__init__.py +27 -24
  3. qiskit/_accelerate.pyd +0 -0
  4. qiskit/_numpy_compat.py +1 -1
  5. qiskit/assembler/assemble_circuits.py +107 -64
  6. qiskit/assembler/assemble_schedules.py +5 -12
  7. qiskit/assembler/disassemble.py +10 -1
  8. qiskit/circuit/__init__.py +6 -3
  9. qiskit/circuit/_classical_resource_map.py +5 -5
  10. qiskit/circuit/_utils.py +0 -13
  11. qiskit/circuit/add_control.py +1 -1
  12. qiskit/circuit/annotated_operation.py +23 -1
  13. qiskit/circuit/classical/expr/expr.py +4 -4
  14. qiskit/circuit/classical/expr/visitors.py +1 -1
  15. qiskit/circuit/classical/types/__init__.py +1 -1
  16. qiskit/circuit/classical/types/types.py +2 -2
  17. qiskit/circuit/classicalfunction/boolean_expression.py +1 -1
  18. qiskit/circuit/classicalfunction/classical_function_visitor.py +5 -5
  19. qiskit/circuit/classicalfunction/utils.py +1 -1
  20. qiskit/circuit/classicalregister.py +1 -1
  21. qiskit/circuit/commutation_checker.py +83 -35
  22. qiskit/circuit/controlflow/_builder_utils.py +1 -1
  23. qiskit/circuit/controlflow/builder.py +10 -6
  24. qiskit/circuit/controlflow/if_else.py +2 -2
  25. qiskit/circuit/controlflow/switch_case.py +1 -1
  26. qiskit/circuit/delay.py +1 -1
  27. qiskit/circuit/duration.py +2 -2
  28. qiskit/circuit/equivalence.py +5 -7
  29. qiskit/circuit/gate.py +11 -8
  30. qiskit/circuit/instruction.py +31 -13
  31. qiskit/circuit/instructionset.py +2 -5
  32. qiskit/circuit/library/__init__.py +2 -1
  33. qiskit/circuit/library/arithmetic/linear_amplitude_function.py +1 -1
  34. qiskit/circuit/library/arithmetic/linear_pauli_rotations.py +1 -1
  35. qiskit/circuit/library/arithmetic/piecewise_chebyshev.py +1 -1
  36. qiskit/circuit/library/arithmetic/piecewise_linear_pauli_rotations.py +1 -1
  37. qiskit/circuit/library/arithmetic/piecewise_polynomial_pauli_rotations.py +3 -3
  38. qiskit/circuit/library/arithmetic/polynomial_pauli_rotations.py +1 -1
  39. qiskit/circuit/library/basis_change/__init__.py +1 -1
  40. qiskit/circuit/library/basis_change/qft.py +40 -6
  41. qiskit/circuit/library/blueprintcircuit.py +3 -5
  42. qiskit/circuit/library/data_preparation/__init__.py +9 -2
  43. qiskit/circuit/library/data_preparation/initializer.py +8 -0
  44. qiskit/circuit/library/data_preparation/state_preparation.py +98 -178
  45. qiskit/circuit/library/generalized_gates/isometry.py +8 -8
  46. qiskit/circuit/library/generalized_gates/linear_function.py +3 -2
  47. qiskit/circuit/library/generalized_gates/mcg_up_to_diagonal.py +4 -4
  48. qiskit/circuit/library/generalized_gates/permutation.py +8 -9
  49. qiskit/circuit/library/generalized_gates/uc.py +3 -3
  50. qiskit/circuit/library/generalized_gates/uc_pauli_rot.py +2 -2
  51. qiskit/circuit/library/generalized_gates/unitary.py +13 -11
  52. qiskit/circuit/library/graph_state.py +1 -1
  53. qiskit/circuit/library/hamiltonian_gate.py +1 -2
  54. qiskit/circuit/library/hidden_linear_function.py +1 -1
  55. qiskit/circuit/library/n_local/evolved_operator_ansatz.py +3 -2
  56. qiskit/circuit/library/n_local/n_local.py +4 -5
  57. qiskit/circuit/library/n_local/pauli_two_design.py +1 -1
  58. qiskit/circuit/library/n_local/qaoa_ansatz.py +6 -8
  59. qiskit/circuit/library/n_local/two_local.py +1 -1
  60. qiskit/circuit/library/overlap.py +11 -5
  61. qiskit/circuit/library/pauli_evolution.py +7 -3
  62. qiskit/circuit/library/standard_gates/dcx.py +3 -0
  63. qiskit/circuit/library/standard_gates/ecr.py +3 -0
  64. qiskit/circuit/library/standard_gates/global_phase.py +3 -0
  65. qiskit/circuit/library/standard_gates/h.py +13 -5
  66. qiskit/circuit/library/standard_gates/i.py +3 -0
  67. qiskit/circuit/library/standard_gates/iswap.py +3 -0
  68. qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py +19 -10
  69. qiskit/circuit/library/standard_gates/p.py +14 -9
  70. qiskit/circuit/library/standard_gates/r.py +3 -0
  71. qiskit/circuit/library/standard_gates/rx.py +21 -6
  72. qiskit/circuit/library/standard_gates/rxx.py +40 -1
  73. qiskit/circuit/library/standard_gates/ry.py +21 -6
  74. qiskit/circuit/library/standard_gates/ryy.py +40 -1
  75. qiskit/circuit/library/standard_gates/rz.py +22 -6
  76. qiskit/circuit/library/standard_gates/rzx.py +40 -1
  77. qiskit/circuit/library/standard_gates/rzz.py +41 -2
  78. qiskit/circuit/library/standard_gates/s.py +77 -0
  79. qiskit/circuit/library/standard_gates/swap.py +12 -5
  80. qiskit/circuit/library/standard_gates/sx.py +14 -5
  81. qiskit/circuit/library/standard_gates/t.py +5 -0
  82. qiskit/circuit/library/standard_gates/u.py +22 -7
  83. qiskit/circuit/library/standard_gates/u1.py +8 -3
  84. qiskit/circuit/library/standard_gates/u2.py +3 -0
  85. qiskit/circuit/library/standard_gates/u3.py +22 -7
  86. qiskit/circuit/library/standard_gates/x.py +156 -92
  87. qiskit/circuit/library/standard_gates/xx_minus_yy.py +40 -1
  88. qiskit/circuit/library/standard_gates/xx_plus_yy.py +52 -11
  89. qiskit/circuit/library/standard_gates/y.py +6 -1
  90. qiskit/circuit/library/standard_gates/z.py +8 -1
  91. qiskit/circuit/operation.py +1 -1
  92. qiskit/circuit/parameter.py +9 -10
  93. qiskit/circuit/parameterexpression.py +16 -13
  94. qiskit/circuit/parametertable.py +1 -190
  95. qiskit/circuit/parametervector.py +1 -1
  96. qiskit/circuit/quantumcircuit.py +395 -387
  97. qiskit/circuit/quantumcircuitdata.py +3 -5
  98. qiskit/circuit/quantumregister.py +1 -1
  99. qiskit/circuit/random/__init__.py +1 -1
  100. qiskit/circuit/random/utils.py +175 -26
  101. qiskit/circuit/register.py +5 -7
  102. qiskit/circuit/singleton.py +3 -3
  103. qiskit/circuit/tools/pi_check.py +4 -4
  104. qiskit/compiler/assembler.py +95 -24
  105. qiskit/compiler/scheduler.py +2 -2
  106. qiskit/compiler/transpiler.py +42 -128
  107. qiskit/converters/circuit_to_dag.py +4 -6
  108. qiskit/converters/circuit_to_gate.py +4 -8
  109. qiskit/converters/circuit_to_instruction.py +5 -17
  110. qiskit/converters/dag_to_circuit.py +2 -6
  111. qiskit/dagcircuit/collect_blocks.py +2 -2
  112. qiskit/dagcircuit/dagcircuit.py +190 -187
  113. qiskit/dagcircuit/dagdependency.py +4 -4
  114. qiskit/dagcircuit/dagdependency_v2.py +4 -4
  115. qiskit/dagcircuit/dagdepnode.py +1 -1
  116. qiskit/dagcircuit/dagnode.py +66 -157
  117. qiskit/passmanager/flow_controllers.py +1 -1
  118. qiskit/passmanager/passmanager.py +3 -3
  119. qiskit/primitives/__init__.py +1 -5
  120. qiskit/primitives/backend_estimator.py +25 -15
  121. qiskit/primitives/backend_estimator_v2.py +31 -7
  122. qiskit/primitives/backend_sampler.py +21 -12
  123. qiskit/primitives/backend_sampler_v2.py +12 -3
  124. qiskit/primitives/base/base_estimator.py +31 -4
  125. qiskit/primitives/base/base_primitive.py +2 -2
  126. qiskit/primitives/base/base_result.py +2 -2
  127. qiskit/primitives/base/base_sampler.py +26 -2
  128. qiskit/primitives/base/estimator_result.py +2 -2
  129. qiskit/primitives/base/sampler_result.py +2 -2
  130. qiskit/primitives/containers/__init__.py +0 -1
  131. qiskit/primitives/containers/bindings_array.py +2 -2
  132. qiskit/primitives/containers/bit_array.py +108 -10
  133. qiskit/primitives/containers/shape.py +3 -3
  134. qiskit/primitives/estimator.py +9 -2
  135. qiskit/primitives/primitive_job.py +1 -1
  136. qiskit/primitives/sampler.py +10 -3
  137. qiskit/primitives/statevector_estimator.py +5 -3
  138. qiskit/primitives/statevector_sampler.py +11 -5
  139. qiskit/primitives/utils.py +16 -0
  140. qiskit/providers/backend.py +15 -6
  141. qiskit/providers/backend_compat.py +7 -4
  142. qiskit/providers/basic_provider/basic_provider_tools.py +1 -1
  143. qiskit/providers/basic_provider/basic_simulator.py +33 -25
  144. qiskit/providers/fake_provider/fake_backend.py +10 -3
  145. qiskit/providers/fake_provider/fake_openpulse_2q.py +157 -149
  146. qiskit/providers/fake_provider/fake_openpulse_3q.py +228 -220
  147. qiskit/providers/fake_provider/fake_pulse_backend.py +2 -1
  148. qiskit/providers/fake_provider/fake_qasm_backend.py +7 -2
  149. qiskit/providers/fake_provider/generic_backend_v2.py +514 -68
  150. qiskit/providers/models/__init__.py +48 -11
  151. qiskit/providers/models/backendconfiguration.py +50 -4
  152. qiskit/providers/models/backendproperties.py +13 -2
  153. qiskit/providers/models/pulsedefaults.py +10 -11
  154. qiskit/providers/options.py +13 -13
  155. qiskit/providers/providerutils.py +3 -1
  156. qiskit/pulse/configuration.py +8 -12
  157. qiskit/pulse/instruction_schedule_map.py +3 -5
  158. qiskit/pulse/instructions/acquire.py +7 -8
  159. qiskit/pulse/instructions/instruction.py +2 -3
  160. qiskit/pulse/library/samplers/decorators.py +5 -9
  161. qiskit/pulse/library/symbolic_pulses.py +4 -7
  162. qiskit/pulse/library/waveform.py +2 -5
  163. qiskit/pulse/macros.py +11 -6
  164. qiskit/pulse/parser.py +8 -10
  165. qiskit/pulse/schedule.py +9 -17
  166. qiskit/pulse/transforms/alignments.py +1 -3
  167. qiskit/pulse/utils.py +1 -2
  168. qiskit/qasm/libs/stdgates.inc +35 -28
  169. qiskit/qasm2/__init__.py +7 -7
  170. qiskit/qasm2/export.py +5 -9
  171. qiskit/qasm2/parse.py +1 -1
  172. qiskit/qasm3/ast.py +9 -25
  173. qiskit/qasm3/exporter.py +582 -479
  174. qiskit/qasm3/printer.py +7 -16
  175. qiskit/qobj/common.py +10 -0
  176. qiskit/qobj/converters/lo_config.py +9 -0
  177. qiskit/qobj/converters/pulse_instruction.py +13 -6
  178. qiskit/qobj/pulse_qobj.py +69 -15
  179. qiskit/qobj/qasm_qobj.py +72 -20
  180. qiskit/qobj/utils.py +9 -0
  181. qiskit/qpy/__init__.py +1 -1
  182. qiskit/qpy/binary_io/circuits.py +8 -5
  183. qiskit/qpy/binary_io/schedules.py +1 -1
  184. qiskit/qpy/binary_io/value.py +3 -3
  185. qiskit/qpy/interface.py +3 -2
  186. qiskit/qpy/type_keys.py +2 -2
  187. qiskit/quantum_info/operators/channel/quantum_channel.py +3 -6
  188. qiskit/quantum_info/operators/channel/superop.py +2 -2
  189. qiskit/quantum_info/operators/channel/transformations.py +1 -1
  190. qiskit/quantum_info/operators/dihedral/dihedral.py +3 -4
  191. qiskit/quantum_info/operators/dihedral/dihedral_circuits.py +1 -3
  192. qiskit/quantum_info/operators/dihedral/random.py +6 -3
  193. qiskit/quantum_info/operators/measures.py +2 -2
  194. qiskit/quantum_info/operators/op_shape.py +12 -20
  195. qiskit/quantum_info/operators/operator.py +14 -21
  196. qiskit/quantum_info/operators/predicates.py +1 -0
  197. qiskit/quantum_info/operators/symplectic/base_pauli.py +7 -11
  198. qiskit/quantum_info/operators/symplectic/clifford.py +1 -1
  199. qiskit/quantum_info/operators/symplectic/pauli.py +3 -3
  200. qiskit/quantum_info/operators/symplectic/pauli_list.py +9 -10
  201. qiskit/quantum_info/operators/symplectic/random.py +1 -1
  202. qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +15 -17
  203. qiskit/quantum_info/quaternion.py +1 -1
  204. qiskit/quantum_info/states/densitymatrix.py +5 -8
  205. qiskit/quantum_info/states/stabilizerstate.py +128 -37
  206. qiskit/quantum_info/states/statevector.py +4 -8
  207. qiskit/result/counts.py +2 -2
  208. qiskit/result/mitigation/correlated_readout_mitigator.py +2 -2
  209. qiskit/result/mitigation/local_readout_mitigator.py +2 -2
  210. qiskit/result/mitigation/utils.py +1 -3
  211. qiskit/result/models.py +17 -16
  212. qiskit/result/result.py +15 -20
  213. qiskit/scheduler/lowering.py +2 -2
  214. qiskit/synthesis/__init__.py +2 -1
  215. qiskit/synthesis/clifford/__init__.py +1 -1
  216. qiskit/synthesis/clifford/clifford_decompose_ag.py +2 -2
  217. qiskit/synthesis/clifford/clifford_decompose_bm.py +10 -240
  218. qiskit/synthesis/clifford/clifford_decompose_greedy.py +9 -303
  219. qiskit/synthesis/clifford/clifford_decompose_layers.py +25 -23
  220. qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_full.py +1 -1
  221. qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_general.py +1 -1
  222. qiskit/synthesis/discrete_basis/generate_basis_approximations.py +1 -1
  223. qiskit/synthesis/discrete_basis/solovay_kitaev.py +2 -2
  224. qiskit/synthesis/evolution/evolution_synthesis.py +4 -2
  225. qiskit/synthesis/evolution/lie_trotter.py +46 -19
  226. qiskit/synthesis/evolution/product_formula.py +111 -55
  227. qiskit/synthesis/evolution/qdrift.py +40 -10
  228. qiskit/synthesis/evolution/suzuki_trotter.py +43 -33
  229. qiskit/synthesis/linear/__init__.py +1 -0
  230. qiskit/synthesis/linear/cnot_synth.py +22 -96
  231. qiskit/synthesis/linear/linear_depth_lnn.py +8 -8
  232. qiskit/synthesis/linear/linear_matrix_utils.py +13 -161
  233. qiskit/synthesis/linear_phase/cnot_phase_synth.py +1 -1
  234. qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py +3 -3
  235. qiskit/synthesis/linear_phase/cz_depth_lnn.py +1 -1
  236. qiskit/synthesis/one_qubit/one_qubit_decompose.py +29 -29
  237. qiskit/synthesis/permutation/permutation_full.py +5 -29
  238. qiskit/synthesis/permutation/permutation_lnn.py +2 -24
  239. qiskit/synthesis/permutation/permutation_utils.py +2 -59
  240. qiskit/synthesis/qft/__init__.py +1 -0
  241. qiskit/synthesis/qft/qft_decompose_full.py +79 -0
  242. qiskit/synthesis/qft/qft_decompose_lnn.py +17 -9
  243. qiskit/synthesis/stabilizer/stabilizer_circuit.py +6 -6
  244. qiskit/synthesis/stabilizer/stabilizer_decompose.py +2 -2
  245. qiskit/synthesis/two_qubit/local_invariance.py +8 -38
  246. qiskit/synthesis/two_qubit/two_qubit_decompose.py +48 -129
  247. qiskit/synthesis/unitary/aqc/cnot_structures.py +1 -1
  248. qiskit/synthesis/unitary/qsd.py +5 -3
  249. qiskit/transpiler/__init__.py +1 -0
  250. qiskit/transpiler/basepasses.py +1 -1
  251. qiskit/transpiler/coupling.py +3 -3
  252. qiskit/transpiler/instruction_durations.py +1 -2
  253. qiskit/transpiler/layout.py +3 -3
  254. qiskit/transpiler/passes/__init__.py +2 -0
  255. qiskit/transpiler/passes/basis/basis_translator.py +84 -64
  256. qiskit/transpiler/passes/basis/translate_parameterized.py +3 -5
  257. qiskit/transpiler/passes/basis/unroll_3q_or_more.py +1 -1
  258. qiskit/transpiler/passes/basis/unroll_custom_definitions.py +10 -10
  259. qiskit/transpiler/passes/calibration/rx_builder.py +3 -3
  260. qiskit/transpiler/passes/calibration/rzx_builder.py +3 -3
  261. qiskit/transpiler/passes/layout/apply_layout.py +13 -3
  262. qiskit/transpiler/passes/layout/sabre_layout.py +10 -8
  263. qiskit/transpiler/passes/layout/sabre_pre_layout.py +4 -1
  264. qiskit/transpiler/passes/layout/set_layout.py +2 -2
  265. qiskit/transpiler/passes/layout/vf2_layout.py +1 -1
  266. qiskit/transpiler/passes/layout/vf2_utils.py +3 -3
  267. qiskit/transpiler/passes/optimization/__init__.py +1 -0
  268. qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py +2 -2
  269. qiskit/transpiler/passes/optimization/commutation_analysis.py +7 -10
  270. qiskit/transpiler/passes/optimization/commutative_cancellation.py +35 -19
  271. qiskit/transpiler/passes/optimization/consolidate_blocks.py +17 -8
  272. qiskit/transpiler/passes/optimization/inverse_cancellation.py +6 -6
  273. qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +64 -41
  274. qiskit/transpiler/passes/optimization/optimize_1q_gates.py +1 -1
  275. qiskit/transpiler/passes/optimization/split_2q_unitaries.py +83 -0
  276. qiskit/transpiler/passes/optimization/template_matching/backward_match.py +1 -1
  277. qiskit/transpiler/passes/optimization/template_matching/forward_match.py +2 -2
  278. qiskit/transpiler/passes/optimization/template_matching/template_substitution.py +1 -1
  279. qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py +3 -2
  280. qiskit/transpiler/passes/routing/commuting_2q_gate_routing/swap_strategy.py +1 -1
  281. qiskit/transpiler/passes/routing/layout_transformation.py +2 -1
  282. qiskit/transpiler/passes/routing/sabre_swap.py +35 -26
  283. qiskit/transpiler/passes/routing/star_prerouting.py +80 -105
  284. qiskit/transpiler/passes/routing/stochastic_swap.py +1 -3
  285. qiskit/transpiler/passes/scheduling/alap.py +1 -2
  286. qiskit/transpiler/passes/scheduling/alignments/__init__.py +2 -2
  287. qiskit/transpiler/passes/scheduling/alignments/check_durations.py +1 -1
  288. qiskit/transpiler/passes/scheduling/alignments/pulse_gate_validation.py +2 -2
  289. qiskit/transpiler/passes/scheduling/alignments/reschedule.py +1 -1
  290. qiskit/transpiler/passes/scheduling/asap.py +1 -2
  291. qiskit/transpiler/passes/scheduling/base_scheduler.py +5 -5
  292. qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +3 -3
  293. qiskit/transpiler/passes/scheduling/padding/base_padding.py +1 -1
  294. qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +20 -14
  295. qiskit/transpiler/passes/scheduling/scheduling/base_scheduler.py +7 -6
  296. qiskit/transpiler/passes/scheduling/time_unit_conversion.py +4 -3
  297. qiskit/transpiler/passes/synthesis/high_level_synthesis.py +211 -36
  298. qiskit/transpiler/passes/synthesis/plugin.py +2 -2
  299. qiskit/transpiler/passes/synthesis/unitary_synthesis.py +80 -40
  300. qiskit/transpiler/passes/utils/__init__.py +0 -1
  301. qiskit/transpiler/passes/utils/check_gate_direction.py +4 -4
  302. qiskit/transpiler/passes/utils/check_map.py +3 -6
  303. qiskit/transpiler/passes/utils/convert_conditions_to_if_ops.py +3 -4
  304. qiskit/transpiler/passes/utils/error.py +2 -2
  305. qiskit/transpiler/passes/utils/fixed_point.py +3 -3
  306. qiskit/transpiler/passes/utils/gate_direction.py +1 -1
  307. qiskit/transpiler/passes/utils/gates_basis.py +1 -2
  308. qiskit/transpiler/passmanager.py +7 -6
  309. qiskit/transpiler/preset_passmanagers/__init__.py +4 -228
  310. qiskit/transpiler/preset_passmanagers/builtin_plugins.py +73 -18
  311. qiskit/transpiler/preset_passmanagers/common.py +3 -6
  312. qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py +518 -0
  313. qiskit/transpiler/preset_passmanagers/level0.py +1 -1
  314. qiskit/transpiler/target.py +27 -8
  315. qiskit/user_config.py +29 -6
  316. qiskit/utils/classtools.py +3 -3
  317. qiskit/utils/deprecation.py +3 -2
  318. qiskit/utils/lazy_tester.py +2 -2
  319. qiskit/utils/optionals.py +8 -8
  320. qiskit/visualization/bloch.py +18 -23
  321. qiskit/visualization/circuit/_utils.py +34 -10
  322. qiskit/visualization/circuit/circuit_visualization.py +23 -16
  323. qiskit/visualization/circuit/latex.py +29 -27
  324. qiskit/visualization/circuit/matplotlib.py +4 -2
  325. qiskit/visualization/circuit/qcstyle.py +2 -2
  326. qiskit/visualization/circuit/text.py +9 -15
  327. qiskit/visualization/dag_visualization.py +2 -2
  328. qiskit/visualization/pulse_v2/core.py +1 -1
  329. qiskit/visualization/pulse_v2/events.py +1 -1
  330. qiskit/visualization/pulse_v2/generators/frame.py +3 -4
  331. qiskit/visualization/pulse_v2/generators/waveform.py +5 -9
  332. qiskit/visualization/pulse_v2/layouts.py +1 -5
  333. qiskit/visualization/pulse_v2/plotters/matplotlib.py +1 -2
  334. qiskit/visualization/state_visualization.py +5 -6
  335. qiskit/visualization/timeline/plotters/matplotlib.py +1 -2
  336. qiskit/visualization/transition_visualization.py +7 -2
  337. {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/METADATA +12 -12
  338. {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/RECORD +342 -340
  339. {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/entry_points.txt +3 -0
  340. qiskit/transpiler/passes/utils/block_to_matrix.py +0 -47
  341. {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/LICENSE.txt +0 -0
  342. {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/WHEEL +0 -0
  343. {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/top_level.txt +0 -0
@@ -19,6 +19,7 @@ from qiskit.circuit.controlledgate import ControlledGate
19
19
  from qiskit.circuit.singleton import SingletonGate, SingletonControlledGate, stdlib_singleton_key
20
20
  from qiskit.circuit.quantumregister import QuantumRegister
21
21
  from qiskit.circuit._utils import _ctrl_state_to_int, with_gate_array, with_controlled_gate_array
22
+ from qiskit._accelerate.circuit import StandardGate
22
23
 
23
24
  _X_ARRAY = [[0, 1], [1, 0]]
24
25
  _SX_ARRAY = [[0.5 + 0.5j, 0.5 - 0.5j], [0.5 - 0.5j, 0.5 + 0.5j]]
@@ -71,6 +72,8 @@ class XGate(SingletonGate):
71
72
  |1\rangle \rightarrow |0\rangle
72
73
  """
73
74
 
75
+ _standard_gate = StandardGate.XGate
76
+
74
77
  def __init__(self, label: Optional[str] = None, *, duration=None, unit="dt"):
75
78
  """Create new X gate."""
76
79
  super().__init__("x", 1, [], label=label, duration=duration, unit=unit)
@@ -109,7 +112,7 @@ class XGate(SingletonGate):
109
112
  label: An optional label for the gate [Default: ``None``]
110
113
  ctrl_state: control state expressed as integer,
111
114
  string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
112
- annotated: indicates whether the controlled gate can be implemented
115
+ annotated: indicates whether the controlled gate should be implemented
113
116
  as an annotated gate.
114
117
 
115
118
  Returns:
@@ -213,6 +216,8 @@ class CXGate(SingletonControlledGate):
213
216
  `|a, b\rangle \rightarrow |a, a \oplus b\rangle`
214
217
  """
215
218
 
219
+ _standard_gate = StandardGate.CXGate
220
+
216
221
  def __init__(
217
222
  self,
218
223
  label: Optional[str] = None,
@@ -252,7 +257,7 @@ class CXGate(SingletonControlledGate):
252
257
  label: An optional label for the gate [Default: ``None``]
253
258
  ctrl_state: control state expressed as integer,
254
259
  string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
255
- annotated: indicates whether the controlled gate can be implemented
260
+ annotated: indicates whether the controlled gate should be implemented
256
261
  as an annotated gate.
257
262
 
258
263
  Returns:
@@ -363,6 +368,8 @@ class CCXGate(SingletonControlledGate):
363
368
 
364
369
  """
365
370
 
371
+ _standard_gate = StandardGate.CCXGate
372
+
366
373
  def __init__(
367
374
  self,
368
375
  label: Optional[str] = None,
@@ -446,7 +453,7 @@ class CCXGate(SingletonControlledGate):
446
453
  label: An optional label for the gate [Default: ``None``]
447
454
  ctrl_state: control state expressed as integer,
448
455
  string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
449
- annotated: indicates whether the controlled gate can be implemented
456
+ annotated: indicates whether the controlled gate should be implemented
450
457
  as an annotated gate.
451
458
 
452
459
  Returns:
@@ -516,6 +523,8 @@ class RCCXGate(SingletonGate):
516
523
  with the :meth:`~qiskit.circuit.QuantumCircuit.rccx` method.
517
524
  """
518
525
 
526
+ _standard_gate = StandardGate.RCCXGate
527
+
519
528
  def __init__(self, label: Optional[str] = None, *, duration=None, unit="dt"):
520
529
  """Create a new simplified CCX gate."""
521
530
  super().__init__("rccx", 3, [], label=label, duration=duration, unit=unit)
@@ -573,6 +582,8 @@ class C3SXGate(SingletonControlledGate):
573
582
  [1] Barenco et al., 1995. https://arxiv.org/pdf/quant-ph/9503016.pdf
574
583
  """
575
584
 
585
+ _standard_gate = StandardGate.C3SXGate
586
+
576
587
  def __init__(
577
588
  self,
578
589
  label: Optional[str] = None,
@@ -677,6 +688,8 @@ class C3XGate(SingletonControlledGate):
677
688
  This implementation uses :math:`\sqrt{T}` and 14 CNOT gates.
678
689
  """
679
690
 
691
+ _standard_gate = StandardGate.C3XGate
692
+
680
693
  def __init__(
681
694
  self,
682
695
  label: Optional[str] = None,
@@ -788,7 +801,7 @@ class C3XGate(SingletonControlledGate):
788
801
  label: An optional label for the gate [Default: ``None``]
789
802
  ctrl_state: control state expressed as integer,
790
803
  string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
791
- annotated: indicates whether the controlled gate can be implemented
804
+ annotated: indicates whether the controlled gate should be implemented
792
805
  as an annotated gate.
793
806
 
794
807
  Returns:
@@ -864,6 +877,8 @@ class RC3XGate(SingletonGate):
864
877
  with the :meth:`~qiskit.circuit.QuantumCircuit.rcccx` method.
865
878
  """
866
879
 
880
+ _standard_gate = StandardGate.RC3XGate
881
+
867
882
  def __init__(self, label: Optional[str] = None, *, duration=None, unit="dt"):
868
883
  """Create a new RC3X gate."""
869
884
  super().__init__("rcccx", 4, [], label=label, duration=duration, unit=unit)
@@ -937,8 +952,8 @@ class C4XGate(SingletonControlledGate):
937
952
  of the relative phase version of c3x, the rc3x [2].
938
953
 
939
954
  References:
940
- [1] Barenco et al., 1995. https://arxiv.org/pdf/quant-ph/9503016.pdf
941
- [2] Maslov, 2015. https://arxiv.org/abs/1508.03273
955
+ 1. Barenco et al., 1995. https://arxiv.org/pdf/quant-ph/9503016.pdf
956
+ 2. Maslov, 2015. https://arxiv.org/abs/1508.03273
942
957
  """
943
958
 
944
959
  def __init__(
@@ -967,7 +982,7 @@ class C4XGate(SingletonControlledGate):
967
982
 
968
983
  _singleton_lookup_key = stdlib_singleton_key(num_ctrl_qubits=4)
969
984
 
970
- # seems like open controls not hapening?
985
+ # seems like open controls not happening?
971
986
  def _define(self):
972
987
  """
973
988
  gate c3sqrtx a,b,c,d
@@ -1032,7 +1047,7 @@ class C4XGate(SingletonControlledGate):
1032
1047
  label: An optional label for the gate [Default: ``None``]
1033
1048
  ctrl_state: control state expressed as integer,
1034
1049
  string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
1035
- annotated: indicates whether the controlled gate can be implemented
1050
+ annotated: indicates whether the controlled gate should be implemented
1036
1051
  as an annotated gate.
1037
1052
 
1038
1053
  Returns:
@@ -1207,7 +1222,7 @@ class MCXGate(ControlledGate):
1207
1222
  label: An optional label for the gate [Default: ``None``]
1208
1223
  ctrl_state: control state expressed as integer,
1209
1224
  string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
1210
- annotated: indicates whether the controlled gate can be implemented
1225
+ annotated: indicates whether the controlled gate should be implemented
1211
1226
  as an annotated gate.
1212
1227
 
1213
1228
  Returns:
@@ -1305,9 +1320,14 @@ class MCXGrayCode(MCXGate):
1305
1320
  class MCXRecursive(MCXGate):
1306
1321
  """Implement the multi-controlled X gate using recursion.
1307
1322
 
1308
- Using a single ancilla qubit, the multi-controlled X gate is recursively split onto
1309
- four sub-registers. This is done until we reach the 3- or 4-controlled X gate since
1310
- for these we have a concrete implementation that do not require ancillas.
1323
+ Using a single clean ancilla qubit, the multi-controlled X gate is split into
1324
+ four sub-registers, each one of them uses the V-chain method.
1325
+
1326
+ The method is based on Lemma 9 of [2], first shown in Lemma 7.3 of [1].
1327
+
1328
+ References:
1329
+ 1. Barenco et al., 1995. https://arxiv.org/pdf/quant-ph/9503016.pdf
1330
+ 2. Iten et al., 2015. https://arxiv.org/abs/1501.06911
1311
1331
  """
1312
1332
 
1313
1333
  def __init__(
@@ -1363,32 +1383,35 @@ class MCXRecursive(MCXGate):
1363
1383
  qc._append(C4XGate(), q[:], [])
1364
1384
  self.definition = qc
1365
1385
  else:
1366
- for instr, qargs, cargs in self._recurse(q[:-1], q_ancilla=q[-1]):
1367
- qc._append(instr, qargs, cargs)
1368
- self.definition = qc
1369
-
1370
- def _recurse(self, q, q_ancilla=None):
1371
- # recursion stop
1372
- if len(q) == 4:
1373
- return [(C3XGate(), q[:], [])]
1374
- if len(q) == 5:
1375
- return [(C4XGate(), q[:], [])]
1376
- if len(q) < 4:
1377
- raise AttributeError("Something went wrong in the recursion, have less than 4 qubits.")
1378
-
1379
- # recurse
1380
- num_ctrl_qubits = len(q) - 1
1381
- middle = ceil(num_ctrl_qubits / 2)
1382
- first_half = [*q[:middle], q_ancilla]
1383
- second_half = [*q[middle:num_ctrl_qubits], q_ancilla, q[num_ctrl_qubits]]
1384
-
1385
- rule = []
1386
- rule += self._recurse(first_half, q_ancilla=q[middle])
1387
- rule += self._recurse(second_half, q_ancilla=q[middle - 1])
1388
- rule += self._recurse(first_half, q_ancilla=q[middle])
1389
- rule += self._recurse(second_half, q_ancilla=q[middle - 1])
1386
+ num_ctrl_qubits = len(q) - 1
1387
+ q_ancilla = q[-1]
1388
+ q_target = q[-2]
1389
+ middle = ceil(num_ctrl_qubits / 2)
1390
+ first_half = [*q[:middle]]
1391
+ second_half = [*q[middle : num_ctrl_qubits - 1], q_ancilla]
1392
+
1393
+ qc._append(
1394
+ MCXVChain(num_ctrl_qubits=len(first_half), dirty_ancillas=True),
1395
+ qargs=[*first_half, q_ancilla, *q[middle : middle + len(first_half) - 2]],
1396
+ cargs=[],
1397
+ )
1398
+ qc._append(
1399
+ MCXVChain(num_ctrl_qubits=len(second_half), dirty_ancillas=True),
1400
+ qargs=[*second_half, q_target, *q[: len(second_half) - 2]],
1401
+ cargs=[],
1402
+ )
1403
+ qc._append(
1404
+ MCXVChain(num_ctrl_qubits=len(first_half), dirty_ancillas=True),
1405
+ qargs=[*first_half, q_ancilla, *q[middle : middle + len(first_half) - 2]],
1406
+ cargs=[],
1407
+ )
1408
+ qc._append(
1409
+ MCXVChain(num_ctrl_qubits=len(second_half), dirty_ancillas=True),
1410
+ qargs=[*second_half, q_target, *q[: len(second_half) - 2]],
1411
+ cargs=[],
1412
+ )
1390
1413
 
1391
- return rule
1414
+ self.definition = qc
1392
1415
 
1393
1416
 
1394
1417
  class MCXVChain(MCXGate):
@@ -1404,6 +1427,8 @@ class MCXVChain(MCXGate):
1404
1427
  duration=None,
1405
1428
  unit="dt",
1406
1429
  _base_label=None,
1430
+ relative_phase: bool = False, # pylint: disable=unused-argument
1431
+ action_only: bool = False, # pylint: disable=unused-argument
1407
1432
  ):
1408
1433
  """Create a new MCX instance.
1409
1434
 
@@ -1429,7 +1454,24 @@ class MCXVChain(MCXGate):
1429
1454
  duration=None,
1430
1455
  unit="dt",
1431
1456
  _base_label=None,
1457
+ relative_phase: bool = False,
1458
+ action_only: bool = False,
1432
1459
  ):
1460
+ """
1461
+ Args:
1462
+ dirty_ancillas: when set to ``True``, the method applies an optimized multicontrolled-X gate
1463
+ up to a relative phase using dirty ancillary qubits with the properties of lemmas 7 and 8
1464
+ from arXiv:1501.06911, with at most 8*k - 6 CNOT gates.
1465
+ For k within the range {1, ..., ceil(n/2)}. And for n representing the total number of
1466
+ qubits.
1467
+ relative_phase: when set to ``True``, the method applies the optimized multicontrolled-X gate
1468
+ up to a relative phase, in a way that, by lemma 7 of arXiv:1501.06911, the relative
1469
+ phases of the ``action part`` cancel out with the phases of the ``reset part``.
1470
+
1471
+ action_only: when set to ``True``, the method applies only the action part of lemma 8
1472
+ from arXiv:1501.06911.
1473
+
1474
+ """
1433
1475
  super().__init__(
1434
1476
  num_ctrl_qubits,
1435
1477
  label=label,
@@ -1440,6 +1482,9 @@ class MCXVChain(MCXGate):
1440
1482
  unit=unit,
1441
1483
  )
1442
1484
  self._dirty_ancillas = dirty_ancillas
1485
+ self._relative_phase = relative_phase
1486
+ self._action_only = action_only
1487
+ super().__init__(num_ctrl_qubits, label=label, ctrl_state=ctrl_state, _name="mcx_vchain")
1443
1488
 
1444
1489
  def inverse(self, annotated: bool = False):
1445
1490
  """Invert this gate. The MCX is its own inverse.
@@ -1457,6 +1502,8 @@ class MCXVChain(MCXGate):
1457
1502
  num_ctrl_qubits=self.num_ctrl_qubits,
1458
1503
  dirty_ancillas=self._dirty_ancillas,
1459
1504
  ctrl_state=self.ctrl_state,
1505
+ relative_phase=self._relative_phase,
1506
+ action_only=self._action_only,
1460
1507
  )
1461
1508
 
1462
1509
  @staticmethod
@@ -1468,8 +1515,6 @@ class MCXVChain(MCXGate):
1468
1515
  """Define the MCX gate using a V-chain of CX gates."""
1469
1516
  # pylint: disable=cyclic-import
1470
1517
  from qiskit.circuit.quantumcircuit import QuantumCircuit
1471
- from .u1 import U1Gate
1472
- from .u2 import U2Gate
1473
1518
 
1474
1519
  q = QuantumRegister(self.num_qubits, name="q")
1475
1520
  qc = QuantumCircuit(q, name=self.name)
@@ -1477,64 +1522,83 @@ class MCXVChain(MCXGate):
1477
1522
  q_target = q[self.num_ctrl_qubits]
1478
1523
  q_ancillas = q[self.num_ctrl_qubits + 1 :]
1479
1524
 
1480
- definition = []
1481
-
1482
1525
  if self._dirty_ancillas:
1483
- i = self.num_ctrl_qubits - 3
1484
- ancilla_pre_rule = [
1485
- (U2Gate(0, numpy.pi), [q_target], []),
1486
- (CXGate(), [q_target, q_ancillas[i]], []),
1487
- (U1Gate(-numpy.pi / 4), [q_ancillas[i]], []),
1488
- (CXGate(), [q_controls[-1], q_ancillas[i]], []),
1489
- (U1Gate(numpy.pi / 4), [q_ancillas[i]], []),
1490
- (CXGate(), [q_target, q_ancillas[i]], []),
1491
- (U1Gate(-numpy.pi / 4), [q_ancillas[i]], []),
1492
- (CXGate(), [q_controls[-1], q_ancillas[i]], []),
1493
- (U1Gate(numpy.pi / 4), [q_ancillas[i]], []),
1494
- ]
1495
- for inst in ancilla_pre_rule:
1496
- definition.append(inst)
1526
+ if self.num_ctrl_qubits < 3:
1527
+ qc.mcx(q_controls, q_target)
1528
+ elif not self._relative_phase and self.num_ctrl_qubits == 3:
1529
+ qc._append(C3XGate(), [*q_controls, q_target], [])
1530
+ else:
1531
+ num_ancillas = self.num_ctrl_qubits - 2
1532
+ targets = [q_target] + q_ancillas[:num_ancillas][::-1]
1533
+
1534
+ for j in range(2):
1535
+ for i in range(self.num_ctrl_qubits): # action part
1536
+ if i < self.num_ctrl_qubits - 2:
1537
+ if targets[i] != q_target or self._relative_phase:
1538
+ # gate cancelling
1539
+
1540
+ # cancel rightmost gates of action part
1541
+ # with leftmost gates of reset part
1542
+ if self._relative_phase and targets[i] == q_target and j == 1:
1543
+ qc.cx(q_ancillas[num_ancillas - i - 1], targets[i])
1544
+ qc.t(targets[i])
1545
+ qc.cx(q_controls[self.num_ctrl_qubits - i - 1], targets[i])
1546
+ qc.tdg(targets[i])
1547
+ qc.h(targets[i])
1548
+ else:
1549
+ qc.h(targets[i])
1550
+ qc.t(targets[i])
1551
+ qc.cx(q_controls[self.num_ctrl_qubits - i - 1], targets[i])
1552
+ qc.tdg(targets[i])
1553
+ qc.cx(q_ancillas[num_ancillas - i - 1], targets[i])
1554
+ else:
1555
+ controls = [
1556
+ q_controls[self.num_ctrl_qubits - i - 1],
1557
+ q_ancillas[num_ancillas - i - 1],
1558
+ ]
1559
+
1560
+ qc.ccx(controls[0], controls[1], targets[i])
1561
+ else:
1562
+ # implements an optimized toffoli operation
1563
+ # up to a diagonal gate, akin to lemma 6 of arXiv:1501.06911
1564
+ qc.h(targets[i])
1565
+ qc.t(targets[i])
1566
+ qc.cx(q_controls[self.num_ctrl_qubits - i - 2], targets[i])
1567
+ qc.tdg(targets[i])
1568
+ qc.cx(q_controls[self.num_ctrl_qubits - i - 1], targets[i])
1569
+ qc.t(targets[i])
1570
+ qc.cx(q_controls[self.num_ctrl_qubits - i - 2], targets[i])
1571
+ qc.tdg(targets[i])
1572
+ qc.h(targets[i])
1573
+
1574
+ break
1575
+
1576
+ for i in range(num_ancillas - 1): # reset part
1577
+ qc.cx(q_ancillas[i], q_ancillas[i + 1])
1578
+ qc.t(q_ancillas[i + 1])
1579
+ qc.cx(q_controls[2 + i], q_ancillas[i + 1])
1580
+ qc.tdg(q_ancillas[i + 1])
1581
+ qc.h(q_ancillas[i + 1])
1582
+
1583
+ if self._action_only:
1584
+ qc.ccx(q_controls[-1], q_ancillas[-1], q_target)
1585
+
1586
+ break
1587
+ else:
1588
+ qc.rccx(q_controls[0], q_controls[1], q_ancillas[0])
1589
+ i = 0
1590
+ for j in range(2, self.num_ctrl_qubits - 1):
1591
+ qc.rccx(q_controls[j], q_ancillas[i], q_ancillas[i + 1])
1497
1592
 
1498
- for j in reversed(range(2, self.num_ctrl_qubits - 1)):
1499
- definition.append(
1500
- (RCCXGate(), [q_controls[j], q_ancillas[i - 1], q_ancillas[i]], [])
1501
- )
1502
- i -= 1
1593
+ i += 1
1503
1594
 
1504
- definition.append((RCCXGate(), [q_controls[0], q_controls[1], q_ancillas[0]], []))
1505
- i = 0
1506
- for j in range(2, self.num_ctrl_qubits - 1):
1507
- definition.append((RCCXGate(), [q_controls[j], q_ancillas[i], q_ancillas[i + 1]], []))
1508
- i += 1
1595
+ qc.ccx(q_controls[-1], q_ancillas[i], q_target)
1509
1596
 
1510
- if self._dirty_ancillas:
1511
- ancilla_post_rule = [
1512
- (U1Gate(-numpy.pi / 4), [q_ancillas[i]], []),
1513
- (CXGate(), [q_controls[-1], q_ancillas[i]], []),
1514
- (U1Gate(numpy.pi / 4), [q_ancillas[i]], []),
1515
- (CXGate(), [q_target, q_ancillas[i]], []),
1516
- (U1Gate(-numpy.pi / 4), [q_ancillas[i]], []),
1517
- (CXGate(), [q_controls[-1], q_ancillas[i]], []),
1518
- (U1Gate(numpy.pi / 4), [q_ancillas[i]], []),
1519
- (CXGate(), [q_target, q_ancillas[i]], []),
1520
- (U2Gate(0, numpy.pi), [q_target], []),
1521
- ]
1522
- for inst in ancilla_post_rule:
1523
- definition.append(inst)
1524
- else:
1525
- definition.append((CCXGate(), [q_controls[-1], q_ancillas[i], q_target], []))
1597
+ for j in reversed(range(2, self.num_ctrl_qubits - 1)):
1598
+ qc.rccx(q_controls[j], q_ancillas[i - 1], q_ancillas[i])
1526
1599
 
1527
- for j in reversed(range(2, self.num_ctrl_qubits - 1)):
1528
- definition.append((RCCXGate(), [q_controls[j], q_ancillas[i - 1], q_ancillas[i]], []))
1529
- i -= 1
1530
- definition.append((RCCXGate(), [q_controls[0], q_controls[1], q_ancillas[i]], []))
1600
+ i -= 1
1531
1601
 
1532
- if self._dirty_ancillas:
1533
- for i, j in enumerate(list(range(2, self.num_ctrl_qubits - 1))):
1534
- definition.append(
1535
- (RCCXGate(), [q_controls[j], q_ancillas[i], q_ancillas[i + 1]], [])
1536
- )
1602
+ qc.rccx(q_controls[0], q_controls[1], q_ancillas[i])
1537
1603
 
1538
- for instr, qargs, cargs in definition:
1539
- qc._append(instr, qargs, cargs)
1540
1604
  self.definition = qc
@@ -11,6 +11,9 @@
11
11
  # that they have been altered from the originals.
12
12
 
13
13
  """Two-qubit XX-YY gate."""
14
+
15
+ from __future__ import annotations
16
+
14
17
  import math
15
18
  from cmath import exp
16
19
  from math import pi
@@ -24,9 +27,10 @@ from qiskit.circuit.library.standard_gates.rz import RZGate
24
27
  from qiskit.circuit.library.standard_gates.s import SdgGate, SGate
25
28
  from qiskit.circuit.library.standard_gates.sx import SXdgGate, SXGate
26
29
  from qiskit.circuit.library.standard_gates.x import CXGate
27
- from qiskit.circuit.parameterexpression import ParameterValueType
30
+ from qiskit.circuit.parameterexpression import ParameterValueType, ParameterExpression
28
31
  from qiskit.circuit.quantumcircuit import QuantumCircuit
29
32
  from qiskit.circuit.quantumregister import QuantumRegister
33
+ from qiskit._accelerate.circuit import StandardGate
30
34
 
31
35
 
32
36
  class XXMinusYYGate(Gate):
@@ -91,6 +95,8 @@ class XXMinusYYGate(Gate):
91
95
  \end{pmatrix}
92
96
  """
93
97
 
98
+ _standard_gate = StandardGate.XXMinusYYGate
99
+
94
100
  def __init__(
95
101
  self,
96
102
  theta: ParameterValueType,
@@ -153,6 +159,39 @@ class XXMinusYYGate(Gate):
153
159
 
154
160
  self.definition = circuit
155
161
 
162
+ def control(
163
+ self,
164
+ num_ctrl_qubits: int = 1,
165
+ label: str | None = None,
166
+ ctrl_state: str | int | None = None,
167
+ annotated: bool | None = None,
168
+ ):
169
+ """Return a (multi-)controlled-(XX-YY) gate.
170
+
171
+ Args:
172
+ num_ctrl_qubits: number of control qubits.
173
+ label: An optional label for the gate [Default: ``None``]
174
+ ctrl_state: control state expressed as integer,
175
+ string (e.g.``'110'``), or ``None``. If ``None``, use all 1s.
176
+ annotated: indicates whether the controlled gate should be implemented
177
+ as an annotated gate. If ``None``, this is set to ``True`` if
178
+ the gate contains free parameters, in which case it cannot
179
+ yet be synthesized.
180
+
181
+ Returns:
182
+ ControlledGate: controlled version of this gate.
183
+ """
184
+ if annotated is None:
185
+ annotated = any(isinstance(p, ParameterExpression) for p in self.params)
186
+
187
+ gate = super().control(
188
+ num_ctrl_qubits=num_ctrl_qubits,
189
+ label=label,
190
+ ctrl_state=ctrl_state,
191
+ annotated=annotated,
192
+ )
193
+ return gate
194
+
156
195
  def inverse(self, annotated: bool = False):
157
196
  """Inverse gate.
158
197
 
@@ -11,6 +11,9 @@
11
11
  # that they have been altered from the originals.
12
12
 
13
13
  """Two-qubit XX+YY gate."""
14
+
15
+ from __future__ import annotations
16
+
14
17
  import math
15
18
  from cmath import exp
16
19
  from math import pi
@@ -20,7 +23,8 @@ import numpy
20
23
 
21
24
  from qiskit.circuit.gate import Gate
22
25
  from qiskit.circuit.quantumregister import QuantumRegister
23
- from qiskit.circuit.parameterexpression import ParameterValueType
26
+ from qiskit.circuit.parameterexpression import ParameterValueType, ParameterExpression
27
+ from qiskit._accelerate.circuit import StandardGate
24
28
 
25
29
 
26
30
  class XXPlusYYGate(Gate):
@@ -71,20 +75,24 @@ class XXPlusYYGate(Gate):
71
75
  q_1: ┤0 ├
72
76
  └───────────────┘
73
77
 
74
- .. math::
78
+ .. math::
75
79
 
76
- \newcommand{\rotationangle}{\frac{\theta}{2}}
80
+ \newcommand{\rotationangle}{\frac{\theta}{2}}
77
81
 
78
- R_{XX+YY}(\theta, \beta)\ q_0, q_1 =
79
- RZ_1(-\beta) \cdot \exp\left(-i \frac{\theta}{2} \frac{XX+YY}{2}\right) \cdot RZ_1(\beta) =
80
- \begin{pmatrix}
81
- 1 & 0 & 0 & 0 \\
82
- 0 & \cos\left(\rotationangle\right) & -i\sin\left(\rotationangle\right)e^{i\beta} & 0 \\
83
- 0 & -i\sin\left(\rotationangle\right)e^{-i\beta} & \cos\left(\rotationangle\right) & 0 \\
84
- 0 & 0 & 0 & 1
85
- \end{pmatrix}
82
+ R_{XX+YY}(\theta, \beta)\ q_0, q_1 =
83
+ RZ_1(-\beta) \cdot \exp\left(-i \frac{\theta}{2} \frac{XX+YY}{2}\right) \cdot RZ_1(\beta) =
84
+ \begin{pmatrix}
85
+ 1 & 0 & 0 & 0 \\
86
+ 0 & \cos\left(\rotationangle\right) &
87
+ -i\sin\left(\rotationangle\right)e^{i\beta} & 0 \\
88
+ 0 & -i\sin\left(\rotationangle\right)e^{-i\beta} &
89
+ \cos\left(\rotationangle\right) & 0 \\
90
+ 0 & 0 & 0 & 1
91
+ \end{pmatrix}
86
92
  """
87
93
 
94
+ _standard_gate = StandardGate.XXPlusYYGate
95
+
88
96
  def __init__(
89
97
  self,
90
98
  theta: ParameterValueType,
@@ -155,6 +163,39 @@ class XXPlusYYGate(Gate):
155
163
 
156
164
  self.definition = qc
157
165
 
166
+ def control(
167
+ self,
168
+ num_ctrl_qubits: int = 1,
169
+ label: str | None = None,
170
+ ctrl_state: str | int | None = None,
171
+ annotated: bool | None = None,
172
+ ):
173
+ """Return a (multi-)controlled-(XX+YY) gate.
174
+
175
+ Args:
176
+ num_ctrl_qubits: number of control qubits.
177
+ label: An optional label for the gate [Default: ``None``]
178
+ ctrl_state: control state expressed as integer,
179
+ string (e.g.``'110'``), or ``None``. If ``None``, use all 1s.
180
+ annotated: indicates whether the controlled gate should be implemented
181
+ as an annotated gate. If ``None``, this is set to ``True`` if
182
+ the gate contains free parameters, in which case it cannot
183
+ yet be synthesized.
184
+
185
+ Returns:
186
+ ControlledGate: controlled version of this gate.
187
+ """
188
+ if annotated is None:
189
+ annotated = any(isinstance(p, ParameterExpression) for p in self.params)
190
+
191
+ gate = super().control(
192
+ num_ctrl_qubits=num_ctrl_qubits,
193
+ label=label,
194
+ ctrl_state=ctrl_state,
195
+ annotated=annotated,
196
+ )
197
+ return gate
198
+
158
199
  def inverse(self, annotated: bool = False):
159
200
  """Return inverse XX+YY gate (i.e. with the negative rotation angle and same phase angle).
160
201
 
@@ -19,6 +19,7 @@ from typing import Optional, Union
19
19
  from qiskit.circuit.singleton import SingletonGate, SingletonControlledGate, stdlib_singleton_key
20
20
  from qiskit.circuit.quantumregister import QuantumRegister
21
21
  from qiskit.circuit._utils import with_gate_array, with_controlled_gate_array
22
+ from qiskit._accelerate.circuit import StandardGate
22
23
 
23
24
  _Y_ARRAY = [[0, -1j], [1j, 0]]
24
25
 
@@ -70,6 +71,8 @@ class YGate(SingletonGate):
70
71
  |1\rangle \rightarrow -i|0\rangle
71
72
  """
72
73
 
74
+ _standard_gate = StandardGate.YGate
75
+
73
76
  def __init__(self, label: Optional[str] = None, *, duration=None, unit="dt"):
74
77
  """Create new Y gate."""
75
78
  super().__init__("y", 1, [], label=label, duration=duration, unit=unit)
@@ -105,7 +108,7 @@ class YGate(SingletonGate):
105
108
  label: An optional label for the gate [Default: ``None``]
106
109
  ctrl_state: control state expressed as integer,
107
110
  string (e.g.``'110'``), or ``None``. If ``None``, use all 1s.
108
- annotated: indicates whether the controlled gate can be implemented
111
+ annotated: indicates whether the controlled gate should be implemented
109
112
  as an annotated gate.
110
113
 
111
114
  Returns:
@@ -197,6 +200,8 @@ class CYGate(SingletonControlledGate):
197
200
 
198
201
  """
199
202
 
203
+ _standard_gate = StandardGate.CYGate
204
+
200
205
  def __init__(
201
206
  self,
202
207
  label: Optional[str] = None,
@@ -20,6 +20,7 @@ import numpy
20
20
  from qiskit.circuit._utils import with_gate_array, with_controlled_gate_array
21
21
  from qiskit.circuit.singleton import SingletonGate, SingletonControlledGate, stdlib_singleton_key
22
22
  from qiskit.circuit.quantumregister import QuantumRegister
23
+ from qiskit._accelerate.circuit import StandardGate
23
24
 
24
25
  from .p import PhaseGate
25
26
 
@@ -73,6 +74,8 @@ class ZGate(SingletonGate):
73
74
  |1\rangle \rightarrow -|1\rangle
74
75
  """
75
76
 
77
+ _standard_gate = StandardGate.ZGate
78
+
76
79
  def __init__(self, label: Optional[str] = None, *, duration=None, unit="dt"):
77
80
  """Create new Z gate."""
78
81
  super().__init__("z", 1, [], label=label, duration=duration, unit=unit)
@@ -109,7 +112,7 @@ class ZGate(SingletonGate):
109
112
  label: An optional label for the gate [Default: ``None``]
110
113
  ctrl_state: control state expressed as integer,
111
114
  string (e.g.``'110'``), or ``None``. If ``None``, use all 1s.
112
- annotated: indicates whether the controlled gate can be implemented
115
+ annotated: indicates whether the controlled gate should be implemented
113
116
  as an annotated gate.
114
117
 
115
118
  Returns:
@@ -181,6 +184,8 @@ class CZGate(SingletonControlledGate):
181
184
  the target qubit if the control qubit is in the :math:`|1\rangle` state.
182
185
  """
183
186
 
187
+ _standard_gate = StandardGate.CZGate
188
+
184
189
  def __init__(
185
190
  self,
186
191
  label: Optional[str] = None,
@@ -281,6 +286,8 @@ class CCZGate(SingletonControlledGate):
281
286
  the target qubit if the control qubits are in the :math:`|11\rangle` state.
282
287
  """
283
288
 
289
+ _standard_gate = StandardGate.CCZGate
290
+
284
291
  def __init__(
285
292
  self,
286
293
  label: Optional[str] = None,
@@ -25,7 +25,7 @@ class Operation(ABC):
25
25
  :class:`~qiskit.circuit.Reset`, :class:`~qiskit.circuit.Barrier`,
26
26
  :class:`~qiskit.circuit.Measure`, and operators such as :class:`~qiskit.quantum_info.Clifford`.
27
27
 
28
- The main purpose is to add allow abstract mathematical objects to be added directly onto
28
+ The main purpose is to allow abstract mathematical objects to be added directly onto
29
29
  abstract circuits, and for the exact syntheses of these to be determined later, during
30
30
  compilation.
31
31