qiskit 1.3.0rc2__cp39-abi3-win32.whl → 1.3.2__cp39-abi3-win32.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. qiskit/VERSION.txt +1 -1
  2. qiskit/_accelerate.pyd +0 -0
  3. qiskit/circuit/__init__.py +2 -0
  4. qiskit/circuit/add_control.py +110 -92
  5. qiskit/circuit/controlledgate.py +2 -0
  6. qiskit/circuit/library/__init__.py +1 -0
  7. qiskit/circuit/library/arithmetic/adders/adder.py +25 -0
  8. qiskit/circuit/library/arithmetic/adders/cdkm_ripple_carry_adder.py +1 -1
  9. qiskit/circuit/library/arithmetic/adders/draper_qft_adder.py +1 -1
  10. qiskit/circuit/library/arithmetic/adders/vbe_ripple_carry_adder.py +1 -1
  11. qiskit/circuit/library/arithmetic/multipliers/multiplier.py +9 -0
  12. qiskit/circuit/library/arithmetic/piecewise_chebyshev.py +1 -0
  13. qiskit/circuit/library/basis_change/qft.py +3 -0
  14. qiskit/circuit/library/boolean_logic/inner_product.py +2 -0
  15. qiskit/circuit/library/boolean_logic/quantum_and.py +4 -0
  16. qiskit/circuit/library/boolean_logic/quantum_or.py +4 -0
  17. qiskit/circuit/library/boolean_logic/quantum_xor.py +2 -0
  18. qiskit/circuit/library/fourier_checking.py +2 -0
  19. qiskit/circuit/library/generalized_gates/gms.py +1 -0
  20. qiskit/circuit/library/generalized_gates/gr.py +4 -0
  21. qiskit/circuit/library/generalized_gates/mcmt.py +1 -0
  22. qiskit/circuit/library/generalized_gates/permutation.py +5 -1
  23. qiskit/circuit/library/generalized_gates/unitary.py +1 -1
  24. qiskit/circuit/library/graph_state.py +2 -0
  25. qiskit/circuit/library/grover_operator.py +7 -3
  26. qiskit/circuit/library/hidden_linear_function.py +2 -0
  27. qiskit/circuit/library/iqp.py +5 -0
  28. qiskit/circuit/library/n_local/efficient_su2.py +7 -2
  29. qiskit/circuit/library/n_local/evolved_operator_ansatz.py +3 -0
  30. qiskit/circuit/library/n_local/excitation_preserving.py +14 -8
  31. qiskit/circuit/library/n_local/n_local.py +10 -5
  32. qiskit/circuit/library/n_local/pauli_two_design.py +5 -2
  33. qiskit/circuit/library/n_local/qaoa_ansatz.py +1 -0
  34. qiskit/circuit/library/n_local/real_amplitudes.py +10 -4
  35. qiskit/circuit/library/overlap.py +1 -0
  36. qiskit/circuit/library/phase_estimation.py +2 -0
  37. qiskit/circuit/library/quantum_volume.py +3 -0
  38. qiskit/circuit/operation.py +1 -0
  39. qiskit/circuit/parameter.py +1 -0
  40. qiskit/circuit/parameterexpression.py +1 -1
  41. qiskit/circuit/quantumcircuit.py +13 -19
  42. qiskit/circuit/random/utils.py +2 -0
  43. qiskit/converters/dag_to_circuit.py +1 -0
  44. qiskit/primitives/statevector_estimator.py +1 -0
  45. qiskit/providers/fake_provider/__init__.py +1 -0
  46. qiskit/pulse/builder.py +8 -0
  47. qiskit/pulse/library/symbolic_pulses.py +1 -0
  48. qiskit/qasm2/export.py +2 -2
  49. qiskit/qasm3/__init__.py +1 -0
  50. qiskit/qasm3/exporter.py +6 -3
  51. qiskit/qpy/__init__.py +5 -5
  52. qiskit/quantum_info/operators/channel/chi.py +9 -9
  53. qiskit/quantum_info/operators/channel/choi.py +9 -9
  54. qiskit/quantum_info/operators/channel/ptm.py +9 -9
  55. qiskit/quantum_info/operators/channel/quantum_channel.py +3 -3
  56. qiskit/quantum_info/operators/channel/stinespring.py +9 -9
  57. qiskit/quantum_info/operators/channel/superop.py +5 -9
  58. qiskit/quantum_info/operators/symplectic/pauli_list.py +8 -8
  59. qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +10 -1
  60. qiskit/quantum_info/states/densitymatrix.py +17 -15
  61. qiskit/quantum_info/states/stabilizerstate.py +7 -6
  62. qiskit/quantum_info/states/statevector.py +15 -6
  63. qiskit/synthesis/arithmetic/multipliers/hrs_cumulative_multiplier.py +1 -0
  64. qiskit/synthesis/arithmetic/multipliers/rg_qft_multiplier.py +1 -0
  65. qiskit/synthesis/evolution/product_formula.py +0 -6
  66. qiskit/synthesis/evolution/suzuki_trotter.py +22 -5
  67. qiskit/transpiler/__init__.py +22 -1
  68. qiskit/transpiler/layout.py +3 -0
  69. qiskit/transpiler/passes/basis/decompose.py +24 -4
  70. qiskit/transpiler/passes/optimization/inverse_cancellation.py +2 -0
  71. qiskit/transpiler/passes/routing/star_prerouting.py +1 -0
  72. qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +1 -0
  73. qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +1 -0
  74. qiskit/transpiler/passes/synthesis/hls_plugins.py +137 -30
  75. qiskit/transpiler/passes/utils/filter_op_nodes.py +2 -1
  76. qiskit/transpiler/passes/utils/remove_barriers.py +1 -0
  77. qiskit/transpiler/preset_passmanagers/__init__.py +5 -5
  78. qiskit/transpiler/preset_passmanagers/builtin_plugins.py +19 -22
  79. qiskit/transpiler/target.py +1 -1
  80. qiskit/visualization/__init__.py +6 -0
  81. qiskit/visualization/circuit/circuit_visualization.py +1 -0
  82. qiskit/visualization/counts_visualization.py +2 -0
  83. qiskit/visualization/dag_visualization.py +1 -0
  84. qiskit/visualization/gate_map.py +7 -3
  85. qiskit/visualization/pulse_v2/interface.py +4 -1
  86. qiskit/visualization/state_visualization.py +13 -2
  87. qiskit/visualization/timeline/interface.py +6 -3
  88. {qiskit-1.3.0rc2.dist-info → qiskit-1.3.2.dist-info}/METADATA +26 -26
  89. {qiskit-1.3.0rc2.dist-info → qiskit-1.3.2.dist-info}/RECORD +93 -93
  90. {qiskit-1.3.0rc2.dist-info → qiskit-1.3.2.dist-info}/WHEEL +1 -1
  91. {qiskit-1.3.0rc2.dist-info → qiskit-1.3.2.dist-info}/entry_points.txt +1 -1
  92. {qiskit-1.3.0rc2.dist-info → qiskit-1.3.2.dist-info}/LICENSE.txt +0 -0
  93. {qiskit-1.3.0rc2.dist-info → qiskit-1.3.2.dist-info}/top_level.txt +0 -0
@@ -103,6 +103,7 @@ def grover_operator(
103
103
  We can construct a Grover operator just from the phase oracle:
104
104
 
105
105
  .. plot::
106
+ :alt: Circuit diagram output by the previous code.
106
107
  :include-source:
107
108
  :context:
108
109
 
@@ -117,8 +118,9 @@ def grover_operator(
117
118
  We can also modify the state preparation:
118
119
 
119
120
  .. plot::
121
+ :alt: Circuit diagram output by the previous code.
120
122
  :include-source:
121
- :context:
123
+ :context: close-figs
122
124
 
123
125
  oracle = QuantumCircuit(1)
124
126
  oracle.z(0) # the qubit state |1> is the good state
@@ -132,8 +134,9 @@ def grover_operator(
132
134
  the oracle:
133
135
 
134
136
  .. plot::
137
+ :alt: Circuit diagram output by the previous code.
135
138
  :include-source:
136
- :context:
139
+ :context: close-figs
137
140
 
138
141
  oracle = QuantumCircuit(4)
139
142
  oracle.z(3)
@@ -149,8 +152,9 @@ def grover_operator(
149
152
  objects:
150
153
 
151
154
  .. plot::
155
+ :alt: Circuit diagram output by the previous code.
152
156
  :include-source:
153
- :context:
157
+ :context: close-figs
154
158
 
155
159
  from qiskit.quantum_info import Statevector, DensityMatrix, Operator
156
160
 
@@ -55,6 +55,7 @@ class HiddenLinearFunction(QuantumCircuit):
55
55
  **Reference Circuit:**
56
56
 
57
57
  .. plot::
58
+ :alt: Diagram illustrating the previously described circuit.
58
59
 
59
60
  from qiskit.circuit.library import HiddenLinearFunction
60
61
  from qiskit.visualization.library import _generate_circuit_library_visualization
@@ -123,6 +124,7 @@ def hidden_linear_function(adjacency_matrix: list | np.ndarray) -> QuantumCircui
123
124
  **Reference Circuit:**
124
125
 
125
126
  .. plot::
127
+ :alt: Circuit diagram output by the previous code.
126
128
  :include-source:
127
129
 
128
130
  from qiskit.circuit.library import hidden_linear_function
@@ -38,6 +38,7 @@ class IQP(QuantumCircuit):
38
38
  **Reference Circuit:**
39
39
 
40
40
  .. plot::
41
+ :alt: Diagram illustrating the previously described circuit.
41
42
 
42
43
  from qiskit.circuit.library import IQP
43
44
  A = [[6, 5, 3], [5, 4, 5], [3, 5, 1]]
@@ -47,6 +48,7 @@ class IQP(QuantumCircuit):
47
48
  **Expanded Circuit:**
48
49
 
49
50
  .. plot::
51
+ :alt: Diagram illustrating the previously described circuit.
50
52
 
51
53
  from qiskit.circuit.library import IQP
52
54
  from qiskit.visualization.library import _generate_circuit_library_visualization
@@ -97,6 +99,7 @@ def iqp(
97
99
  **Reference Circuit:**
98
100
 
99
101
  .. plot::
102
+ :alt: Diagram illustrating the previously described circuit.
100
103
 
101
104
  from qiskit.circuit.library import iqp
102
105
  A = [[6, 5, 3], [5, 4, 5], [3, 5, 1]]
@@ -106,6 +109,7 @@ def iqp(
106
109
  **Expanded Circuit:**
107
110
 
108
111
  .. plot::
112
+ :alt: Diagram illustrating the previously described circuit.
109
113
 
110
114
  from qiskit.circuit.library import iqp
111
115
  from qiskit.visualization.library import _generate_circuit_library_visualization
@@ -154,6 +158,7 @@ def random_iqp(
154
158
  Example:
155
159
 
156
160
  .. plot::
161
+ :alt: Circuit diagram output by the previous code.
157
162
  :include-source:
158
163
 
159
164
  from qiskit.circuit.library import random_iqp
@@ -71,6 +71,7 @@ def efficient_su2(
71
71
  CX gates, is equivalent to an all-to-all entanglement:
72
72
 
73
73
  .. plot::
74
+ :alt: Circuit diagram output by the previous code.
74
75
  :include-source:
75
76
  :context:
76
77
 
@@ -84,8 +85,9 @@ def efficient_su2(
84
85
  For example:
85
86
 
86
87
  .. plot::
88
+ :alt: Circuit diagram output by the previous code.
87
89
  :include-source:
88
- :context:
90
+ :context: close-figs
89
91
 
90
92
  circuit = efficient_su2(4, su2_gates=["rx", "y"], entanglement="circular", reps=1)
91
93
  circuit.draw("mpl")
@@ -114,10 +116,13 @@ def efficient_su2(
114
116
  if su2_gates is None:
115
117
  su2_gates = ["ry", "rz"]
116
118
 
119
+ # Set entanglement_blocks to None when num_qubits == 1
120
+ entanglement_blocks = ["cx"] if num_qubits > 1 else []
121
+
117
122
  return n_local(
118
123
  num_qubits,
119
124
  su2_gates,
120
- ["cx"],
125
+ entanglement_blocks,
121
126
  entanglement,
122
127
  reps,
123
128
  insert_barriers,
@@ -61,6 +61,7 @@ def evolved_operator_ansatz(
61
61
  Examples:
62
62
 
63
63
  .. plot::
64
+ :alt: Circuit diagram output by the previous code.
64
65
  :include-source:
65
66
 
66
67
  from qiskit.circuit.library import evolved_operator_ansatz
@@ -213,6 +214,7 @@ def hamiltonian_variational_ansatz(
213
214
  A single operator will be split into commuting terms automatically:
214
215
 
215
216
  .. plot::
217
+ :alt: Circuit diagram output by the previous code.
216
218
  :include-source:
217
219
 
218
220
  from qiskit.quantum_info import SparsePauliOp
@@ -226,6 +228,7 @@ def hamiltonian_variational_ansatz(
226
228
  Alternatively, we can directly provide the terms:
227
229
 
228
230
  .. plot::
231
+ :alt: Circuit diagram output by the previous code.
229
232
  :include-source:
230
233
 
231
234
  from qiskit.quantum_info import SparsePauliOp
@@ -70,8 +70,9 @@ def excitation_preserving(
70
70
  With linear entanglement, this circuit is given by:
71
71
 
72
72
  .. plot::
73
+ :alt: Circuit diagram output by the previous code.
73
74
  :include-source:
74
- :context:
75
+ :context: close-figs
75
76
 
76
77
  from qiskit.circuit.library import excitation_preserving
77
78
 
@@ -83,6 +84,7 @@ def excitation_preserving(
83
84
  in each block:
84
85
 
85
86
  .. plot::
87
+ :alt: Circuit diagram output by the previous code.
86
88
  :include-source:
87
89
  :context:
88
90
 
@@ -112,17 +114,21 @@ def excitation_preserving(
112
114
  raise ValueError(f"Unsupported mode {mode}, choose one of {supported_modes}")
113
115
 
114
116
  theta = Parameter("θ")
115
- swap = QuantumCircuit(2, name="Interaction")
116
- swap.rxx(theta, 0, 1)
117
- swap.ryy(theta, 0, 1)
118
- if mode == "fsim":
119
- phi = Parameter("φ")
120
- swap.cp(phi, 0, 1)
117
+ if num_qubits > 1:
118
+ swap = QuantumCircuit(2, name="Interaction")
119
+ swap.rxx(theta, 0, 1)
120
+ swap.ryy(theta, 0, 1)
121
+ if mode == "fsim":
122
+ phi = Parameter("φ")
123
+ swap.cp(phi, 0, 1)
124
+ entanglement_blocks = [swap.to_gate()]
125
+ else:
126
+ entanglement_blocks = []
121
127
 
122
128
  return n_local(
123
129
  num_qubits,
124
130
  ["rz"],
125
- [swap.to_gate()],
131
+ entanglement_blocks,
126
132
  entanglement,
127
133
  reps,
128
134
  insert_barriers,
@@ -148,6 +148,7 @@ def n_local(
148
148
  are made up of a single block per layer:
149
149
 
150
150
  .. plot::
151
+ :alt: Circuit diagram output by the previous code.
151
152
  :include-source:
152
153
  :context:
153
154
 
@@ -160,8 +161,9 @@ def n_local(
160
161
  Pauli-Y and Pauli-Z rotations in the rotation layer:
161
162
 
162
163
  .. plot::
164
+ :alt: Circuit diagram output by the previous code.
163
165
  :include-source:
164
- :context:
166
+ :context: close-figs
165
167
 
166
168
  circuit = n_local(3, ["ry", "rz"], "cz", "full", reps=1, insert_barriers=True)
167
169
  circuit.draw("mpl")
@@ -169,8 +171,9 @@ def n_local(
169
171
  To omit rotation or entanglement layers, the block can be set to an empty list:
170
172
 
171
173
  .. plot::
174
+ :alt: Circuit diagram output by the previous code.
172
175
  :include-source:
173
- :context:
176
+ :context: close-figs
174
177
 
175
178
  circuit = n_local(4, [], "cry", reps=2)
176
179
  circuit.draw("mpl")
@@ -178,8 +181,9 @@ def n_local(
178
181
  The entanglement can be set explicitly via the ``entanglement`` argument:
179
182
 
180
183
  .. plot::
184
+ :alt: Circuit diagram output by the previous code.
181
185
  :include-source:
182
- :context:
186
+ :context: close-figs
183
187
 
184
188
  entangler_map = [[0, 1], [2, 0]]
185
189
  circuit = n_local(3, "x", "crx", entangler_map, reps=2)
@@ -189,9 +193,10 @@ def n_local(
189
193
  as input the current layer index, and returns the entanglement structure. For example,
190
194
  the following uses different entanglements for odd and even layers:
191
195
 
192
- .. plot:
196
+ .. plot::
197
+ :alt: Circuit diagram output by the previous code.
193
198
  :include-source:
194
- :context:
199
+ :context: close-figs
195
200
 
196
201
  def entanglement(layer_index):
197
202
  if layer_index % 2 == 0:
@@ -59,6 +59,7 @@ def pauli_two_design(
59
59
  Examples:
60
60
 
61
61
  .. plot::
62
+ :alt: Circuit diagram output by the previous code.
62
63
  :include-source:
63
64
 
64
65
  from qiskit.circuit.library import pauli_two_design
@@ -88,19 +89,20 @@ def pauli_two_design(
88
89
  """
89
90
  rng = np.random.default_rng(seed)
90
91
  random_block = Block.from_callable(1, 1, lambda params: _random_pauli_builder(params, rng))
91
- cz_block = Block.from_standard_gate(CZGate._standard_gate)
92
+ entanglement_block = [Block.from_standard_gate(CZGate._standard_gate)] if num_qubits > 1 else []
92
93
 
93
94
  data = py_n_local(
94
95
  num_qubits=num_qubits,
95
96
  reps=reps,
96
97
  rotation_blocks=[random_block],
97
- entanglement_blocks=[cz_block],
98
+ entanglement_blocks=entanglement_block,
98
99
  entanglement=["pairwise"],
99
100
  insert_barriers=insert_barriers,
100
101
  skip_final_rotation_layer=False,
101
102
  skip_unentangled_qubits=False,
102
103
  parameter_prefix=parameter_prefix,
103
104
  )
105
+
104
106
  two_design = QuantumCircuit._from_circuit_data(data)
105
107
 
106
108
  circuit = QuantumCircuit(num_qubits, name=name)
@@ -147,6 +149,7 @@ class PauliTwoDesign(TwoLocal):
147
149
  Examples:
148
150
 
149
151
  .. plot::
152
+ :alt: Circuit diagram output by the previous code.
150
153
  :include-source:
151
154
 
152
155
  from qiskit.circuit.library import PauliTwoDesign
@@ -47,6 +47,7 @@ def qaoa_ansatz(
47
47
  optimization problem:
48
48
 
49
49
  .. plot::
50
+ :alt: Circuit diagram output by the previous code.
50
51
  :include-source:
51
52
 
52
53
  from qiskit.quantum_info import SparsePauliOp
@@ -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
- ["cx"],
127
+ entanglement_blocks,
122
128
  entanglement,
123
129
  reps,
124
130
  insert_barriers,
@@ -128,6 +128,7 @@ def unitary_overlap(
128
128
  **Reference Circuit:**
129
129
 
130
130
  .. plot::
131
+ :alt: Circuit diagram output by the previous code.
131
132
  :include-source:
132
133
 
133
134
  import numpy as np
@@ -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)
@@ -34,6 +34,7 @@ class Operation(ABC):
34
34
  Add a Clifford and a Toffoli gate to a :class:`QuantumCircuit`.
35
35
 
36
36
  .. plot::
37
+ :alt: Circuit diagram output by the previous code.
37
38
  :include-source:
38
39
 
39
40
  from qiskit import QuantumCircuit
@@ -41,6 +41,7 @@ class Parameter(ParameterExpression):
41
41
  Construct a variable-rotation X gate using circuit parameters.
42
42
 
43
43
  .. plot::
44
+ :alt: Circuit diagram output by the previous code.
44
45
  :include-source:
45
46
 
46
47
  from qiskit.circuit import QuantumCircuit, Parameter
@@ -340,7 +340,7 @@ class ParameterExpression:
340
340
  either a constant or a second ParameterExpression.
341
341
 
342
342
  Args:
343
- operation: One of operator.{add,sub,mul,truediv}.
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".
@@ -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
@@ -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
@@ -34,6 +34,7 @@ def dag_to_circuit(dag, copy_operations=True):
34
34
 
35
35
  Example:
36
36
  .. plot::
37
+ :alt: Circuit diagram output by the previous code.
37
38
  :include-source:
38
39
 
39
40
  from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
@@ -49,6 +49,7 @@ class StatevectorEstimator(BaseEstimatorV2):
49
49
  ``StatevectorEstimator(seed=123)``.
50
50
 
51
51
  .. plot::
52
+ :alt: Output from the previous code.
52
53
  :include-source:
53
54
 
54
55
  from qiskit.circuit import Parameter, QuantumCircuit
@@ -29,6 +29,7 @@ Example Usage
29
29
  Here is an example of using a simulated backend for transpilation and running.
30
30
 
31
31
  .. plot::
32
+ :alt: Output from the previous code.
32
33
  :include-source:
33
34
 
34
35
  from qiskit import QuantumCircuit, transpile
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
@@ -330,6 +330,7 @@ class SymbolicPulse(Pulse):
330
330
  without knowing the envelope definition. Now you need to provide the envelope.
331
331
 
332
332
  .. plot::
333
+ :alt: Output from the previous code.
333
334
  :include-source:
334
335
 
335
336
  import sympy
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, "_qasm2_decomposition"):
318
- new_op = operation._qasm2_decomposition()
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
@@ -126,6 +126,7 @@ For example, we can define a quantum program using OpenQASM 3, and use :func:`lo
126
126
  convert it into a :class:`.QuantumCircuit`:
127
127
 
128
128
  .. plot::
129
+ :alt: Circuit diagram output by the previous code.
129
130
  :include-source:
130
131
 
131
132
  import qiskit.qasm3
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
- ident = self.symbols.get_gate(instruction.operation)
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(instruction.operation)
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 instruction.operation.params
1192
+ for param in operation.params
1190
1193
  ]
1191
1194
  if not self.disable_constants:
1192
1195
  for parameter in parameters: