The Stim package is a tool for simulation and analysis of quantum stabilizer circuits. Stim's built-in surface code circuit generation, stim.Circuit.generated, can run different code tasks (rotated and unrotated surface codes for X and Z error probabilities for example) and takes as parameter the "desired code distance of the generated circuit". Is it possible to give two distances $d_X$ and $d_Z$ for rectangular surface codes ?


1 Answer 1


The stim.Circuit.generated method doesn't support rectangular surface codes (this method is only meant to generate some common example circuits to get going, rather than all possible variants of surface code circuits). However, I also wanted to make some small tweaks to these example circuits recently, so I translated the surface code circuits from C++ to Python so that I could change them without needing to use the Stim C++ API. I've open sourced the code, so feel free to use it and make the necessary tweaks for generating rectangular surface codes: https://github.com/oscarhiggott/StimCircuits

  • $\begingroup$ The PR has been merged on Apr 13, 2023 so I'll accept this answer ! Thanks again Oscar ! $\endgroup$ Commented May 2, 2023 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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