Within stim stim.Tableau.random(n) returns a random sample from $n$-qubit Clifford group using algorithm described here https://arxiv.org/pdf/2003.09412.pdf. Is there any function in stim or any relatively simple way of modifying stim.Tableau.random() which instead of sampling the group uniformly would simply return all the elements of the $n$-qubit Clifford group (for $n<5$)? (Brute-forcing by sampling the group and keeping matrices in the list only if they have not appeared there yet sounds very inefficient for $n>2$ given the expected number of elements being at least of order $10^8$).

  • $\begingroup$ This is sequence for orders of clifford group oeis.org/A003956 for n=4 it's 743178240 ... so not realistic to list all of them $\endgroup$
    – unknown
    Jul 8 at 19:11
  • $\begingroup$ I mostly care about the way of generating these for n=2 and n=3 which is more efficient than the brute-force and a simple modification of what is available in the already existing implementations... $\endgroup$
    – CatQubit
    Jul 8 at 19:21
  • 1
    $\begingroup$ @unknown Just a few hundred million? A computer would do that no problem. You probably don't want to print them, but you could for example do a short simulation with each one. $\endgroup$ Jul 8 at 19:25
  • $\begingroup$ I guess "realistic" is subjective. Actually if all you need are the tableaux then you can mod out the Pauli group. If you work with the real clifford group then the tableaux correspond to elements of the orthogonal group over $GF(2)$...see this related post math.stackexchange.com/questions/4170129/… (real pauli group is same as extraspecial group in the post) $\endgroup$
    – unknown
    Jul 8 at 20:05
  • 1
    $\begingroup$ @unknown The number you quoted has an extra factor of 8 for global phase, and it's for n=3 not for n=4. There are 92 897 280 observably distinguishable Cliffords for n=3. $\endgroup$ Jul 8 at 20:19

1 Answer 1


The method stim.Tableau.iter_all iterates over all tableaus. This method doesn't exist in 1.9 (the current stable version), but you can get it in the latest dev version of 1.10: pip install stim==1.10.dev1657673691.

You can count that there are 24 single qubit Clifford operations (up to global phase):

import stim
from typing import List

rotations: List[stim.Tableau] = []
for tab in stim.Tableau.iter_all(1):
assert len(rotations) == 24

# Verify they're distinct.
assert len(set(repr(e) for e in rotations)) == 24

The OEIS says the number of 3-qubit cliffords is 743178240. By ignoring column signs, you can count up this number in about 4 seconds:

c = 0
for _ in stim.Tableau.iter_all(3, unsigned=True):
    c += 1
c *= 2**6  # Account for the 6 column signs
c *= 8  # Account for the 8 ignored global phases
assert c == 743178240

The question says you want $n<5$, which would include $n=4$. I haven't tested fully iterating over the 47 trillion unsigned 4-qubit tableaus. Modifying the above code to count how fast the loop is running, and running it on the 4 qubit tableaus, iterates through them at about 350KHz. Which suggests it would take about a day and a half to finish the whole iteration.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.