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.24k stars 2.36k forks source link

Add `Clifford.from_operation` to shortcut checking matrix representation #9576

Open kdk opened 1 year ago

kdk commented 1 year ago

From https://github.com/Qiskit/qiskit-terra/pull/9475:

@ShellyGarion 's comment is hinting that another thing that would be nice to have is something like Clifford.from_operation or similar, that could rely on methods that might be quicker than generating and checking the unitary matrix representation.

For example, checking if the name is in the list of hard coded names in _BASIS_1Q/_BASIS_2Q to know if an Instruction is Clifford, or utilizing the equivalence library to see if a Gate has an all Clifford decomposition, or for cases like the parameterized rotations where there may be a simple arithmetic check on the params to know if it is Clifford.

Additionally, the same methods could be available to know quickly if an unknown operation is_clifford.

Opening this issue to discuss how and where we can include such checks for Clifford, and for the other Operation subclasses more generally.

ShellyGarion commented 1 year ago

See more details here: https://github.com/Qiskit/qiskit-terra/pull/9475#issuecomment-1431014041

alexanderivrii commented 1 year ago

It would be also good to directly create Cliffords from LinearFunctions or from quantum circuits containing LinearFunctions. We can actually create Cliffords from linear functions already, however this requires first building the the definition of a linear function and then constructing Clifford out of that, while the much simpler direct method is also possible (if the linear function has matrix A, then the Clifford's stabilizer tableau will be something like [A^T, 0; 0, A]).

Additionally, it would be nice to create Cliffords from new PermutationGates (and because PermutationGates do not have definitions, we currently are not able to do it at all).

ShellyGarion commented 1 year ago

The main question is whether Clifford.from_operation is needed or is it enough to use the existing Clifford.from_circuit, where the circuit could contain any Operations that are Clifford (including: LinearFunction, Permutation, Rz(pi) etc.)

ShellyGarion commented 1 year ago

See the discussion in #9582