qiskit 1.3.1__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 +1 -1
- qiskit/_accelerate.pyd +0 -0
- qiskit/circuit/__init__.py +7 -2
- qiskit/circuit/controlledgate.py +2 -0
- qiskit/circuit/delay.py +5 -0
- qiskit/circuit/library/__init__.py +1 -0
- qiskit/circuit/library/arithmetic/piecewise_chebyshev.py +1 -0
- qiskit/circuit/library/basis_change/qft.py +3 -0
- qiskit/circuit/library/boolean_logic/inner_product.py +2 -0
- qiskit/circuit/library/boolean_logic/quantum_and.py +4 -0
- qiskit/circuit/library/boolean_logic/quantum_or.py +4 -0
- qiskit/circuit/library/boolean_logic/quantum_xor.py +2 -0
- qiskit/circuit/library/fourier_checking.py +2 -0
- qiskit/circuit/library/generalized_gates/gms.py +1 -0
- qiskit/circuit/library/generalized_gates/gr.py +4 -0
- qiskit/circuit/library/generalized_gates/mcmt.py +1 -0
- qiskit/circuit/library/generalized_gates/permutation.py +5 -1
- qiskit/circuit/library/generalized_gates/unitary.py +1 -1
- qiskit/circuit/library/graph_state.py +2 -0
- qiskit/circuit/library/grover_operator.py +7 -3
- qiskit/circuit/library/hidden_linear_function.py +2 -0
- qiskit/circuit/library/iqp.py +5 -0
- qiskit/circuit/library/n_local/efficient_su2.py +7 -2
- qiskit/circuit/library/n_local/evolved_operator_ansatz.py +3 -0
- qiskit/circuit/library/n_local/excitation_preserving.py +14 -8
- qiskit/circuit/library/n_local/n_local.py +10 -5
- qiskit/circuit/library/n_local/pauli_two_design.py +5 -2
- qiskit/circuit/library/n_local/qaoa_ansatz.py +1 -0
- qiskit/circuit/library/n_local/real_amplitudes.py +10 -4
- qiskit/circuit/library/overlap.py +1 -0
- qiskit/circuit/library/phase_estimation.py +2 -0
- qiskit/circuit/library/quantum_volume.py +3 -0
- qiskit/circuit/library/standard_gates/rz.py +7 -7
- qiskit/circuit/library/standard_gates/xx_minus_yy.py +0 -30
- qiskit/circuit/operation.py +1 -0
- qiskit/circuit/parameter.py +1 -0
- qiskit/circuit/parameterexpression.py +1 -1
- qiskit/circuit/parametervector.py +25 -5
- qiskit/circuit/quantumcircuit.py +17 -20
- qiskit/circuit/random/utils.py +2 -0
- qiskit/compiler/transpiler.py +1 -1
- qiskit/converters/dag_to_circuit.py +1 -0
- qiskit/primitives/statevector_estimator.py +1 -0
- qiskit/providers/fake_provider/__init__.py +1 -0
- qiskit/pulse/builder.py +8 -0
- qiskit/pulse/library/symbolic_pulses.py +1 -0
- qiskit/qasm2/export.py +2 -2
- qiskit/qasm3/__init__.py +1 -0
- qiskit/qasm3/exporter.py +6 -3
- qiskit/quantum_info/operators/channel/transformations.py +15 -0
- qiskit/quantum_info/operators/symplectic/pauli_list.py +8 -8
- qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +10 -1
- qiskit/quantum_info/states/statevector.py +1 -0
- qiskit/synthesis/arithmetic/multipliers/hrs_cumulative_multiplier.py +1 -0
- qiskit/synthesis/arithmetic/multipliers/rg_qft_multiplier.py +1 -0
- qiskit/synthesis/evolution/product_formula.py +0 -6
- qiskit/synthesis/evolution/suzuki_trotter.py +22 -5
- qiskit/transpiler/__init__.py +780 -529
- qiskit/transpiler/layout.py +9 -6
- qiskit/transpiler/passes/layout/sabre_layout.py +13 -0
- qiskit/transpiler/passes/optimization/remove_identity_equiv.py +2 -3
- qiskit/transpiler/passes/routing/star_prerouting.py +1 -0
- qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +1 -0
- qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +1 -0
- qiskit/transpiler/passes/scheduling/scheduling/alap.py +1 -1
- qiskit/transpiler/passes/scheduling/scheduling/asap.py +1 -1
- qiskit/transpiler/passes/synthesis/hls_plugins.py +48 -9
- qiskit/transpiler/passes/utils/filter_op_nodes.py +2 -1
- qiskit/transpiler/passes/utils/remove_barriers.py +1 -0
- qiskit/transpiler/preset_passmanagers/__init__.py +31 -11
- qiskit/transpiler/preset_passmanagers/builtin_plugins.py +19 -22
- qiskit/transpiler/preset_passmanagers/plugin.py +33 -42
- qiskit/transpiler/target.py +1 -1
- qiskit/visualization/__init__.py +6 -0
- qiskit/visualization/circuit/circuit_visualization.py +1 -0
- qiskit/visualization/circuit/text.py +3 -2
- qiskit/visualization/counts_visualization.py +2 -0
- qiskit/visualization/dag_visualization.py +1 -0
- qiskit/visualization/gate_map.py +7 -3
- qiskit/visualization/pulse_v2/interface.py +4 -1
- qiskit/visualization/state_visualization.py +13 -2
- qiskit/visualization/timeline/interface.py +6 -3
- {qiskit-1.3.1.dist-info → qiskit-1.3.3.dist-info}/METADATA +20 -23
- {qiskit-1.3.1.dist-info → qiskit-1.3.3.dist-info}/RECORD +88 -88
- {qiskit-1.3.1.dist-info → qiskit-1.3.3.dist-info}/WHEEL +1 -1
- {qiskit-1.3.1.dist-info → qiskit-1.3.3.dist-info}/LICENSE.txt +0 -0
- {qiskit-1.3.1.dist-info → qiskit-1.3.3.dist-info}/entry_points.txt +0 -0
- {qiskit-1.3.1.dist-info → qiskit-1.3.3.dist-info}/top_level.txt +0 -0
@@ -68,6 +68,7 @@ def real_amplitudes(
|
|
68
68
|
Examples:
|
69
69
|
|
70
70
|
.. plot::
|
71
|
+
:alt: Circuit diagram output by the previous code.
|
71
72
|
:include-source:
|
72
73
|
:context:
|
73
74
|
|
@@ -77,22 +78,25 @@ def real_amplitudes(
|
|
77
78
|
ansatz.draw("mpl")
|
78
79
|
|
79
80
|
.. plot::
|
81
|
+
:alt: Circuit diagram output by the previous code.
|
80
82
|
:include-source:
|
81
|
-
:context:
|
83
|
+
:context: close-figs
|
82
84
|
|
83
85
|
ansatz = real_amplitudes(3, entanglement="full", reps=2) # it is the same unitary as above
|
84
86
|
ansatz.draw("mpl")
|
85
87
|
|
86
88
|
.. plot::
|
89
|
+
:alt: Circuit diagram output by the previous code.
|
87
90
|
:include-source:
|
88
|
-
:context:
|
91
|
+
:context: close-figs
|
89
92
|
|
90
93
|
ansatz = real_amplitudes(3, entanglement="linear", reps=2, insert_barriers=True)
|
91
94
|
ansatz.draw("mpl")
|
92
95
|
|
93
96
|
.. plot::
|
97
|
+
:alt: Circuit diagram output by the previous code.
|
94
98
|
:include-source:
|
95
|
-
:context:
|
99
|
+
:context: close-figs
|
96
100
|
|
97
101
|
ansatz = real_amplitudes(4, reps=2, entanglement=[[0,3], [0,2]], skip_unentangled_qubits=True)
|
98
102
|
ansatz.draw("mpl")
|
@@ -114,11 +118,13 @@ def real_amplitudes(
|
|
114
118
|
Returns:
|
115
119
|
A real-amplitudes circuit.
|
116
120
|
"""
|
121
|
+
# Set entanglement_blocks to None when num_qubits == 1
|
122
|
+
entanglement_blocks = ["cx"] if num_qubits > 1 else []
|
117
123
|
|
118
124
|
return n_local(
|
119
125
|
num_qubits,
|
120
126
|
["ry"],
|
121
|
-
|
127
|
+
entanglement_blocks,
|
122
128
|
entanglement,
|
123
129
|
reps,
|
124
130
|
insert_barriers,
|
@@ -76,6 +76,7 @@ class PhaseEstimation(QuantumCircuit):
|
|
76
76
|
|
77
77
|
Reference Circuit:
|
78
78
|
.. plot::
|
79
|
+
:alt: Diagram illustrating the previously described circuit.
|
79
80
|
|
80
81
|
from qiskit.circuit import QuantumCircuit
|
81
82
|
from qiskit.circuit.library import PhaseEstimation
|
@@ -131,6 +132,7 @@ def phase_estimation(
|
|
131
132
|
**Reference Circuit:**
|
132
133
|
|
133
134
|
.. plot::
|
135
|
+
:alt: Circuit diagram output by the previous code.
|
134
136
|
:include-source:
|
135
137
|
|
136
138
|
from qiskit.circuit import QuantumCircuit
|
@@ -35,6 +35,7 @@ class QuantumVolume(QuantumCircuit):
|
|
35
35
|
**Reference Circuit:**
|
36
36
|
|
37
37
|
.. plot::
|
38
|
+
:alt: Diagram illustrating the previously described circuit.
|
38
39
|
|
39
40
|
from qiskit.circuit.library import QuantumVolume
|
40
41
|
circuit = QuantumVolume(5, 6, seed=10)
|
@@ -43,6 +44,7 @@ class QuantumVolume(QuantumCircuit):
|
|
43
44
|
**Expanded Circuit:**
|
44
45
|
|
45
46
|
.. plot::
|
47
|
+
:alt: Diagram illustrating the previously described circuit.
|
46
48
|
|
47
49
|
from qiskit.circuit.library import QuantumVolume
|
48
50
|
from qiskit.visualization.library import _generate_circuit_library_visualization
|
@@ -150,6 +152,7 @@ def quantum_volume(
|
|
150
152
|
**Reference Circuit:**
|
151
153
|
|
152
154
|
.. plot::
|
155
|
+
:alt: Diagram illustrating the previously described circuit.
|
153
156
|
|
154
157
|
from qiskit.circuit.library import quantum_volume
|
155
158
|
circuit = quantum_volume(5, 6, seed=10)
|
@@ -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(\
|
47
|
+
RZ(\phi) = \exp\left(-i\frac{\phi}{2}Z\right) =
|
48
48
|
\begin{pmatrix}
|
49
|
-
e^{-i\frac{\
|
50
|
-
0 & e^{i\frac{\
|
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(\
|
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{\
|
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
|
qiskit/circuit/operation.py
CHANGED
qiskit/circuit/parameter.py
CHANGED
@@ -340,7 +340,7 @@ class ParameterExpression:
|
|
340
340
|
either a constant or a second ParameterExpression.
|
341
341
|
|
342
342
|
Args:
|
343
|
-
operation:
|
343
|
+
operation: An operator, such as add, sub, mul, and truediv.
|
344
344
|
other: The second argument to be used with self in operation.
|
345
345
|
reflected: Optional - The default ordering is "self operator other".
|
346
346
|
If reflected is True, this is switched to "other operator self".
|
@@ -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
|
-
"""
|
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
|
-
"""
|
81
|
+
"""The name of the :class:`ParameterVector`."""
|
66
82
|
return self._name
|
67
83
|
|
68
84
|
@property
|
69
85
|
def params(self):
|
70
|
-
"""
|
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
|
-
"""
|
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):
|
qiskit/circuit/quantumcircuit.py
CHANGED
@@ -835,6 +835,7 @@ class QuantumCircuit:
|
|
835
835
|
Consider the following circuit:
|
836
836
|
|
837
837
|
.. plot::
|
838
|
+
:alt: Circuit diagram output by the previous code.
|
838
839
|
:include-source:
|
839
840
|
|
840
841
|
from qiskit import QuantumCircuit
|
@@ -887,25 +888,6 @@ class QuantumCircuit:
|
|
887
888
|
|
888
889
|
assert qc.size() == 19
|
889
890
|
|
890
|
-
A particularly important circuit property is known as the circuit :meth:`depth`. The depth
|
891
|
-
of a quantum circuit is a measure of how many "layers" of quantum gates, executed in
|
892
|
-
parallel, it takes to complete the computation defined by the circuit. Because quantum
|
893
|
-
gates take time to implement, the depth of a circuit roughly corresponds to the amount of
|
894
|
-
time it takes the quantum computer to execute the circuit. Thus, the depth of a circuit
|
895
|
-
is one important quantity used to measure if a quantum circuit can be run on a device.
|
896
|
-
|
897
|
-
The depth of a quantum circuit has a mathematical definition as the longest path in a
|
898
|
-
directed acyclic graph (DAG). However, such a definition is a bit hard to grasp, even for
|
899
|
-
experts. Fortunately, the depth of a circuit can be easily understood by anyone familiar
|
900
|
-
with playing `Tetris <https://en.wikipedia.org/wiki/Tetris>`_. Lets see how to compute this
|
901
|
-
graphically:
|
902
|
-
|
903
|
-
.. image:: /source_images/depth.gif
|
904
|
-
|
905
|
-
We can verify our graphical result using :meth:`QuantumCircuit.depth`::
|
906
|
-
|
907
|
-
assert qc.depth() == 9
|
908
|
-
|
909
891
|
.. automethod:: count_ops
|
910
892
|
.. automethod:: depth
|
911
893
|
.. automethod:: get_instructions
|
@@ -2169,6 +2151,7 @@ class QuantumCircuit:
|
|
2169
2151
|
Examples:
|
2170
2152
|
|
2171
2153
|
.. plot::
|
2154
|
+
:alt: Circuit diagram output by the previous code.
|
2172
2155
|
:include-source:
|
2173
2156
|
|
2174
2157
|
from qiskit import QuantumCircuit
|
@@ -3425,6 +3408,7 @@ class QuantumCircuit:
|
|
3425
3408
|
|
3426
3409
|
Example:
|
3427
3410
|
.. plot::
|
3411
|
+
:alt: Circuit diagram output by the previous code.
|
3428
3412
|
:include-source:
|
3429
3413
|
|
3430
3414
|
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
|
@@ -3484,6 +3468,14 @@ class QuantumCircuit:
|
|
3484
3468
|
) -> int:
|
3485
3469
|
"""Return circuit depth (i.e., length of critical path).
|
3486
3470
|
|
3471
|
+
The depth of a quantum circuit is a measure of how many
|
3472
|
+
"layers" of quantum gates, executed in parallel, it takes to
|
3473
|
+
complete the computation defined by the circuit. Because
|
3474
|
+
quantum gates take time to implement, the depth of a circuit
|
3475
|
+
roughly corresponds to the amount of time it takes the quantum
|
3476
|
+
computer to execute the circuit.
|
3477
|
+
|
3478
|
+
|
3487
3479
|
.. warning::
|
3488
3480
|
This operation is not well defined if the circuit contains control-flow operations.
|
3489
3481
|
|
@@ -4306,6 +4298,7 @@ class QuantumCircuit:
|
|
4306
4298
|
Create a parameterized circuit and assign the parameters in-place.
|
4307
4299
|
|
4308
4300
|
.. plot::
|
4301
|
+
:alt: Circuit diagram output by the previous code.
|
4309
4302
|
:include-source:
|
4310
4303
|
|
4311
4304
|
from qiskit.circuit import QuantumCircuit, Parameter
|
@@ -4321,6 +4314,7 @@ class QuantumCircuit:
|
|
4321
4314
|
Bind the values out-of-place by list and get a copy of the original circuit.
|
4322
4315
|
|
4323
4316
|
.. plot::
|
4317
|
+
:alt: Circuit diagram output by the previous code.
|
4324
4318
|
:include-source:
|
4325
4319
|
|
4326
4320
|
from qiskit.circuit import QuantumCircuit, ParameterVector
|
@@ -6652,7 +6646,10 @@ class QuantumCircuit:
|
|
6652
6646
|
if len(qubits) == len([done for done in dones.values() if done]): # all done
|
6653
6647
|
return max(stop for stop in stops.values())
|
6654
6648
|
|
6655
|
-
|
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
|
6656
6653
|
|
6657
6654
|
|
6658
6655
|
class _OuterCircuitScopeInterface(CircuitScopeInterface):
|
qiskit/circuit/random/utils.py
CHANGED
@@ -37,6 +37,7 @@ def random_circuit(
|
|
37
37
|
from the set of standard gates in :mod:`qiskit.circuit.library.standard_gates`. For example:
|
38
38
|
|
39
39
|
.. plot::
|
40
|
+
:alt: Circuit diagram output by the previous code.
|
40
41
|
:include-source:
|
41
42
|
|
42
43
|
from qiskit.circuit.random import random_circuit
|
@@ -295,6 +296,7 @@ def random_clifford_circuit(num_qubits, num_gates, gates="all", seed=None):
|
|
295
296
|
gates from the set of standard gates in :mod:`qiskit.circuit.library.standard_gates`. For example:
|
296
297
|
|
297
298
|
.. plot::
|
299
|
+
:alt: Circuit diagram output by the previous code.
|
298
300
|
:include-source:
|
299
301
|
|
300
302
|
from qiskit.circuit.random import random_clifford_circuit
|
qiskit/compiler/transpiler.py
CHANGED
@@ -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 (
|
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.
|
qiskit/pulse/builder.py
CHANGED
@@ -39,6 +39,7 @@ execution. For example, to play a series of pulses on channels is as simple as:
|
|
39
39
|
|
40
40
|
|
41
41
|
.. plot::
|
42
|
+
:alt: Output from the previous code.
|
42
43
|
:include-source:
|
43
44
|
|
44
45
|
from qiskit import pulse
|
@@ -61,6 +62,7 @@ statements. For example, below we write a simple program that :func:`play`\s
|
|
61
62
|
a pulse:
|
62
63
|
|
63
64
|
.. plot::
|
65
|
+
:alt: Output from the previous code.
|
64
66
|
:include-source:
|
65
67
|
|
66
68
|
from qiskit import pulse
|
@@ -90,6 +92,7 @@ state we prepared. This program which mixes circuits and pulses will be
|
|
90
92
|
automatically lowered to be run as a pulse program:
|
91
93
|
|
92
94
|
.. plot::
|
95
|
+
:alt: Output from the previous code.
|
93
96
|
:include-source:
|
94
97
|
|
95
98
|
from math import pi
|
@@ -273,6 +276,7 @@ Instructions
|
|
273
276
|
Pulse instructions are available within the builder interface. Here's an example:
|
274
277
|
|
275
278
|
.. plot::
|
279
|
+
:alt: Output from the previous code.
|
276
280
|
:include-source:
|
277
281
|
|
278
282
|
from qiskit import pulse
|
@@ -321,6 +325,7 @@ example an alignment context like :func:`align_right` may
|
|
321
325
|
be used to align all pulses as late as possible in a pulse program.
|
322
326
|
|
323
327
|
.. plot::
|
328
|
+
:alt: Output from the previous code.
|
324
329
|
:include-source:
|
325
330
|
|
326
331
|
from qiskit import pulse
|
@@ -1165,6 +1170,7 @@ def align_equispaced(duration: int | ParameterExpression) -> Generator[None, Non
|
|
1165
1170
|
Examples:
|
1166
1171
|
|
1167
1172
|
.. plot::
|
1173
|
+
:alt: Output from the previous code.
|
1168
1174
|
:include-source:
|
1169
1175
|
|
1170
1176
|
from qiskit import pulse
|
@@ -1219,6 +1225,7 @@ def align_func(
|
|
1219
1225
|
Examples:
|
1220
1226
|
|
1221
1227
|
.. plot::
|
1228
|
+
:alt: Output from the previous code.
|
1222
1229
|
:include-source:
|
1223
1230
|
|
1224
1231
|
import numpy as np
|
@@ -2043,6 +2050,7 @@ def macro(func: Callable):
|
|
2043
2050
|
Examples:
|
2044
2051
|
|
2045
2052
|
.. plot::
|
2053
|
+
:alt: Output from the previous code.
|
2046
2054
|
:include-source:
|
2047
2055
|
|
2048
2056
|
from qiskit import pulse
|
qiskit/qasm2/export.py
CHANGED
@@ -314,8 +314,8 @@ def _define_custom_operation(operation, gates_to_define):
|
|
314
314
|
# definition, but still continue to return the given object as the call-site object.
|
315
315
|
if operation.base_class in known_good_parameterized:
|
316
316
|
parameterized_operation = type(operation)(*_FIXED_PARAMETERS[: len(operation.params)])
|
317
|
-
elif hasattr(operation, "
|
318
|
-
new_op = operation.
|
317
|
+
elif hasattr(operation, "_qasm_decomposition"):
|
318
|
+
new_op = operation._qasm_decomposition()
|
319
319
|
parameterized_operation = operation = new_op.copy(name=_escape_name(new_op.name, "gate_"))
|
320
320
|
else:
|
321
321
|
parameterized_operation = operation
|
qiskit/qasm3/__init__.py
CHANGED
qiskit/qasm3/exporter.py
CHANGED
@@ -1180,13 +1180,16 @@ class QASM3Builder:
|
|
1180
1180
|
|
1181
1181
|
This will also push the gate into the symbol table (if required), including recursively
|
1182
1182
|
defining the gate blocks."""
|
1183
|
-
|
1183
|
+
operation = instruction.operation
|
1184
|
+
if hasattr(operation, "_qasm_decomposition"):
|
1185
|
+
operation = operation._qasm_decomposition()
|
1186
|
+
ident = self.symbols.get_gate(operation)
|
1184
1187
|
if ident is None:
|
1185
|
-
ident = self.define_gate(
|
1188
|
+
ident = self.define_gate(operation)
|
1186
1189
|
qubits = [self._lookup_bit(qubit) for qubit in instruction.qubits]
|
1187
1190
|
parameters = [
|
1188
1191
|
ast.StringifyAndPray(self._rebind_scoped_parameters(param))
|
1189
|
-
for param in
|
1192
|
+
for param in operation.params
|
1190
1193
|
]
|
1191
1194
|
if not self.disable_constants:
|
1192
1195
|
for parameter in parameters:
|
@@ -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.
|
@@ -445,16 +445,14 @@ class PauliList(BasePauli, LinearMixin, GroupMixin):
|
|
445
445
|
f"Index {ind} is greater than number of qubits"
|
446
446
|
f" in the PauliList ({self.num_qubits})"
|
447
447
|
)
|
448
|
-
if len(value) ==
|
449
|
-
# Pad blocks to correct size
|
450
|
-
value_x = np.vstack(size * [value.x])
|
451
|
-
value_z = np.vstack(size * [value.z])
|
452
|
-
value_phase = np.vstack(size * [value.phase])
|
453
|
-
elif len(value) == size:
|
448
|
+
if len(value) == size:
|
454
449
|
# Blocks are already correct size
|
455
450
|
value_x = value.x
|
456
451
|
value_z = value.z
|
457
|
-
|
452
|
+
elif len(value) == 1:
|
453
|
+
# Pad blocks to correct size
|
454
|
+
value_x = np.vstack(size * [value.x])
|
455
|
+
value_z = np.vstack(size * [value.z])
|
458
456
|
else:
|
459
457
|
# Blocks are incorrect size
|
460
458
|
raise QiskitError(
|
@@ -465,7 +463,7 @@ class PauliList(BasePauli, LinearMixin, GroupMixin):
|
|
465
463
|
# Build new array by blocks
|
466
464
|
z = np.hstack([self.z[:, :ind], value_z, self.z[:, ind:]])
|
467
465
|
x = np.hstack([self.x[:, :ind], value_x, self.x[:, ind:]])
|
468
|
-
phase = self.phase +
|
466
|
+
phase = self.phase + value.phase
|
469
467
|
|
470
468
|
return PauliList.from_symplectic(z, x, phase)
|
471
469
|
|
@@ -1121,6 +1119,8 @@ class PauliList(BasePauli, LinearMixin, GroupMixin):
|
|
1121
1119
|
Returns:
|
1122
1120
|
PauliList: the constructed PauliList.
|
1123
1121
|
"""
|
1122
|
+
if isinstance(phase, np.ndarray) and np.ndim(phase) > 1:
|
1123
|
+
raise ValueError(f"phase should be at most 1D but has {np.ndim(phase)} dimensions.")
|
1124
1124
|
base_z, base_x, base_phase = cls._from_array(z, x, phase)
|
1125
1125
|
return cls(BasePauli(base_z, base_x, base_phase))
|
1126
1126
|
|
@@ -165,7 +165,16 @@ class SparsePauliOp(LinearOp):
|
|
165
165
|
# move the phase of `pauli_list` to `self._coeffs`
|
166
166
|
phase = pauli_list._phase
|
167
167
|
count_y = pauli_list._count_y()
|
168
|
-
|
168
|
+
|
169
|
+
# Compute exponentiation via integer arithmetic and lookup table to avoid
|
170
|
+
# floating point errors
|
171
|
+
exponent = (phase - count_y) % 4
|
172
|
+
lookup = np.array([1 + 0j, -1j, -1 + 0j, 1j], dtype=coeffs.dtype)
|
173
|
+
|
174
|
+
vals = lookup[exponent]
|
175
|
+
self._coeffs = vals * coeffs
|
176
|
+
|
177
|
+
# Update pauli_list phase
|
169
178
|
pauli_list._phase = np.mod(count_y, 4)
|
170
179
|
self._pauli_list = pauli_list
|
171
180
|
|
@@ -27,6 +27,7 @@ def multiplier_cumulative_h18(
|
|
27
27
|
performs a non-modular multiplication on two 3-qubit sized registers is:
|
28
28
|
|
29
29
|
.. plot::
|
30
|
+
:alt: Circuit diagram output by the previous code.
|
30
31
|
:include-source:
|
31
32
|
|
32
33
|
from qiskit.synthesis.arithmetic import multiplier_cumulative_h18
|
@@ -191,12 +191,6 @@ class ProductFormula(EvolutionSynthesis):
|
|
191
191
|
"preserve_order": self.preserve_order,
|
192
192
|
}
|
193
193
|
|
194
|
-
def _normalize_coefficients(
|
195
|
-
self, paulis: list[str | list[int], float | complex | ParameterExpression]
|
196
|
-
) -> list[str | list[int] | ParameterValueType]:
|
197
|
-
"""Ensure the coefficients are real (or parameter expressions)."""
|
198
|
-
return [[(op, qubits, real_or_fail(coeff)) for op, qubits, coeff in ops] for ops in paulis]
|
199
|
-
|
200
194
|
def _custom_evolution(self, num_qubits, pauli_rotations):
|
201
195
|
"""Implement the evolution for the non-standard path.
|
202
196
|
|