transpiler introduces non-clifford gates in a purely clifford circuit
ajavadia opened this issue · comments
Environment
- Qiskit version: 1.1
- Python version: 3.10
- Operating system: macOS
What is happening?
Given a circuit with only clifford gates (i.e all angles multiples of pi/2), the transpiler sometimes introduces non-clifford angles. This can be a problem as many optimizations work best when dealing with Clifford angles rather than arbitrary angles, so the transpiler is making it harder for downstream passes.
How can we reproduce the issue?
consider the following example circuit
OPENQASM 2.0;
include "qelib1.inc";
qreg q[5];
u2(-pi,0) q[1];
u2(-pi,0) q[2];
u2(-pi,0) q[3];
u2(-pi,0) q[4];
cx q[4],q[0];
ry(-pi/2) q[4];
cx q[4],q[0];
u2(-pi,-pi) q[4];
cx q[3],q[4];
ry(-pi/2) q[3];
ry(-pi/2) q[4];
This circuit is purely Clifford (i.e. all angles are integer multiples of pi/2). However when transpiled with optimization levels 1 and above, the transpiler introduces non-clifford angles.
What should happen?
The transpiler should preserve the clifford property of circuits and not introduce arbitrary angles.
Any suggestions?
The culprit is probably OneQubitEulerDecomposer or TwoQubitBasisDecomposer although I have not investigated deeply.