qliff
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 Pauli-frame propagation, and exporters (parity-check matrix + priors, matching weights, syndrome/label tensors). These drop directly into MWPM (pymatching), BP, or ML decoders.
Install
pip install qliff
Docs at plutoniumm.github.io/qliff.
Clifford simulation
from qliff 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 qliff 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 qliff.noise import Sampler, then
Sampler(c).expect(obs, shots, stratify=True). Add a custom channel by subclassing
qliff.noise.Channel and dropping it in with c.noise(ch, q).
Quantum error correction
qliff.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 qliff.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
qliff.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 build # all wheels (macOS/Linux/Windows, x86_64 + arm) + sdist, no upload
./do deploy # publish what `build` made to PyPI (no rebuild)
cd docs && npm run build && npm run deploy # docs site -> GitHub Pages
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 :)
Release files for qliff 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| qliff-0.2.2.tar.gz | 84.9 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| qliff-0.2.2-cp311-abi3-win_arm64.whl | CPython 3.11 | abi3 | Windows ARM64 | Details |
| qliff-0.2.2-cp311-abi3-win_amd64.whl | CPython 3.11 | abi3 | Windows x86-64 | Details |
| qliff-0.2.2-cp311-abi3-manylinux_2_28_x86_64.whl | CPython 3.11 | abi3 | Linux glibc 2.28+ x86-64 | Details |
| qliff-0.2.2-cp311-abi3-manylinux_2_28_aarch64.whl | CPython 3.11 | abi3 | Linux glibc 2.28+ ARM64 | Details |
| qliff-0.2.2-cp311-abi3-macosx_11_0_x86_64.whl | CPython 3.11 | abi3 | macOS 11.0+ x86-64 | Details |
| qliff-0.2.2-cp311-abi3-macosx_11_0_arm64.whl | CPython 3.11 | abi3 | macOS 11.0+ ARM64 | Details |
Total release size: 2.1 MB
Release files / qliff-0.2.2.tar.gz
| Download URL | qliff-0.2.2.tar.gz |
|---|---|
| Size | 84.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1960969911b0ffcfe5fd973c2c5bba38e9b907acc23d12267287de943c5cc37c
|
|
BLAKE2b-256 checksum How to use checksums |
bf13127427208f0d6953cd6d161fe0c6554283d09fa97c9c2fe4d1db780218a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / qliff-0.2.2-cp311-abi3-win_arm64.whl
| Download URL | qliff-0.2.2-cp311-abi3-win_arm64.whl |
|---|---|
| Size | 252.5 kB |
| Tags | CPython 3.11 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
3549e2cdd63c8c53f927c0af28241945dae2d512542d817d9abf3be2c9bba64d
|
|
BLAKE2b-256 checksum How to use checksums |
6ea4dc62dada9550d490af15e3ea615847e613e7c541ec7d58701dbe09cc9dcc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / qliff-0.2.2-cp311-abi3-win_amd64.whl
| Download URL | qliff-0.2.2-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 264.1 kB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
4243ceb7291e0cb73d6e3934d66c143d28d0262ca8ef7b2a877d5496a81107b9
|
|
BLAKE2b-256 checksum How to use checksums |
2eb07124a2a77c0ff1000da722f74919a353fb60ef7e86b51193752a75fd066f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / qliff-0.2.2-cp311-abi3-manylinux_2_28_x86_64.whl
| Download URL | qliff-0.2.2-cp311-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 387.4 kB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
f8faca2d085fe16e19360671461000c1ab7d75b85cab9f0592598f5e49d6c3c2
|
|
BLAKE2b-256 checksum How to use checksums |
0d7c894cd06fef4fe23aad8d95a0a6853d08a63c287a2b407533800c204bb371
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / qliff-0.2.2-cp311-abi3-manylinux_2_28_aarch64.whl
| Download URL | qliff-0.2.2-cp311-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 382.5 kB |
| Tags | CPython 3.11 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
b2e9f7a501f8807e20bc53b9aee6f43de218ac88da8e5eabdc7d84241bde70a3
|
|
BLAKE2b-256 checksum How to use checksums |
9ff0afd23dd22f529f66ec06b4337b59fcb98072ac52824a1ac9858db8eac595
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / qliff-0.2.2-cp311-abi3-macosx_11_0_x86_64.whl
| Download URL | qliff-0.2.2-cp311-abi3-macosx_11_0_x86_64.whl |
|---|---|
| Size | 365.1 kB |
| Tags | CPython 3.11 abi3 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
7a6f0a8888740cebb1364a56ff21433efea9cd45278a6c6d0fdc9ceaf5e3f0cd
|
|
BLAKE2b-256 checksum How to use checksums |
2bf110a32f74105413dbaa98b01f913561e88249a914379afa775f06687cbb2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / qliff-0.2.2-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | qliff-0.2.2-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 349.5 kB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
219dd70fcc76a3ddeb34def13831c564fb026750c91fd5a0d39675c939d74397
|
|
BLAKE2b-256 checksum How to use checksums |
a76d63a9a103b96d94dadb6dac4cf9509cf992914039416d0b88515fae12c701
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|