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.
- qiskit/VERSION.txt +1 -1
- qiskit/_accelerate.pyd +0 -0
- qiskit/circuit/__init__.py +2 -0
- qiskit/circuit/add_control.py +110 -92
- qiskit/circuit/controlledgate.py +2 -0
- qiskit/circuit/library/__init__.py +1 -0
- qiskit/circuit/library/arithmetic/adders/adder.py +25 -0
- qiskit/circuit/library/arithmetic/adders/cdkm_ripple_carry_adder.py +1 -1
- qiskit/circuit/library/arithmetic/adders/draper_qft_adder.py +1 -1
- qiskit/circuit/library/arithmetic/adders/vbe_ripple_carry_adder.py +1 -1
- qiskit/circuit/library/arithmetic/multipliers/multiplier.py +9 -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/operation.py +1 -0
- qiskit/circuit/parameter.py +1 -0
- qiskit/circuit/parameterexpression.py +1 -1
- qiskit/circuit/quantumcircuit.py +13 -19
- qiskit/circuit/random/utils.py +2 -0
- 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/qpy/__init__.py +5 -5
- qiskit/quantum_info/operators/channel/chi.py +9 -9
- qiskit/quantum_info/operators/channel/choi.py +9 -9
- qiskit/quantum_info/operators/channel/ptm.py +9 -9
- qiskit/quantum_info/operators/channel/quantum_channel.py +3 -3
- qiskit/quantum_info/operators/channel/stinespring.py +9 -9
- qiskit/quantum_info/operators/channel/superop.py +5 -9
- 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/densitymatrix.py +17 -15
- qiskit/quantum_info/states/stabilizerstate.py +7 -6
- qiskit/quantum_info/states/statevector.py +15 -6
- 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 +22 -1
- qiskit/transpiler/layout.py +3 -0
- qiskit/transpiler/passes/basis/decompose.py +24 -4
- qiskit/transpiler/passes/optimization/inverse_cancellation.py +2 -0
- 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/synthesis/hls_plugins.py +137 -30
- 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 +5 -5
- qiskit/transpiler/preset_passmanagers/builtin_plugins.py +19 -22
- qiskit/transpiler/target.py +1 -1
- qiskit/visualization/__init__.py +6 -0
- qiskit/visualization/circuit/circuit_visualization.py +1 -0
- 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.0rc2.dist-info → qiskit-1.3.2.dist-info}/METADATA +26 -26
- {qiskit-1.3.0rc2.dist-info → qiskit-1.3.2.dist-info}/RECORD +93 -93
- {qiskit-1.3.0rc2.dist-info → qiskit-1.3.2.dist-info}/WHEEL +1 -1
- {qiskit-1.3.0rc2.dist-info → qiskit-1.3.2.dist-info}/entry_points.txt +1 -1
- {qiskit-1.3.0rc2.dist-info → qiskit-1.3.2.dist-info}/LICENSE.txt +0 -0
- {qiskit-1.3.0rc2.dist-info → qiskit-1.3.2.dist-info}/top_level.txt +0 -0
@@ -263,11 +263,12 @@ Pauli Evolution Synthesis
|
|
263
263
|
- Targeted connectivity
|
264
264
|
* - ``"rustiq"``
|
265
265
|
- :class:`~.PauliEvolutionSynthesisRustiq`
|
266
|
-
- use
|
266
|
+
- use the synthesis method from `Rustiq circuit synthesis library
|
267
|
+
<https://github.com/smartiel/rustiq-core>`_
|
267
268
|
- all-to-all
|
268
269
|
* - ``"default"``
|
269
270
|
- :class:`~.PauliEvolutionSynthesisDefault`
|
270
|
-
- use
|
271
|
+
- use a diagonalizing Clifford per Pauli term
|
271
272
|
- all-to-all
|
272
273
|
|
273
274
|
.. autosummary::
|
@@ -299,6 +300,10 @@ Modular Adder Synthesis
|
|
299
300
|
- :class:`.ModularAdderSynthesisD00`
|
300
301
|
- 0
|
301
302
|
- a QFT-based adder
|
303
|
+
* - ``"default"``
|
304
|
+
- :class:`~.ModularAdderSynthesisDefault`
|
305
|
+
- any
|
306
|
+
- chooses the best algorithm based on the ancillas available
|
302
307
|
|
303
308
|
.. autosummary::
|
304
309
|
:toctree: ../stubs/
|
@@ -306,6 +311,7 @@ Modular Adder Synthesis
|
|
306
311
|
ModularAdderSynthesisC04
|
307
312
|
ModularAdderSynthesisD00
|
308
313
|
ModularAdderSynthesisV95
|
314
|
+
ModularAdderSynthesisDefault
|
309
315
|
|
310
316
|
Half Adder Synthesis
|
311
317
|
''''''''''''''''''''
|
@@ -329,6 +335,10 @@ Half Adder Synthesis
|
|
329
335
|
- :class:`.HalfAdderSynthesisD00`
|
330
336
|
- 0
|
331
337
|
- a QFT-based adder
|
338
|
+
* - ``"default"``
|
339
|
+
- :class:`~.HalfAdderSynthesisDefault`
|
340
|
+
- any
|
341
|
+
- chooses the best algorithm based on the ancillas available
|
332
342
|
|
333
343
|
.. autosummary::
|
334
344
|
:toctree: ../stubs/
|
@@ -336,6 +346,7 @@ Half Adder Synthesis
|
|
336
346
|
HalfAdderSynthesisC04
|
337
347
|
HalfAdderSynthesisD00
|
338
348
|
HalfAdderSynthesisV95
|
349
|
+
HalfAdderSynthesisDefault
|
339
350
|
|
340
351
|
Full Adder Synthesis
|
341
352
|
''''''''''''''''''''
|
@@ -355,12 +366,17 @@ Full Adder Synthesis
|
|
355
366
|
- :class:`.FullAdderSynthesisV95`
|
356
367
|
- :math:`n-1`, for :math:`n`-bit numbers
|
357
368
|
- a ripple-carry adder
|
369
|
+
* - ``"default"``
|
370
|
+
- :class:`~.FullAdderSynthesisDefault`
|
371
|
+
- any
|
372
|
+
- chooses the best algorithm based on the ancillas available
|
358
373
|
|
359
374
|
.. autosummary::
|
360
375
|
:toctree: ../stubs/
|
361
376
|
|
362
377
|
FullAdderSynthesisC04
|
363
378
|
FullAdderSynthesisV95
|
379
|
+
FullAdderSynthesisDefault
|
364
380
|
|
365
381
|
|
366
382
|
Multiplier Synthesis
|
@@ -375,7 +391,7 @@ Multiplier Synthesis
|
|
375
391
|
- Description
|
376
392
|
* - ``"cumulative"``
|
377
393
|
- :class:`.MultiplierSynthesisH18`
|
378
|
-
- depending on the :class:`.
|
394
|
+
- depending on the :class:`.HalfAdderGate` used
|
379
395
|
- a cumulative adder based on controlled adders
|
380
396
|
* - ``"qft"``
|
381
397
|
- :class:`.MultiplierSynthesisR17`
|
@@ -404,12 +420,13 @@ from qiskit.circuit.library import (
|
|
404
420
|
C3XGate,
|
405
421
|
C4XGate,
|
406
422
|
PauliEvolutionGate,
|
423
|
+
PermutationGate,
|
424
|
+
MCMTGate,
|
407
425
|
ModularAdderGate,
|
408
426
|
HalfAdderGate,
|
409
427
|
FullAdderGate,
|
410
428
|
MultiplierGate,
|
411
429
|
)
|
412
|
-
from qiskit.transpiler.exceptions import TranspilerError
|
413
430
|
from qiskit.transpiler.coupling import CouplingMap
|
414
431
|
|
415
432
|
from qiskit.synthesis.clifford import (
|
@@ -451,6 +468,7 @@ from qiskit.synthesis.arithmetic import (
|
|
451
468
|
multiplier_qft_r17,
|
452
469
|
multiplier_cumulative_h18,
|
453
470
|
)
|
471
|
+
from qiskit.quantum_info.operators import Clifford
|
454
472
|
from qiskit.transpiler.passes.routing.algorithms import ApproximateTokenSwapper
|
455
473
|
from .plugin import HighLevelSynthesisPlugin
|
456
474
|
|
@@ -468,6 +486,9 @@ class DefaultSynthesisClifford(HighLevelSynthesisPlugin):
|
|
468
486
|
|
469
487
|
def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
|
470
488
|
"""Run synthesis for the given Clifford."""
|
489
|
+
if not isinstance(high_level_object, Clifford):
|
490
|
+
return None
|
491
|
+
|
471
492
|
decomposition = synth_clifford_full(high_level_object)
|
472
493
|
return decomposition
|
473
494
|
|
@@ -481,6 +502,9 @@ class AGSynthesisClifford(HighLevelSynthesisPlugin):
|
|
481
502
|
|
482
503
|
def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
|
483
504
|
"""Run synthesis for the given Clifford."""
|
505
|
+
if not isinstance(high_level_object, Clifford):
|
506
|
+
return None
|
507
|
+
|
484
508
|
decomposition = synth_clifford_ag(high_level_object)
|
485
509
|
return decomposition
|
486
510
|
|
@@ -497,10 +521,14 @@ class BMSynthesisClifford(HighLevelSynthesisPlugin):
|
|
497
521
|
|
498
522
|
def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
|
499
523
|
"""Run synthesis for the given Clifford."""
|
524
|
+
if not isinstance(high_level_object, Clifford):
|
525
|
+
return None
|
526
|
+
|
500
527
|
if high_level_object.num_qubits <= 3:
|
501
528
|
decomposition = synth_clifford_bm(high_level_object)
|
502
529
|
else:
|
503
530
|
decomposition = None
|
531
|
+
|
504
532
|
return decomposition
|
505
533
|
|
506
534
|
|
@@ -514,6 +542,9 @@ class GreedySynthesisClifford(HighLevelSynthesisPlugin):
|
|
514
542
|
|
515
543
|
def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
|
516
544
|
"""Run synthesis for the given Clifford."""
|
545
|
+
if not isinstance(high_level_object, Clifford):
|
546
|
+
return None
|
547
|
+
|
517
548
|
decomposition = synth_clifford_greedy(high_level_object)
|
518
549
|
return decomposition
|
519
550
|
|
@@ -528,6 +559,9 @@ class LayerSynthesisClifford(HighLevelSynthesisPlugin):
|
|
528
559
|
|
529
560
|
def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
|
530
561
|
"""Run synthesis for the given Clifford."""
|
562
|
+
if not isinstance(high_level_object, Clifford):
|
563
|
+
return None
|
564
|
+
|
531
565
|
decomposition = synth_clifford_layers(high_level_object)
|
532
566
|
return decomposition
|
533
567
|
|
@@ -543,6 +577,9 @@ class LayerLnnSynthesisClifford(HighLevelSynthesisPlugin):
|
|
543
577
|
|
544
578
|
def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
|
545
579
|
"""Run synthesis for the given Clifford."""
|
580
|
+
if not isinstance(high_level_object, Clifford):
|
581
|
+
return None
|
582
|
+
|
546
583
|
decomposition = synth_clifford_depth_lnn(high_level_object)
|
547
584
|
return decomposition
|
548
585
|
|
@@ -556,6 +593,9 @@ class DefaultSynthesisLinearFunction(HighLevelSynthesisPlugin):
|
|
556
593
|
|
557
594
|
def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
|
558
595
|
"""Run synthesis for the given LinearFunction."""
|
596
|
+
if not isinstance(high_level_object, LinearFunction):
|
597
|
+
return None
|
598
|
+
|
559
599
|
decomposition = synth_cnot_count_full_pmh(high_level_object.linear)
|
560
600
|
return decomposition
|
561
601
|
|
@@ -579,11 +619,8 @@ class KMSSynthesisLinearFunction(HighLevelSynthesisPlugin):
|
|
579
619
|
|
580
620
|
def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
|
581
621
|
"""Run synthesis for the given LinearFunction."""
|
582
|
-
|
583
622
|
if not isinstance(high_level_object, LinearFunction):
|
584
|
-
|
585
|
-
"PMHSynthesisLinearFunction only accepts objects of type LinearFunction"
|
586
|
-
)
|
623
|
+
return None
|
587
624
|
|
588
625
|
use_inverted = options.get("use_inverted", False)
|
589
626
|
use_transposed = options.get("use_transposed", False)
|
@@ -630,11 +667,8 @@ class PMHSynthesisLinearFunction(HighLevelSynthesisPlugin):
|
|
630
667
|
|
631
668
|
def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
|
632
669
|
"""Run synthesis for the given LinearFunction."""
|
633
|
-
|
634
670
|
if not isinstance(high_level_object, LinearFunction):
|
635
|
-
|
636
|
-
"PMHSynthesisLinearFunction only accepts objects of type LinearFunction"
|
637
|
-
)
|
671
|
+
return None
|
638
672
|
|
639
673
|
section_size = options.get("section_size", 2)
|
640
674
|
use_inverted = options.get("use_inverted", False)
|
@@ -666,6 +700,9 @@ class KMSSynthesisPermutation(HighLevelSynthesisPlugin):
|
|
666
700
|
|
667
701
|
def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
|
668
702
|
"""Run synthesis for the given Permutation."""
|
703
|
+
if not isinstance(high_level_object, PermutationGate):
|
704
|
+
return None
|
705
|
+
|
669
706
|
decomposition = synth_permutation_depth_lnn_kms(high_level_object.pattern)
|
670
707
|
return decomposition
|
671
708
|
|
@@ -679,6 +716,9 @@ class BasicSynthesisPermutation(HighLevelSynthesisPlugin):
|
|
679
716
|
|
680
717
|
def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
|
681
718
|
"""Run synthesis for the given Permutation."""
|
719
|
+
if not isinstance(high_level_object, PermutationGate):
|
720
|
+
return None
|
721
|
+
|
682
722
|
decomposition = synth_permutation_basic(high_level_object.pattern)
|
683
723
|
return decomposition
|
684
724
|
|
@@ -692,6 +732,9 @@ class ACGSynthesisPermutation(HighLevelSynthesisPlugin):
|
|
692
732
|
|
693
733
|
def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
|
694
734
|
"""Run synthesis for the given Permutation."""
|
735
|
+
if not isinstance(high_level_object, PermutationGate):
|
736
|
+
return None
|
737
|
+
|
695
738
|
decomposition = synth_permutation_acg(high_level_object.pattern)
|
696
739
|
return decomposition
|
697
740
|
|
@@ -842,6 +885,9 @@ class TokenSwapperSynthesisPermutation(HighLevelSynthesisPlugin):
|
|
842
885
|
def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
|
843
886
|
"""Run synthesis for the given Permutation."""
|
844
887
|
|
888
|
+
if not isinstance(high_level_object, PermutationGate):
|
889
|
+
return None
|
890
|
+
|
845
891
|
trials = options.get("trials", 5)
|
846
892
|
seed = options.get("seed", 0)
|
847
893
|
parallel_threshold = options.get("parallel_threshold", 50)
|
@@ -1140,6 +1186,9 @@ class MCMTSynthesisDefault(HighLevelSynthesisPlugin):
|
|
1140
1186
|
|
1141
1187
|
def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
|
1142
1188
|
# first try to use the V-chain synthesis if enough auxiliary qubits are available
|
1189
|
+
if not isinstance(high_level_object, MCMTGate):
|
1190
|
+
return None
|
1191
|
+
|
1143
1192
|
if (
|
1144
1193
|
decomposition := MCMTSynthesisVChain().run(
|
1145
1194
|
high_level_object, coupling_map, target, qubits, **options
|
@@ -1154,6 +1203,9 @@ class MCMTSynthesisNoAux(HighLevelSynthesisPlugin):
|
|
1154
1203
|
"""A V-chain based synthesis for ``MCMTGate``."""
|
1155
1204
|
|
1156
1205
|
def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
|
1206
|
+
if not isinstance(high_level_object, MCMTGate):
|
1207
|
+
return None
|
1208
|
+
|
1157
1209
|
base_gate = high_level_object.base_gate
|
1158
1210
|
ctrl_state = options.get("ctrl_state", None)
|
1159
1211
|
|
@@ -1179,6 +1231,9 @@ class MCMTSynthesisVChain(HighLevelSynthesisPlugin):
|
|
1179
1231
|
"""A V-chain based synthesis for ``MCMTGate``."""
|
1180
1232
|
|
1181
1233
|
def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
|
1234
|
+
if not isinstance(high_level_object, MCMTGate):
|
1235
|
+
return None
|
1236
|
+
|
1182
1237
|
if options.get("num_clean_ancillas", 0) < high_level_object.num_ctrl_qubits - 1:
|
1183
1238
|
return None # insufficient number of auxiliary qubits
|
1184
1239
|
|
@@ -1211,10 +1266,26 @@ class ModularAdderSynthesisDefault(HighLevelSynthesisPlugin):
|
|
1211
1266
|
if not isinstance(high_level_object, ModularAdderGate):
|
1212
1267
|
return None
|
1213
1268
|
|
1214
|
-
|
1215
|
-
|
1269
|
+
# For up to 5 qubits, the QFT-based adder is best
|
1270
|
+
if high_level_object.num_state_qubits <= 5:
|
1271
|
+
decomposition = ModularAdderSynthesisD00().run(
|
1272
|
+
high_level_object, coupling_map, target, qubits, **options
|
1273
|
+
)
|
1274
|
+
if decomposition is not None:
|
1275
|
+
return decomposition
|
1216
1276
|
|
1217
|
-
|
1277
|
+
# Otherwise, the following decomposition is best (if there are enough ancillas)
|
1278
|
+
if (
|
1279
|
+
decomposition := ModularAdderSynthesisC04().run(
|
1280
|
+
high_level_object, coupling_map, target, qubits, **options
|
1281
|
+
)
|
1282
|
+
) is not None:
|
1283
|
+
return decomposition
|
1284
|
+
|
1285
|
+
# Otherwise, use the QFT-adder again
|
1286
|
+
return ModularAdderSynthesisD00().run(
|
1287
|
+
high_level_object, coupling_map, target, qubits, **options
|
1288
|
+
)
|
1218
1289
|
|
1219
1290
|
|
1220
1291
|
class ModularAdderSynthesisC04(HighLevelSynthesisPlugin):
|
@@ -1263,8 +1334,8 @@ class ModularAdderSynthesisV95(HighLevelSynthesisPlugin):
|
|
1263
1334
|
|
1264
1335
|
num_state_qubits = high_level_object.num_state_qubits
|
1265
1336
|
|
1266
|
-
#
|
1267
|
-
if num_state_qubits
|
1337
|
+
# The synthesis method needs n-1 clean ancilla qubits
|
1338
|
+
if num_state_qubits - 1 > options.get("num_clean_ancillas", 0):
|
1268
1339
|
return None
|
1269
1340
|
|
1270
1341
|
return adder_ripple_v95(num_state_qubits, kind="fixed")
|
@@ -1308,10 +1379,26 @@ class HalfAdderSynthesisDefault(HighLevelSynthesisPlugin):
|
|
1308
1379
|
if not isinstance(high_level_object, HalfAdderGate):
|
1309
1380
|
return None
|
1310
1381
|
|
1311
|
-
|
1312
|
-
|
1382
|
+
# For up to 3 qubits, ripple_v95 is better (if there are enough ancilla qubits)
|
1383
|
+
if high_level_object.num_state_qubits <= 3:
|
1384
|
+
decomposition = HalfAdderSynthesisV95().run(
|
1385
|
+
high_level_object, coupling_map, target, qubits, **options
|
1386
|
+
)
|
1387
|
+
if decomposition is not None:
|
1388
|
+
return decomposition
|
1313
1389
|
|
1314
|
-
|
1390
|
+
# The next best option is to use ripple_c04 (if there are enough ancilla qubits)
|
1391
|
+
if (
|
1392
|
+
decomposition := HalfAdderSynthesisC04().run(
|
1393
|
+
high_level_object, coupling_map, target, qubits, **options
|
1394
|
+
)
|
1395
|
+
) is not None:
|
1396
|
+
return decomposition
|
1397
|
+
|
1398
|
+
# The QFT-based adder does not require ancilla qubits and should always succeed
|
1399
|
+
return HalfAdderSynthesisD00().run(
|
1400
|
+
high_level_object, coupling_map, target, qubits, **options
|
1401
|
+
)
|
1315
1402
|
|
1316
1403
|
|
1317
1404
|
class HalfAdderSynthesisC04(HighLevelSynthesisPlugin):
|
@@ -1359,8 +1446,8 @@ class HalfAdderSynthesisV95(HighLevelSynthesisPlugin):
|
|
1359
1446
|
|
1360
1447
|
num_state_qubits = high_level_object.num_state_qubits
|
1361
1448
|
|
1362
|
-
#
|
1363
|
-
if num_state_qubits
|
1449
|
+
# The synthesis method needs n-1 clean ancilla qubits
|
1450
|
+
if num_state_qubits - 1 > options.get("num_clean_ancillas", 0):
|
1364
1451
|
return None
|
1365
1452
|
|
1366
1453
|
return adder_ripple_v95(num_state_qubits, kind="half")
|
@@ -1380,18 +1467,38 @@ class HalfAdderSynthesisD00(HighLevelSynthesisPlugin):
|
|
1380
1467
|
return adder_qft_d00(high_level_object.num_state_qubits, kind="half")
|
1381
1468
|
|
1382
1469
|
|
1383
|
-
class
|
1470
|
+
class FullAdderSynthesisDefault(HighLevelSynthesisPlugin):
|
1384
1471
|
"""A ripple-carry adder with a carry-in and a carry-out bit.
|
1385
1472
|
|
1386
|
-
This plugin name is:``FullAdder.
|
1473
|
+
This plugin name is:``FullAdder.default`` which can be used as the key on
|
1387
1474
|
an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
|
1475
|
+
"""
|
1388
1476
|
|
1389
|
-
|
1477
|
+
def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
|
1478
|
+
if not isinstance(high_level_object, FullAdderGate):
|
1479
|
+
return None
|
1390
1480
|
|
1391
|
-
|
1481
|
+
# FullAdderSynthesisC04 requires no ancilla qubits and returns better results
|
1482
|
+
# than FullAdderSynthesisV95 in all cases except for n=1.
|
1483
|
+
if high_level_object.num_state_qubits == 1:
|
1484
|
+
decomposition = FullAdderSynthesisV95().run(
|
1485
|
+
high_level_object, coupling_map, target, qubits, **options
|
1486
|
+
)
|
1487
|
+
if decomposition is not None:
|
1488
|
+
return decomposition
|
1392
1489
|
|
1393
|
-
|
1490
|
+
return FullAdderSynthesisC04().run(
|
1491
|
+
high_level_object, coupling_map, target, qubits, **options
|
1492
|
+
)
|
1394
1493
|
|
1494
|
+
|
1495
|
+
class FullAdderSynthesisC04(HighLevelSynthesisPlugin):
|
1496
|
+
"""A ripple-carry adder with a carry-in and a carry-out bit.
|
1497
|
+
|
1498
|
+
This plugin name is:``FullAdder.ripple_c04`` which can be used as the key on
|
1499
|
+
an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
|
1500
|
+
|
1501
|
+
This plugin requires no auxiliary qubits.
|
1395
1502
|
"""
|
1396
1503
|
|
1397
1504
|
def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **options):
|
@@ -1408,7 +1515,7 @@ class FullAdderSynthesisV95(HighLevelSynthesisPlugin):
|
|
1408
1515
|
an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`.
|
1409
1516
|
|
1410
1517
|
For an adder on 2 registers with :math:`n` qubits each, this plugin requires at
|
1411
|
-
least :math:`n-1` clean auxiliary
|
1518
|
+
least :math:`n-1` clean auxiliary qubits.
|
1412
1519
|
|
1413
1520
|
The plugin supports the following plugin-specific options:
|
1414
1521
|
|
@@ -1421,8 +1528,8 @@ class FullAdderSynthesisV95(HighLevelSynthesisPlugin):
|
|
1421
1528
|
|
1422
1529
|
num_state_qubits = high_level_object.num_state_qubits
|
1423
1530
|
|
1424
|
-
#
|
1425
|
-
if num_state_qubits
|
1531
|
+
# The synthesis method needs n-1 clean ancilla qubits
|
1532
|
+
if num_state_qubits - 1 > options.get("num_clean_ancillas", 0):
|
1426
1533
|
return None
|
1427
1534
|
|
1428
1535
|
return adder_ripple_v95(num_state_qubits, kind="full")
|
@@ -35,9 +35,10 @@ class FilterOpNodes(TransformationPass):
|
|
35
35
|
|
36
36
|
Example:
|
37
37
|
|
38
|
-
Filter out operations that are
|
38
|
+
Filter out operations that are labeled ``"foo"``
|
39
39
|
|
40
40
|
.. plot::
|
41
|
+
:alt: Circuit diagram output by the previous code.
|
41
42
|
:include-source:
|
42
43
|
|
43
44
|
from qiskit import QuantumCircuit
|
@@ -23,11 +23,11 @@ for the transpiler. The preset pass managers are instances of
|
|
23
23
|
transformations as part of Qiskit's compiler inside the
|
24
24
|
:func:`~.transpile` function at the different optimization levels, but
|
25
25
|
can also be used in a standalone manner.
|
26
|
-
The functionality here is divided into two parts
|
27
|
-
functions used generate the entire pass manager which is used by
|
28
|
-
:func:`~.transpile` (:ref:`preset_pass_manager_generators`) and the
|
29
|
-
second includes functions
|
30
|
-
part) the stages
|
26
|
+
The functionality here is divided into two parts. The first includes the
|
27
|
+
functions used to generate the entire pass manager, which is used by
|
28
|
+
:func:`~.transpile` (:ref:`preset_pass_manager_generators`), and the
|
29
|
+
second includes functions that are used to build (either entirely or in
|
30
|
+
part) the stages that comprise the preset pass managers
|
31
31
|
(:ref:`stage_generators`).
|
32
32
|
|
33
33
|
.. _preset_pass_manager_generators:
|
@@ -238,7 +238,6 @@ class BasicSwapPassManager(PassManagerStagePlugin):
|
|
238
238
|
|
239
239
|
def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager:
|
240
240
|
"""Build routing stage PassManager."""
|
241
|
-
seed_transpiler = pass_manager_config.seed_transpiler
|
242
241
|
target = pass_manager_config.target
|
243
242
|
coupling_map = pass_manager_config.coupling_map
|
244
243
|
backend_properties = pass_manager_config.backend_properties
|
@@ -257,7 +256,7 @@ class BasicSwapPassManager(PassManagerStagePlugin):
|
|
257
256
|
routing_pass,
|
258
257
|
target,
|
259
258
|
coupling_map=coupling_map,
|
260
|
-
seed_transpiler
|
259
|
+
seed_transpiler=-1,
|
261
260
|
use_barrier_before_measurement=True,
|
262
261
|
)
|
263
262
|
if optimization_level == 1:
|
@@ -268,7 +267,7 @@ class BasicSwapPassManager(PassManagerStagePlugin):
|
|
268
267
|
vf2_call_limit=vf2_call_limit,
|
269
268
|
vf2_max_trials=vf2_max_trials,
|
270
269
|
backend_properties=backend_properties,
|
271
|
-
seed_transpiler
|
270
|
+
seed_transpiler=-1,
|
272
271
|
check_trivial=True,
|
273
272
|
use_barrier_before_measurement=True,
|
274
273
|
)
|
@@ -280,7 +279,7 @@ class BasicSwapPassManager(PassManagerStagePlugin):
|
|
280
279
|
vf2_call_limit=vf2_call_limit,
|
281
280
|
vf2_max_trials=vf2_max_trials,
|
282
281
|
backend_properties=backend_properties,
|
283
|
-
seed_transpiler
|
282
|
+
seed_transpiler=-1,
|
284
283
|
use_barrier_before_measurement=True,
|
285
284
|
)
|
286
285
|
if optimization_level == 3:
|
@@ -291,7 +290,7 @@ class BasicSwapPassManager(PassManagerStagePlugin):
|
|
291
290
|
vf2_call_limit=vf2_call_limit,
|
292
291
|
vf2_max_trials=vf2_max_trials,
|
293
292
|
backend_properties=backend_properties,
|
294
|
-
seed_transpiler
|
293
|
+
seed_transpiler=-1,
|
295
294
|
use_barrier_before_measurement=True,
|
296
295
|
)
|
297
296
|
raise TranspilerError(f"Invalid optimization level specified: {optimization_level}")
|
@@ -324,7 +323,7 @@ class StochasticSwapPassManager(PassManagerStagePlugin):
|
|
324
323
|
routing_pass,
|
325
324
|
target,
|
326
325
|
coupling_map=coupling_map,
|
327
|
-
seed_transpiler
|
326
|
+
seed_transpiler=-1,
|
328
327
|
use_barrier_before_measurement=True,
|
329
328
|
)
|
330
329
|
if optimization_level == 1:
|
@@ -335,7 +334,7 @@ class StochasticSwapPassManager(PassManagerStagePlugin):
|
|
335
334
|
vf2_call_limit=vf2_call_limit,
|
336
335
|
vf2_max_trials=vf2_max_trials,
|
337
336
|
backend_properties=backend_properties,
|
338
|
-
seed_transpiler
|
337
|
+
seed_transpiler=-1,
|
339
338
|
check_trivial=True,
|
340
339
|
use_barrier_before_measurement=True,
|
341
340
|
)
|
@@ -347,7 +346,7 @@ class StochasticSwapPassManager(PassManagerStagePlugin):
|
|
347
346
|
vf2_call_limit=vf2_call_limit,
|
348
347
|
vf2_max_trials=vf2_max_trials,
|
349
348
|
backend_properties=backend_properties,
|
350
|
-
seed_transpiler
|
349
|
+
seed_transpiler=-1,
|
351
350
|
use_barrier_before_measurement=True,
|
352
351
|
)
|
353
352
|
raise TranspilerError(f"Invalid optimization level specified: {optimization_level}")
|
@@ -358,7 +357,6 @@ class LookaheadSwapPassManager(PassManagerStagePlugin):
|
|
358
357
|
|
359
358
|
def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager:
|
360
359
|
"""Build routing stage PassManager."""
|
361
|
-
seed_transpiler = pass_manager_config.seed_transpiler
|
362
360
|
target = pass_manager_config.target
|
363
361
|
coupling_map = pass_manager_config.coupling_map
|
364
362
|
coupling_map_routing = target
|
@@ -376,7 +374,7 @@ class LookaheadSwapPassManager(PassManagerStagePlugin):
|
|
376
374
|
routing_pass,
|
377
375
|
target,
|
378
376
|
coupling_map=coupling_map,
|
379
|
-
seed_transpiler
|
377
|
+
seed_transpiler=-1,
|
380
378
|
use_barrier_before_measurement=True,
|
381
379
|
)
|
382
380
|
if optimization_level == 1:
|
@@ -388,7 +386,7 @@ class LookaheadSwapPassManager(PassManagerStagePlugin):
|
|
388
386
|
vf2_call_limit=vf2_call_limit,
|
389
387
|
vf2_max_trials=vf2_max_trials,
|
390
388
|
backend_properties=backend_properties,
|
391
|
-
seed_transpiler
|
389
|
+
seed_transpiler=-1,
|
392
390
|
check_trivial=True,
|
393
391
|
use_barrier_before_measurement=True,
|
394
392
|
)
|
@@ -401,7 +399,7 @@ class LookaheadSwapPassManager(PassManagerStagePlugin):
|
|
401
399
|
vf2_call_limit=vf2_call_limit,
|
402
400
|
vf2_max_trials=vf2_max_trials,
|
403
401
|
backend_properties=backend_properties,
|
404
|
-
seed_transpiler
|
402
|
+
seed_transpiler=-1,
|
405
403
|
use_barrier_before_measurement=True,
|
406
404
|
)
|
407
405
|
if optimization_level == 3:
|
@@ -413,7 +411,7 @@ class LookaheadSwapPassManager(PassManagerStagePlugin):
|
|
413
411
|
vf2_call_limit=vf2_call_limit,
|
414
412
|
vf2_max_trials=vf2_max_trials,
|
415
413
|
backend_properties=backend_properties,
|
416
|
-
seed_transpiler
|
414
|
+
seed_transpiler=-1,
|
417
415
|
use_barrier_before_measurement=True,
|
418
416
|
)
|
419
417
|
raise TranspilerError(f"Invalid optimization level specified: {optimization_level}")
|
@@ -448,7 +446,7 @@ class SabreSwapPassManager(PassManagerStagePlugin):
|
|
448
446
|
routing_pass,
|
449
447
|
target,
|
450
448
|
coupling_map=coupling_map,
|
451
|
-
seed_transpiler
|
449
|
+
seed_transpiler=-1,
|
452
450
|
use_barrier_before_measurement=True,
|
453
451
|
)
|
454
452
|
if optimization_level == 1:
|
@@ -466,7 +464,7 @@ class SabreSwapPassManager(PassManagerStagePlugin):
|
|
466
464
|
vf2_call_limit=vf2_call_limit,
|
467
465
|
vf2_max_trials=vf2_max_trials,
|
468
466
|
backend_properties=backend_properties,
|
469
|
-
seed_transpiler
|
467
|
+
seed_transpiler=-1,
|
470
468
|
check_trivial=True,
|
471
469
|
use_barrier_before_measurement=True,
|
472
470
|
)
|
@@ -486,7 +484,7 @@ class SabreSwapPassManager(PassManagerStagePlugin):
|
|
486
484
|
vf2_call_limit=vf2_call_limit,
|
487
485
|
vf2_max_trials=vf2_max_trials,
|
488
486
|
backend_properties=backend_properties,
|
489
|
-
seed_transpiler
|
487
|
+
seed_transpiler=-1,
|
490
488
|
use_barrier_before_measurement=True,
|
491
489
|
)
|
492
490
|
if optimization_level == 3:
|
@@ -504,7 +502,7 @@ class SabreSwapPassManager(PassManagerStagePlugin):
|
|
504
502
|
vf2_call_limit=vf2_call_limit,
|
505
503
|
vf2_max_trials=vf2_max_trials,
|
506
504
|
backend_properties=backend_properties,
|
507
|
-
seed_transpiler
|
505
|
+
seed_transpiler=-1,
|
508
506
|
use_barrier_before_measurement=True,
|
509
507
|
)
|
510
508
|
raise TranspilerError(f"Invalid optimization level specified: {optimization_level}")
|
@@ -515,7 +513,6 @@ class NoneRoutingPassManager(PassManagerStagePlugin):
|
|
515
513
|
|
516
514
|
def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager:
|
517
515
|
"""Build routing stage PassManager."""
|
518
|
-
seed_transpiler = pass_manager_config.seed_transpiler
|
519
516
|
target = pass_manager_config.target
|
520
517
|
coupling_map = pass_manager_config.coupling_map
|
521
518
|
routing_pass = Error(
|
@@ -527,7 +524,7 @@ class NoneRoutingPassManager(PassManagerStagePlugin):
|
|
527
524
|
routing_pass,
|
528
525
|
target,
|
529
526
|
coupling_map=coupling_map,
|
530
|
-
seed_transpiler
|
527
|
+
seed_transpiler=-1,
|
531
528
|
use_barrier_before_measurement=True,
|
532
529
|
)
|
533
530
|
|
@@ -793,7 +790,7 @@ class DefaultLayoutPassManager(PassManagerStagePlugin):
|
|
793
790
|
)
|
794
791
|
choose_layout_1 = VF2Layout(
|
795
792
|
coupling_map=pass_manager_config.coupling_map,
|
796
|
-
seed
|
793
|
+
seed=-1,
|
797
794
|
call_limit=int(5e4), # Set call limit to ~100ms with rustworkx 0.10.2
|
798
795
|
properties=pass_manager_config.backend_properties,
|
799
796
|
target=pass_manager_config.target,
|
@@ -826,7 +823,7 @@ class DefaultLayoutPassManager(PassManagerStagePlugin):
|
|
826
823
|
elif optimization_level == 2:
|
827
824
|
choose_layout_0 = VF2Layout(
|
828
825
|
coupling_map=pass_manager_config.coupling_map,
|
829
|
-
seed
|
826
|
+
seed=-1,
|
830
827
|
call_limit=int(5e6), # Set call limit to ~10s with rustworkx 0.10.2
|
831
828
|
properties=pass_manager_config.backend_properties,
|
832
829
|
target=pass_manager_config.target,
|
@@ -861,7 +858,7 @@ class DefaultLayoutPassManager(PassManagerStagePlugin):
|
|
861
858
|
elif optimization_level == 3:
|
862
859
|
choose_layout_0 = VF2Layout(
|
863
860
|
coupling_map=pass_manager_config.coupling_map,
|
864
|
-
seed
|
861
|
+
seed=-1,
|
865
862
|
call_limit=int(3e7), # Set call limit to ~60s with rustworkx 0.10.2
|
866
863
|
properties=pass_manager_config.backend_properties,
|
867
864
|
target=pass_manager_config.target,
|
qiskit/transpiler/target.py
CHANGED
@@ -725,7 +725,7 @@ class Target(BaseTarget):
|
|
725
725
|
|
726
726
|
@property
|
727
727
|
def instructions(self):
|
728
|
-
"""Get the list of tuples
|
728
|
+
"""Get the list of tuples (:class:`~qiskit.circuit.Instruction`, (qargs))
|
729
729
|
for the target
|
730
730
|
|
731
731
|
For globally defined variable width operations the tuple will be of the form
|