Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a supported_gates function #277

Merged
merged 8 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions circuit_knitting/cutting/qpd/qpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,16 @@ def qpdbasis_from_gate(gate: Gate) -> QPDBasis:
return f(gate)


def supported_gates() -> set[str]:
caleb-johnson marked this conversation as resolved.
Show resolved Hide resolved
"""
Return a set of gate names supported for automatic decomposition.

Returns:
Set of gate names supported for automatic decomposition.
"""
return {"rxx", "ryy", "rzz", "crx", "cry", "crz", "cx", "cz"}
caleb-johnson marked this conversation as resolved.
Show resolved Hide resolved


@_register_qpdbasis_from_gate("rxx", "ryy", "rzz", "crx", "cry", "crz")
def _(gate: RXXGate | RYYGate | RZZGate | CRXGate | CRYGate | CRZGate):
# Constructing a virtual two-qubit gate by sampling single-qubit operations - Mitarai et al
Expand Down
4 changes: 4 additions & 0 deletions releasenotes/notes/supported-gates-d2156f58bc07fc7a.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
upgrade:
- |
Addition of :func:`~circuit_knitting.cutting.qpd.supported_gates` function, which returns the names of all gates which may be automatically decomposed using :func:`~circuit_knitting.cutting.qpd.qpdbasis_from_gate`.
4 changes: 4 additions & 0 deletions test/cutting/qpd/test_qpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,7 @@ def test_qpdbasis_from_gate_unique_maps(
]
assert len(unique_by_eq(a for (a, b) in relevant_maps)) == q0_num_unique
assert len(unique_by_eq(b for (a, b) in relevant_maps)) == q1_num_unique

def test_supported_gates(self):
gates = supported_gates()
self.assertEqual({"rxx", "ryy", "rzz", "crx", "cry", "crz", "cx", "cz"}, gates)