From cf0017a3ebd3a6e6f48b59b8dc8aa5a3b637b29e Mon Sep 17 00:00:00 2001 From: Jim Garrison Date: Fri, 30 Jun 2023 15:14:17 -0400 Subject: [PATCH] `CSXGate` (#296) * sxgate * Add t rotation * Tests pass * Black --------- Co-authored-by: Caleb Johnson --- circuit_knitting/cutting/qpd/qpd.py | 10 ++++++++++ test/cutting/qpd/test_qpd.py | 3 ++- test/cutting/test_cutting_roundtrip.py | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/circuit_knitting/cutting/qpd/qpd.py b/circuit_knitting/cutting/qpd/qpd.py index 6771798c0..9f3d34d01 100644 --- a/circuit_knitting/cutting/qpd/qpd.py +++ b/circuit_knitting/cutting/qpd/qpd.py @@ -32,6 +32,7 @@ ZGate, HGate, SGate, + TGate, SdgGate, RXGate, RYGate, @@ -46,6 +47,7 @@ CRXGate, CRYGate, CRZGate, + CSXGate, ) from .qpd_basis import QPDBasis @@ -308,6 +310,14 @@ def _(gate: RXXGate | RYYGate | RZZGate | CRXGate | CRYGate | CRZGate): return QPDBasis(maps, coeffs) +@_register_qpdbasis_from_gate("csx") +def _(gate: CSXGate): + retval = qpdbasis_from_gate(CRXGate(np.pi / 2)) + for operations in unique_by_id(m[0] for m in retval.maps): + operations.insert(0, TGate()) + return retval + + @_register_qpdbasis_from_gate("cx", "cy", "cz", "ch") def _(gate: CXGate | CYGate | CZGate | CHGate): # Constructing a virtual two-qubit gate by sampling single-qubit operations - Mitarai et al diff --git a/test/cutting/qpd/test_qpd.py b/test/cutting/qpd/test_qpd.py index 144b2849d..bed100af5 100644 --- a/test/cutting/qpd/test_qpd.py +++ b/test/cutting/qpd/test_qpd.py @@ -283,5 +283,6 @@ def test_qpdbasis_from_gate_unique_maps( def test_supported_gates(self): gates = supported_gates() self.assertEqual( - {"rxx", "ryy", "rzz", "crx", "cry", "crz", "cx", "cy", "cz", "ch"}, gates + {"rxx", "ryy", "rzz", "crx", "cry", "crz", "cx", "cy", "cz", "ch", "csx"}, + gates, ) diff --git a/test/cutting/test_cutting_roundtrip.py b/test/cutting/test_cutting_roundtrip.py index be36cbacd..9ce5ecbc7 100644 --- a/test/cutting/test_cutting_roundtrip.py +++ b/test/cutting/test_cutting_roundtrip.py @@ -28,6 +28,7 @@ CRXGate, CRYGate, CRZGate, + CSXGate, ) from qiskit.extensions import UnitaryGate from qiskit.quantum_info import PauliList, random_unitary @@ -54,6 +55,7 @@ def append_random_unitary(circuit: QuantumCircuit, qubits): [CYGate()], [CZGate()], [CHGate()], + [CSXGate()], [RYYGate(0.0)], [RZZGate(np.pi)], [RXXGate(np.pi / 3)],