Skip to content

Commit

Permalink
Add support for CSXGate().inverse() (#379)
Browse files Browse the repository at this point in the history
Fixes #309
  • Loading branch information
garrison authored Aug 22, 2023
1 parent 9cc17ed commit d933abc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions circuit_knitting/cutting/qpd/qpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from qiskit.circuit import (
QuantumCircuit,
Gate,
ControlledGate,
Instruction,
ClassicalRegister,
CircuitInstruction,
Expand All @@ -41,6 +42,7 @@
SXGate,
SXdgGate,
TGate,
TdgGate,
RXGate,
RYGate,
RZGate,
Expand Down Expand Up @@ -953,6 +955,14 @@ def _(gate: CSXGate):
return retval


@_register_qpdbasis_from_instruction("csxdg")
def _(gate: ControlledGate):
retval = qpdbasis_from_instruction(CRXGate(-np.pi / 2))
for operations in unique_by_id(m[0] for m in retval.maps):
operations.insert(0, TdgGate())
return retval


@_register_qpdbasis_from_instruction("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
2 changes: 2 additions & 0 deletions test/cutting/qpd/test_qpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ def test_decompose_qpd_instructions(self):
(CSGate(), 1 + np.sqrt(2)),
(CSdgGate(), 1 + np.sqrt(2)),
(CSXGate(), 1 + np.sqrt(2)),
(CSXGate().inverse(), 1 + np.sqrt(2)),
(SwapGate(), 7),
(iSwapGate(), 7),
(DCXGate(), 7),
Expand Down Expand Up @@ -442,6 +443,7 @@ def test_explicitly_supported_gates(self):
"cz",
"ch",
"csx",
"csxdg",
"cs",
"csdg",
"cp",
Expand Down
1 change: 1 addition & 0 deletions test/cutting/test_cutting_roundtrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def append_random_unitary(circuit: QuantumCircuit, qubits):
[CHGate()],
[ECRGate()],
[CSXGate()],
[CSXGate().inverse()],
[CSGate()],
[CSdgGate()],
[RYYGate(0.0)],
Expand Down

0 comments on commit d933abc

Please sign in to comment.