FaultScope
FaultScope is a stabilizer circuit simulator for quantum error correction, with a Rust core and a Python API. It simulates noisy Clifford circuits, samples detector syndromes, and estimates logical error rates with external decoders. It also generates detector error models and estimates how individual noise rates affect logical failure.
Documentation | User Guide | API Reference
- Sample measurements, detector syndromes, and logical observables from noisy Clifford circuits.
- Generate detector error models (DEMs) and sample their independent error mechanisms.
- Integrate decoders and collect logical error rates across code distances and noise rates.
- Estimate noise sensitivities and rank fault locations by their effect on a chosen loss.
Installation
Use 64-bit CPython 3.10–3.14. Prebuilt wheels are available for supported Linux, macOS, and Windows platforms, so installing on these platforms does not require Rust.
Create and activate a virtual environment, then install from PyPI:
python -m venv .venv
source .venv/bin/activate
pip install faultscope
On Windows, activate the environment with .venv\Scripts\Activate.ps1 in
PowerShell instead. For the quickstart below, add the example dependencies:
pip install "faultscope[pymatching]" stim
The pymatching extra supplies PyMatching, NumPy, and SciPy; Stim supplies the
example circuit. See the installation guide
for more details, or Development for source builds and
contributions.
Quickstart: Simulate a Surface-Code Memory
This example runs a distance-3 rotated surface-code Z-memory experiment for three rounds, with depolarizing noise after Clifford gates. Stim constructs the circuit and a decomposed DEM for the decoding graph. FaultScope samples the original circuit, and PyMatching predicts logical flips from the detector syndromes.
Save the following code as surface_code.py and run python -I surface_code.py
in the activated environment. The -I option imports the installed package even
when the script is inside the source checkout.
import pymatching
import stim
from faultscope import FaultScopeSimulator, PyMatchingDecoder, parse_stim_circuit
stim_circuit = stim.Circuit.generated(
"surface_code:rotated_memory_z",
distance=3,
rounds=3,
after_clifford_depolarization=0.005,
)
imported = parse_stim_circuit(str(stim_circuit))
simulator = FaultScopeSimulator(imported.circuit)
# Inspect a batch of circuit samples.
batch = simulator.run_batch(shots=1024, seed=1)
detector_ids = tuple(detector.id for detector in imported.detectors)
observable_ids = tuple(observable.id for observable in imported.observables)
print(f"Sampled {batch.shots} shots with {len(batch.detectors)} detectors")
print("First-shot syndrome:", [batch.detector_bit(d, 0) for d in detector_ids])
# Construct a matching decoder for this circuit's detector layout.
stim_dem = stim_circuit.detector_error_model(decompose_errors=True)
matching = pymatching.Matching.from_detector_error_model(stim_dem)
decoder = PyMatchingDecoder(
matching=matching,
detector_ids=detector_ids,
observable_ids=observable_ids,
edge_count=matching.num_edges,
)
# Sample a new batch and estimate failure after decoding.
result = simulator.estimate(shots=10_000, seed=2, decoder=decoder)
print(f"Logical failure rate: {result.logical_failure_rate:.4%}")
A logical failure occurs when the decoder's predicted logical flips disagree with the sampled logical observable record. The reported rate is a Monte Carlo estimate; increase the shot count to reduce sampling uncertainty.
Batch fields such as batch.detectors hold packed integer masks, with one bit per
shot. Helpers such as detector_bit(detector_id, shot) expose individual values.
The same compiled simulator can be reused for additional batches.
Simulation Workflows
| Task | Public entry point | Result |
|---|---|---|
| Sample a noisy circuit | FaultScopeSimulator.run_batch(...) |
Measurements, detectors, observables, and noise-event masks |
| Generate a DEM | generate_native_dem(circuit) |
Detector and logical effects of error mechanisms |
| Sample a DEM | DemFaultScopeSimulator(circuit) or DemHotspotEstimator(dem) |
Detector syndromes and logical flips from independent error mechanisms |
| Estimate decoded failure | simulator.estimate(..., decoder=decoder) |
Logical failure rate and noise sensitivities |
| Run repeated QEC experiments | Collector with CollectionTask(circuit=...) |
Logical error-rate statistics with parallel collection and CSV resume |
Circuit-based collection uses forward circuit sampling. A DEM used to construct its decoder does not change the sampling path. Collection also supports stopping conditions and analysis of code-distance and noise-rate sweeps; see logical error-rate collection.
DEM sampling operates on independent error mechanisms. Some circuit noise channels convert exactly; others require explicitly enabled approximation. Use forward sampling when the original channel's mutually exclusive outcomes must be preserved. See detector error models.
The simulator supports Clifford gates, Pauli measurements and resets, and the supported stochastic Pauli noise models. Non-Clifford gates, general non-Pauli channels, and general per-shot adaptive branching are outside its scope.
Noise Sensitivity Analysis
The quickstart's estimate also contains sensitivities for the physical noise
locations in the circuit. Append this line to surface_code.py to print the five
highest-ranked locations from the same estimate:
print(result.hotspot_table(top_k=5))
A sensitivity estimates how the chosen loss changes when a location's noise rate increases, with the decoder held fixed. A positive value indicates increasing loss; a negative value indicates decreasing loss. Hotspot rankings use the absolute sensitivity, so they highlight large effects in either direction.
Location tags allow results to be grouped by qubit, round, gate, or operation. Forward sensitivities refer to physical noise rates. DEM sensitivities refer to DEM edge probabilities; their location summaries are not generally derivatives with respect to the original circuit noise rates. See the sensitivity guide for interpretation and theory for the estimator's statistical assumptions.
Performance
FaultScope processes many shots together using packed bit arrays in Rust. Reuse a compiled simulator when sampling the same circuit repeatedly.
The quickstart uses the Python PyMatching integration. Optional native PyMatching and fusion-blossom backends keep batch decoding in native code; see native decoder integration.
For reproducible measurements, use a release build and report the circuit, shot count, decoder, and hardware alongside the timings. Start with the sampling benchmark or the surface-code decoder benchmark. The benchmark guide documents build instructions, commands, and comparison settings.
Documentation and Development
- Getting Started: installation and a complete surface-code example.
- User Guide: sampling, decoding, collection, and noise sensitivities.
- API Reference: Python and Rust interfaces and result fields.
- Theory: sampling models, sensitivity estimators, and DEM semantics.
- Decoder Development: custom Python and native decoders.
- Release and Compatibility: supported platforms and version policy.
- Development: build, test, lint, documentation, and benchmarks.
FaultScope is pre-1.0; Python and Rust APIs may change between releases. Contributions should pass the relevant development checks above.
License
FaultScope is distributed under the GNU Affero General Public License v3.0.
Metadata
Release files for faultscope 0.2.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| faultscope-0.2.12.tar.gz | 319.3 kB | With provenance | Details for faultscope-0.2.12.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| faultscope-0.2.12-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details for faultscope-0.2.12-cp310-abi3-win_amd64.whl |
| faultscope-0.2.12-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details for faultscope-0.2.12-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| faultscope-0.2.12-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details for faultscope-0.2.12-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
| faultscope-0.2.12-cp310-abi3-macosx_11_0_x86_64.whl | CPython 3.10 | abi3 | macOS 11.0+ x86-64 | Details for faultscope-0.2.12-cp310-abi3-macosx_11_0_x86_64.whl |
| faultscope-0.2.12-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details for faultscope-0.2.12-cp310-abi3-macosx_11_0_arm64.whl |
Total release size: 7.0 MB
Release files / faultscope-0.2.12.tar.gz
| Download URL | faultscope-0.2.12.tar.gz |
|---|---|
| Size | 319.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2e8455a768f1293aeb448bfb5a30a556e760564cad5732f9eaaafc9bbd795528
|
|
BLAKE2b-256 checksum How to use checksums |
dff158f3dfc1cacb3c9ba2d5bcd481b4a97409b2e3ce4e3abec75f4f4631d509
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logRelease files / faultscope-0.2.12-cp310-abi3-win_amd64.whl
| Download URL | faultscope-0.2.12-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
16f809e63488117db7b728084be3a8b705389c0b133d665e5ca041f03fcd0746
|
|
BLAKE2b-256 checksum How to use checksums |
30bd7f3dfe8e5fca29bc116ea7a044d68ac04482eb3f3b5c7b819a04efdcf767
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logRelease files / faultscope-0.2.12-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | faultscope-0.2.12-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
824241388a1fdd802188d5ac7338b5ab4181f5f5db7b83f4bb7b27015ed07e66
|
|
BLAKE2b-256 checksum How to use checksums |
d6d93df22a6c19825b87705b827136a7760082a8d0de826110a8cc52df63943f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logRelease files / faultscope-0.2.12-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | faultscope-0.2.12-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
4c5a253bef63ae3529661b9a4771e4a7fe475f1869af4dbf3d580593c0175a88
|
|
BLAKE2b-256 checksum How to use checksums |
0c136a0d814241f573d3d3656ee6d1f055db828689d686bf8828e9d56e9f75f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logRelease files / faultscope-0.2.12-cp310-abi3-macosx_11_0_x86_64.whl
| Download URL | faultscope-0.2.12-cp310-abi3-macosx_11_0_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
9f6bee734193c981df90c1ad38f2f09ea63759b2f7c8c316bcc7132c67ebf99e
|
|
BLAKE2b-256 checksum How to use checksums |
acc10bce7e3bbeb4fbbc54f4c71780961c72714c513668c5a8c06c249c3489b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logRelease files / faultscope-0.2.12-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | faultscope-0.2.12-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
258a8042fb8625cfb29f50e78484ffc917bffa434bbbaa209621386bd564555c
|
|
BLAKE2b-256 checksum How to use checksums |
fb15a89be853e1d99fb9d979a446bff57bce7f358539ca1f813646b047605dd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logSecurity for faultscope 0.2.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 6 files in this release have been uploaded with provenance metadata.
Attestation for faultscope-0.2.12.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.