Suppose you are given the following quantum circuit in Qiskit:
from numpy import pi
from qiskit import QuantumCircuit
angle = pi / 3
qc = QuantumCircuit(1)
qc.ry(angle, 0)
qc.ry(-angle, 0)
qc.draw('mpl')
The circuit simply performs two rotations around the $y$-axis with angle $\theta = \pi/3$ and then $-\theta$. These operations should be resolved in a simple identity because $I = R_y(-\theta) R_y(\theta)$. However, the Qiskit transpile
function seems not to do the job as expected in this case:
from qiskit import transpile
tqc = transpile(qc, optimization_level=3)
tqc.draw('mpl')
Moreover, trying exactly the same thing with $R_x$ (qc.rx
) or $R_z$ (qc.rz
) rotations, the transpilation runs perfectly returning an empty circuit. Is this a bug in Qiskit? Or maybe I'm missing something?