Clifford + noisy stabilizer simulator: noise-free and noisy (importance-sampled) stabilizer simulation with a native core.
Project description
aaronson
A Clifford stabilizer simulator with support for noisy and mid-circuit measurement-based simulation.
- Clifford stab simulation via the Aaronson–Gottesman tableau
- Noisy sim via stabilizer-channel
decomposition
E = Σ_μ q_μ S_μand stratified importance sampling (arXiv:2512.07304), "nearly as cheap as Pauli noise." - Decoder-ready QEC primitives: detectors, observables, detection-event sampling, a detector error model by exact Pauli-frame propagation, and exporters (parity-check matrix + priors, matching weights, syndrome/label tensors). No decoder is bundled — these drop straight into MWPM (pymatching), BP, or ML decoders.
Install
pip install aaronson
Docs at plutoniumm.github.io/aaronson.
Clifford simulation
from aaronson import Simulator
s = Simulator(2).H(0).CX(0, 1)
s.canon() # ['+XX', '+ZZ']
s.peek("ZZ") # +1
s.measure("XX") # (+1, False)
m0, m1 = Simulator(2).H(0).CX(0, 1).M(0, 1) # m0 == m1
Mid-circuit measurement and classical feedback are just Python — the simulator is stateful, so conditionals (teleportation, syndrome correction) need no special API:
s = Simulator(3, seed=0)
s.H(0)
s.H(1).CX(1, 2)
s.CX(0, 1).H(0)
if s.M(1) == 1:
s.X(2)
if s.M(0) == 1:
s.Z(2)
s.peek("__X") # +1
Noise
Build Circuit with gate/noise methods, then sample or estimate.
Circuit.estimate picks the right sampler by default — plain Monte-Carlo when every channel is Pauli, otherwise
stratified importance sampling
from aaronson import Circuit
c = Circuit(1)
c.H(0).DEPOLARIZE1(0, 0.1).M(0)
c.sample(1000)
c = Circuit(1)
c.H(0).RZ(0, 0.3)
c.estimate("X", 20000) # ≈ cos(0.3)
c = Circuit(1)
c.X(0).AMPLITUDE_DAMP(0, 0.3)
c.estimate("Z", 60000) # ≈ 2p - 1
Force the variance strategy with c.estimate(obs, shots, stratify=False) (flat) or stratify=True
(stratified), or drive the sampler directly: from aaronson.noise import Sampler, then
Sampler(c).expect(obs, shots, stratify=True). Add a custom channel by subclassing
aaronson.noise.Channel and dropping it in with c.noise(ch, q).
Quantum error correction
aaronson.qec ships code-circuit generators, so you can go straight to a logical-error-rate
curve. Any circuit's detectors and observables are declared with c.detector(...) /
c.observable(...), then turned into decoder inputs:
from aaronson.qec import rotated_surface_code, logical_fidelity
from pymatching import Matching
c = rotated_surface_code(distance=5, rounds=5, p=0.01)
dem = c.dem()
H, priors, obs_matrix = dem.check_matrix()
m = Matching.from_check_matrix(
H,
weights=dem.weights(),
faults_matrix=obs_matrix
)
dets, flips = c.detector_sampler().sample(20000)
fidelity = logical_fidelity(m.decode_batch(dets), flips)
Extending
Everything you'd customize lives in Python. Add a noise channel by subclassing
aaronson.noise.Channel and returning its stabilizer-channel branches; plug in a custom
sampler or observable; export the DEM to whatever decoder you like. The Rust core stays a thin,
fast tableau engine.
Develop
./do develop # build rust core
./do test
./do lint
./do bench
./do docs # build docs
./do deploy # publish the package to PyPI
License
MIT
If you are a company using this, please get a grad student to help you with issues. If you are a grad student, please feel free to email me :)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aaronson-0.1.0.tar.gz.
File metadata
- Download URL: aaronson-0.1.0.tar.gz
- Upload date:
- Size: 25.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd903f0f0adc14e0d7337974a696e0510595ae6d7bb9b5b99a91c68d0d6b636e
|
|
| MD5 |
c5c7f8a1952c155497598b88dcf98e6e
|
|
| BLAKE2b-256 |
0c451a38ef6a106e3e3212654964f508fa10b284174e85e7dc08b0c0e325f817
|
File details
Details for the file aaronson-0.1.0-cp314-cp314-macosx_12_0_arm64.whl.
File metadata
- Download URL: aaronson-0.1.0-cp314-cp314-macosx_12_0_arm64.whl
- Upload date:
- Size: 236.0 kB
- Tags: CPython 3.14, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8fc742e6cc0d5bc914d51e8f11620f84894972c82b1466a8e8dec61fa866c0e
|
|
| MD5 |
f2bc1cff034f077502e7e8f6914fd54c
|
|
| BLAKE2b-256 |
e6b8f07d1556da67aa1a02bceb6f01e16822967a6d4c0636f94d3202d43b1c62
|