stim

A fast stabilizer circuit library.

https://github.com/quantumlib/stim

Science Score: 57.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.7%) to scientific vocabulary

Keywords

algorithms api cirq cpp google-quantum nisq python quantum quantum-algorithms quantum-circuit quantum-circuit-simulator quantum-computer-simulator quantum-computing quantum-error-correction quantum-information quantum-programming quantum-simulation simulation stabilizer-circuits

Keywords from Contributors

quantum-programming-language quantum-development-kit
Last synced: 4 months ago · JSON representation ·

Repository

A fast stabilizer circuit library.

Basic Info
  • Host: GitHub
  • Owner: quantumlib
  • License: apache-2.0
  • Language: C++
  • Default Branch: main
  • Homepage:
  • Size: 12.5 MB
Statistics
  • Stars: 529
  • Watchers: 14
  • Forks: 155
  • Open Issues: 64
  • Releases: 19
Topics
algorithms api cirq cpp google-quantum nisq python quantum quantum-algorithms quantum-circuit quantum-circuit-simulator quantum-computer-simulator quantum-computing quantum-error-correction quantum-information quantum-programming quantum-simulation simulation stabilizer-circuits
Created almost 5 years ago · Last pushed 4 months ago
Metadata Files
Readme Contributing License Code of conduct Citation Security Support

README.md

Stim

Stim logo

High-performance simulation of quantum stabilizer circuits for quantum error correction.

◼︎︎  What is Stim?
◼︎︎  How do I use Stim?
◼︎  How does Stim work?
◼︎  How do I cite Stim?
◼︎  Subproject: Sinter decoding sampler
◼︎  Subproject: Crumble interactive editor

What is Stim?

Stim is a tool for high performance simulation and analysis of quantum stabilizer circuits, especially quantum error correction (QEC) circuits. Typically Stim is used as a Python package (pip install stim), though Stim can also be used as a command-line tool or a C++ library.

Stim's key features:

  1. Really fast simulation of stabilizer circuits. Have a circuit with thousands of qubits and millions of operations? stim.Circuit.compile_sampler() will perform a few seconds of analysis and then produce an object that can sample shots at kilohertz rates.

  2. Semi-automatic decoder configuration. stim.Circuit.detector_error_model() converts a noisy circuit into a detector error model (a Tanner graph) which can be used to configure decoders. Adding the option decompose_operations=True will additionally suggest how hyper errors can be decomposed into graphlike errors, making it easier to configure matching-based decoders.

  3. Useful building blocks for working with stabilizers, such as stim.PauliString, stim.Tableau, and stim.TableauSimulator.

Stim's main limitations are:

  1. There is no support for non-Clifford operations, such as T gates and Toffoli gates. Only stabilizer operations are supported.

  2. stim.Circuit only supports Pauli noise channels (eg. no amplitude decay). For more complex noise you must manually drive a stim.TableauSimulator.

  3. stim.Circuit only supports single-control Pauli feedback. For multi-control feedback, or non-Pauli feedback, you must manually drive a stim.TableauSimulator.

Stim's design philosophy:

  • Performance is king. The goal is not to be fast enough, it is to be fast in an absolute sense. Think of it this way. The difference between doing one thing per second (human speeds) and doing ten billion things per second (computer speeds) is 100 decibels (100 factors of 1.26). Because software slowdowns tend to compound exponentially, the choices we make can be thought of multiplicatively; they can be thought of as spending or saving decibels. For example, under default usage, Python is 100 times slower than C++. That's 20dB of the 100dB budget! A fifth of the multiplicative performance budget allocated to language choice! Too expensive! Although Stim will never achieve the glory of 30 GiB per second of FizzBuzz, it at least wishes it could.

  • Bottom up. Stim is intended to be like an assembly language: a mostly straightforward layer upon which more complex layers can be built. The user may define QEC constructions at some high level, perhaps as a set of stabilizers or as a parity check matrix, but these concepts are explained to Stim at a low level (e.g., as circuits). Stim is not necessarily the abstraction that the user wants, but Stim wants to implement low-level pieces simple enough and fast enough that the high-level pieces that the user wants can be built on top.

  • Backwards compatibility. Stim's Python package uses semantic versioning. Within a major version (1.X), Stim guarantees backwards compatibility of its Python API and of its command-line API. Note Stim DOESN'T guarantee backwards compatibility of the underlying C++ API.

How do I use Stim?

See the Getting Started Notebook.

Stuck? Get help on the quantum computing stack exchange and use the stim tag.

See the reference documentation:

How does Stim work?

See the paper describing Stim. Stim makes three core improvements over previous stabilizer simulators:

  1. Vectorized code. 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. Reference Frame Sampling. 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. Inverted Stabilizer Tableau. 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 that commute with the current stabilizers take linear time instead of quadratic time. This is beneficial in error correcting codes, because the measurements they perform are usually redundant and so commute with the current stabilizers.

How do I cite Stim?

When using Stim for research, please cite:

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

Contact

For any questions or concerns not addressed here, please email quantum-oss-maintainers@google.com.

Disclaimer

This is not an officially supported Google product. This project is not eligible for the Google Open Source Software Vulnerability Rewards Program.

Copyright 2025 Google LLC.

Google Quantum AI

Owner

  • Name: quantumlib
  • Login: quantumlib
  • Kind: organization

Google's open source code library for the quantum world

Citation (CITATION.cff)

# Citation information for this repository.                         -*- yaml -*-
#
# CITATION.cff files provide human- & machine-readable citation information for
# software and datasets. GitHub, Zenodo, and the Zotero browser plugin all use
# CFF files automatically if provided. https://citation-file-format.github.io/.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cff-version: 1.2.0
message: If you use Stim, please cite it using this metadata.

# CITATION.cff files describe how to cite software or datasets, with the goal of
# making software and data be citable in their own right. However, sometimes
# projects want citations to go to a paper instead. 'Preferred-citation' serves
# to communicate that. The distinction matters in different situations. If this
# field is present, GitHub uses the value for the "cite this repository" button
# and ignores the rest of this file; conversely, the Zenodo-GitHub integration
# ignores this field when creating an entry for a new software release because
# the Zenodo entry is specifically about the software in this repository.
preferred-citation:
  type: article
  authors:
    - family-names: Gidney
      given-names: Craig
  title: 'Stim: a fast stabilizer circuit simulator'
  journal: Quantum
  year: 2021
  month: 7
  volume: 5
  start: 497
  issn: 2521-327X
  url: https://doi.org/10.22331/q-2021-07-06-497
  publisher:
    name: >-
      Verein zur Förderung des Open Access Publizierens in den
      Quantenwissenschaften

# The remaining metadata in this file describes the current software release.

title: Stim
abstract: >-
  Stim is a tool for high performance simulation and analysis of quantum
  stabilizer circuits, especially quantum error correction (QEC) circuits.
authors:
  - family-names: Gidney
    given-names: Craig
version: 1.14.0
date-released: 2024-09-24
url: https://github.com/quantumlib/stim
repository-code: https://github.com/quantumlib/stim
license: Apache-2.0
type: software
identifiers:
  - description: The GitHub repository for Stim
    value: https://github.com/quantumlib/Stim
    type: url
  - description: PyPI project for Stim
    value: https://pypi.org/project/Stim
    type: url
  - description: Publication about Stim
    value: 10.22331/q-2021-07-06-497
    type: doi
keywords:
  - algorithms
  - API
  - application programming interface
  - C++
  - Clifford gates
  - Clifford operations
  - high performance
  - open-source software
  - physics
  - Python
  - QEC
  - quantum
  - quantum algorithms
  - quantum circuits
  - quantum computing
  - quantum error correction
  - quantum error decoder
  - quantum gates
  - quantum programming
  - quantum simulation
  - quantum state
  - qubit
  - science
  - SDK
  - simulation
  - simulator
  - software
  - software development toolkit
  - stabilizer circuits

GitHub Events

Total
  • Create event: 44
  • Release event: 1
  • Issues event: 123
  • Watch event: 175
  • Delete event: 38
  • Member event: 1
  • Issue comment event: 99
  • Push event: 187
  • Pull request review comment event: 42
  • Pull request review event: 68
  • Pull request event: 134
  • Fork event: 51
Last Year
  • Create event: 44
  • Release event: 1
  • Issues event: 123
  • Watch event: 175
  • Delete event: 38
  • Member event: 1
  • Issue comment event: 99
  • Push event: 187
  • Pull request review comment event: 42
  • Pull request review event: 68
  • Pull request event: 134
  • Fork event: 51

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 459
  • Total Committers: 17
  • Avg Commits per committer: 27.0
  • Development Distribution Score (DDS): 0.203
Top Committers
Name Email Commits
Craig Gidney c****y@g****m 366
Craig Gidney c****y@g****m 32
Craig Gidney C****y@g****m 22
Adam Zalcman 4****r@u****m 14
Daniel Barter d****r@u****m 5
Matthew McEwen 3****g@u****m 4
Matthew Neeley m****o@g****m 3
Alexandre Bourassa A****a@u****m 3
Noah Shutty n****u@u****m 2
Chris Pattison c****n@l****m 1
Eric Peterson p****c@g****m 1
Doug Strain d****n@g****m 1
Cody Wang s****6@g****m 1
Scott P. Jones S****s@u****m 1
Matthew Neeley m****y@g****m 1
Michael Newman 6****g@u****m 1
oon3m0oo o****o@u****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 235
  • Total pull requests: 332
  • Average time to close issues: 2 months
  • Average time to close pull requests: 7 days
  • Total issue authors: 60
  • Total pull request authors: 41
  • Average comments per issue: 0.8
  • Average comments per pull request: 0.52
  • Merged pull requests: 264
  • Bot issues: 0
  • Bot pull requests: 3
Past Year
  • Issues: 64
  • Pull requests: 133
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 8 days
  • Issue authors: 36
  • Pull request authors: 20
  • Average comments per issue: 0.8
  • Average comments per pull request: 0.43
  • Merged pull requests: 101
  • Bot issues: 0
  • Bot pull requests: 3
Top Authors
Issue Authors
  • Strilanc (137)
  • mmcewen-g (9)
  • oscarhiggott (6)
  • m-mcewen (5)
  • mhucka (4)
  • ghost (4)
  • AlexBourassa (3)
  • nelimee (3)
  • The193thDoctor (2)
  • markturner289 (2)
  • BrunoLiegiBastonLiegi (2)
  • qodesign (2)
  • AlMrvn (2)
  • RefatIsmail96 (2)
  • nathlacroix (1)
Pull Request Authors
  • Strilanc (270)
  • mhucka (38)
  • markturner289 (9)
  • AlexBourassa (7)
  • inmzhang (6)
  • folded (6)
  • fdmalone (6)
  • viathor (5)
  • yuewuo (4)
  • qu-tan-um (4)
  • dougthor42 (4)
  • qec-pconner (3)
  • nickdgardner (3)
  • dependabot[bot] (3)
  • cesarBLG (2)
Top Labels
Issue Labels
Pull Request Labels
dependencies (3) cla: yes (1) javascript (1)

Packages

  • Total packages: 5
  • Total downloads:
    • pypi 138,236 last-month
  • Total dependent packages: 17
    (may contain duplicates)
  • Total dependent repositories: 10
    (may contain duplicates)
  • Total versions: 1,165
  • Total maintainers: 4
pypi.org: stim

A fast library for analyzing with quantum stabilizer circuits.

  • Versions: 405
  • Dependent Packages: 14
  • Dependent Repositories: 7
  • Downloads: 119,813 Last month
Rankings
Dependent packages count: 1.0%
Downloads: 1.7%
Average: 3.5%
Stargazers count: 4.2%
Forks count: 5.2%
Dependent repos count: 5.5%
Maintainers (3)
Last synced: 4 months ago
pypi.org: stimcirq

Implements a cirq.Sampler backed by stim.

  • Versions: 405
  • Dependent Packages: 1
  • Dependent Repositories: 2
  • Downloads: 6,757 Last month
Rankings
Stargazers count: 4.2%
Downloads: 4.3%
Dependent packages count: 4.8%
Forks count: 5.2%
Average: 6.0%
Dependent repos count: 11.6%
Maintainers (4)
Last synced: 4 months ago
proxy.golang.org: github.com/quantumlib/Stim
  • Versions: 19
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 6.4%
Average: 6.7%
Dependent repos count: 6.9%
Last synced: 4 months ago
proxy.golang.org: github.com/quantumlib/stim
  • Versions: 19
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 6.4%
Average: 6.7%
Dependent repos count: 6.9%
Last synced: 4 months ago
pypi.org: sinter

Samples stim circuits and decodes them using pymatching.

  • Versions: 317
  • Dependent Packages: 2
  • Dependent Repositories: 1
  • Downloads: 11,666 Last month
Rankings
Downloads: 4.1%
Dependent packages count: 4.8%
Average: 10.2%
Dependent repos count: 21.5%
Maintainers (2)
Last synced: 12 months ago

Dependencies

package.json npm
  • puppeteer ^5.3.0 development
glue/cirq/setup.py pypi
  • cirq-core *
  • stim *
glue/sample/requirements.txt pypi
  • matplotlib *
  • networkx *
  • numpy *
  • pandas *
  • pymatching *
  • pytest *
  • stim *
glue/zx/setup.py pypi
  • networkx *
  • stim *
setup.py pypi
  • numpy *
.github/workflows/ci.yml actions
  • actions/checkout v3 composite
  • actions/checkout v1 composite
  • actions/download-artifact v2 composite
  • actions/setup-node v3 composite
  • actions/setup-node v1 composite
  • actions/setup-python v3 composite
  • actions/upload-artifact v3 composite
  • bazelbuild/setup-bazelisk v1 composite
  • egor-tensin/setup-clang v1 composite
  • microsoft/setup-msbuild v1.0.2 composite
  • mymindstorm/setup-emsdk v9 composite
  • pypa/gh-action-pypi-publish release/v1 composite
glue/crumble/package.json npm
glue/sample/setup.py pypi
pyproject.toml pypi