Skip to content

Commit

Permalink
Add more 1q and 2q Pauli rotation equivalences (#7407)
Browse files Browse the repository at this point in the history
* added rx to equevalence library

* fixed sign in ry_to_rx

* added rzz to rxx

* gate correction

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* added ryyrzz, rxxrzz, rzzryy translations, fixed ryrx translation to a more logical variant

* fixed errors

* Add Ryy to Rxx equivalence

* Add release note

---------

Co-authored-by: artemiyburov <artemiy.v.burov@gmail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
  • Loading branch information
4 people authored Jun 20, 2023
1 parent 93a8172 commit 9ef34b7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
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>`__.

0 comments on commit 9ef34b7

Please sign in to comment.