Skip to content

Commit

Permalink
Use parameterless gates where possible
Browse files Browse the repository at this point in the history
Now that Qiskit supports singleton gates, we might as well use
parameterless gates in each place possible to take advantage of
this.
  • Loading branch information
garrison committed Sep 29, 2023
1 parent 54ca9c6 commit 19cb883
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
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

0 comments on commit 19cb883

Please sign in to comment.