# How to define a Clifford Gate while given a tableau in Google Cirq?

I would like to uniformly sample from the group of random Clifford gates. I am aware of the paper https://arxiv.org/abs/2003.09412 where they have designed the algorithm to do this task and even provided a Python implementation of it. The algorithm outputs a Clifford tableau uniformly sampled from the corresonding Clifford group. I would like to define a Clifford gate with this tableau in Google Cirq - is there any simple way to do that?

• What do you want to do with it in cirq? How many qubits are we talking about here: less than 10? More than 100? This exact method is the one used by stim.Tableau.random, but there's nothing in stimcirq to convert that tableau into a cirq object at the moment. Jun 11 at 18:50
• Thanks for the response! The number of qubits N to be simulated is ideally of order few hundred with a circuit depth O(N). I most likely do not need anything beyond 3-qubit random Clifford. Within Cirq I guess one possibility might be to use clifford decomposition into a list of 1 and 2 qubit operations (cirq.decompose_clifford_tableau_to_operations: github.com/quantumlib/Cirq/blob/v0.14.1/cirq-core/cirq/… ) and create a Clifford Tableau by simply specifying the state - but this sounds like a bit of an overkill... Jun 11 at 20:41
• @CatQubit There is a way but it's fairly involved. Assuming this is a full tableau (i.e. it has the stabilisers + logicals + destabilisers) then it corresponds to a symplectic matrix. This matrix can be ("Bruhat") decomposed as a product of simpler matrices which are then mapped to clifford circuits (CNOT's + phase + hadarmard). See this for details arxiv.org/pdf/1803.06987.pdf Jun 11 at 21:39
• If you're working with hundreds of qubits then you're probably doing a pure stabilizer simulation. In that case I'd recommend giving stim.TableauSimulator a try for your specific problem. Cirq's stabilizer simulation stuff is really minimal, and not optimized for performance. I watch this stack exchange for stim questions so you'd get answers relatively quickly. (That being said, I might be a bit biased since I made stim. But then again I guess I also wrote and drove a large part of cirq. Maybe it all cancels out.) Jun 11 at 23:17
• @CraigGidney is it then possible to implement say a layer of 2 qubit random Clifford gates between selected qubits in stim? I understand that normally one would use combination of stim.Tableau.random and stim.TableauSimulator().set_inverse_tableau but it does not seem to allow to specify on which qubits I apply these operations and set_inverse_tableau overwrites the previous number of qubits I might have had. Furthermore, is there any way to bypass the stim limitation and apply a non-Pauli gate as a feedback? I do not require this latter operation to be efficient neccesarily. Jun 12 at 15:23