Skip to content

Clifford protocols #7463

Open
Enhancement
@daxfohl

Description

@daxfohl

Is your design idea/issue related to a use case or problem? Please explain

SV, MPS, and DM simulators use apply_unitary, apply_mixture, and apply_channel protocols for simulating each step of a circuit. This makes them flexible and able to work with third-party gates easily. The Clifford simulators (both tableau and ch-form) use reflection to check for specific (Pauli, controlled-Pauli, sqrt-Pauli, and measurement) gate types, and fall back to decomposition. This makes it harder and slower when using other gate types, which is especially unfortunate because there is a whole set of CliffordGates in Cirq itself that require decomposition when simulating.

Describe your design idea/issue

Create a set of Clifford protocols that work like the other simulator protocols, with clifford, apply_clifford, has_clifford. (Would there need to be one set for clifford_tableau and a separate set for clifford_ch_form, or could a single set of Clifford protocols serve both purposes? Not sure offhand.), and have the Clifford simulators use them instead of reflection and special-casing. This way, both the Pauli gates and the CliffordGates could implement these protocols, as well as could any third parties, allowing faster simulation without having to resort to decomposition so much. Optimizations for things like SWAP gates could be included by coding the swap gate's Clifford protocol implementation instead of having to build it into the Clifford simulators.

NB: maybe the "apply" protocol is the only useful one here? If one asks for the unitary of a (unitary) gate, that's a well-defined structure, so a "unitary" protocol makes sense. Is there some similar structure that represents the "Clifford" of a (Clifford) gate? Probably? But IDK offhand.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions