qiskit 2.0.0rc1__cp39-abi3-win_amd64.whl → 2.0.1__cp39-abi3-win_amd64.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 (57) hide show
  1. qiskit/VERSION.txt +1 -1
  2. qiskit/__init__.py +1 -4
  3. qiskit/_accelerate.pyd +0 -0
  4. qiskit/circuit/__init__.py +11 -5
  5. qiskit/circuit/classical/expr/constructors.py +0 -12
  6. qiskit/circuit/library/__init__.py +449 -163
  7. qiskit/circuit/library/graph_state.py +1 -0
  8. qiskit/circuit/library/n_local/efficient_su2.py +1 -1
  9. qiskit/circuit/library/n_local/excitation_preserving.py +1 -1
  10. qiskit/circuit/library/quantum_volume.py +9 -0
  11. qiskit/circuit/library/standard_gates/r.py +5 -4
  12. qiskit/circuit/library/standard_gates/x.py +1 -2
  13. qiskit/circuit/parameterexpression.py +7 -0
  14. qiskit/circuit/quantumcircuit.py +405 -80
  15. qiskit/circuit/tools/pi_check.py +3 -0
  16. qiskit/converters/circuit_to_dag.py +2 -2
  17. qiskit/converters/dag_to_circuit.py +2 -3
  18. qiskit/dagcircuit/dagdependency_v2.py +3 -2
  19. qiskit/primitives/statevector_estimator.py +1 -1
  20. qiskit/qpy/__init__.py +21 -0
  21. qiskit/qpy/binary_io/circuits.py +5 -0
  22. qiskit/qpy/binary_io/parse_sympy_repr.py +121 -0
  23. qiskit/qpy/binary_io/value.py +5 -5
  24. qiskit/result/models.py +1 -2
  25. qiskit/result/result.py +10 -8
  26. qiskit/synthesis/discrete_basis/commutator_decompose.py +30 -6
  27. qiskit/synthesis/discrete_basis/gate_sequence.py +10 -4
  28. qiskit/synthesis/discrete_basis/generate_basis_approximations.py +1 -1
  29. qiskit/synthesis/discrete_basis/solovay_kitaev.py +36 -13
  30. qiskit/transpiler/passes/__init__.py +2 -0
  31. qiskit/transpiler/passes/basis/basis_translator.py +1 -1
  32. qiskit/transpiler/passes/layout/full_ancilla_allocation.py +2 -3
  33. qiskit/transpiler/passes/layout/sabre_layout.py +3 -1
  34. qiskit/transpiler/passes/layout/vf2_utils.py +2 -5
  35. qiskit/transpiler/passes/optimization/__init__.py +1 -0
  36. qiskit/transpiler/passes/optimization/template_matching/template_substitution.py +2 -2
  37. qiskit/transpiler/passes/scheduling/alignments/check_durations.py +1 -1
  38. qiskit/transpiler/passes/scheduling/padding/base_padding.py +2 -2
  39. qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +5 -5
  40. qiskit/transpiler/passes/scheduling/padding/pad_delay.py +1 -1
  41. qiskit/transpiler/passes/scheduling/time_unit_conversion.py +10 -6
  42. qiskit/transpiler/passes/synthesis/solovay_kitaev_synthesis.py +29 -19
  43. qiskit/transpiler/passes/synthesis/unitary_synthesis.py +2 -1
  44. qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py +13 -7
  45. qiskit/transpiler/target.py +11 -0
  46. qiskit/visualization/circuit/text.py +1 -1
  47. qiskit/visualization/counts_visualization.py +4 -0
  48. qiskit/visualization/library.py +4 -1
  49. qiskit/visualization/state_visualization.py +13 -2
  50. qiskit/visualization/timeline/core.py +1 -1
  51. qiskit/visualization/timeline/plotters/matplotlib.py +4 -1
  52. {qiskit-2.0.0rc1.dist-info → qiskit-2.0.1.dist-info}/METADATA +4 -3
  53. {qiskit-2.0.0rc1.dist-info → qiskit-2.0.1.dist-info}/RECORD +57 -56
  54. {qiskit-2.0.0rc1.dist-info → qiskit-2.0.1.dist-info}/WHEEL +1 -1
  55. {qiskit-2.0.0rc1.dist-info → qiskit-2.0.1.dist-info}/entry_points.txt +0 -0
  56. {qiskit-2.0.0rc1.dist-info → qiskit-2.0.1.dist-info/licenses}/LICENSE.txt +0 -0
  57. {qiskit-2.0.0rc1.dist-info → qiskit-2.0.1.dist-info}/top_level.txt +0 -0
@@ -10,38 +10,124 @@
10
10
  # copyright notice, and modified files need to carry a notice indicating
11
11
  # that they have been altered from the originals.
12
12
 
13
- """
13
+
14
+ r"""
14
15
  ===============================================
15
16
  Circuit Library (:mod:`qiskit.circuit.library`)
16
17
  ===============================================
17
18
 
18
19
  .. currentmodule:: qiskit.circuit.library
19
20
 
20
- The circuit library is a collection of well-studied and valuable circuits, directives, and gates.
21
- We call them valuable for different reasons, for instance they can serve as building blocks for
22
- algorithms or they are circuits that we think are hard to simulate classically.
21
+ The circuit library is a collection of valuable circuits and building blocks. We call these valuable
22
+ for different reasons. For instance, they can be used as building blocks for algorithms, serve as
23
+ benchmarks, or they are circuits conjectured to be difficult to simulate classically.
24
+
25
+ Elements in the circuit library are either :class:`.QuantumCircuit`\ s or
26
+ :class:`~.circuit.Instruction`\ s, allowing them to be easily investigated or plugged into other
27
+ circuits. This enables fast prototyping and circuit design at higher levels of abstraction.
23
28
 
24
- Each element can be plugged into a circuit using the :meth:`.QuantumCircuit.append`
25
- method and so the circuit library allows users to program at higher levels of abstraction.
26
- For example, to append a multi-controlled CNOT:
29
+ For example:
27
30
 
28
31
  .. plot::
29
- :alt: Circuit diagram output by the previous code.
32
+ :alt: A circuit implementing a Suzuki-Trotter expansion of a Hamiltonian evolution.
30
33
  :include-source:
31
34
 
32
- from qiskit.circuit.library import MCXGate
33
- gate = MCXGate(4)
35
+ from qiskit.circuit import QuantumCircuit
36
+ from qiskit.circuit.library import PauliEvolutionGate
37
+ from qiskit.quantum_info import SparsePauliOp
34
38
 
35
- from qiskit import QuantumCircuit
36
- circuit = QuantumCircuit(5)
37
- circuit.append(gate, [0, 1, 4, 2, 3])
38
- circuit.draw('mpl')
39
+ hamiltonian = SparsePauliOp(["ZZI", "IZZ", "IXI"], coeffs=[1, 1, -1])
40
+ gate = PauliEvolutionGate(hamiltonian)
39
41
 
40
- The library is organized in several sections. The function
41
- :func:`.get_standard_gate_name_mapping` allows you to see the available standard gates and operations.
42
+ circuit = QuantumCircuit(hamiltonian.num_qubits)
43
+ circuit.append(gate, circuit.qubits)
42
44
 
43
- .. autofunction:: get_standard_gate_name_mapping
45
+ circuit.draw("mpl")
46
+
47
+ This library is organized in different sections:
48
+
49
+ * :ref:`Standard gates <standard-gates>`
50
+ * :ref:`Standard directives <standard-directives>`
51
+ * :ref:`Standard operations <standard-operations>`
52
+ * :ref:`Generalized gates <generalized-gates>`
53
+ * :ref:`Arithmetic operations <arithmetic>`
54
+ * :ref:`Basis changes <basis-change>`
55
+ * :ref:`Boolean logic <boolean-logic>`
56
+ * :ref:`Data encoding <data-encoding>`
57
+ * :ref:`Data preparation <data-preparation>`
58
+ * :ref:`Particular operations <particular>`
59
+ * :ref:`N-local circuits <n-local>`
60
+ * :ref:`Oracles <oracles>`
61
+ * :ref:`Template circuits <template>`
62
+
63
+ We distinguish into different categories of operations:
64
+
65
+ Standard gates
66
+ These are fundamental quantum gates, a subset of which typically forms a basis gate
67
+ set on a quantum computer. These are unitary operations represented as :class:`.Gate`.
68
+ The library also provides standard compiler directives (a :class:`.Barrier`) and non-unitary
69
+ operations (like :class:`.Measure`).
70
+
71
+ Abstract operations
72
+ This category includes operations that are defined by a mathematical action, but can be implemented
73
+ with different decompositions. For example, a multi-controlled :class:`.XGate` flips the target
74
+ qubit if all control qubits are :math:`|1\rangle`, and there are a variety of concrete circuits
75
+ implementing this operation using lower-level gates. Such abstract operations are represented as
76
+ :class:`.Gate` or :class:`~.circuit.Instruction`. This allows building the circuit without choosing
77
+ a concrete implementation of each block and, finally, let the compiler (or you as user) choose the
78
+ optimal decomposition. For example:
79
+
80
+ .. plot::
81
+ :alt: A circuit with a multi-controlled X gate.
82
+ :include-source:
83
+
84
+ from qiskit.circuit.library import MCXGate
85
+ mcx = MCXGate(4)
86
+
87
+ from qiskit import QuantumCircuit
88
+ circuit = QuantumCircuit(5)
89
+ circuit.append(mcx, [0, 1, 4, 2, 3])
90
+ circuit.draw("mpl")
91
+
92
+ For circuits with abstract operations, the circuit context is taken into account during
93
+ transpilation. For example, if idle qubits are available, they can be used to obtain a shallower
94
+ circuit::
95
+
96
+ from qiskit import transpile
97
+
98
+ small_circuit = QuantumCircuit(5) # here we have no idle qubits
99
+ small_circuit.append(mcx, [0, 1, 4, 2, 3])
100
+ small_tqc = transpile(small_circuit, basis_gates=["u", "cx"])
101
+ print("No aux:", small_tqc.count_ops())
102
+
103
+ large_circuit = QuantumCircuit(10) # now we will have 5 idle qubits
104
+ large_circuit.append(mcx, [0, 1, 4, 2, 3])
105
+ large_tqc = transpile(large_circuit, basis_gates=["u", "cx"])
106
+ print("With aux:", large_tqc.count_ops())
107
+
108
+ Which prints:
109
+
110
+ .. parsed-literal::
111
+
112
+ No aux: OrderedDict([('u', 41), ('cx', 36)])
113
+ With aux: OrderedDict([('u', 24), ('cx', 18)])
114
+
115
+ Structural operations
116
+ These operations have a unique decomposition. As the compiler does not need to reason about
117
+ them on a higher level, they are implemented as functions that return a :class:`.QuantumCircuit`
118
+ object. For example:
119
+
120
+ .. plot::
121
+ :alt: The real amplitudes ansatz circuit.
122
+ :include-source:
44
123
 
124
+ from qiskit.circuit.library import real_amplitudes
125
+
126
+ ansatz = real_amplitudes(5, entanglement="pairwise")
127
+ ansatz.draw("mpl")
128
+
129
+
130
+ .. _standard-gates:
45
131
 
46
132
  Standard gates
47
133
  ==============
@@ -54,13 +140,14 @@ and :meth:`~qiskit.circuit.Gate.control`, which we can generally only apply to u
54
140
  For example:
55
141
 
56
142
  .. plot::
143
+ :alt: The X gate and the matrix, power, and control methods.
57
144
  :include-source:
58
145
  :nofigs:
59
146
 
60
147
  from qiskit.circuit.library import XGate
61
148
  gate = XGate()
62
149
  print(gate.to_matrix()) # X gate
63
- print(gate.power(1/2).to_matrix()) # √X gate
150
+ print(gate.power(1/2).to_matrix()) # √X gate -- see also the SXGate
64
151
  print(gate.control(1).to_matrix()) # CX (controlled X) gate
65
152
 
66
153
  .. code-block:: text
@@ -74,52 +161,27 @@ For example:
74
161
  [0.+0.j 0.+0.j 1.+0.j 0.+0.j]
75
162
  [0.+0.j 1.+0.j 0.+0.j 0.+0.j]]
76
163
 
164
+
165
+ The function :func:`.get_standard_gate_name_mapping` allows you to see the available standard gates
166
+ and operations.
167
+
168
+ .. autofunction:: get_standard_gate_name_mapping
169
+
170
+ 1-qubit standard gates
171
+ ----------------------
172
+
77
173
  .. autosummary::
78
174
  :toctree: ../stubs/
79
- :template: autosummary/class_no_inherited_members.rst
80
175
 
81
- C3XGate
82
- C3SXGate
83
- C4XGate
84
- CCXGate
85
- DCXGate
86
- CHGate
87
- CPhaseGate
88
- CRXGate
89
- CRYGate
90
- CRZGate
91
- CSGate
92
- CSdgGate
93
- CSwapGate
94
- CSXGate
95
- CUGate
96
- CU1Gate
97
- CU3Gate
98
- CXGate
99
- CYGate
100
- CZGate
101
- CCZGate
102
- ECRGate
103
176
  HGate
104
177
  IGate
105
- MSGate
106
178
  PhaseGate
107
- RCCXGate
108
- RC3XGate
109
179
  RGate
110
180
  RXGate
111
- RXXGate
112
181
  RYGate
113
- RYYGate
114
182
  RZGate
115
- RZZGate
116
- RZXGate
117
- XXMinusYYGate
118
- XXPlusYYGate
119
183
  SGate
120
184
  SdgGate
121
- SwapGate
122
- iSwapGate
123
185
  SXGate
124
186
  SXdgGate
125
187
  TGate
@@ -131,9 +193,66 @@ For example:
131
193
  XGate
132
194
  YGate
133
195
  ZGate
196
+
197
+ 2-qubit standard gates
198
+ ----------------------
199
+
200
+ .. autosummary::
201
+ :toctree: ../stubs/
202
+
203
+ CHGate
204
+ CPhaseGate
205
+ CRXGate
206
+ CRYGate
207
+ CRZGate
208
+ CSGate
209
+ CSdgGate
210
+ CSXGate
211
+ CUGate
212
+ CU1Gate
213
+ CU3Gate
214
+ CXGate
215
+ CYGate
216
+ CZGate
217
+ DCXGate
218
+ ECRGate
219
+ iSwapGate
220
+ RXXGate
221
+ RYYGate
222
+ RZXGate
223
+ RZZGate
224
+ SwapGate
225
+ XXMinusYYGate
226
+ XXPlusYYGate
227
+
228
+ 3+ qubit standard gates
229
+ -----------------------
230
+
231
+ .. autosummary::
232
+ :toctree: ../stubs/
233
+
234
+ C3SXGate
235
+ C3XGate
236
+ C4XGate
237
+ CCXGate
238
+ CCZGate
239
+ CSwapGate
240
+ RCCXGate
241
+ RC3XGate
242
+
243
+ Global standard gates
244
+ ---------------------
245
+
246
+ The following gate is global and does not take any qubit arguments.
247
+
248
+ .. autosummary::
249
+ :toctree: ../stubs/
250
+
134
251
  GlobalPhaseGate
135
252
 
136
253
 
254
+ .. _standard-directives:
255
+
137
256
  Standard Directives
138
257
  ===================
139
258
 
@@ -141,26 +260,28 @@ Directives are operations to the quantum stack that are meant to be interpreted
141
260
  the transpiler. In general, the transpiler or backend might optionally ignore them if there is no
142
261
  implementation for them.
143
262
 
144
- * :class:`qiskit.circuit.Barrier`
263
+ * :class:`~qiskit.circuit.Barrier`
264
+
265
+
266
+ .. _standard-operations:
145
267
 
146
268
  Standard Operations
147
269
  ===================
148
270
 
149
271
  Operations are non-reversible changes in the quantum state of the circuit.
150
272
 
151
- * :class:`qiskit.circuit.Measure`
152
- * :class:`qiskit.circuit.Reset`
273
+ * :class:`~qiskit.circuit.Measure`
274
+ * :class:`~qiskit.circuit.Reset`
275
+
276
+
277
+ .. _generalized-gates:
153
278
 
154
279
  Generalized Gates
155
280
  =================
156
281
 
157
- These "gates" (many are :class:`~qiskit.circuit.QuantumCircuit` subclasses) allow to
158
- set the amount of qubits involved at instantiation time.
159
-
160
-
161
- .. plot::
162
- :include-source:
163
- :nofigs:
282
+ This module extends the standard gates with a broader collection of basic gates. This includes
283
+ gates that are variadic, meaning that the number of qubits depends on the input.
284
+ For example::
164
285
 
165
286
  from qiskit.circuit.library import DiagonalGate
166
287
 
@@ -170,33 +291,22 @@ set the amount of qubits involved at instantiation time.
170
291
  diagonal = DiagonalGate([1, 1, 1, -1])
171
292
  print(diagonal.num_qubits)
172
293
 
294
+ which prints:
295
+
173
296
  .. code-block:: text
174
297
 
175
298
  1
176
299
  2
177
300
 
178
-
179
301
  .. autosummary::
180
302
  :toctree: ../stubs/
181
- :template: autosummary/class_no_inherited_members.rst
182
303
 
183
- Diagonal
184
304
  DiagonalGate
185
- MCMT
186
- MCMTVChain
187
- Permutation
188
305
  PermutationGate
189
- GMS
190
- GR
191
- GRX
192
- GRY
193
- GRZ
194
306
  MCMTGate
195
307
  MCPhaseGate
196
308
  MCXGate
197
- MCXGrayCode
198
- MCXRecursive
199
- MCXVChain
309
+ MSGate
200
310
  RVGate
201
311
  PauliGate
202
312
  LinearFunction
@@ -208,81 +318,117 @@ set the amount of qubits involved at instantiation time.
208
318
  UCRYGate
209
319
  UCRZGate
210
320
 
211
- Boolean Logic Circuits
212
- ======================
321
+ The above objects derive :class:`.Gate` or :class:`~.circuit.Instruction`, which allows the
322
+ compiler to reason about them on an abstract level. We therefore suggest using these instead
323
+ of the following, which derive :class:`.QuantumCircuit` and are eagerly constructed.
213
324
 
214
- These are :class:`~qiskit.circuit.QuantumCircuit` subclasses
215
- that implement boolean logic operations, such as the logical
216
- or of a set of qubit states.
325
+ .. autosummary::
326
+ :toctree: ../stubs/
327
+ :template: autosummary/class_no_inherited_members.rst
217
328
 
329
+ Diagonal
330
+ MCMT
331
+ MCMTVChain
332
+ MCXGrayCode
333
+ MCXRecursive
334
+ MCXVChain
335
+ Permutation
336
+ GMS
337
+ GR
338
+ GRX
339
+ GRY
340
+ GRZ
341
+
342
+ .. _boolean-logic:
343
+
344
+ Boolean Logic
345
+ =============
346
+
347
+ These :class:`.Gate`\ s implement boolean logic operations, such as the logical
348
+ ``or`` of a set of qubit states.
218
349
 
219
350
  .. autosummary::
220
351
  :toctree: ../stubs/
221
- :template: autosummary/class_no_inherited_members.rst
222
352
 
223
- AND
224
353
  AndGate
225
- OR
226
354
  OrGate
227
- XOR
228
355
  BitwiseXorGate
229
- random_bitwise_xor
230
- InnerProduct
231
356
  InnerProductGate
232
357
 
358
+ The above objects derive :class:`.Gate` (or return this type), which allows the
359
+ compiler to reason about them on an abstract level. We therefore suggest using these instead
360
+ of the following which derive :class:`.QuantumCircuit` and are eagerly constructed.
233
361
 
234
- Basis Change Circuits
235
- =====================
362
+ .. autosummary::
363
+ :toctree: ../stubs/
364
+ :template: autosummary/class_no_inherited_members.rst
236
365
 
237
- These circuits allow basis transformations of the qubit states. For example,
238
- in the case of the Quantum Fourier Transform (QFT), it transforms between
239
- the computational basis and the Fourier basis.
366
+ AND
367
+ OR
368
+ XOR
369
+ InnerProduct
370
+
371
+
372
+ A random bitwise ``xor`` circuit can be directly generated using:
240
373
 
241
374
  .. autosummary::
242
375
  :toctree: ../stubs/
243
- :template: autosummary/class_no_inherited_members.rst
244
376
 
245
- QFT
246
- QFTGate
377
+ random_bitwise_xor
247
378
 
248
- Arithmetic Circuits
249
- ===================
379
+ .. _basis-change:
250
380
 
251
- These :class:`~qiskit.circuit.QuantumCircuit`\\ s perform classical arithmetic,
252
- such as addition or multiplication.
381
+ Basis Change
382
+ ============
253
383
 
254
- Amplitude Functions
255
- -------------------
384
+ These gates perform basis transformations of the qubit states. For example,
385
+ in the case of the Quantum Fourier Transform (QFT), it transforms between
386
+ the computational basis and the Fourier basis.
256
387
 
257
388
  .. autosummary::
258
389
  :toctree: ../stubs/
259
- :template: autosummary/class_no_inherited_members.rst
260
390
 
261
- LinearAmplitudeFunction
262
- LinearAmplitudeFunctionGate
391
+ QFTGate
263
392
 
264
- Functional Pauli Rotations
265
- --------------------------
393
+ The above object derives :class:`.Gate`, which allows the
394
+ compiler to reason about it on an abstract level. We therefore suggest using this instead
395
+ of the following which derives :class:`.QuantumCircuit` and is eagerly constructed.
266
396
 
267
397
  .. autosummary::
268
398
  :toctree: ../stubs/
269
399
  :template: autosummary/class_no_inherited_members.rst
270
400
 
271
- FunctionalPauliRotations
272
- LinearPauliRotations
273
- LinearPauliRotationsGate
274
- PolynomialPauliRotations
275
- PolynomialPauliRotationsGate
276
- PiecewiseLinearPauliRotations
277
- PiecewiseLinearPauliRotationsGate
278
- PiecewisePolynomialPauliRotations
279
- PiecewisePolynomialPauliRotationsGate
280
- PiecewiseChebyshev
281
- PiecewiseChebyshevGate
401
+ QFT
402
+
403
+ .. _arithmetic:
404
+
405
+ Arithmetic
406
+ ==========
407
+
408
+ These gates and circuits perform classical arithmetic, such as addition or multiplication.
282
409
 
283
410
  Adders
284
411
  ------
285
412
 
413
+ Adders compute the sum of two :math:`n`-qubit registers, that is
414
+
415
+ .. math::
416
+
417
+ |a\rangle_n |b\rangle_n \mapsto |a\rangle_n |a + b\rangle_{t},
418
+
419
+ where the size :math:`t` of the output register depends on the type of adder used.
420
+
421
+ .. autosummary::
422
+ :toctree: ../stubs/
423
+
424
+ ModularAdderGate
425
+ HalfAdderGate
426
+ FullAdderGate
427
+
428
+ The above objects derive :class:`.Gate`, which allows the
429
+ compiler to reason about them on an abstract level. We therefore suggest using these instead
430
+ of the following which derive :class:`.QuantumCircuit` and are eagerly constructed.
431
+
286
432
  .. autosummary::
287
433
  :toctree: ../stubs/
288
434
  :template: autosummary/class_no_inherited_members.rst
@@ -290,84 +436,128 @@ Adders
290
436
  DraperQFTAdder
291
437
  CDKMRippleCarryAdder
292
438
  VBERippleCarryAdder
293
- ModularAdderGate
294
- HalfAdderGate
295
- FullAdderGate
296
439
 
297
440
  Multipliers
298
441
  -----------
299
442
 
443
+ Multipliers compute the product of two :math:`n`-qubit registers, that is
444
+
445
+ .. math::
446
+
447
+ |a\rangle_n |b\rangle_n |0\rangle_{t} \mapsto |a\rangle_n |b\rangle_n |a \cdot b\rangle_t,
448
+
449
+ where :math:`t` is the number of bits used to represent the result.
450
+
451
+ .. autosummary::
452
+ :toctree: ../stubs/
453
+
454
+ MultiplierGate
455
+
456
+ The above object derives :class:`.Gate`, which allows the
457
+ compiler to reason about it on an abstract level. We therefore suggest using this instead
458
+ of the following which derive :class:`.QuantumCircuit` and are eagerly constructed.
459
+
300
460
  .. autosummary::
301
461
  :toctree: ../stubs/
302
462
  :template: autosummary/class_no_inherited_members.rst
303
463
 
304
464
  HRSCumulativeMultiplier
305
465
  RGQFTMultiplier
306
- MultiplierGate
307
466
 
308
- Comparators
309
- -----------
467
+ Amplitude Functions
468
+ -------------------
469
+
470
+ An amplitude function approximates a function :math:`f: \{0, ..., 2^n - 1\} \rightarrow [0, 1]`
471
+ applied on the amplitudes of :math:`n` qubits. See the class docstring for more detailed information.
472
+
473
+ .. autosummary::
474
+ :toctree: ../stubs/
475
+
476
+ LinearAmplitudeFunctionGate
477
+
478
+ The above object derives :class:`.Gate`, which allows the
479
+ compiler to reason about it on an abstract level. We therefore suggest using this instead
480
+ of the following which derives :class:`.QuantumCircuit` and is eagerly constructed.
310
481
 
311
482
  .. autosummary::
312
483
  :toctree: ../stubs/
313
484
  :template: autosummary/class_no_inherited_members.rst
314
485
 
315
- IntegerComparator
316
- IntegerComparatorGate
486
+ LinearAmplitudeFunction
487
+
488
+ Functional Pauli Rotations
489
+ --------------------------
490
+
491
+ Functional Pauli rotations implement operations of the form
492
+
493
+ .. math::
494
+
495
+ |x\rangle |0\rangle \mapsto \cos(f(x))|x\rangle|0\rangle + \sin(f(x))|x\rangle|1\rangle
317
496
 
318
- Functions on binary variables
319
- -----------------------------
497
+ using Pauli-:math:`Y` rotations for different types of functions :math:`f`, such as linear,
498
+ polynomial, or a piecewise version of these. They are similar to the amplitude functions above, but
499
+ without pre- and post-processing for the domain and image of the target function.
500
+
501
+ .. autosummary::
502
+ :toctree: ../stubs/
503
+
504
+ LinearPauliRotationsGate
505
+ PolynomialPauliRotationsGate
506
+ PiecewiseLinearPauliRotationsGate
507
+ PiecewisePolynomialPauliRotationsGate
508
+ PiecewiseChebyshevGate
509
+
510
+ The above objects derive :class:`.Gate`, which allows the
511
+ compiler to reason about them on an abstract level. We therefore suggest using these instead
512
+ of the following which derive :class:`.QuantumCircuit` and are eagerly constructed.
320
513
 
321
514
  .. autosummary::
322
515
  :toctree: ../stubs/
323
516
  :template: autosummary/class_no_inherited_members.rst
324
517
 
325
- QuadraticForm
326
- QuadraticFormGate
518
+ FunctionalPauliRotations
519
+ LinearPauliRotations
520
+ PolynomialPauliRotations
521
+ PiecewiseLinearPauliRotations
522
+ PiecewisePolynomialPauliRotations
523
+ PiecewiseChebyshev
524
+
327
525
 
328
526
  Other arithmetic functions
329
527
  --------------------------
330
528
 
529
+ Here we list additional arithmetic circuits. See the individual class docstrings for more details.
530
+
331
531
  .. autosummary::
332
532
  :toctree: ../stubs/
333
- :template: autosummary/class_no_inherited_members.rst
334
533
 
335
- ExactReciprocal
336
534
  ExactReciprocalGate
337
- WeightedAdder
535
+ IntegerComparatorGate
536
+ QuadraticFormGate
338
537
  WeightedSumGate
339
538
 
340
- Particular Quantum Circuits
341
- ===========================
342
-
343
- The following gates and quantum circuits define specific
344
- quantum circuits of interest:
539
+ The above objects derive :class:`.Gate`, which allows the
540
+ compiler to reason about them on an abstract level. We therefore suggest using these instead
541
+ of the following which derive :class:`.QuantumCircuit` and are eagerly constructed.
345
542
 
346
543
  .. autosummary::
347
544
  :toctree: ../stubs/
348
545
  :template: autosummary/class_no_inherited_members.rst
349
546
 
350
- FourierChecking
351
- GraphState
352
- GraphStateGate
353
- HiddenLinearFunction
354
- IQP
355
- QuantumVolume
356
- PhaseEstimation
357
- GroverOperator
358
- BitFlipOracleGate
359
- PhaseOracleGate
360
- PhaseOracle
361
- PauliEvolutionGate
362
- HamiltonianGate
363
- UnitaryOverlap
547
+ ExactReciprocal
548
+ IntegerComparator
549
+ QuadraticForm
550
+ WeightedAdder
551
+
552
+ .. _particular:
553
+
554
+ Particular Quantum Circuits
555
+ ===========================
364
556
 
365
- For circuits that have a well-defined structure it is preferrable
366
- to use the following functions to construct them:
557
+ The following gates and quantum circuits define specific operations of interest:
367
558
 
368
559
  .. autosummary::
369
560
  :toctree: ../stubs/
370
- :template: autosummary/class_no_inherited_members.rst
371
561
 
372
562
  fourier_checking
373
563
  hidden_linear_function
@@ -377,17 +567,68 @@ to use the following functions to construct them:
377
567
  phase_estimation
378
568
  grover_operator
379
569
  unitary_overlap
570
+ GraphStateGate
571
+ PauliEvolutionGate
572
+ HamiltonianGate
573
+
574
+ Below we provide the same operations as classes deriving :class:`.QuantumCircuit`. For better
575
+ runtime and compiler performance, however, we suggest using above functions and gates.
576
+
577
+ .. autosummary::
578
+ :toctree: ../stubs/
579
+ :template: autosummary/class_no_inherited_members.rst
580
+
581
+ FourierChecking
582
+ GraphState
583
+ HiddenLinearFunction
584
+ IQP
585
+ QuantumVolume
586
+ PhaseEstimation
587
+ GroverOperator
588
+ UnitaryOverlap
380
589
 
590
+ .. _n-local:
381
591
 
382
592
  N-local circuits
383
593
  ================
384
594
 
385
595
  The following functions return a parameterized :class:`.QuantumCircuit` to use as ansatz in
386
- a broad set of variational quantum algorithms:
596
+ a broad set of variational quantum algorithms.
597
+
598
+ For example, we can build a variational circuit
599
+
600
+ .. plot::
601
+ :alt: The efficient SU2 ansatz circuit...
602
+ :context:
603
+
604
+ from qiskit.circuit.library import efficient_su2
605
+
606
+ num_qubits = 4
607
+ ansatz = efficient_su2(num_qubits, entanglement="pairwise")
608
+ ansatz.draw("mpl")
609
+
610
+ and combine it with
611
+
612
+ .. plot::
613
+ :alt: ... combined with the ZZ feature map.
614
+ :include-source:
615
+ :context:
616
+
617
+ from qiskit.circuit.library import zz_feature_map
618
+
619
+ circuit = zz_feature_map(num_qubits)
620
+ circuit.barrier()
621
+ circuit.compose(ansatz, inplace=True)
622
+
623
+ circuit.draw("mpl")
624
+
625
+ to obtain a circuit for variational quantum classification.
626
+
627
+ The following functions all construct variational circuits and are optimized for a fast
628
+ construction:
387
629
 
388
630
  .. autosummary::
389
631
  :toctree: ../stubs/
390
- :template: autosummary/class_no_inherited_members.rst
391
632
 
392
633
  n_local
393
634
  efficient_su2
@@ -398,9 +639,9 @@ a broad set of variational quantum algorithms:
398
639
  hamiltonian_variational_ansatz
399
640
  evolved_operator_ansatz
400
641
 
401
- These :class:`~qiskit.circuit.library.BlueprintCircuit` subclasses are used
402
- as parameterized models (a.k.a. ansatzes or variational forms) in variational algorithms.
403
- They are heavily used in near-term algorithms in e.g. Chemistry, Physics or Optimization.
642
+ While we suggest using the above functions, we also continue supporting the following
643
+ :class:`.BlueprintCircuit`, which wrap the circuits into a block
644
+ and allow for inplace mutations of the circuits:
404
645
 
405
646
  .. autosummary::
406
647
  :toctree: ../stubs/
@@ -416,6 +657,8 @@ They are heavily used in near-term algorithms in e.g. Chemistry, Physics or Opti
416
657
  QAOAAnsatz
417
658
 
418
659
 
660
+ .. _data-encoding:
661
+
419
662
  Data encoding circuits
420
663
  ======================
421
664
 
@@ -424,14 +667,14 @@ encoding circuits in a series of variational quantum algorithms:
424
667
 
425
668
  .. autosummary::
426
669
  :toctree: ../stubs/
427
- :template: autosummary/class_no_inherited_members.rst
428
670
 
429
671
  pauli_feature_map
430
672
  z_feature_map
431
673
  zz_feature_map
432
674
 
433
- These :class:`~qiskit.circuit.library.BlueprintCircuit` encode classical
434
- data in quantum states and are used as feature maps for classification.
675
+ While we suggest using the above functions, we also continue supporting the following
676
+ :class:`.BlueprintCircuit`, which wrap the circuits into a block
677
+ and allow for inplace mutations of the circuits:
435
678
 
436
679
  .. autosummary::
437
680
  :toctree: ../stubs/
@@ -442,6 +685,8 @@ data in quantum states and are used as feature maps for classification.
442
685
  ZZFeatureMap
443
686
 
444
687
 
688
+ .. _data-preparation:
689
+
445
690
  Data preparation circuits
446
691
  =========================
447
692
 
@@ -449,11 +694,51 @@ The following operations are used for state preparation:
449
694
 
450
695
  .. autosummary::
451
696
  :toctree: ../stubs/
452
- :template: autosummary/class_no_inherited_members.rst
453
697
 
454
698
  StatePreparation
455
699
  Initialize
456
700
 
701
+ .. _oracles:
702
+
703
+ Oracles
704
+ =======
705
+
706
+ An "oracle" can refer to a variety of black-box operations on quantum states. Here, we consider
707
+ oracles implementing boolean functions :math:`f: \{0, ..., 2^n - 1\} \rightarrow \{0, 1\}` via
708
+ phase-flips
709
+
710
+ .. math::
711
+
712
+ |x\rangle_n \mapsto (-1)^{f(x)} |x\rangle_n,
713
+
714
+ or bit-flips
715
+
716
+ .. math::
717
+
718
+ |x\rangle_n |b\rangle \mapsto |x\rangle_n |b \oplus f(x)\rangle.
719
+
720
+ These are implemented in
721
+
722
+ .. autosummary::
723
+ :toctree: ../stubs/
724
+
725
+ PhaseOracleGate
726
+ BitFlipOracleGate
727
+
728
+ and an important building block for Grover's algorithm (see :func:`.grover_operator`).
729
+
730
+ In addition to the :class:`.Gate`-based implementation we also support the
731
+ :class:`.QuantumCircuit`-version of the phase flip oracle
732
+
733
+ .. autosummary::
734
+ :toctree: ../stubs/
735
+ :template: autosummary/class_no_inherited_members.rst
736
+
737
+ PhaseOracle
738
+
739
+
740
+ .. _template:
741
+
457
742
  Template circuits
458
743
  =================
459
744
 
@@ -464,6 +749,7 @@ to replace the match with the inverse of the remainder from the template.
464
749
  In this example, the identity constant in a template is checked:
465
750
 
466
751
  .. plot::
752
+ :alt: A Toffoli template circuit.
467
753
  :include-source:
468
754
  :nofigs:
469
755