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.
- Code factories for surface, toric, color/triangular/kagome, subsystem
(Bacon-Shor, gauge), and qLDPC (hypergraph-product, bivariate-bicycle) families, plus
from_stabilisers/from_gaugesfor arbitrary Pauli codes.
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).
For deep-tail logical error rates where plain Monte-Carlo needs prohibitively many shots,
from qliff.noise import SplittingEstimator runs a multilevel-splitting (subset-sampling)
estimator that reaches the far tail with orders of magnitude fewer decodes.
Quantum error correction
qliff.qec ships code-circuit generators, so you can go straight to a logical-error-rate
curve. Alongside rotated_surface_code there are unrotated_surface_code, toric_code,
repetition_code, the color family (color_code, hex_color_code, triangular_code,
kagome_code), subsystem codes (bacon_shor_code, from_gauges), and qLDPC codes
(hypergraph_product_code, bivariate_bicycle_code); from_stabilisers builds a full
memory circuit from an arbitrary Pauli stabiliser set. 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(5, 5, 0.01) # distance, rounds, p (square d x d patch)
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.3.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.3.2.tar.gz | 125.5 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| qliff-0.3.2-cp311-abi3-win_arm64.whl | CPython 3.11 | abi3 | Windows ARM64 | Details |
| qliff-0.3.2-cp311-abi3-win_amd64.whl | CPython 3.11 | abi3 | Windows x86-64 | Details |
| qliff-0.3.2-cp311-abi3-manylinux_2_28_x86_64.whl | CPython 3.11 | abi3 | Linux glibc 2.28+ x86-64 | Details |
| qliff-0.3.2-cp311-abi3-manylinux_2_28_aarch64.whl | CPython 3.11 | abi3 | Linux glibc 2.28+ ARM64 | Details |
| qliff-0.3.2-cp311-abi3-macosx_11_0_x86_64.whl | CPython 3.11 | abi3 | macOS 11.0+ x86-64 | Details |
| qliff-0.3.2-cp311-abi3-macosx_11_0_arm64.whl | CPython 3.11 | abi3 | macOS 11.0+ ARM64 | Details |
Total release size: 2.8 MB
Release files / qliff-0.3.2.tar.gz
| Download URL | qliff-0.3.2.tar.gz |
|---|---|
| Size | 125.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
25c0a429200f6d12cc06889f94ab0f3b24dba6002b94f2d2925241c22b1f6b55
|
|
BLAKE2b-256 checksum How to use checksums |
beea989cab22efdb07b57ec3155e0a04b7ee09693bce6f804e423b54c9f33273
|
| 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.3.2-cp311-abi3-win_arm64.whl
| Download URL | qliff-0.3.2-cp311-abi3-win_arm64.whl |
|---|---|
| Size | 365.2 kB |
| Tags | CPython 3.11 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
7f22163eef15ccc4b5fa908701da18640fc04a23ecd216d879bd5d30818c104d
|
|
BLAKE2b-256 checksum How to use checksums |
9e07bcb09b431b8acd2147ed5124c43e8ae1c240720238f99f48e00fe471e078
|
| 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.3.2-cp311-abi3-win_amd64.whl
| Download URL | qliff-0.3.2-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 384.9 kB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
66ee0c89471990b1690af4673c72cf83f208e6756a97773699cb0d2a0352d517
|
|
BLAKE2b-256 checksum How to use checksums |
24a61db8d15862363f48aeaa4cfc3fd3ca422b391ceebc8da607d7172fef1905
|
| 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.3.2-cp311-abi3-manylinux_2_28_x86_64.whl
| Download URL | qliff-0.3.2-cp311-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 511.3 kB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
e3dd125cedb9c7090cd4899d385e490a683cf829c5d2eca1334ddf24fc5d4f13
|
|
BLAKE2b-256 checksum How to use checksums |
266ad4e188382ba735071c24f368075d98b06c22e7594fb8b84e24c44be7d181
|
| 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.3.2-cp311-abi3-manylinux_2_28_aarch64.whl
| Download URL | qliff-0.3.2-cp311-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 502.7 kB |
| Tags | CPython 3.11 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
217c6dfe856ec0924af41b1450eceed1cfa59562e7160c1ee864e640aa1d0fec
|
|
BLAKE2b-256 checksum How to use checksums |
2869d5359be9e101a0e8c7b62d4e817ff9ecef727c1a8e6eaceb17a172262c4a
|
| 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.3.2-cp311-abi3-macosx_11_0_x86_64.whl
| Download URL | qliff-0.3.2-cp311-abi3-macosx_11_0_x86_64.whl |
|---|---|
| Size | 481.3 kB |
| Tags | CPython 3.11 abi3 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
357c1f8bb8fb66770d85fdd7e130efdf438b5b4246c3f12b18560964c78b5bc9
|
|
BLAKE2b-256 checksum How to use checksums |
96d4eebec95e1e382336d8449acc2b7dcfa7e9f0d8177974fc5351d0db71122b
|
| 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.3.2-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | qliff-0.3.2-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 457.8 kB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
8b41e79aa8fdacefe4e63533b7bd9c8c4f7d58cea787d803d71fa2739b95110a
|
|
BLAKE2b-256 checksum How to use checksums |
5887a15d972f1a2f608eb17e5df9f86063c39e536efff4061e4ddcfeffdc0191
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|