qiskit 1.3.2__cp39-abi3-win32.whl → 1.3.3__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.
qiskit/VERSION.txt CHANGED
@@ -1 +1 @@
1
- 1.3.2
1
+ 1.3.3
qiskit/_accelerate.pyd CHANGED
Binary file
@@ -294,6 +294,7 @@ main related classes are:
294
294
  * :class:`Parameter`, the atom of compile-time expressions
295
295
  * :class:`ParameterExpression`, a symbolic calculation on parameters
296
296
  * :class:`ParameterVector`, a convenience collection of many :class:`Parameter`\ s
297
+ * :class:`ParameterVectorElement`, a subclass of :class:`Parameter` used by :class:`ParameterVector`
297
298
 
298
299
  The :mod:`qiskit.circuit` module also exposes some calculation classes that work with circuits to
299
300
  assist compilation workflows. These include:
@@ -667,12 +668,14 @@ execution. You can do this assignment using :meth:`QuantumCircuit.assign_parame
667
668
 
668
669
  You may want to use many parameters that are related to each other. To make this easier (and to
669
670
  avoid you needing to come up with many names), you can use the convenience constructor
670
- :class:`ParameterVector`. The elements of the vector are all valid :class:`Parameter` instances.
671
+ :class:`ParameterVector`. The elements of the vector are all valid :class:`Parameter` instances, of
672
+ a special subclass :class:`ParameterVectorElement`.
671
673
 
672
674
  .. autosummary::
673
675
  :toctree: ../stubs/
674
676
 
675
677
  ParameterVector
678
+ ParameterVectorElement
676
679
 
677
680
  .. _circuit-control-flow-repr:
678
681
 
@@ -1289,7 +1292,7 @@ from .measure import Measure
1289
1292
  from .reset import Reset
1290
1293
  from .store import Store
1291
1294
  from .parameter import Parameter
1292
- from .parametervector import ParameterVector
1295
+ from .parametervector import ParameterVector, ParameterVectorElement
1293
1296
  from .parameterexpression import ParameterExpression
1294
1297
  from .quantumcircuitdata import CircuitInstruction
1295
1298
  from .equivalence import EquivalenceLibrary
qiskit/circuit/delay.py CHANGED
@@ -81,6 +81,11 @@ class Delay(Instruction):
81
81
  """
82
82
  return self.__array__(dtype=complex)
83
83
 
84
+ def __eq__(self, other):
85
+ return (
86
+ isinstance(other, Delay) and self.unit == other.unit and self._compare_parameters(other)
87
+ )
88
+
84
89
  def __repr__(self):
85
90
  """Return the official string representing the delay."""
86
91
  return f"{self.__class__.__name__}(duration={self.params[0]}[unit={self.unit}])"
@@ -37,17 +37,17 @@ class RZGate(Gate):
37
37
  .. code-block:: text
38
38
 
39
39
  ┌───────┐
40
- q_0: ┤ Rz(λ) ├
40
+ q_0: ┤ Rz(φ) ├
41
41
  └───────┘
42
42
 
43
43
  **Matrix Representation:**
44
44
 
45
45
  .. math::
46
46
 
47
- RZ(\lambda) = \exp\left(-i\frac{\lambda}{2}Z\right) =
47
+ RZ(\phi) = \exp\left(-i\frac{\phi}{2}Z\right) =
48
48
  \begin{pmatrix}
49
- e^{-i\frac{\lambda}{2}} & 0 \\
50
- 0 & e^{i\frac{\lambda}{2}}
49
+ e^{-i\frac{\phi}{2}} & 0 \\
50
+ 0 & e^{i\frac{\phi}{2}}
51
51
  \end{pmatrix}
52
52
 
53
53
  .. seealso::
@@ -57,7 +57,7 @@ class RZGate(Gate):
57
57
 
58
58
  .. math::
59
59
 
60
- U1(\lambda) = e^{i{\lambda}/2}RZ(\lambda)
60
+ U1(\theta=\phi) = e^{i{\phi}/2}RZ(\phi)
61
61
 
62
62
  Reference for virtual Z gate implementation:
63
63
  `1612.00858 <https://arxiv.org/abs/1612.00858>`_
@@ -186,10 +186,10 @@ class CRZGate(ControlledGate):
186
186
  .. math::
187
187
 
188
188
  CRZ(\theta)\ q_0, q_1 =
189
- I \otimes |0\rangle\langle 0| + RZ(\theta) \otimes |1\rangle\langle 1| =
189
+ I \otimes |0\rangle\langle 0| + RZ(\phi=\theta) \otimes |1\rangle\langle 1| =
190
190
  \begin{pmatrix}
191
191
  1 & 0 & 0 & 0 \\
192
- 0 & e^{-i\frac{\lambda}{2}} & 0 & 0 \\
192
+ 0 & e^{-i\frac{\theta}{2}} & 0 & 0 \\
193
193
  0 & 0 & 1 & 0 \\
194
194
  0 & 0 & 0 & e^{i\frac{\theta}{2}}
195
195
  \end{pmatrix}
@@ -63,36 +63,6 @@ class XXMinusYYGate(Gate):
63
63
  0 & 0 & 1 & 0 \\
64
64
  -i\sin\left(\rotationangle\right)e^{i\beta} & 0 & 0 & \cos\left(\rotationangle\right)
65
65
  \end{pmatrix}
66
-
67
- .. note::
68
-
69
- In Qiskit's convention, higher qubit indices are more significant
70
- (little endian convention). In the above example we apply the gate
71
- on (q_0, q_1) which results in adding the (optional) phase defined
72
- by :math:`\beta` on q_1. Instead, if we apply it on (q_1, q_0), the
73
- phase is added on q_0. If :math:`\beta` is set to its default value
74
- of :math:`0`, the gate is equivalent in big and little endian.
75
-
76
- .. code-block:: text
77
-
78
- ┌───────────────┐
79
- q_0: ┤1 ├
80
- │ (XX-YY)(θ,β) │
81
- q_1: ┤0 ├
82
- └───────────────┘
83
-
84
- .. math::
85
-
86
- \newcommand{\rotationangle}{\frac{\theta}{2}}
87
-
88
- R_{XX-YY}(\theta, \beta) q_1, q_0 =
89
- RZ_0(\beta) \cdot \exp\left(-i \frac{\theta}{2} \frac{XX-YY}{2}\right) \cdot RZ_0(-\beta) =
90
- \begin{pmatrix}
91
- \cos\left(\rotationangle\right) & 0 & 0 & -i\sin\left(\rotationangle\right)e^{i\beta} \\
92
- 0 & 1 & 0 & 0 \\
93
- 0 & 0 & 1 & 0 \\
94
- -i\sin\left(\rotationangle\right)e^{-i\beta} & 0 & 0 & \cos\left(\rotationangle\right)
95
- \end{pmatrix}
96
66
  """
97
67
 
98
68
  _standard_gate = StandardGate.XXMinusYYGate
@@ -18,7 +18,12 @@ from .parameter import Parameter
18
18
 
19
19
 
20
20
  class ParameterVectorElement(Parameter):
21
- """An element of a ParameterVector."""
21
+ """An element of a :class:`ParameterVector`.
22
+
23
+ .. note::
24
+ There is very little reason to ever construct this class directly. Objects of this type are
25
+ automatically constructed efficiently as part of creating a :class:`ParameterVector`.
26
+ """
22
27
 
23
28
  ___slots__ = ("_vector", "_index")
24
29
 
@@ -48,7 +53,18 @@ class ParameterVectorElement(Parameter):
48
53
 
49
54
 
50
55
  class ParameterVector:
51
- """ParameterVector class to quickly generate lists of parameters."""
56
+ """A container of many related :class:`Parameter` objects.
57
+
58
+ This class is faster to construct than constructing many :class:`Parameter` objects
59
+ individually, and the individual names of the parameters will all share a common stem (the name
60
+ of the vector). For a vector called ``v`` with length 3, the individual elements will have
61
+ names ``v[0]``, ``v[1]`` and ``v[2]``.
62
+
63
+ The elements of a vector are sorted by the name of the vector, then the numeric value of their
64
+ index.
65
+
66
+ This class fulfill the :class:`collections.abc.Sequence` interface.
67
+ """
52
68
 
53
69
  __slots__ = ("_name", "_params", "_root_uuid")
54
70
 
@@ -62,16 +78,20 @@ class ParameterVector:
62
78
 
63
79
  @property
64
80
  def name(self):
65
- """Returns the name of the ParameterVector."""
81
+ """The name of the :class:`ParameterVector`."""
66
82
  return self._name
67
83
 
68
84
  @property
69
85
  def params(self):
70
- """Returns the list of parameters in the ParameterVector."""
86
+ """A list of the contained :class:`ParameterVectorElement` instances.
87
+
88
+ It is not safe to mutate this list."""
71
89
  return self._params
72
90
 
73
91
  def index(self, value):
74
- """Returns first index of value."""
92
+ """Find the index of a :class:`ParameterVectorElement` within the list.
93
+
94
+ It is typically much faster to use the :attr:`ParameterVectorElement.index` property."""
75
95
  return self._params.index(value)
76
96
 
77
97
  def __getitem__(self, key):
@@ -6646,7 +6646,10 @@ class QuantumCircuit:
6646
6646
  if len(qubits) == len([done for done in dones.values() if done]): # all done
6647
6647
  return max(stop for stop in stops.values())
6648
6648
 
6649
- return 0 # If there are no instructions over bits
6649
+ if len(stops) > 0: # not all but some qubits has instructions
6650
+ return max(stops.values())
6651
+ else:
6652
+ return 0 # If there are no instructions over bits
6650
6653
 
6651
6654
 
6652
6655
  class _OuterCircuitScopeInterface(CircuitScopeInterface):
@@ -191,7 +191,7 @@ def transpile( # pylint: disable=too-many-return-statements
191
191
  This can also be the external plugin name to use for the ``routing`` stage.
192
192
  You can see a list of installed plugins by using :func:`~.list_stage_plugins` with
193
193
  ``"routing"`` for the ``stage_name`` argument.
194
- translation_method: Name of translation pass ('unroller', 'translator', 'synthesis')
194
+ translation_method: Name of translation pass (``"translator"`` or ``"synthesis"``)
195
195
  This can also be the external plugin name to use for the ``translation`` stage.
196
196
  You can see a list of installed plugins by using :func:`~.list_stage_plugins` with
197
197
  ``"translation"`` for the ``stage_name`` argument.
@@ -234,8 +234,23 @@ def _choi_to_kraus(data, input_dim, output_dim, atol=ATOL_DEFAULT):
234
234
  #
235
235
  # So the eigenvalues are on the diagonal, therefore the basis-transformation matrix must be
236
236
  # a spanning set of the eigenspace.
237
+ #
238
+ # In addition, to prevent `numpy.linalg` errors when the matrix A is ill-conditioned,
239
+ # we apply a small perturbation, replacing A by A + eI. Since (A + eI)x = kx is
240
+ # equivalent to Ax = (k-e)x, it means that the eigenvectors of A + eI and A are the same,
241
+ # and we can perfectly recover the eigenvalues of A from the eigenvalues of A + eI by
242
+ # subtracting e.
243
+ apply_perturbation = np.linalg.cond(data) >= 1e10
244
+
245
+ if apply_perturbation:
246
+ data += 1e-10 * np.eye(data.shape[0])
247
+
237
248
  triangular, vecs = scipy.linalg.schur(data)
238
249
  values = triangular.diagonal().real
250
+
251
+ if apply_perturbation:
252
+ values = values - 1e-10
253
+
239
254
  # If we're not a CP map, fall-through back to the generalization handling. Since we needed
240
255
  # to get the eigenvalues anyway, we can do the CP check manually rather than deferring to a
241
256
  # separate re-calculation.