Skip to content

Commit

Permalink
Merge branch 'main' into ecr
Browse files Browse the repository at this point in the history
  • Loading branch information
garrison committed Jun 27, 2023
2 parents a4332f4 + b896f4c commit 551bc66
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
26 changes: 19 additions & 7 deletions circuit_knitting/cutting/qpd/qpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
RYGate,
RZGate,
CXGate,
CYGate,
CZGate,
CHGate,
RXXGate,
RYYGate,
RZZGate,
Expand Down Expand Up @@ -193,15 +195,18 @@ def qpdbasis_from_gate(gate: Gate) -> QPDBasis:
"""
Generate a QPDBasis object, given a supported operation.
This method currently supports 8 operations:
This method currently supports 11 operations:
- :class:`~qiskit.circuit.library.RXXGate`
- :class:`~qiskit.circuit.library.RYYGate`
- :class:`~qiskit.circuit.library.RZZGate`
- :class:`~qiskit.circuit.library.CRXGate`
- :class:`~qiskit.circuit.library.CRYGate`
- :class:`~qiskit.circuit.library.CRZGate`
- :class:`~qiskit.circuit.library.CXGate`
- :class:`~qiskit.circuit.library.CYGate`
- :class:`~qiskit.circuit.library.CZGate`
- :class:`~qiskit.circuit.library.CHGate`
- :class:`~qiskit.circuit.library.ECRGate`
Returns:
The newly-instantiated :class:`QPDBasis` object
Expand Down Expand Up @@ -306,8 +311,8 @@ def _(gate: RXXGate | RYYGate | RZZGate | CRXGate | CRYGate | CRZGate):
return QPDBasis(maps, coeffs)


@_register_qpdbasis_from_gate("cz", "cx")
def _(gate: CZGate | CXGate):
@_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
# https://iopscience.iop.org/article/10.1088/1367-2630/abd7bc/pdf
measurement_0 = [SdgGate(), QPDMeasure()]
Expand All @@ -325,12 +330,19 @@ def _(gate: CZGate | CXGate):
([ZGate()], measurement_1),
]

if gate.name == "cx":
# Modify `maps` to sandwich the target operations inside of Hadamards
if gate.name != "cz":
# Modify `maps` to sandwich the target operations inside of basis rotations
for operations in unique_by_id(m[1] for m in maps):
if operations:
operations.insert(0, HGate())
operations.append(HGate())
if gate.name in ("cx", "cy"):
operations.insert(0, HGate())
operations.append(HGate())
if gate.name == "cy":
operations.insert(0, SdgGate())
operations.append(SGate())
elif gate.name == "ch":
operations.insert(0, RYGate(-np.pi / 4))
operations.append(RYGate(np.pi / 4))

coeffs = [0.5, 0.5, 0.5, -0.5, 0.5, -0.5]

Expand Down
7 changes: 7 additions & 0 deletions releasenotes/notes/additional-gates-f4ed6c0e8dc3a9be.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
features:
- |
This release adds support for additional cut gates:
- :class:`~qiskit.circuit.library.CHGate`
- :class:`~qiskit.circuit.library.CYGate`
- :class:`~qiskit.circuit.library.ECRGate`
5 changes: 4 additions & 1 deletion test/cutting/qpd/test_qpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,7 @@ def test_qpdbasis_from_gate_unique_maps(

def test_supported_gates(self):
gates = supported_gates()
self.assertEqual({"rxx", "ryy", "rzz", "crx", "cry", "crz", "cx", "cz", "ecr"}, gates)
self.assertEqual(
{"rxx", "ryy", "rzz", "crx", "cry", "crz", "cx", "cy", "cz", "ch", "ecr"},
gates,
)
4 changes: 4 additions & 0 deletions test/cutting/test_cutting_roundtrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
RXXGate,
RYYGate,
RZZGate,
CHGate,
CXGate,
CYGate,
CZGate,
CRXGate,
CRYGate,
Expand Down Expand Up @@ -50,8 +52,10 @@ def append_random_unitary(circuit: QuantumCircuit, qubits):
@pytest.fixture(
params=[
[CXGate()],
[CYGate()],
[CZGate()],
[ECRGate()],
[CHGate()],
[RYYGate(0.0)],
[RZZGate(np.pi)],
[RXXGate(np.pi / 3)],
Expand Down

0 comments on commit 551bc66

Please sign in to comment.