Skip to content

Commit

Permalink
CSXGate (#296)
Browse files Browse the repository at this point in the history
* sxgate

* Add t rotation

* Tests pass

* Black

---------

Co-authored-by: Caleb Johnson <[email protected]>
  • Loading branch information
garrison and caleb-johnson committed Jul 5, 2023
1 parent 66baddb commit cf0017a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions circuit_knitting/cutting/qpd/qpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
ZGate,
HGate,
SGate,
TGate,
SdgGate,
RXGate,
RYGate,
Expand All @@ -46,6 +47,7 @@
CRXGate,
CRYGate,
CRZGate,
CSXGate,
)

from .qpd_basis import QPDBasis
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/cutting/qpd/test_qpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
2 changes: 2 additions & 0 deletions test/cutting/test_cutting_roundtrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
CRXGate,
CRYGate,
CRZGate,
CSXGate,
)
from qiskit.extensions import UnitaryGate
from qiskit.quantum_info import PauliList, random_unitary
Expand All @@ -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)],
Expand Down

0 comments on commit cf0017a

Please sign in to comment.