qiskit 2.0.3__cp39-abi3-macosx_11_0_arm64.whl → 2.1.0__cp39-abi3-macosx_11_0_arm64.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 (180) hide show
  1. qiskit/VERSION.txt +1 -1
  2. qiskit/__init__.py +19 -1
  3. qiskit/_accelerate.abi3.so +0 -0
  4. qiskit/circuit/__init__.py +104 -20
  5. qiskit/circuit/_add_control.py +57 -31
  6. qiskit/circuit/_classical_resource_map.py +4 -0
  7. qiskit/circuit/annotation.py +504 -0
  8. qiskit/circuit/classical/expr/__init__.py +1 -1
  9. qiskit/circuit/classical/expr/expr.py +104 -446
  10. qiskit/circuit/classical/expr/visitors.py +6 -0
  11. qiskit/circuit/classical/types/types.py +7 -130
  12. qiskit/circuit/controlflow/box.py +32 -7
  13. qiskit/circuit/delay.py +11 -9
  14. qiskit/circuit/library/arithmetic/adders/adder.py +4 -4
  15. qiskit/circuit/library/arithmetic/multipliers/multiplier.py +2 -2
  16. qiskit/circuit/library/arithmetic/piecewise_chebyshev.py +8 -4
  17. qiskit/circuit/library/arithmetic/piecewise_linear_pauli_rotations.py +23 -15
  18. qiskit/circuit/library/arithmetic/piecewise_polynomial_pauli_rotations.py +22 -14
  19. qiskit/circuit/library/arithmetic/quadratic_form.py +6 -0
  20. qiskit/circuit/library/arithmetic/weighted_adder.py +43 -24
  21. qiskit/circuit/library/basis_change/qft.py +2 -2
  22. qiskit/circuit/library/blueprintcircuit.py +6 -0
  23. qiskit/circuit/library/boolean_logic/inner_product.py +2 -2
  24. qiskit/circuit/library/boolean_logic/quantum_and.py +2 -2
  25. qiskit/circuit/library/boolean_logic/quantum_or.py +3 -3
  26. qiskit/circuit/library/boolean_logic/quantum_xor.py +2 -2
  27. qiskit/circuit/library/data_preparation/_z_feature_map.py +2 -2
  28. qiskit/circuit/library/data_preparation/_zz_feature_map.py +2 -2
  29. qiskit/circuit/library/data_preparation/pauli_feature_map.py +2 -2
  30. qiskit/circuit/library/fourier_checking.py +2 -2
  31. qiskit/circuit/library/generalized_gates/diagonal.py +5 -1
  32. qiskit/circuit/library/generalized_gates/gms.py +5 -1
  33. qiskit/circuit/library/generalized_gates/linear_function.py +2 -2
  34. qiskit/circuit/library/generalized_gates/permutation.py +5 -1
  35. qiskit/circuit/library/generalized_gates/uc.py +1 -1
  36. qiskit/circuit/library/generalized_gates/unitary.py +21 -2
  37. qiskit/circuit/library/graph_state.py +2 -2
  38. qiskit/circuit/library/grover_operator.py +2 -2
  39. qiskit/circuit/library/hidden_linear_function.py +2 -2
  40. qiskit/circuit/library/iqp.py +2 -2
  41. qiskit/circuit/library/n_local/efficient_su2.py +2 -2
  42. qiskit/circuit/library/n_local/evolved_operator_ansatz.py +1 -1
  43. qiskit/circuit/library/n_local/excitation_preserving.py +7 -9
  44. qiskit/circuit/library/n_local/n_local.py +4 -3
  45. qiskit/circuit/library/n_local/pauli_two_design.py +2 -2
  46. qiskit/circuit/library/n_local/real_amplitudes.py +2 -2
  47. qiskit/circuit/library/n_local/two_local.py +2 -2
  48. qiskit/circuit/library/overlap.py +2 -2
  49. qiskit/circuit/library/pauli_evolution.py +3 -2
  50. qiskit/circuit/library/phase_estimation.py +2 -2
  51. qiskit/circuit/library/standard_gates/dcx.py +11 -12
  52. qiskit/circuit/library/standard_gates/ecr.py +21 -24
  53. qiskit/circuit/library/standard_gates/equivalence_library.py +232 -96
  54. qiskit/circuit/library/standard_gates/global_phase.py +5 -6
  55. qiskit/circuit/library/standard_gates/h.py +22 -45
  56. qiskit/circuit/library/standard_gates/i.py +1 -1
  57. qiskit/circuit/library/standard_gates/iswap.py +13 -31
  58. qiskit/circuit/library/standard_gates/p.py +19 -26
  59. qiskit/circuit/library/standard_gates/r.py +11 -17
  60. qiskit/circuit/library/standard_gates/rx.py +21 -45
  61. qiskit/circuit/library/standard_gates/rxx.py +7 -22
  62. qiskit/circuit/library/standard_gates/ry.py +21 -39
  63. qiskit/circuit/library/standard_gates/ryy.py +13 -28
  64. qiskit/circuit/library/standard_gates/rz.py +18 -35
  65. qiskit/circuit/library/standard_gates/rzx.py +7 -22
  66. qiskit/circuit/library/standard_gates/rzz.py +7 -19
  67. qiskit/circuit/library/standard_gates/s.py +44 -39
  68. qiskit/circuit/library/standard_gates/swap.py +25 -38
  69. qiskit/circuit/library/standard_gates/sx.py +34 -41
  70. qiskit/circuit/library/standard_gates/t.py +18 -27
  71. qiskit/circuit/library/standard_gates/u.py +8 -24
  72. qiskit/circuit/library/standard_gates/u1.py +28 -52
  73. qiskit/circuit/library/standard_gates/u2.py +9 -9
  74. qiskit/circuit/library/standard_gates/u3.py +24 -40
  75. qiskit/circuit/library/standard_gates/x.py +190 -336
  76. qiskit/circuit/library/standard_gates/xx_minus_yy.py +12 -50
  77. qiskit/circuit/library/standard_gates/xx_plus_yy.py +13 -52
  78. qiskit/circuit/library/standard_gates/y.py +19 -23
  79. qiskit/circuit/library/standard_gates/z.py +31 -38
  80. qiskit/circuit/parameter.py +14 -5
  81. qiskit/circuit/parameterexpression.py +109 -75
  82. qiskit/circuit/quantumcircuit.py +172 -99
  83. qiskit/circuit/quantumcircuitdata.py +1 -0
  84. qiskit/circuit/random/__init__.py +37 -2
  85. qiskit/circuit/random/utils.py +445 -56
  86. qiskit/circuit/tools/pi_check.py +5 -13
  87. qiskit/compiler/transpiler.py +1 -1
  88. qiskit/converters/circuit_to_instruction.py +2 -2
  89. qiskit/dagcircuit/dagnode.py +8 -3
  90. qiskit/primitives/__init__.py +2 -2
  91. qiskit/primitives/base/base_estimator.py +2 -2
  92. qiskit/primitives/containers/data_bin.py +0 -3
  93. qiskit/primitives/containers/observables_array.py +192 -108
  94. qiskit/primitives/primitive_job.py +29 -10
  95. qiskit/providers/fake_provider/generic_backend_v2.py +2 -0
  96. qiskit/qasm3/__init__.py +106 -12
  97. qiskit/qasm3/ast.py +15 -1
  98. qiskit/qasm3/exporter.py +59 -36
  99. qiskit/qasm3/printer.py +12 -0
  100. qiskit/qpy/__init__.py +182 -6
  101. qiskit/qpy/binary_io/circuits.py +256 -24
  102. qiskit/qpy/binary_io/parse_sympy_repr.py +5 -0
  103. qiskit/qpy/binary_io/schedules.py +12 -32
  104. qiskit/qpy/binary_io/value.py +36 -18
  105. qiskit/qpy/common.py +11 -3
  106. qiskit/qpy/formats.py +17 -1
  107. qiskit/qpy/interface.py +52 -12
  108. qiskit/qpy/type_keys.py +7 -1
  109. qiskit/quantum_info/__init__.py +10 -0
  110. qiskit/quantum_info/operators/__init__.py +1 -0
  111. qiskit/quantum_info/operators/symplectic/__init__.py +1 -0
  112. qiskit/quantum_info/operators/symplectic/clifford_circuits.py +26 -0
  113. qiskit/quantum_info/operators/symplectic/pauli.py +2 -2
  114. qiskit/result/sampled_expval.py +3 -1
  115. qiskit/synthesis/__init__.py +10 -0
  116. qiskit/synthesis/arithmetic/__init__.py +1 -1
  117. qiskit/synthesis/arithmetic/adders/__init__.py +1 -0
  118. qiskit/synthesis/arithmetic/adders/draper_qft_adder.py +6 -2
  119. qiskit/synthesis/arithmetic/adders/rv_ripple_carry_adder.py +156 -0
  120. qiskit/synthesis/discrete_basis/generate_basis_approximations.py +14 -126
  121. qiskit/synthesis/discrete_basis/solovay_kitaev.py +161 -121
  122. qiskit/synthesis/evolution/lie_trotter.py +10 -7
  123. qiskit/synthesis/evolution/product_formula.py +10 -7
  124. qiskit/synthesis/evolution/qdrift.py +10 -7
  125. qiskit/synthesis/evolution/suzuki_trotter.py +10 -7
  126. qiskit/synthesis/multi_controlled/__init__.py +4 -0
  127. qiskit/synthesis/multi_controlled/mcx_synthesis.py +402 -178
  128. qiskit/synthesis/multi_controlled/multi_control_rotation_gates.py +14 -15
  129. qiskit/synthesis/qft/qft_decompose_lnn.py +7 -25
  130. qiskit/synthesis/unitary/qsd.py +80 -9
  131. qiskit/transpiler/__init__.py +10 -3
  132. qiskit/transpiler/instruction_durations.py +2 -20
  133. qiskit/transpiler/passes/__init__.py +5 -2
  134. qiskit/transpiler/passes/layout/dense_layout.py +26 -6
  135. qiskit/transpiler/passes/layout/disjoint_utils.py +1 -166
  136. qiskit/transpiler/passes/layout/sabre_layout.py +22 -3
  137. qiskit/transpiler/passes/layout/sabre_pre_layout.py +1 -1
  138. qiskit/transpiler/passes/layout/vf2_layout.py +49 -13
  139. qiskit/transpiler/passes/layout/vf2_utils.py +10 -0
  140. qiskit/transpiler/passes/optimization/__init__.py +1 -1
  141. qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +2 -1
  142. qiskit/transpiler/passes/optimization/optimize_clifford_t.py +68 -0
  143. qiskit/transpiler/passes/optimization/template_matching/template_substitution.py +3 -9
  144. qiskit/transpiler/passes/routing/sabre_swap.py +4 -2
  145. qiskit/transpiler/passes/routing/star_prerouting.py +106 -81
  146. qiskit/transpiler/passes/scheduling/__init__.py +1 -1
  147. qiskit/transpiler/passes/scheduling/alignments/check_durations.py +1 -1
  148. qiskit/transpiler/passes/scheduling/padding/__init__.py +1 -0
  149. qiskit/transpiler/passes/scheduling/padding/context_aware_dynamical_decoupling.py +876 -0
  150. qiskit/transpiler/passes/synthesis/__init__.py +1 -0
  151. qiskit/transpiler/passes/synthesis/clifford_unitary_synth_plugin.py +123 -0
  152. qiskit/transpiler/passes/synthesis/hls_plugins.py +494 -93
  153. qiskit/transpiler/passes/synthesis/plugin.py +4 -0
  154. qiskit/transpiler/passes/synthesis/solovay_kitaev_synthesis.py +27 -22
  155. qiskit/transpiler/passmanager_config.py +3 -0
  156. qiskit/transpiler/preset_passmanagers/builtin_plugins.py +149 -28
  157. qiskit/transpiler/preset_passmanagers/common.py +101 -0
  158. qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py +6 -0
  159. qiskit/transpiler/preset_passmanagers/level3.py +2 -2
  160. qiskit/transpiler/target.py +15 -2
  161. qiskit/utils/optionals.py +6 -5
  162. qiskit/visualization/circuit/_utils.py +5 -3
  163. qiskit/visualization/circuit/latex.py +9 -2
  164. qiskit/visualization/circuit/matplotlib.py +26 -4
  165. qiskit/visualization/circuit/qcstyle.py +9 -157
  166. qiskit/visualization/dag/__init__.py +13 -0
  167. qiskit/visualization/dag/dagstyle.py +103 -0
  168. qiskit/visualization/dag/styles/__init__.py +13 -0
  169. qiskit/visualization/dag/styles/color.json +10 -0
  170. qiskit/visualization/dag/styles/plain.json +5 -0
  171. qiskit/visualization/dag_visualization.py +169 -98
  172. qiskit/visualization/style.py +223 -0
  173. {qiskit-2.0.3.dist-info → qiskit-2.1.0.dist-info}/METADATA +7 -6
  174. {qiskit-2.0.3.dist-info → qiskit-2.1.0.dist-info}/RECORD +178 -169
  175. {qiskit-2.0.3.dist-info → qiskit-2.1.0.dist-info}/entry_points.txt +6 -0
  176. qiskit/synthesis/discrete_basis/commutator_decompose.py +0 -265
  177. qiskit/synthesis/discrete_basis/gate_sequence.py +0 -421
  178. {qiskit-2.0.3.dist-info → qiskit-2.1.0.dist-info}/WHEEL +0 -0
  179. {qiskit-2.0.3.dist-info → qiskit-2.1.0.dist-info}/licenses/LICENSE.txt +0 -0
  180. {qiskit-2.0.3.dist-info → qiskit-2.1.0.dist-info}/top_level.txt +0 -0
@@ -12,12 +12,6 @@
12
12
 
13
13
  """Type-system definition for the expression tree."""
14
14
 
15
- # Given the nature of the tree representation and that there are helper functions associated with
16
- # many of the classes whose arguments naturally share names with themselves, it's inconvenient to
17
- # use synonyms everywhere. This goes for the builtin 'type' as well.
18
- # pylint: disable=redefined-builtin,redefined-outer-name
19
-
20
- from __future__ import annotations
21
15
 
22
16
  __all__ = [
23
17
  "Type",
@@ -27,127 +21,10 @@ __all__ = [
27
21
  "Uint",
28
22
  ]
29
23
 
30
- import typing
31
-
32
-
33
- class _Singleton(type):
34
- """Metaclass to make the child, which should take zero initialization arguments, a singleton
35
- object."""
36
-
37
- def _get_singleton_instance(cls):
38
- return cls._INSTANCE
39
-
40
- @classmethod
41
- def __prepare__(mcs, name, bases): # pylint: disable=unused-argument
42
- return {"__new__": mcs._get_singleton_instance}
43
-
44
- @staticmethod
45
- def __new__(cls, name, bases, namespace):
46
- out = super().__new__(cls, name, bases, namespace)
47
- out._INSTANCE = object.__new__(out) # pylint: disable=invalid-name
48
- return out
49
-
50
-
51
- class Type:
52
- """Root base class of all nodes in the type tree. The base case should never be instantiated
53
- directly.
54
-
55
- This must not be subclassed by users; subclasses form the internal data of the representation of
56
- expressions, and it does not make sense to add more outside of Qiskit library code."""
57
-
58
- __slots__ = ()
59
-
60
- @property
61
- def kind(self):
62
- """Get the kind of this type. This is exactly equal to the Python type object that defines
63
- this type, that is ``t.kind is type(t)``, but is exposed like this to make it clear that
64
- this a hashable enum-like discriminator you can rely on."""
65
- return self.__class__
66
-
67
- # Enforcement of immutability. The constructor methods need to manually skip this.
68
-
69
- def __setattr__(self, _key, _value):
70
- raise AttributeError(f"'{self.kind.__name__}' instances are immutable")
71
-
72
- def __copy__(self):
73
- return self
74
-
75
- def __deepcopy__(self, _memo):
76
- return self
77
-
78
- def __setstate__(self, state):
79
- _dict, slots = state
80
- for slot, value in slots.items():
81
- # We need to overcome the type's enforcement of immutability post initialization.
82
- super().__setattr__(slot, value)
83
-
84
-
85
- @typing.final
86
- class Bool(Type, metaclass=_Singleton):
87
- """The Boolean type. This has exactly two values: ``True`` and ``False``."""
88
-
89
- __slots__ = ()
90
-
91
- def __repr__(self):
92
- return "Bool()"
93
-
94
- def __hash__(self):
95
- return hash(self.__class__)
96
-
97
- def __eq__(self, other):
98
- return isinstance(other, Bool)
99
-
100
-
101
- @typing.final
102
- class Uint(Type):
103
- """An unsigned integer of fixed bit width."""
104
-
105
- __slots__ = ("width",)
106
-
107
- def __init__(self, width: int):
108
- if isinstance(width, int) and width <= 0:
109
- raise ValueError("uint width must be greater than zero")
110
- super(Type, self).__setattr__("width", width)
111
-
112
- def __repr__(self):
113
- return f"Uint({self.width})"
114
-
115
- def __hash__(self):
116
- return hash((self.__class__, self.width))
117
-
118
- def __eq__(self, other):
119
- return isinstance(other, Uint) and self.width == other.width
120
-
121
-
122
- @typing.final
123
- class Float(Type, metaclass=_Singleton):
124
- """An IEEE-754 double-precision floating point number.
125
- In the future, this may also be used to represent other fixed-width floats.
126
- """
127
-
128
- __slots__ = ()
129
-
130
- def __repr__(self):
131
- return "Float()"
132
-
133
- def __hash__(self):
134
- return hash(self.__class__)
135
-
136
- def __eq__(self, other):
137
- return isinstance(other, Float)
138
-
139
-
140
- @typing.final
141
- class Duration(Type, metaclass=_Singleton):
142
- """A length of time, possibly negative."""
143
-
144
- __slots__ = ()
145
-
146
- def __repr__(self):
147
- return "Duration()"
148
-
149
- def __hash__(self):
150
- return hash(self.__class__)
151
-
152
- def __eq__(self, other):
153
- return isinstance(other, Duration)
24
+ from qiskit._accelerate.circuit.classical.types import (
25
+ Type,
26
+ Bool,
27
+ Uint,
28
+ Float,
29
+ Duration,
30
+ ) # pylint: disable=unused-import
@@ -16,11 +16,12 @@ from __future__ import annotations
16
16
 
17
17
  import typing
18
18
 
19
+ from qiskit.circuit.delay import Delay
19
20
  from qiskit.circuit.exceptions import CircuitError
20
21
  from .control_flow import ControlFlowOp
21
22
 
22
23
  if typing.TYPE_CHECKING:
23
- from qiskit.circuit import QuantumCircuit
24
+ from qiskit.circuit import QuantumCircuit, Annotation
24
25
 
25
26
 
26
27
  class BoxOp(ControlFlowOp):
@@ -31,6 +32,11 @@ class BoxOp(ControlFlowOp):
31
32
  commute operations "all the way" through the box. The box is also an explicit scope for the
32
33
  purposes of variables, stretches and compiler passes.
33
34
 
35
+ A box may be "annotated" with arbitrary user-defined custom :class:`.Annotation` objects. In
36
+ cases where order is important, these should be interpreted by applying the first annotation in
37
+ the list first, then the second, and so on. It is generally recommended that annotations should
38
+ not be order-dependent, wherever possible.
39
+
34
40
  Typically you create this by using the builder-interface form of :meth:`.QuantumCircuit.box`.
35
41
  """
36
42
 
@@ -38,8 +44,9 @@ class BoxOp(ControlFlowOp):
38
44
  self,
39
45
  body: QuantumCircuit,
40
46
  duration: None = None,
41
- unit: typing.Literal["dt", "s", "ms", "us", "ns", "ps"] = "dt",
47
+ unit: typing.Literal["dt", "s", "ms", "us", "ns", "ps", "expr"] | None = None,
42
48
  label: str | None = None,
49
+ annotations: typing.Iterable[Annotation] = (),
43
50
  ):
44
51
  """
45
52
  Default constructor of :class:`BoxOp`.
@@ -52,10 +59,13 @@ class BoxOp(ControlFlowOp):
52
59
  duration: an optional duration for the box as a whole.
53
60
  unit: the unit of the ``duration``.
54
61
  label: an optional string label for the instruction.
62
+ annotations: any :class:`.Annotation`\\ s to apply to the box. In cases where order
63
+ is important, annotations are to be interpreted in the same order they appear in
64
+ the iterable.
55
65
  """
56
66
  super().__init__("box", body.num_qubits, body.num_clbits, [body], label=label)
57
- self.duration = duration
58
- self.unit = unit
67
+ self.annotations = list(annotations)
68
+ self.duration, self.unit = Delay._validate_arguments(duration, unit)
59
69
 
60
70
  @property
61
71
  def params(self):
@@ -100,13 +110,20 @@ class BoxOp(ControlFlowOp):
100
110
 
101
111
  def replace_blocks(self, blocks):
102
112
  (body,) = blocks
103
- return BoxOp(body, duration=self.duration, unit=self.unit, label=self.label)
113
+ return BoxOp(
114
+ body,
115
+ duration=self.duration,
116
+ unit=self.unit,
117
+ label=self.label,
118
+ annotations=self.annotations,
119
+ )
104
120
 
105
121
  def __eq__(self, other):
106
122
  return (
107
123
  isinstance(other, BoxOp)
108
124
  and self.duration == other.duration
109
125
  and self.unit == other.unit
126
+ and self.annotations == other.annotations
110
127
  and super().__eq__(other)
111
128
  )
112
129
 
@@ -117,7 +134,7 @@ class BoxContext:
117
134
  This is not part of the public interface, and should not be instantiated by users.
118
135
  """
119
136
 
120
- __slots__ = ("_circuit", "_duration", "_unit", "_label")
137
+ __slots__ = ("_circuit", "_duration", "_unit", "_label", "_annotations")
121
138
 
122
139
  def __init__(
123
140
  self,
@@ -126,6 +143,7 @@ class BoxContext:
126
143
  duration: None = None,
127
144
  unit: typing.Literal["dt", "s", "ms", "us", "ns", "ps"] = "dt",
128
145
  label: str | None = None,
146
+ annotations: typing.Iterable[Annotation] = (),
129
147
  ):
130
148
  """
131
149
  Args:
@@ -138,6 +156,7 @@ class BoxContext:
138
156
  self._duration = duration
139
157
  self._unit = unit
140
158
  self._label = label
159
+ self._annotations = annotations
141
160
 
142
161
  def __enter__(self):
143
162
  # For a box to have the semantics of internal qubit alignment with a resolvable duration, we
@@ -156,7 +175,13 @@ class BoxContext:
156
175
  # `box` permitted.
157
176
  body = scope.build(scope.qubits(), scope.clbits())
158
177
  self._circuit.append(
159
- BoxOp(body, duration=self._duration, unit=self._unit, label=self._label),
178
+ BoxOp(
179
+ body,
180
+ duration=self._duration,
181
+ unit=self._unit,
182
+ label=self._label,
183
+ annotations=self._annotations,
184
+ ),
160
185
  body.qubits,
161
186
  body.clbits,
162
187
  )
qiskit/circuit/delay.py CHANGED
@@ -44,6 +44,13 @@ class Delay(Instruction):
44
44
  CircuitError: A ``duration`` expression was specified with a resolved
45
45
  type that is not timing-based, or the ``unit`` was improperly specified.
46
46
  """
47
+ duration, self._unit = self._validate_arguments(duration, unit)
48
+ super().__init__("delay", 1, 0, params=[duration])
49
+
50
+ @staticmethod
51
+ def _validate_arguments(duration, unit):
52
+ # This method is a centralization of the unit-handling logic, so used elsewhere in Qiskit
53
+ # (e.g. in `BoxOp`).
47
54
  if isinstance(duration, expr.Expr):
48
55
  if unit is not None and unit != "expr":
49
56
  raise CircuitError(
@@ -60,12 +67,7 @@ class Delay(Instruction):
60
67
  unit = "dt"
61
68
  elif unit not in {"s", "ms", "us", "ns", "ps", "dt"}:
62
69
  raise CircuitError(f"Unknown unit {unit} is specified.")
63
- # Double underscore to differentiate from the private attribute in
64
- # `Instruction`. This can be changed to `_unit` in 2.0 after we
65
- # remove `unit` and `duration` from the standard instruction model
66
- # as it only will exist in `Delay` after that point.
67
- self.__unit = unit
68
- super().__init__("delay", 1, 0, params=[duration])
70
+ return duration, unit
69
71
 
70
72
  broadcast_arguments = Gate.broadcast_arguments
71
73
 
@@ -76,13 +78,13 @@ class Delay(Instruction):
76
78
  @property
77
79
  def unit(self):
78
80
  """The unit for the duration of the delay in :attr`.params`"""
79
- return self.__unit
81
+ return self._unit
80
82
 
81
83
  @unit.setter
82
84
  def unit(self, value):
83
85
  if value not in {"s", "ms", "us", "ns", "ps", "dt"}:
84
86
  raise CircuitError(f"Unknown unit {value} is specified.")
85
- self.__unit = value
87
+ self._unit = value
86
88
 
87
89
  @property
88
90
  def duration(self):
@@ -126,7 +128,7 @@ class Delay(Instruction):
126
128
  raise CircuitError(
127
129
  f"Duration for Delay instruction must be positive. Found {parameter}"
128
130
  )
129
- if self.__unit == "dt":
131
+ if self._unit == "dt":
130
132
  parameter_int = int(parameter)
131
133
  if parameter != parameter_int:
132
134
  raise CircuitError("Integer duration is expected for 'dt' unit.")
@@ -43,14 +43,14 @@ class Adder(QuantumCircuit):
43
43
  """
44
44
 
45
45
  @deprecate_func(
46
- since="1.3",
46
+ since="2.1",
47
47
  additional_msg=(
48
48
  "Use the adder gates provided in qiskit.circuit.library.arithmetic instead. "
49
49
  "The gate type depends on the adder kind: fixed, half, full are represented by "
50
50
  "ModularAdderGate, HalfAdderGate, FullAdderGate, respectively. For different adder "
51
51
  "implementations, see https://quantum.cloud.ibm.com/docs/api/qiskit/synthesis.",
52
52
  ),
53
- pending=True,
53
+ removal_timeline="in Qiskit 3.0",
54
54
  )
55
55
  def __init__(self, num_state_qubits: int, name: str = "Adder") -> None:
56
56
  """
@@ -118,12 +118,12 @@ class HalfAdderGate(Gate):
118
118
 
119
119
  def _define(self):
120
120
  """Populates self.definition with some decomposition of this gate."""
121
- from qiskit.synthesis.arithmetic import adder_qft_d00
121
+ from qiskit.synthesis.arithmetic import adder_ripple_r25
122
122
 
123
123
  # This particular decomposition does not use any ancilla qubits.
124
124
  # Note that the transpiler may choose a different decomposition
125
125
  # based on the number of ancilla qubits available.
126
- self.definition = adder_qft_d00(self.num_state_qubits, kind="half")
126
+ self.definition = adder_ripple_r25(self.num_state_qubits)
127
127
 
128
128
 
129
129
  class ModularAdderGate(Gate):
@@ -47,13 +47,13 @@ class Multiplier(QuantumCircuit):
47
47
  """
48
48
 
49
49
  @deprecate_func(
50
- since="1.3",
50
+ since="2.1",
51
51
  additional_msg=(
52
52
  "Use the MultiplierGate provided in qiskit.circuit.library.arithmetic instead. "
53
53
  "For different multiplier implementations, see "
54
54
  "https://quantum.cloud.ibm.com/docs/api/qiskit/synthesis.",
55
55
  ),
56
- pending=True,
56
+ removal_timeline="in Qiskit 3.0",
57
57
  )
58
58
  def __init__(
59
59
  self,
@@ -13,6 +13,7 @@
13
13
  """Piecewise polynomial Chebyshev approximation to a given f(x)."""
14
14
 
15
15
  from __future__ import annotations
16
+ import warnings
16
17
  from typing import Callable
17
18
  import numpy as np
18
19
  from numpy.polynomial.chebyshev import Chebyshev
@@ -345,9 +346,12 @@ class PiecewiseChebyshev(BlueprintCircuit):
345
346
 
346
347
  super()._build()
347
348
 
348
- poly_r = PiecewisePolynomialPauliRotations(
349
- self.num_state_qubits, self.breakpoints, self.polynomials, name=self.name
350
- )
349
+ # the class itself is deprecated, no need to raise additional warnings during runtime
350
+ with warnings.catch_warnings():
351
+ warnings.filterwarnings("ignore", category=DeprecationWarning, module="qiskit")
352
+ poly_r = PiecewisePolynomialPauliRotations(
353
+ self.num_state_qubits, self.breakpoints, self.polynomials, name=self.name
354
+ )
351
355
 
352
356
  # Apply polynomial approximation
353
357
  self.append(poly_r.to_gate(), self.qubits)
@@ -373,7 +377,7 @@ class PiecewiseChebyshevGate(Gate):
373
377
  from qiskit import QuantumCircuit
374
378
  from qiskit.circuit.library.arithmetic import PiecewiseChebyshevGate
375
379
 
376
- f_x, num_state_qubits, degree, breakpoints = lambda x: np.arcsin(1 / x), 2, 2, [2, 4]
380
+ f_x, num_state_qubits, degree, breakpoints = lambda x: np.sin(1 / x), 2, 2, [2, 4]
377
381
  pw_approximation = PiecewiseChebyshevGate(f_x, num_state_qubits, degree, breakpoints)
378
382
 
379
383
  qc = QuantumCircuit(pw_approximation.num_qubits)
@@ -14,6 +14,7 @@
14
14
  """Piecewise-linearly-controlled rotation."""
15
15
 
16
16
  from __future__ import annotations
17
+ import warnings
17
18
  from collections.abc import Sequence
18
19
  import numpy as np
19
20
 
@@ -244,32 +245,39 @@ class PiecewiseLinearPauliRotations(FunctionalPauliRotations):
244
245
  # apply comparators and controlled linear rotations
245
246
  for i, point in enumerate(self.breakpoints):
246
247
  if i == 0 and self.contains_zero_breakpoint:
247
- # apply rotation
248
- lin_r = LinearPauliRotations(
249
- num_state_qubits=self.num_state_qubits,
250
- slope=self.mapped_slopes[i],
251
- offset=self.mapped_offsets[i],
252
- basis=self.basis,
253
- )
248
+ # deprecation warning is already triggered upon init, filter the rest
249
+ with warnings.catch_warnings():
250
+ warnings.filterwarnings("ignore", category=DeprecationWarning, module="qiskit")
251
+ # apply rotation
252
+ lin_r = LinearPauliRotations(
253
+ num_state_qubits=self.num_state_qubits,
254
+ slope=self.mapped_slopes[i],
255
+ offset=self.mapped_offsets[i],
256
+ basis=self.basis,
257
+ )
254
258
  circuit.append(lin_r.to_gate(), qr_state[:] + qr_target)
255
259
 
256
260
  else:
257
261
  qr_compare = [qr_ancilla[0]]
258
262
  qr_helper = qr_ancilla[1:]
259
263
 
260
- # apply Comparator
261
- comp = IntegerComparator(num_state_qubits=self.num_state_qubits, value=point)
264
+ with warnings.catch_warnings():
265
+ warnings.filterwarnings("ignore", category=DeprecationWarning, module="qiskit")
266
+ # apply Comparator
267
+ comp = IntegerComparator(num_state_qubits=self.num_state_qubits, value=point)
262
268
  qr = qr_state[:] + qr_compare[:] # add ancilla as compare qubit
263
269
 
264
270
  circuit.append(comp.to_gate(), qr[:] + qr_helper[: comp.num_ancillas])
265
271
 
266
272
  # apply controlled rotation
267
- lin_r = LinearPauliRotations(
268
- num_state_qubits=self.num_state_qubits,
269
- slope=self.mapped_slopes[i],
270
- offset=self.mapped_offsets[i],
271
- basis=self.basis,
272
- )
273
+ with warnings.catch_warnings():
274
+ warnings.filterwarnings("ignore", category=DeprecationWarning, module="qiskit")
275
+ lin_r = LinearPauliRotations(
276
+ num_state_qubits=self.num_state_qubits,
277
+ slope=self.mapped_slopes[i],
278
+ offset=self.mapped_offsets[i],
279
+ basis=self.basis,
280
+ )
273
281
  circuit.append(lin_r.to_gate().control(), qr_compare[:] + qr_state[:] + qr_target)
274
282
 
275
283
  # uncompute comparator
@@ -13,6 +13,7 @@
13
13
  """Piecewise-polynomially-controlled Pauli rotations."""
14
14
 
15
15
  from __future__ import annotations
16
+ import warnings
16
17
  from typing import List, Optional
17
18
  import numpy as np
18
19
 
@@ -271,17 +272,22 @@ class PiecewisePolynomialPauliRotations(FunctionalPauliRotations):
271
272
  # apply comparators and controlled linear rotations
272
273
  for i, point in enumerate(self.breakpoints[:-1]):
273
274
  if i == 0 and self.contains_zero_breakpoint:
274
- # apply rotation
275
- poly_r = PolynomialPauliRotations(
276
- num_state_qubits=self.num_state_qubits,
277
- coeffs=self.mapped_coeffs[i],
278
- basis=self.basis,
279
- )
275
+ # the class itself is deprecated, no need to raise additional warnings during runtime
276
+ with warnings.catch_warnings():
277
+ warnings.filterwarnings("ignore", category=DeprecationWarning, module="qiskit")
278
+ poly_r = PolynomialPauliRotations(
279
+ num_state_qubits=self.num_state_qubits,
280
+ coeffs=self.mapped_coeffs[i],
281
+ basis=self.basis,
282
+ )
280
283
  circuit.append(poly_r.to_gate(), qr_state[:] + qr_target)
281
284
 
282
285
  else:
283
- # apply Comparator
284
- comp = IntegerComparator(num_state_qubits=self.num_state_qubits, value=point)
286
+ # the class itself is deprecated, no need to raise additional warnings during runtime
287
+ with warnings.catch_warnings():
288
+ warnings.filterwarnings("ignore", category=DeprecationWarning, module="qiskit")
289
+ comp = IntegerComparator(num_state_qubits=self.num_state_qubits, value=point)
290
+
285
291
  qr_state_full = qr_state[:] + [qr_ancilla[0]] # add compare qubit
286
292
  qr_remaining_ancilla = qr_ancilla[1:] # take remaining ancillas
287
293
 
@@ -289,12 +295,14 @@ class PiecewisePolynomialPauliRotations(FunctionalPauliRotations):
289
295
  comp.to_gate(), qr_state_full[:] + qr_remaining_ancilla[: comp.num_ancillas]
290
296
  )
291
297
 
292
- # apply controlled rotation
293
- poly_r = PolynomialPauliRotations(
294
- num_state_qubits=self.num_state_qubits,
295
- coeffs=self.mapped_coeffs[i],
296
- basis=self.basis,
297
- )
298
+ # the class itself is deprecated, no need to raise additional warnings during runtime
299
+ with warnings.catch_warnings():
300
+ warnings.filterwarnings("ignore", category=DeprecationWarning, module="qiskit")
301
+ poly_r = PolynomialPauliRotations(
302
+ num_state_qubits=self.num_state_qubits,
303
+ coeffs=self.mapped_coeffs[i],
304
+ basis=self.basis,
305
+ )
298
306
  circuit.append(
299
307
  poly_r.to_gate().control(), [qr_ancilla[0]] + qr_state[:] + qr_target
300
308
  )
@@ -21,6 +21,7 @@ from collections.abc import Sequence
21
21
  import numpy as np
22
22
 
23
23
  from qiskit.circuit import QuantumCircuit, QuantumRegister, ParameterExpression, Gate, CircuitError
24
+ from qiskit.utils.deprecation import deprecate_func
24
25
  from ..basis_change import QFT, QFTGate
25
26
 
26
27
  _ValueType = Union[int, float, np.integer, np.floating, ParameterExpression]
@@ -64,6 +65,11 @@ class QuadraticForm(QuantumCircuit):
64
65
 
65
66
  """
66
67
 
68
+ @deprecate_func(
69
+ since="2.1",
70
+ additional_msg="Use the QuadraticFormGate instead.",
71
+ removal_timeline="Qiskit 3.0",
72
+ )
67
73
  def __init__(
68
74
  self,
69
75
  num_result_qubits: Optional[int] = None,
@@ -14,6 +14,7 @@
14
14
 
15
15
  from __future__ import annotations
16
16
 
17
+ import warnings
17
18
  from typing import List, Optional
18
19
  import numpy as np
19
20
 
@@ -263,12 +264,18 @@ class WeightedAdder(BlueprintCircuit):
263
264
  # - controlled by q_state[i]
264
265
  circuit.x(qr_sum[j])
265
266
  circuit.x(qr_carry[j - 1])
266
- circuit.mcx(
267
- [q_state, qr_sum[j], qr_carry[j - 1]],
268
- qr_carry[j],
269
- qr_control,
270
- mode="v-chain",
271
- )
267
+
268
+ with warnings.catch_warnings():
269
+ warnings.filterwarnings(
270
+ "ignore", category=DeprecationWarning, module="qiskit"
271
+ )
272
+ circuit.mcx(
273
+ [q_state, qr_sum[j], qr_carry[j - 1]],
274
+ qr_carry[j],
275
+ qr_control,
276
+ mode="v-chain",
277
+ )
278
+
272
279
  circuit.cx(q_state, qr_carry[j])
273
280
  circuit.x(qr_sum[j])
274
281
  circuit.x(qr_carry[j - 1])
@@ -287,12 +294,16 @@ class WeightedAdder(BlueprintCircuit):
287
294
  else:
288
295
  # compute (q_sum[j] + q_carry[j-1]) into (q_sum[j], q_carry[j])
289
296
  # - controlled by q_state[i]
290
- circuit.mcx(
291
- [q_state, qr_sum[j], qr_carry[j - 1]],
292
- qr_carry[j],
293
- qr_control,
294
- mode="v-chain",
295
- )
297
+ with warnings.catch_warnings():
298
+ warnings.filterwarnings(
299
+ "ignore", category=DeprecationWarning, module="qiskit"
300
+ )
301
+ circuit.mcx(
302
+ [q_state, qr_sum[j], qr_carry[j - 1]],
303
+ qr_carry[j],
304
+ qr_control,
305
+ mode="v-chain",
306
+ )
296
307
  circuit.ccx(q_state, qr_carry[j - 1], qr_sum[j])
297
308
 
298
309
  # uncompute carry qubits
@@ -309,12 +320,16 @@ class WeightedAdder(BlueprintCircuit):
309
320
  pass
310
321
  else:
311
322
  circuit.x(qr_carry[j - 1])
312
- circuit.mcx(
313
- [q_state, qr_sum[j], qr_carry[j - 1]],
314
- qr_carry[j],
315
- qr_control,
316
- mode="v-chain",
317
- )
323
+ with warnings.catch_warnings():
324
+ warnings.filterwarnings(
325
+ "ignore", category=DeprecationWarning, module="qiskit"
326
+ )
327
+ circuit.mcx(
328
+ [q_state, qr_sum[j], qr_carry[j - 1]],
329
+ qr_carry[j],
330
+ qr_control,
331
+ mode="v-chain",
332
+ )
318
333
  circuit.cx(q_state, qr_carry[j])
319
334
  circuit.x(qr_carry[j - 1])
320
335
  else:
@@ -328,12 +343,16 @@ class WeightedAdder(BlueprintCircuit):
328
343
  # compute (q_sum[j] + q_carry[j-1]) into (q_sum[j], q_carry[j])
329
344
  # - controlled by q_state[i]
330
345
  circuit.x(qr_sum[j])
331
- circuit.mcx(
332
- [q_state, qr_sum[j], qr_carry[j - 1]],
333
- qr_carry[j],
334
- qr_control,
335
- mode="v-chain",
336
- )
346
+ with warnings.catch_warnings():
347
+ warnings.filterwarnings(
348
+ "ignore", category=DeprecationWarning, module="qiskit"
349
+ )
350
+ circuit.mcx(
351
+ [q_state, qr_sum[j], qr_carry[j - 1]],
352
+ qr_carry[j],
353
+ qr_control,
354
+ mode="v-chain",
355
+ )
337
356
  circuit.x(qr_sum[j])
338
357
 
339
358
  self.append(circuit.to_gate(), self.qubits)
@@ -76,12 +76,12 @@ class QFT(BlueprintCircuit):
76
76
  """
77
77
 
78
78
  @deprecate_func(
79
- since="1.3",
79
+ since="2.1",
80
80
  additional_msg=(
81
81
  "Use qiskit.circuit.library.QFTGate or qiskit.synthesis.qft.synth_qft_full instead, "
82
82
  "for access to all previous arguments.",
83
83
  ),
84
- pending=True,
84
+ removal_timeline="in Qiskit 3.0",
85
85
  )
86
86
  def __init__(
87
87
  self,