stim-rs provides Rust bindings for Stim, a high-performance stabilizer circuit simulator and analyzer widely used in quantum error-correction workflows.
It consists of two crates:
stim-cxx: a low-level C++ bridge tostimbuilt withcxxstim: a safe Rust API built on top ofstim-cxx, intended to be fully feature-aligned with the upstream Python API
The Rust API uses ndarray to provide an experience similar to working with NumPy in Python.
The stim crate also includes a small layer of Rust-native utilities that do not
come from upstream Stim directly:
stim::noise::UniformDepolarizingandstim::noise::Si1000: ready-made pure-Rust noise modelsstim::Circuit::with_noise(...): a convenience method for applying those models to an existing circuit
This keeps the low-level bridge minimal while still allowing Rust-specific ergonomic features to grow independently when they can be implemented safely on top of the existing binding surface.
In most cases, users should depend only on the stim crate:
cargo add stimIssues and pull requests are very welcome, whether they relate to performance, ergonomics, or bugs.
This repo ships a committed pre-commit configuration. Install it locally with:
pre-commit installRun the full hook suite manually with:
pre-commit run --all-filesCommon local workflows are also exposed through the repo justfile:
just verify
just pre-commit-runThe configured hooks run:
cargo fmt --all --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace
cargo test --doc -p stim
env RUSTDOCFLAGS=-Dwarnings cargo doc -p stim --no-depsLicensed under Apache-2.0. The vendored upstream Stim sources under
crates/stim-cxx/vendor/stim are also distributed under Apache-2.0.
The upstream Stim C++ library is vendored as a git submodule at
crates/stim-cxx/vendor/stim. To update it:
git -C crates/stim-cxx/vendor/stim fetch origin
git -C crates/stim-cxx/vendor/stim checkout <commit-or-tag>
# Update STIM_RS_PINNED_STIM_COMMIT in crates/stim-cxx/build.rs to match.
cargo nextest run -p stim && cargo test --doc -p stim
git add crates/stim-cxx/vendor/stim crates/stim-cxx/build.rs