Stim is a tool for high performance simulation and analysis of quantum stabilizer circuits,
intended to help with research into quantum error correcting codes.
Stim can be used as a python package (pip install stim
),
as a command line tool (built from source in this repo),
or as a C++ library (also built from source in this repo).
-
Watch the 15 minute lightning talk presenting Stim at QPL2021.
-
Watch Stim used to estimate the threshold of the honeycomb code within days of it being published.
Important Stim features include:
- Really fast simulation of stabilizer circuits. As in thousands of times faster than what came before. Stim can pull thousands of full shots out of circuits with millions of operations in seconds.
- Support for annotating noise, detection events, and logical observables directly into circuits.
- The ability to convert circuits into detector error models, which is a convenient format for configuring syndrome decoders.
The main limitations of Stim are:
- All circuits must be stabilizer circuits (eg. no Toffoli gates).
- All error channels must be probabilistic Pauli channels (eg. no amplitude decay).
- All feedback must be Pauli feedback (eg. no classically controlled S gates).
See the Getting Started Notebook.
For using Stim from python, see the python documentation and the python API reference. For using Stim from the command line, see the command line documentation. For building Stim for yourself, see the developer documentation.
Circuits are specified using the stim circuit file format (.stim). See the supported gate reference for a list of available circuit instructions, and details on what they do. Samples can be output using a variety of text and binary formats.
Error models are specified using the detector error model file format (.dem).
See the paper describing Stim published in Quantum.
In terms of performance, Stim makes three core improvements over previous stabilizer simulators:
- Stim's hot loops are heavily vectorized, using 256 bit wide AVX instructions. This makes them very fast. For example, Stim can multiply Pauli strings with 100 billion terms in one second.
- When bulk sampling, Stim only uses a general stabilizer simulator for an initial reference sample. After that, it cheaply derives as many samples as needed by propagating simulated errors diffed against the reference. This simple trick is ridiculously cheaper than the alternative: constant cost per gate, instead of linear cost or even quadratic cost.
- When doing general stabilizer simulation, Stim tracks the inverse of the stabilizer tableau that was historically used. This has the unexpected benefit of making measurements with a deterministic result (given previous measurements) take linear time instead of quadratic time.
When using Stim for research, please cite:
@article{gidney2021stim,
doi = {10.22331/q-2021-07-06-497},
url = {https://doi.org/10.22331/q-2021-07-06-497},
title = {Stim: a fast stabilizer circuit simulator},
author = {Gidney, Craig},
journal = {{Quantum}},
issn = {2521-327X},
publisher = {{Verein zur F{\"{o}}rderung des Open Access Publizierens in den Quantenwissenschaften}},
volume = {5},
pages = {497},
month = jul,
year = {2021}
}