Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.28k stars 2.37k forks source link

`Pauli.evolve()` should recognize common rotations by (n*pi/2) as Clifford gates #12085

Open aeddins-ibm opened 7 months ago

aeddins-ibm commented 7 months ago

Environment

What is happening?

qc = QuantumCircuit(1)
qc.rz(np.pi)
qi.Pauli('X').evolve(qc)

The above call to evolve() raises an error even though qc contains only Clifford gates.

For comparison, qiskit_aer's AerSimulator with method='stabilizer' does not have this problem. Transpiling for this backend leaves the circuit invariant (does not turn the rz into a z), so I can't use that as a quick workaround.

How can we reproduce the issue?

qc = QuantumCircuit(1)
qc.rz(np.pi)
qi.Pauli('X').evolve(qc)

What should happen?

Common 1- and 2-qubit rotations (rx, ry, rz, rxx, ...) should be recognized as Clifford gates when their gate angles are multiples of pi/2, and the Pauli should evolve successfully. (if not gate_angle%(np.pi/2): ...)

Related: #12086

Any suggestions?

No response

ShellyGarion commented 7 months ago

Currently, the RZGate(np.pi) is a Clifford gate, and can be transformed into a Clifford operator, so this code should work:

from qiskit.quantum_info import *
qc = QuantumCircuit(1)
qc.rz(np.pi, 0)
cliff = Clifford(qc)
Pauli('X').evolve(cliff)

but since the RZGate definition contains non-Clifford gates, when appending it to a QuantumCircuit, it's being decomposed into non-Clifford gates, and that's why your code doesn't work.

ShellyGarion commented 7 months ago

See also the discussion here: https://github.com/Qiskit/qiskit/issues/9576 and here: https://github.com/Qiskit/qiskit/pull/9475#issuecomment-1431014041

ShellyGarion commented 7 months ago

I think that this can be handled similarly to the way that the RZGate was added to the Clifford class in https://github.com/Qiskit/qiskit/pull/9475