Stim ships in three forms: a Python package on PyPI (the most common way to use it), a standalone command-line binary, and a C++ library you can link into your own programs. The Python package is the recommended starting point for most users. The C++ library is useful when you need to embed Stim functionality directly in a C++ project, but be aware that the C++ API carries no backwards-compatibility guarantee.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/quantumlib/Stim/llms.txt
Use this file to discover all available pages before exploring further.
Python package
The Python package is available on PyPI and can be installed with a single command. It requires Python 3.6 or later and automatically installs NumPy as a dependency.Command-line binary
The Stim CLI accepts commands such asstim sample -shots 100 -in circuit.stim. You can build it from source using CMake, Bazel, or GCC.
SIMD width
CMake lets you control vectorization via the-DSIMD_WIDTH flag:
| Flag | Effect |
|---|---|
| (omitted) | Use the best option for the current machine (-march=native) |
-DSIMD_WIDTH=256 | Force 256-bit AVX2 operations |
-DSIMD_WIDTH=128 | Force 128-bit SSE2 operations |
-DSIMD_WIDTH=64 | Disable SIMD entirely |
C++ library
To embed Stim in a C++ project, buildlibstim and link against it. The recommended approach is CMake with FetchContent.
Link with CMake
In yourCMakeLists.txt, fetch Stim from GitHub and add libstim as a link dependency:
System requirements
| Component | Requirement |
|---|---|
| Python package | Python ≥ 3.6, NumPy (installed automatically) |
| C++ build | C++17-capable compiler (GCC, Clang, or MSVC); CMake or Bazel optional |
| SIMD acceleration | AVX2 or SSE2 capable CPU (optional; falls back to scalar) |
Versioning and compatibility
Stim’s Python package uses semantic versioning. Within a major version (1.X):
- The Python API is backwards compatible, except for bug fixes, trap fixes, and spandrels.
- The command-line API is backwards compatible under the same exceptions; a command will not stop working due to cleanup efforts alone.
- The C++ API carries no compatibility guarantee and may change arbitrarily between minor versions.
Stim is not an officially supported Google product. For questions, use the quantum computing Stack Exchange with the
stim tag.