qiskit 2.0.3__cp39-abi3-macosx_11_0_arm64.whl → 2.1.0__cp39-abi3-macosx_11_0_arm64.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/__init__.py +19 -1
- qiskit/_accelerate.abi3.so +0 -0
- qiskit/circuit/__init__.py +104 -20
- qiskit/circuit/_add_control.py +57 -31
- qiskit/circuit/_classical_resource_map.py +4 -0
- qiskit/circuit/annotation.py +504 -0
- qiskit/circuit/classical/expr/__init__.py +1 -1
- qiskit/circuit/classical/expr/expr.py +104 -446
- qiskit/circuit/classical/expr/visitors.py +6 -0
- qiskit/circuit/classical/types/types.py +7 -130
- qiskit/circuit/controlflow/box.py +32 -7
- qiskit/circuit/delay.py +11 -9
- qiskit/circuit/library/arithmetic/adders/adder.py +4 -4
- qiskit/circuit/library/arithmetic/multipliers/multiplier.py +2 -2
- qiskit/circuit/library/arithmetic/piecewise_chebyshev.py +8 -4
- qiskit/circuit/library/arithmetic/piecewise_linear_pauli_rotations.py +23 -15
- qiskit/circuit/library/arithmetic/piecewise_polynomial_pauli_rotations.py +22 -14
- qiskit/circuit/library/arithmetic/quadratic_form.py +6 -0
- qiskit/circuit/library/arithmetic/weighted_adder.py +43 -24
- qiskit/circuit/library/basis_change/qft.py +2 -2
- qiskit/circuit/library/blueprintcircuit.py +6 -0
- qiskit/circuit/library/boolean_logic/inner_product.py +2 -2
- qiskit/circuit/library/boolean_logic/quantum_and.py +2 -2
- qiskit/circuit/library/boolean_logic/quantum_or.py +3 -3
- qiskit/circuit/library/boolean_logic/quantum_xor.py +2 -2
- qiskit/circuit/library/data_preparation/_z_feature_map.py +2 -2
- qiskit/circuit/library/data_preparation/_zz_feature_map.py +2 -2
- qiskit/circuit/library/data_preparation/pauli_feature_map.py +2 -2
- qiskit/circuit/library/fourier_checking.py +2 -2
- qiskit/circuit/library/generalized_gates/diagonal.py +5 -1
- qiskit/circuit/library/generalized_gates/gms.py +5 -1
- qiskit/circuit/library/generalized_gates/linear_function.py +2 -2
- qiskit/circuit/library/generalized_gates/permutation.py +5 -1
- qiskit/circuit/library/generalized_gates/uc.py +1 -1
- qiskit/circuit/library/generalized_gates/unitary.py +21 -2
- qiskit/circuit/library/graph_state.py +2 -2
- qiskit/circuit/library/grover_operator.py +2 -2
- qiskit/circuit/library/hidden_linear_function.py +2 -2
- qiskit/circuit/library/iqp.py +2 -2
- qiskit/circuit/library/n_local/efficient_su2.py +2 -2
- qiskit/circuit/library/n_local/evolved_operator_ansatz.py +1 -1
- qiskit/circuit/library/n_local/excitation_preserving.py +7 -9
- qiskit/circuit/library/n_local/n_local.py +4 -3
- qiskit/circuit/library/n_local/pauli_two_design.py +2 -2
- qiskit/circuit/library/n_local/real_amplitudes.py +2 -2
- qiskit/circuit/library/n_local/two_local.py +2 -2
- qiskit/circuit/library/overlap.py +2 -2
- qiskit/circuit/library/pauli_evolution.py +3 -2
- qiskit/circuit/library/phase_estimation.py +2 -2
- qiskit/circuit/library/standard_gates/dcx.py +11 -12
- qiskit/circuit/library/standard_gates/ecr.py +21 -24
- qiskit/circuit/library/standard_gates/equivalence_library.py +232 -96
- qiskit/circuit/library/standard_gates/global_phase.py +5 -6
- qiskit/circuit/library/standard_gates/h.py +22 -45
- qiskit/circuit/library/standard_gates/i.py +1 -1
- qiskit/circuit/library/standard_gates/iswap.py +13 -31
- qiskit/circuit/library/standard_gates/p.py +19 -26
- qiskit/circuit/library/standard_gates/r.py +11 -17
- qiskit/circuit/library/standard_gates/rx.py +21 -45
- qiskit/circuit/library/standard_gates/rxx.py +7 -22
- qiskit/circuit/library/standard_gates/ry.py +21 -39
- qiskit/circuit/library/standard_gates/ryy.py +13 -28
- qiskit/circuit/library/standard_gates/rz.py +18 -35
- qiskit/circuit/library/standard_gates/rzx.py +7 -22
- qiskit/circuit/library/standard_gates/rzz.py +7 -19
- qiskit/circuit/library/standard_gates/s.py +44 -39
- qiskit/circuit/library/standard_gates/swap.py +25 -38
- qiskit/circuit/library/standard_gates/sx.py +34 -41
- qiskit/circuit/library/standard_gates/t.py +18 -27
- qiskit/circuit/library/standard_gates/u.py +8 -24
- qiskit/circuit/library/standard_gates/u1.py +28 -52
- qiskit/circuit/library/standard_gates/u2.py +9 -9
- qiskit/circuit/library/standard_gates/u3.py +24 -40
- qiskit/circuit/library/standard_gates/x.py +190 -336
- qiskit/circuit/library/standard_gates/xx_minus_yy.py +12 -50
- qiskit/circuit/library/standard_gates/xx_plus_yy.py +13 -52
- qiskit/circuit/library/standard_gates/y.py +19 -23
- qiskit/circuit/library/standard_gates/z.py +31 -38
- qiskit/circuit/parameter.py +14 -5
- qiskit/circuit/parameterexpression.py +109 -75
- qiskit/circuit/quantumcircuit.py +172 -99
- qiskit/circuit/quantumcircuitdata.py +1 -0
- qiskit/circuit/random/__init__.py +37 -2
- qiskit/circuit/random/utils.py +445 -56
- qiskit/circuit/tools/pi_check.py +5 -13
- qiskit/compiler/transpiler.py +1 -1
- qiskit/converters/circuit_to_instruction.py +2 -2
- qiskit/dagcircuit/dagnode.py +8 -3
- qiskit/primitives/__init__.py +2 -2
- qiskit/primitives/base/base_estimator.py +2 -2
- qiskit/primitives/containers/data_bin.py +0 -3
- qiskit/primitives/containers/observables_array.py +192 -108
- qiskit/primitives/primitive_job.py +29 -10
- qiskit/providers/fake_provider/generic_backend_v2.py +2 -0
- qiskit/qasm3/__init__.py +106 -12
- qiskit/qasm3/ast.py +15 -1
- qiskit/qasm3/exporter.py +59 -36
- qiskit/qasm3/printer.py +12 -0
- qiskit/qpy/__init__.py +182 -6
- qiskit/qpy/binary_io/circuits.py +256 -24
- qiskit/qpy/binary_io/parse_sympy_repr.py +5 -0
- qiskit/qpy/binary_io/schedules.py +12 -32
- qiskit/qpy/binary_io/value.py +36 -18
- qiskit/qpy/common.py +11 -3
- qiskit/qpy/formats.py +17 -1
- qiskit/qpy/interface.py +52 -12
- qiskit/qpy/type_keys.py +7 -1
- qiskit/quantum_info/__init__.py +10 -0
- qiskit/quantum_info/operators/__init__.py +1 -0
- qiskit/quantum_info/operators/symplectic/__init__.py +1 -0
- qiskit/quantum_info/operators/symplectic/clifford_circuits.py +26 -0
- qiskit/quantum_info/operators/symplectic/pauli.py +2 -2
- qiskit/result/sampled_expval.py +3 -1
- qiskit/synthesis/__init__.py +10 -0
- qiskit/synthesis/arithmetic/__init__.py +1 -1
- qiskit/synthesis/arithmetic/adders/__init__.py +1 -0
- qiskit/synthesis/arithmetic/adders/draper_qft_adder.py +6 -2
- qiskit/synthesis/arithmetic/adders/rv_ripple_carry_adder.py +156 -0
- qiskit/synthesis/discrete_basis/generate_basis_approximations.py +14 -126
- qiskit/synthesis/discrete_basis/solovay_kitaev.py +161 -121
- qiskit/synthesis/evolution/lie_trotter.py +10 -7
- qiskit/synthesis/evolution/product_formula.py +10 -7
- qiskit/synthesis/evolution/qdrift.py +10 -7
- qiskit/synthesis/evolution/suzuki_trotter.py +10 -7
- qiskit/synthesis/multi_controlled/__init__.py +4 -0
- qiskit/synthesis/multi_controlled/mcx_synthesis.py +402 -178
- qiskit/synthesis/multi_controlled/multi_control_rotation_gates.py +14 -15
- qiskit/synthesis/qft/qft_decompose_lnn.py +7 -25
- qiskit/synthesis/unitary/qsd.py +80 -9
- qiskit/transpiler/__init__.py +10 -3
- qiskit/transpiler/instruction_durations.py +2 -20
- qiskit/transpiler/passes/__init__.py +5 -2
- qiskit/transpiler/passes/layout/dense_layout.py +26 -6
- qiskit/transpiler/passes/layout/disjoint_utils.py +1 -166
- qiskit/transpiler/passes/layout/sabre_layout.py +22 -3
- qiskit/transpiler/passes/layout/sabre_pre_layout.py +1 -1
- qiskit/transpiler/passes/layout/vf2_layout.py +49 -13
- qiskit/transpiler/passes/layout/vf2_utils.py +10 -0
- qiskit/transpiler/passes/optimization/__init__.py +1 -1
- qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +2 -1
- qiskit/transpiler/passes/optimization/optimize_clifford_t.py +68 -0
- qiskit/transpiler/passes/optimization/template_matching/template_substitution.py +3 -9
- qiskit/transpiler/passes/routing/sabre_swap.py +4 -2
- qiskit/transpiler/passes/routing/star_prerouting.py +106 -81
- qiskit/transpiler/passes/scheduling/__init__.py +1 -1
- qiskit/transpiler/passes/scheduling/alignments/check_durations.py +1 -1
- qiskit/transpiler/passes/scheduling/padding/__init__.py +1 -0
- qiskit/transpiler/passes/scheduling/padding/context_aware_dynamical_decoupling.py +876 -0
- qiskit/transpiler/passes/synthesis/__init__.py +1 -0
- qiskit/transpiler/passes/synthesis/clifford_unitary_synth_plugin.py +123 -0
- qiskit/transpiler/passes/synthesis/hls_plugins.py +494 -93
- qiskit/transpiler/passes/synthesis/plugin.py +4 -0
- qiskit/transpiler/passes/synthesis/solovay_kitaev_synthesis.py +27 -22
- qiskit/transpiler/passmanager_config.py +3 -0
- qiskit/transpiler/preset_passmanagers/builtin_plugins.py +149 -28
- qiskit/transpiler/preset_passmanagers/common.py +101 -0
- qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py +6 -0
- qiskit/transpiler/preset_passmanagers/level3.py +2 -2
- qiskit/transpiler/target.py +15 -2
- qiskit/utils/optionals.py +6 -5
- qiskit/visualization/circuit/_utils.py +5 -3
- qiskit/visualization/circuit/latex.py +9 -2
- qiskit/visualization/circuit/matplotlib.py +26 -4
- qiskit/visualization/circuit/qcstyle.py +9 -157
- qiskit/visualization/dag/__init__.py +13 -0
- qiskit/visualization/dag/dagstyle.py +103 -0
- qiskit/visualization/dag/styles/__init__.py +13 -0
- qiskit/visualization/dag/styles/color.json +10 -0
- qiskit/visualization/dag/styles/plain.json +5 -0
- qiskit/visualization/dag_visualization.py +169 -98
- qiskit/visualization/style.py +223 -0
- {qiskit-2.0.3.dist-info → qiskit-2.1.0.dist-info}/METADATA +7 -6
- {qiskit-2.0.3.dist-info → qiskit-2.1.0.dist-info}/RECORD +178 -169
- {qiskit-2.0.3.dist-info → qiskit-2.1.0.dist-info}/entry_points.txt +6 -0
- qiskit/synthesis/discrete_basis/commutator_decompose.py +0 -265
- qiskit/synthesis/discrete_basis/gate_sequence.py +0 -421
- {qiskit-2.0.3.dist-info → qiskit-2.1.0.dist-info}/WHEEL +0 -0
- {qiskit-2.0.3.dist-info → qiskit-2.1.0.dist-info}/licenses/LICENSE.txt +0 -0
- {qiskit-2.0.3.dist-info → qiskit-2.1.0.dist-info}/top_level.txt +0 -0
@@ -12,8 +12,8 @@
|
|
12
12
|
|
13
13
|
"""X, CX, CCX and multi-controlled X gates."""
|
14
14
|
from __future__ import annotations
|
15
|
+
import warnings
|
15
16
|
from typing import Optional, Union, Type
|
16
|
-
from math import pi
|
17
17
|
import numpy
|
18
18
|
from qiskit.circuit.controlledgate import ControlledGate
|
19
19
|
from qiskit.circuit.singleton import SingletonGate, SingletonControlledGate, stdlib_singleton_key
|
@@ -72,7 +72,7 @@ class XGate(SingletonGate):
|
|
72
72
|
|1\rangle \rightarrow |0\rangle
|
73
73
|
"""
|
74
74
|
|
75
|
-
_standard_gate = StandardGate.
|
75
|
+
_standard_gate = StandardGate.X
|
76
76
|
|
77
77
|
def __init__(self, label: Optional[str] = None):
|
78
78
|
"""Create new X gate."""
|
@@ -81,20 +81,17 @@ class XGate(SingletonGate):
|
|
81
81
|
_singleton_lookup_key = stdlib_singleton_key()
|
82
82
|
|
83
83
|
def _define(self):
|
84
|
-
"""
|
85
|
-
gate x a { u3(pi,0,pi) a; }
|
86
|
-
"""
|
84
|
+
"""Default definition"""
|
87
85
|
# pylint: disable=cyclic-import
|
88
|
-
from qiskit.circuit import QuantumCircuit
|
89
|
-
from .u3 import U3Gate
|
86
|
+
from qiskit.circuit import QuantumCircuit
|
90
87
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
for instr, qargs, cargs in rules:
|
95
|
-
qc._append(instr, qargs, cargs)
|
88
|
+
# ┌──────────┐
|
89
|
+
# q: ┤ U(π,0,π) ├
|
90
|
+
# └──────────┘
|
96
91
|
|
97
|
-
self.definition =
|
92
|
+
self.definition = QuantumCircuit._from_circuit_data(
|
93
|
+
StandardGate.X._get_definition(self.params), add_regs=True, name=self.name
|
94
|
+
)
|
98
95
|
|
99
96
|
def control(
|
100
97
|
self,
|
@@ -217,7 +214,7 @@ class CXGate(SingletonControlledGate):
|
|
217
214
|
`|a, b\rangle \rightarrow |a, a \oplus b\rangle`
|
218
215
|
"""
|
219
216
|
|
220
|
-
_standard_gate = StandardGate.
|
217
|
+
_standard_gate = StandardGate.CX
|
221
218
|
|
222
219
|
def __init__(
|
223
220
|
self,
|
@@ -365,7 +362,7 @@ class CCXGate(SingletonControlledGate):
|
|
365
362
|
|
366
363
|
"""
|
367
364
|
|
368
|
-
_standard_gate = StandardGate.
|
365
|
+
_standard_gate = StandardGate.CCX
|
369
366
|
|
370
367
|
def __init__(
|
371
368
|
self,
|
@@ -388,18 +385,9 @@ class CCXGate(SingletonControlledGate):
|
|
388
385
|
_singleton_lookup_key = stdlib_singleton_key(num_ctrl_qubits=2)
|
389
386
|
|
390
387
|
def _define(self):
|
391
|
-
"""
|
392
|
-
gate ccx a,b,c
|
393
|
-
{
|
394
|
-
h c; cx b,c; tdg c; cx a,c;
|
395
|
-
t c; cx b,c; tdg c; cx a,c;
|
396
|
-
t b; t c; h c; cx a,b;
|
397
|
-
t a; tdg b; cx a,b;}
|
398
|
-
"""
|
388
|
+
"""Default definition"""
|
399
389
|
# pylint: disable=cyclic-import
|
400
|
-
from qiskit.circuit import QuantumCircuit
|
401
|
-
from .h import HGate
|
402
|
-
from .t import TGate, TdgGate
|
390
|
+
from qiskit.circuit import QuantumCircuit
|
403
391
|
|
404
392
|
# ┌───┐
|
405
393
|
# q_0: ───────────────────■─────────────────────■────■───┤ T ├───■──
|
@@ -408,29 +396,10 @@ class CCXGate(SingletonControlledGate):
|
|
408
396
|
# ┌───┐┌─┴─┐┌─────┐┌─┴─┐┌───┐┌─┴─┐┌┴───┴┐┌─┴─┐├───┤└┬───┬┘└───┘
|
409
397
|
# q_2: ┤ H ├┤ X ├┤ Tdg ├┤ X ├┤ T ├┤ X ├┤ Tdg ├┤ X ├┤ T ├─┤ H ├──────
|
410
398
|
# └───┘└───┘└─────┘└───┘└───┘└───┘└─────┘└───┘└───┘ └───┘
|
411
|
-
q = QuantumRegister(3, "q")
|
412
|
-
qc = QuantumCircuit(q, name=self.name)
|
413
|
-
rules = [
|
414
|
-
(HGate(), [q[2]], []),
|
415
|
-
(CXGate(), [q[1], q[2]], []),
|
416
|
-
(TdgGate(), [q[2]], []),
|
417
|
-
(CXGate(), [q[0], q[2]], []),
|
418
|
-
(TGate(), [q[2]], []),
|
419
|
-
(CXGate(), [q[1], q[2]], []),
|
420
|
-
(TdgGate(), [q[2]], []),
|
421
|
-
(CXGate(), [q[0], q[2]], []),
|
422
|
-
(TGate(), [q[1]], []),
|
423
|
-
(TGate(), [q[2]], []),
|
424
|
-
(HGate(), [q[2]], []),
|
425
|
-
(CXGate(), [q[0], q[1]], []),
|
426
|
-
(TGate(), [q[0]], []),
|
427
|
-
(TdgGate(), [q[1]], []),
|
428
|
-
(CXGate(), [q[0], q[1]], []),
|
429
|
-
]
|
430
|
-
for instr, qargs, cargs in rules:
|
431
|
-
qc._append(instr, qargs, cargs)
|
432
399
|
|
433
|
-
self.definition =
|
400
|
+
self.definition = QuantumCircuit._from_circuit_data(
|
401
|
+
StandardGate.CCX._get_definition(self.params), add_regs=True, name=self.name
|
402
|
+
)
|
434
403
|
|
435
404
|
def control(
|
436
405
|
self,
|
@@ -516,7 +485,7 @@ class RCCXGate(SingletonGate):
|
|
516
485
|
with the :meth:`~qiskit.circuit.QuantumCircuit.rccx` method.
|
517
486
|
"""
|
518
487
|
|
519
|
-
_standard_gate = StandardGate.
|
488
|
+
_standard_gate = StandardGate.RCCX
|
520
489
|
|
521
490
|
def __init__(self, label: Optional[str] = None):
|
522
491
|
"""Create a new simplified CCX gate."""
|
@@ -525,41 +494,21 @@ class RCCXGate(SingletonGate):
|
|
525
494
|
_singleton_lookup_key = stdlib_singleton_key()
|
526
495
|
|
527
496
|
def _define(self):
|
528
|
-
"""
|
529
|
-
|
530
|
-
{ u2(0,pi) c;
|
531
|
-
u1(pi/4) c;
|
532
|
-
cx b, c;
|
533
|
-
u1(-pi/4) c;
|
534
|
-
cx a, c;
|
535
|
-
u1(pi/4) c;
|
536
|
-
cx b, c;
|
537
|
-
u1(-pi/4) c;
|
538
|
-
u2(0,pi) c;
|
539
|
-
}
|
540
|
-
"""
|
497
|
+
"""Default definition"""
|
498
|
+
|
541
499
|
# pylint: disable=cyclic-import
|
542
|
-
from qiskit.circuit import QuantumCircuit
|
543
|
-
from .u1 import U1Gate
|
544
|
-
from .u2 import U2Gate
|
500
|
+
from qiskit.circuit import QuantumCircuit
|
545
501
|
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
(U1Gate(-pi / 4), [q[2]], []), # inverse T gate
|
553
|
-
(CXGate(), [q[0], q[2]], []),
|
554
|
-
(U1Gate(pi / 4), [q[2]], []),
|
555
|
-
(CXGate(), [q[1], q[2]], []),
|
556
|
-
(U1Gate(-pi / 4), [q[2]], []), # inverse T gate
|
557
|
-
(U2Gate(0, pi), [q[2]], []), # H gate
|
558
|
-
]
|
559
|
-
for instr, qargs, cargs in rules:
|
560
|
-
qc._append(instr, qargs, cargs)
|
502
|
+
# q_0: ────────────────────────■────────────────────────
|
503
|
+
# │
|
504
|
+
# q_1: ────────────■───────────┼─────────■──────────────
|
505
|
+
# ┌───┐┌───┐┌─┴─┐┌─────┐┌─┴─┐┌───┐┌─┴─┐┌─────┐┌───┐
|
506
|
+
# q_2: ┤ H ├┤ T ├┤ X ├┤ Tdg ├┤ X ├┤ T ├┤ X ├┤ Tdg ├┤ H ├
|
507
|
+
# └───┘└───┘└───┘└─────┘└───┘└───┘└───┘└─────┘└───┘
|
561
508
|
|
562
|
-
self.definition =
|
509
|
+
self.definition = QuantumCircuit._from_circuit_data(
|
510
|
+
StandardGate.RCCX._get_definition(self.params), add_regs=True, name=self.name
|
511
|
+
)
|
563
512
|
|
564
513
|
def __eq__(self, other):
|
565
514
|
return isinstance(other, RCCXGate)
|
@@ -575,7 +524,7 @@ class C3SXGate(SingletonControlledGate):
|
|
575
524
|
[1] Barenco et al., 1995. https://arxiv.org/pdf/quant-ph/9503016.pdf
|
576
525
|
"""
|
577
526
|
|
578
|
-
_standard_gate = StandardGate.
|
527
|
+
_standard_gate = StandardGate.C3SX
|
579
528
|
|
580
529
|
def __init__(
|
581
530
|
self,
|
@@ -606,65 +555,13 @@ class C3SXGate(SingletonControlledGate):
|
|
606
555
|
_singleton_lookup_key = stdlib_singleton_key(num_ctrl_qubits=3)
|
607
556
|
|
608
557
|
def _define(self):
|
609
|
-
"""
|
610
|
-
gate c3sqrtx a,b,c,d
|
611
|
-
{
|
612
|
-
h d; cu1(pi/8) a,d; h d;
|
613
|
-
cx a,b;
|
614
|
-
h d; cu1(-pi/8) b,d; h d;
|
615
|
-
cx a,b;
|
616
|
-
h d; cu1(pi/8) b,d; h d;
|
617
|
-
cx b,c;
|
618
|
-
h d; cu1(-pi/8) c,d; h d;
|
619
|
-
cx a,c;
|
620
|
-
h d; cu1(pi/8) c,d; h d;
|
621
|
-
cx b,c;
|
622
|
-
h d; cu1(-pi/8) c,d; h d;
|
623
|
-
cx a,c;
|
624
|
-
h d; cu1(pi/8) c,d; h d;
|
625
|
-
}
|
626
|
-
"""
|
558
|
+
"""Default definition"""
|
627
559
|
# pylint: disable=cyclic-import
|
628
|
-
from qiskit.circuit import QuantumCircuit
|
629
|
-
from .u1 import CU1Gate
|
630
|
-
from .h import HGate
|
631
|
-
|
632
|
-
angle = numpy.pi / 8
|
633
|
-
q = QuantumRegister(4, name="q")
|
634
|
-
rules = [
|
635
|
-
(HGate(), [q[3]], []),
|
636
|
-
(CU1Gate(angle), [q[0], q[3]], []),
|
637
|
-
(HGate(), [q[3]], []),
|
638
|
-
(CXGate(), [q[0], q[1]], []),
|
639
|
-
(HGate(), [q[3]], []),
|
640
|
-
(CU1Gate(-angle), [q[1], q[3]], []),
|
641
|
-
(HGate(), [q[3]], []),
|
642
|
-
(CXGate(), [q[0], q[1]], []),
|
643
|
-
(HGate(), [q[3]], []),
|
644
|
-
(CU1Gate(angle), [q[1], q[3]], []),
|
645
|
-
(HGate(), [q[3]], []),
|
646
|
-
(CXGate(), [q[1], q[2]], []),
|
647
|
-
(HGate(), [q[3]], []),
|
648
|
-
(CU1Gate(-angle), [q[2], q[3]], []),
|
649
|
-
(HGate(), [q[3]], []),
|
650
|
-
(CXGate(), [q[0], q[2]], []),
|
651
|
-
(HGate(), [q[3]], []),
|
652
|
-
(CU1Gate(angle), [q[2], q[3]], []),
|
653
|
-
(HGate(), [q[3]], []),
|
654
|
-
(CXGate(), [q[1], q[2]], []),
|
655
|
-
(HGate(), [q[3]], []),
|
656
|
-
(CU1Gate(-angle), [q[2], q[3]], []),
|
657
|
-
(HGate(), [q[3]], []),
|
658
|
-
(CXGate(), [q[0], q[2]], []),
|
659
|
-
(HGate(), [q[3]], []),
|
660
|
-
(CU1Gate(angle), [q[2], q[3]], []),
|
661
|
-
(HGate(), [q[3]], []),
|
662
|
-
]
|
663
|
-
qc = QuantumCircuit(q)
|
664
|
-
for instr, qargs, cargs in rules:
|
665
|
-
qc._append(instr, qargs, cargs)
|
560
|
+
from qiskit.circuit import QuantumCircuit
|
666
561
|
|
667
|
-
self.definition =
|
562
|
+
self.definition = QuantumCircuit._from_circuit_data(
|
563
|
+
StandardGate.C3SX._get_definition(self.params), add_regs=True, name=self.name
|
564
|
+
)
|
668
565
|
|
669
566
|
def __eq__(self, other):
|
670
567
|
return isinstance(other, C3SXGate) and self.ctrl_state == other.ctrl_state
|
@@ -677,7 +574,7 @@ class C3XGate(SingletonControlledGate):
|
|
677
574
|
This implementation uses :math:`\sqrt{T}` and 14 CNOT gates.
|
678
575
|
"""
|
679
576
|
|
680
|
-
_standard_gate = StandardGate.
|
577
|
+
_standard_gate = StandardGate.C3X
|
681
578
|
|
682
579
|
def __init__(
|
683
580
|
self,
|
@@ -701,76 +598,13 @@ class C3XGate(SingletonControlledGate):
|
|
701
598
|
|
702
599
|
# seems like open controls not happening?
|
703
600
|
def _define(self):
|
704
|
-
"""
|
705
|
-
|
706
|
-
|
707
|
-
h d;
|
708
|
-
p(pi/8) a;
|
709
|
-
p(pi/8) b;
|
710
|
-
p(pi/8) c;
|
711
|
-
p(pi/8) d;
|
712
|
-
cx a, b;
|
713
|
-
p(-pi/8) b;
|
714
|
-
cx a, b;
|
715
|
-
cx b, c;
|
716
|
-
p(-pi/8) c;
|
717
|
-
cx a, c;
|
718
|
-
p(pi/8) c;
|
719
|
-
cx b, c;
|
720
|
-
p(-pi/8) c;
|
721
|
-
cx a, c;
|
722
|
-
cx c, d;
|
723
|
-
p(-pi/8) d;
|
724
|
-
cx b, d;
|
725
|
-
p(pi/8) d;
|
726
|
-
cx c, d;
|
727
|
-
p(-pi/8) d;
|
728
|
-
cx a, d;
|
729
|
-
p(pi/8) d;
|
730
|
-
cx c, d;
|
731
|
-
p(-pi/8) d;
|
732
|
-
cx b, d;
|
733
|
-
p(pi/8) d;
|
734
|
-
cx c, d;
|
735
|
-
p(-pi/8) d;
|
736
|
-
cx a, d;
|
737
|
-
h d;
|
738
|
-
}
|
739
|
-
"""
|
740
|
-
from qiskit.circuit import QuantumCircuit, QuantumRegister
|
741
|
-
|
742
|
-
q = QuantumRegister(4, name="q")
|
743
|
-
qc = QuantumCircuit(q, name=self.name)
|
744
|
-
qc.h(3)
|
745
|
-
qc.p(pi / 8, [0, 1, 2, 3])
|
746
|
-
qc.cx(0, 1)
|
747
|
-
qc.p(-pi / 8, 1)
|
748
|
-
qc.cx(0, 1)
|
749
|
-
qc.cx(1, 2)
|
750
|
-
qc.p(-pi / 8, 2)
|
751
|
-
qc.cx(0, 2)
|
752
|
-
qc.p(pi / 8, 2)
|
753
|
-
qc.cx(1, 2)
|
754
|
-
qc.p(-pi / 8, 2)
|
755
|
-
qc.cx(0, 2)
|
756
|
-
qc.cx(2, 3)
|
757
|
-
qc.p(-pi / 8, 3)
|
758
|
-
qc.cx(1, 3)
|
759
|
-
qc.p(pi / 8, 3)
|
760
|
-
qc.cx(2, 3)
|
761
|
-
qc.p(-pi / 8, 3)
|
762
|
-
qc.cx(0, 3)
|
763
|
-
qc.p(pi / 8, 3)
|
764
|
-
qc.cx(2, 3)
|
765
|
-
qc.p(-pi / 8, 3)
|
766
|
-
qc.cx(1, 3)
|
767
|
-
qc.p(pi / 8, 3)
|
768
|
-
qc.cx(2, 3)
|
769
|
-
qc.p(-pi / 8, 3)
|
770
|
-
qc.cx(0, 3)
|
771
|
-
qc.h(3)
|
601
|
+
"""Default definition"""
|
602
|
+
# pylint: disable=cyclic-import
|
603
|
+
from qiskit.circuit import QuantumCircuit
|
772
604
|
|
773
|
-
self.definition =
|
605
|
+
self.definition = QuantumCircuit._from_circuit_data(
|
606
|
+
StandardGate.C3X._get_definition(self.params), add_regs=True, name=self.name
|
607
|
+
)
|
774
608
|
|
775
609
|
def control(
|
776
610
|
self,
|
@@ -862,7 +696,7 @@ class RC3XGate(SingletonGate):
|
|
862
696
|
with the :meth:`~qiskit.circuit.QuantumCircuit.rcccx` method.
|
863
697
|
"""
|
864
698
|
|
865
|
-
_standard_gate = StandardGate.
|
699
|
+
_standard_gate = StandardGate.RC3X
|
866
700
|
|
867
701
|
def __init__(self, label: Optional[str] = None):
|
868
702
|
"""Create a new RC3X gate."""
|
@@ -871,59 +705,13 @@ class RC3XGate(SingletonGate):
|
|
871
705
|
_singleton_lookup_key = stdlib_singleton_key()
|
872
706
|
|
873
707
|
def _define(self):
|
874
|
-
"""
|
875
|
-
gate rc3x a,b,c,d
|
876
|
-
{ u2(0,pi) d;
|
877
|
-
u1(pi/4) d;
|
878
|
-
cx c,d;
|
879
|
-
u1(-pi/4) d;
|
880
|
-
u2(0,pi) d;
|
881
|
-
cx a,d;
|
882
|
-
u1(pi/4) d;
|
883
|
-
cx b,d;
|
884
|
-
u1(-pi/4) d;
|
885
|
-
cx a,d;
|
886
|
-
u1(pi/4) d;
|
887
|
-
cx b,d;
|
888
|
-
u1(-pi/4) d;
|
889
|
-
u2(0,pi) d;
|
890
|
-
u1(pi/4) d;
|
891
|
-
cx c,d;
|
892
|
-
u1(-pi/4) d;
|
893
|
-
u2(0,pi) d;
|
894
|
-
}
|
895
|
-
"""
|
708
|
+
"""Default definition"""
|
896
709
|
# pylint: disable=cyclic-import
|
897
|
-
from qiskit.circuit import QuantumCircuit
|
898
|
-
from .u1 import U1Gate
|
899
|
-
from .u2 import U2Gate
|
710
|
+
from qiskit.circuit import QuantumCircuit
|
900
711
|
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
(U2Gate(0, pi), [q[3]], []), # H gate
|
905
|
-
(U1Gate(pi / 4), [q[3]], []), # T gate
|
906
|
-
(CXGate(), [q[2], q[3]], []),
|
907
|
-
(U1Gate(-pi / 4), [q[3]], []), # inverse T gate
|
908
|
-
(U2Gate(0, pi), [q[3]], []),
|
909
|
-
(CXGate(), [q[0], q[3]], []),
|
910
|
-
(U1Gate(pi / 4), [q[3]], []),
|
911
|
-
(CXGate(), [q[1], q[3]], []),
|
912
|
-
(U1Gate(-pi / 4), [q[3]], []),
|
913
|
-
(CXGate(), [q[0], q[3]], []),
|
914
|
-
(U1Gate(pi / 4), [q[3]], []),
|
915
|
-
(CXGate(), [q[1], q[3]], []),
|
916
|
-
(U1Gate(-pi / 4), [q[3]], []),
|
917
|
-
(U2Gate(0, pi), [q[3]], []),
|
918
|
-
(U1Gate(pi / 4), [q[3]], []),
|
919
|
-
(CXGate(), [q[2], q[3]], []),
|
920
|
-
(U1Gate(-pi / 4), [q[3]], []),
|
921
|
-
(U2Gate(0, pi), [q[3]], []),
|
922
|
-
]
|
923
|
-
for instr, qargs, cargs in rules:
|
924
|
-
qc._append(instr, qargs, cargs)
|
925
|
-
|
926
|
-
self.definition = qc
|
712
|
+
self.definition = QuantumCircuit._from_circuit_data(
|
713
|
+
StandardGate.RC3X._get_definition(self.params), add_regs=True, name=self.name
|
714
|
+
)
|
927
715
|
|
928
716
|
def __eq__(self, other):
|
929
717
|
return isinstance(other, RC3XGate)
|
@@ -963,46 +751,22 @@ class C4XGate(SingletonControlledGate):
|
|
963
751
|
|
964
752
|
# seems like open controls not happening?
|
965
753
|
def _define(self):
|
966
|
-
"""
|
967
|
-
gate c3sqrtx a,b,c,d
|
968
|
-
{
|
969
|
-
h d; cu1(pi/8) a,d; h d;
|
970
|
-
cx a,b;
|
971
|
-
h d; cu1(-pi/8) b,d; h d;
|
972
|
-
cx a,b;
|
973
|
-
h d; cu1(pi/8) b,d; h d;
|
974
|
-
cx b,c;
|
975
|
-
h d; cu1(-pi/8) c,d; h d;
|
976
|
-
cx a,c;
|
977
|
-
h d; cu1(pi/8) c,d; h d;
|
978
|
-
cx b,c;
|
979
|
-
h d; cu1(-pi/8) c,d; h d;
|
980
|
-
cx a,c;
|
981
|
-
h d; cu1(pi/8) c,d; h d;
|
982
|
-
}
|
983
|
-
gate c4x a,b,c,d,e
|
984
|
-
{
|
985
|
-
h e; cu1(pi/2) d,e; h e;
|
986
|
-
rc3x a,b,c,d;
|
987
|
-
h e; cu1(-pi/2) d,e; h e;
|
988
|
-
rc3x a,b,c,d;
|
989
|
-
c3sqrtx a,b,c,e;
|
990
|
-
}
|
991
|
-
"""
|
754
|
+
"""Default definition"""
|
992
755
|
# pylint: disable=cyclic-import
|
993
756
|
from qiskit.circuit import QuantumCircuit, QuantumRegister
|
994
|
-
from .u1 import CU1Gate
|
995
757
|
from .h import HGate
|
758
|
+
from .p import CPhaseGate
|
996
759
|
|
760
|
+
# This is not a standard gate in Rust
|
997
761
|
q = QuantumRegister(5, name="q")
|
998
762
|
qc = QuantumCircuit(q, name=self.name)
|
999
763
|
rules = [
|
1000
764
|
(HGate(), [q[4]], []),
|
1001
|
-
(
|
765
|
+
(CPhaseGate(numpy.pi / 2), [q[3], q[4]], []),
|
1002
766
|
(HGate(), [q[4]], []),
|
1003
767
|
(RC3XGate(), [q[0], q[1], q[2], q[3]], []),
|
1004
768
|
(HGate(), [q[4]], []),
|
1005
|
-
(
|
769
|
+
(CPhaseGate(-numpy.pi / 2), [q[3], q[4]], []),
|
1006
770
|
(HGate(), [q[4]], []),
|
1007
771
|
(RC3XGate().inverse(), [q[0], q[1], q[2], q[3]], []),
|
1008
772
|
(C3SXGate(), [q[0], q[1], q[2], q[4]], []),
|
@@ -1115,7 +879,25 @@ class MCXGate(ControlledGate):
|
|
1115
879
|
_base_label=None,
|
1116
880
|
):
|
1117
881
|
"""Create new MCX gate."""
|
1118
|
-
|
882
|
+
if self.__class__ in [MCXGate, MCXGrayCode, MCXRecursive, MCXVChain]:
|
883
|
+
# DeprecationWarning for internal subclasses (that are deprecated) is fine. We should
|
884
|
+
# still raise warnings for other subclasses out of our control
|
885
|
+
# TODO MCXGate, MCXGrayCode, MCXRecursive, MCXVChain are deprecated and this path can be
|
886
|
+
# removed once they get removed:
|
887
|
+
# https://github.com/Qiskit/qiskit/pull/12961
|
888
|
+
with warnings.catch_warnings():
|
889
|
+
warnings.filterwarnings(
|
890
|
+
"ignore",
|
891
|
+
category=DeprecationWarning,
|
892
|
+
message=r".+qiskit\.circuit\.library\.standard_gates\.x\.MCXGate\."
|
893
|
+
r"get_num_ancilla_qubits.+",
|
894
|
+
module="qiskit",
|
895
|
+
)
|
896
|
+
num_ancilla_qubits = self.__class__.get_num_ancilla_qubits(num_ctrl_qubits)
|
897
|
+
else:
|
898
|
+
num_ancilla_qubits = self.__class__.get_num_ancilla_qubits(num_ctrl_qubits)
|
899
|
+
|
900
|
+
# alternative: just remove the above
|
1119
901
|
super().__init__(
|
1120
902
|
_name,
|
1121
903
|
num_ctrl_qubits + 1 + num_ancilla_qubits,
|
@@ -1151,8 +933,8 @@ class MCXGate(ControlledGate):
|
|
1151
933
|
"qubits is require, one can create a custom gate by calling the corresponding "
|
1152
934
|
"synthesis function directly."
|
1153
935
|
),
|
1154
|
-
since="1
|
1155
|
-
|
936
|
+
since="2.1",
|
937
|
+
removal_timeline="in Qiskit 3.0",
|
1156
938
|
)
|
1157
939
|
def get_num_ancilla_qubits(num_ctrl_qubits: int, mode: str = "noancilla") -> int:
|
1158
940
|
"""Get the number of required ancilla qubits without instantiating the class.
|
@@ -1179,7 +961,7 @@ class MCXGate(ControlledGate):
|
|
1179
961
|
@property
|
1180
962
|
def num_ancilla_qubits(self):
|
1181
963
|
"""The number of ancilla qubits."""
|
1182
|
-
return self.
|
964
|
+
return self.get_num_ancilla_qubits(self.num_ctrl_qubits)
|
1183
965
|
|
1184
966
|
def control(
|
1185
967
|
self,
|
@@ -1203,16 +985,65 @@ class MCXGate(ControlledGate):
|
|
1203
985
|
"""
|
1204
986
|
if not annotated and ctrl_state is None:
|
1205
987
|
# use __class__ so this works for derived classes
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
988
|
+
if self.__class__ in [MCXGrayCode, MCXRecursive, MCXVChain]:
|
989
|
+
# DeprecationWarning for internal subclasses (that are deprecated) is fine. We should
|
990
|
+
# still raise warnings for other subclasses out of our control
|
991
|
+
# TODO MCXGate, MCXGrayCode, MCXRecursive, MCXVChain are deprecated and this path can be
|
992
|
+
# removed once they get removed:
|
993
|
+
# https://github.com/Qiskit/qiskit/pull/12961
|
994
|
+
with warnings.catch_warnings():
|
995
|
+
warnings.filterwarnings(
|
996
|
+
"ignore",
|
997
|
+
category=DeprecationWarning,
|
998
|
+
module="qiskit",
|
999
|
+
)
|
1000
|
+
gate = self.__class__(
|
1001
|
+
self.num_ctrl_qubits + num_ctrl_qubits,
|
1002
|
+
label=label,
|
1003
|
+
ctrl_state=ctrl_state,
|
1004
|
+
_base_label=self.label,
|
1005
|
+
)
|
1006
|
+
else:
|
1007
|
+
gate = MCXGate(
|
1008
|
+
self.num_ctrl_qubits + num_ctrl_qubits,
|
1009
|
+
label=label,
|
1010
|
+
ctrl_state=ctrl_state,
|
1011
|
+
_base_label=self.label,
|
1012
|
+
)
|
1212
1013
|
else:
|
1213
1014
|
gate = super().control(num_ctrl_qubits, label=label, ctrl_state=ctrl_state)
|
1214
1015
|
return gate
|
1215
1016
|
|
1017
|
+
def copy(self, name=None):
|
1018
|
+
"""
|
1019
|
+
Copy of the instruction.
|
1020
|
+
|
1021
|
+
Args:
|
1022
|
+
name (str): name to be given to the copied circuit, if ``None`` then the name stays the same.
|
1023
|
+
|
1024
|
+
Returns:
|
1025
|
+
qiskit.circuit.Instruction: a copy of the current instruction, with the name updated if it
|
1026
|
+
was provided
|
1027
|
+
"""
|
1028
|
+
if self.__class__ in [MCXGrayCode, MCXRecursive, MCXVChain]:
|
1029
|
+
with warnings.catch_warnings():
|
1030
|
+
warnings.filterwarnings(
|
1031
|
+
"ignore",
|
1032
|
+
category=DeprecationWarning,
|
1033
|
+
message=r".*qiskit\.circuit\.library\.standard_gates\.x.*",
|
1034
|
+
)
|
1035
|
+
return super().copy(name=name)
|
1036
|
+
return super().copy(name=name)
|
1037
|
+
|
1038
|
+
def __deepcopy__(self, memo=None):
|
1039
|
+
if self.__class__ in [MCXGrayCode, MCXRecursive, MCXVChain]:
|
1040
|
+
with warnings.catch_warnings():
|
1041
|
+
warnings.filterwarnings(
|
1042
|
+
"ignore", category=DeprecationWarning, message=".+MCXVChain.+"
|
1043
|
+
)
|
1044
|
+
return super().__deepcopy__(memo=memo)
|
1045
|
+
return super().__deepcopy__(memo=memo)
|
1046
|
+
|
1216
1047
|
|
1217
1048
|
class MCXGrayCode(MCXGate):
|
1218
1049
|
r"""Implement the multi-controlled X gate using the Gray code.
|
@@ -1220,6 +1051,17 @@ class MCXGrayCode(MCXGate):
|
|
1220
1051
|
This delegates the implementation to the MCU1 gate, since :math:`X = H \cdot U1(\pi) \cdot H`.
|
1221
1052
|
"""
|
1222
1053
|
|
1054
|
+
@deprecate_func(
|
1055
|
+
since="2.1",
|
1056
|
+
additional_msg=(
|
1057
|
+
"It is recommended to use MCXGate and let HighLevelSynthesis choose "
|
1058
|
+
"the best synthesis method depending on the number of ancilla qubits available. "
|
1059
|
+
"If this specific synthesis method is required, one can specify it using the "
|
1060
|
+
"high-level-synthesis plugin 'gray_code' for MCX gates, or, alternatively, "
|
1061
|
+
"one can use synth_mcx_gray_code' to construct the gate directly."
|
1062
|
+
),
|
1063
|
+
removal_timeline="in Qiskit 3.0",
|
1064
|
+
)
|
1223
1065
|
def __new__(
|
1224
1066
|
cls,
|
1225
1067
|
num_ctrl_qubits: Optional[int] = None,
|
@@ -1247,17 +1089,6 @@ class MCXGrayCode(MCXGate):
|
|
1247
1089
|
return gate
|
1248
1090
|
return super().__new__(cls)
|
1249
1091
|
|
1250
|
-
@deprecate_func(
|
1251
|
-
additional_msg=(
|
1252
|
-
"It is recommended to use MCXGate and let HighLevelSynthesis choose "
|
1253
|
-
"the best synthesis method depending on the number of ancilla qubits available. "
|
1254
|
-
"If this specific synthesis method is required, one can specify it using the "
|
1255
|
-
"high-level-synthesis plugin `gray_code` for MCX gates, or, alternatively, "
|
1256
|
-
"one can use synth_mcx_gray_code to construct the gate directly."
|
1257
|
-
),
|
1258
|
-
since="1.3",
|
1259
|
-
pending=True,
|
1260
|
-
)
|
1261
1092
|
def __init__(
|
1262
1093
|
self,
|
1263
1094
|
num_ctrl_qubits: int,
|
@@ -1278,7 +1109,10 @@ class MCXGrayCode(MCXGate):
|
|
1278
1109
|
Returns:
|
1279
1110
|
MCXGrayCode: inverse gate (self-inverse).
|
1280
1111
|
"""
|
1281
|
-
|
1112
|
+
with warnings.catch_warnings():
|
1113
|
+
warnings.filterwarnings("ignore", category=DeprecationWarning, module="qiskit")
|
1114
|
+
inverse = MCXGrayCode(num_ctrl_qubits=self.num_ctrl_qubits, ctrl_state=self.ctrl_state)
|
1115
|
+
return inverse
|
1282
1116
|
|
1283
1117
|
def _define(self):
|
1284
1118
|
"""Define the MCX gate using the Gray code."""
|
@@ -1303,16 +1137,26 @@ class MCXRecursive(MCXGate):
|
|
1303
1137
|
"""
|
1304
1138
|
|
1305
1139
|
@deprecate_func(
|
1140
|
+
since="2.1",
|
1306
1141
|
additional_msg=(
|
1307
1142
|
"It is recommended to use MCXGate and let HighLevelSynthesis choose "
|
1308
1143
|
"the best synthesis method depending on the number of ancilla qubits available. "
|
1309
1144
|
"If this specific synthesis method is required, one can specify it using the "
|
1310
|
-
"high-level-synthesis plugin '
|
1311
|
-
"one can use synth_mcx_1_clean to construct the gate directly."
|
1145
|
+
"high-level-synthesis plugin ``'gray_code'`` for MCX gates, or, alternatively, "
|
1146
|
+
"one can use ``'synth_mcx_1_clean'`` to construct the gate directly."
|
1312
1147
|
),
|
1313
|
-
|
1314
|
-
pending=True,
|
1148
|
+
removal_timeline="in Qiskit 3.0",
|
1315
1149
|
)
|
1150
|
+
def __new__(
|
1151
|
+
cls,
|
1152
|
+
num_ctrl_qubits: Optional[int] = None,
|
1153
|
+
label: Optional[str] = None,
|
1154
|
+
ctrl_state: Optional[Union[str, int]] = None,
|
1155
|
+
*,
|
1156
|
+
_base_label=None,
|
1157
|
+
):
|
1158
|
+
return super().__new__(cls, num_ctrl_qubits, label, ctrl_state, _base_label=_base_label)
|
1159
|
+
|
1316
1160
|
def __init__(
|
1317
1161
|
self,
|
1318
1162
|
num_ctrl_qubits: int,
|
@@ -1346,7 +1190,10 @@ class MCXRecursive(MCXGate):
|
|
1346
1190
|
Returns:
|
1347
1191
|
MCXRecursive: inverse gate (self-inverse).
|
1348
1192
|
"""
|
1349
|
-
|
1193
|
+
with warnings.catch_warnings():
|
1194
|
+
warnings.filterwarnings("ignore", category=DeprecationWarning, module="qiskit")
|
1195
|
+
inverse = MCXRecursive(num_ctrl_qubits=self.num_ctrl_qubits, ctrl_state=self.ctrl_state)
|
1196
|
+
return inverse
|
1350
1197
|
|
1351
1198
|
def _define(self):
|
1352
1199
|
"""Define the MCX gate using recursion."""
|
@@ -1361,6 +1208,18 @@ class MCXRecursive(MCXGate):
|
|
1361
1208
|
class MCXVChain(MCXGate):
|
1362
1209
|
"""Implement the multi-controlled X gate using a V-chain of CX gates."""
|
1363
1210
|
|
1211
|
+
@deprecate_func(
|
1212
|
+
since="2.1",
|
1213
|
+
additional_msg=(
|
1214
|
+
"It is recommended to use MCXGate and let HighLevelSynthesis choose "
|
1215
|
+
"the best synthesis method depending on the number of ancilla qubits available. "
|
1216
|
+
"If this specific synthesis method is required, one can specify it using the "
|
1217
|
+
"high-level-synthesis plugins `n_clean_m15` (using clean ancillas) or "
|
1218
|
+
"`n_dirty_i15` (using dirty ancillas) for MCX gates. Alternatively, one can "
|
1219
|
+
"use synth_mcx_n_dirty_i15 and synth_mcx_n_clean_m15 to construct the gate directly."
|
1220
|
+
),
|
1221
|
+
removal_timeline="in Qiskit 3.0",
|
1222
|
+
)
|
1364
1223
|
def __new__(
|
1365
1224
|
cls,
|
1366
1225
|
num_ctrl_qubits: Optional[int] = None,
|
@@ -1384,18 +1243,6 @@ class MCXVChain(MCXGate):
|
|
1384
1243
|
_base_label=_base_label,
|
1385
1244
|
)
|
1386
1245
|
|
1387
|
-
@deprecate_func(
|
1388
|
-
additional_msg=(
|
1389
|
-
"It is recommended to use MCXGate and let HighLevelSynthesis choose "
|
1390
|
-
"the best synthesis method depending on the number of ancilla qubits available. "
|
1391
|
-
"If this specific synthesis method is required, one can specify it using the "
|
1392
|
-
"high-level-synthesis plugins `n_clean_m15` (using clean ancillas) or "
|
1393
|
-
"`n_dirty_i15` (using dirty ancillas) for MCX gates. Alternatively, one can "
|
1394
|
-
"use synth_mcx_n_dirty_i15 and synth_mcx_n_clean_m15 to construct the gate directly."
|
1395
|
-
),
|
1396
|
-
since="1.3",
|
1397
|
-
pending=True,
|
1398
|
-
)
|
1399
1246
|
def __init__(
|
1400
1247
|
self,
|
1401
1248
|
num_ctrl_qubits: int,
|
@@ -1446,13 +1293,20 @@ class MCXVChain(MCXGate):
|
|
1446
1293
|
Returns:
|
1447
1294
|
MCXVChain: inverse gate (self-inverse).
|
1448
1295
|
"""
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1296
|
+
with warnings.catch_warnings():
|
1297
|
+
warnings.filterwarnings(
|
1298
|
+
"ignore",
|
1299
|
+
category=DeprecationWarning,
|
1300
|
+
message=r".+qiskit\.circuit\.library\.standard_gates\.x\.MCXVChain\..+",
|
1301
|
+
)
|
1302
|
+
inverse = MCXVChain(
|
1303
|
+
num_ctrl_qubits=self.num_ctrl_qubits,
|
1304
|
+
dirty_ancillas=self._dirty_ancillas,
|
1305
|
+
ctrl_state=self.ctrl_state,
|
1306
|
+
relative_phase=self._relative_phase,
|
1307
|
+
action_only=self._action_only,
|
1308
|
+
)
|
1309
|
+
return inverse
|
1456
1310
|
|
1457
1311
|
@staticmethod
|
1458
1312
|
def get_num_ancilla_qubits(num_ctrl_qubits: int, mode: str = "v-chain"):
|