ElonDormancy / Stim

A fast stabilizer circuit simulator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is Stim?

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).

Important Stim features include:

  1. 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.
  2. Support for annotating noise, detection events, and logical observables directly into circuits.
  3. The ability to convert circuits into detector error models, which is a convenient format for configuring syndrome decoders.

The main limitations of Stim are:

  1. All circuits must be stabilizer circuits (eg. no Toffoli gates).
  2. All error channels must be probabilistic Pauli channels (eg. no amplitude decay).
  3. All feedback must be Pauli feedback (eg. no classically controlled S gates).

How do I use Stim?

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).

How does Stim work?

See the paper describing Stim published in Quantum.

In terms of performance, Stim makes three core improvements over previous stabilizer simulators:

  1. 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.
  2. 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.
  3. 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.

Attribution

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}
}

About

A fast stabilizer circuit simulator

License:Apache License 2.0


Languages

Language:C++ 87.7%Language:Python 10.5%Language:JavaScript 0.8%Language:CMake 0.4%Language:C 0.3%Language:Starlark 0.2%Language:Shell 0.1%