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 more 1q and 2q Pauli rotation equivalences #7407

Merged
merged 15 commits into from
Jun 20, 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
29 changes: 28 additions & 1 deletion qiskit/circuit/library/standard_gates/equivalence_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,13 @@
def_ry.append(RGate(theta, pi / 2), [q[0]], [])
_sel.add_equivalence(RYGate(theta), def_ry)

q = QuantumRegister(1, "q")
ry_to_rx = QuantumCircuit(q)
ry_to_rx.sdg(0)
ry_to_rx.rx(theta, 0)
ry_to_rx.s(0)
_sel.add_equivalence(RYGate(theta), ry_to_rx)

# CRYGate
#
# q_0: ────■──── q_0: ─────────────■────────────────■──
Expand Down Expand Up @@ -451,6 +458,20 @@
ryy_to_rzz.append(inst, qargs, cargs)
_sel.add_equivalence(RYYGate(theta), ryy_to_rzz)

# RYY to RXX
q = QuantumRegister(2, "q")
theta = Parameter("theta")
ryy_to_rxx = QuantumCircuit(q)
for inst, qargs, cargs in [
(SdgGate(), [q[0]], []),
(SdgGate(), [q[1]], []),
(RXXGate(theta), [q[0], q[1]], []),
(SGate(), [q[0]], []),
(SGate(), [q[1]], []),
]:
ryy_to_rxx.append(inst, qargs, cargs)
_sel.add_equivalence(RYYGate(theta), ryy_to_rxx)

# RZGate
# global phase: -ϴ/2
# ┌───────┐ ┌───────┐
Expand All @@ -474,6 +495,13 @@
rz_to_sxry.sxdg(0)
_sel.add_equivalence(RZGate(theta), rz_to_sxry)

q = QuantumRegister(1, "q")
rz_to_rx = QuantumCircuit(q)
rz_to_rx.h(0)
rz_to_rx.rx(theta, 0)
rz_to_rx.h(0)
_sel.add_equivalence(RZGate(theta), rz_to_rx)

# CRZGate
#
# q_0: ────■──── q_0: ─────────────■────────────────■──
Expand Down Expand Up @@ -588,7 +616,6 @@
rzz_to_ryy.append(inst, qargs, cargs)
_sel.add_equivalence(RZZGate(theta), rzz_to_ryy)


# RZXGate
#
# ┌─────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
features:
- |
The transpiler's built-in :class:`.EquivalenceLibrary` has been taught more Pauli-rotation
equivalences between the one-qubit :math:`R_X`, :math:`R_Y` and :math:`R_Z` gates, and between
the two-qubit :math:`R_{XX}`, :math:`R_{YY}` and :math:`R_{ZZ}` gates. This should make
simple basis translations more reliable, especially circuits that use :math:`Y` rotations.
See `#7332 <https://github.com/Qiskit/qiskit-terra/issues/7332>`__.