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

Use parameterless gates where possible #425

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions circuit_knitting/cutting/qpd/qpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ def _(gate: RXXGate | RYYGate | RZZGate | CRXGate | CRYGate | CRZGate):
# https://iopscience.iop.org/article/10.1088/1367-2630/abd7bc/pdf
if gate.name in ("rxx", "crx"):
pauli = XGate()
r_plus = RXGate(0.5 * np.pi)
r_plus = SXGate()
# x basis measurement (and back again)
measurement_0 = [HGate(), QPDMeasure(), HGate()]
elif gate.name in ("ryy", "cry"):
Expand All @@ -869,7 +869,7 @@ def _(gate: RXXGate | RYYGate | RZZGate | CRXGate | CRYGate | CRZGate):
else:
assert gate.name in ("rzz", "crz")
pauli = ZGate()
r_plus = RZGate(0.5 * np.pi)
r_plus = SGate()
# z basis measurement
measurement_0 = [QPDMeasure()]

Expand Down Expand Up @@ -901,7 +901,7 @@ def _(gate: RXXGate | RYYGate | RZZGate | CRXGate | CRYGate | CRZGate):
operations.append(SdgGate())
operations.insert(0, HGate())
operations.append(HGate())
rot = type(r_plus)(-theta)
rot = {"x": RXGate, "y": RYGate, "z": RZGate}[gate.name[2]](-theta)
for operations in unique_by_id(m[1] for m in maps):
operations.append(rot)

Expand Down
2 changes: 1 addition & 1 deletion test/cutting/qpd/test_qpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def test_decompose_qpd_instructions(self):
creg = ClassicalRegister(1, name="qpd_measurements")
dx_circ_truth.add_register(creg)
dx_circ_truth.h(0)
dx_circ_truth.rx(np.pi / 2, 1)
dx_circ_truth.sx(1)
dx_circ_truth.measure(0, 0)
dx_circ_truth.h(0)
dx_circ = decompose_qpd_instructions(qpd_circ, [[0]], [2])
Expand Down
8 changes: 4 additions & 4 deletions test/cutting/qpd/test_qpd_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class TestQPDBasis(unittest.TestCase):
def setUp(self):
# RXX decomp
x_gate = XGate()
x_r_plus = RXGate(1 * np.pi / 2)
x_r_minus = RXGate(-1 * np.pi / 2)
x_r_plus = SXGate()
x_r_minus = SXdgGate()
x_measure = [HGate(), QPDMeasure(), HGate()]
self.truth_rxx_maps = [
([], []),
Expand Down Expand Up @@ -72,8 +72,8 @@ def setUp(self):

# RZZ decomp
z_gate = ZGate()
z_r_plus = RZGate(1 * np.pi / 2)
z_r_minus = RZGate(-1 * np.pi / 2)
z_r_plus = SGate()
z_r_minus = SdgGate()
z_measure = [QPDMeasure()]
self.truth_rzz_maps = [
([], []),
Expand Down