Skip to main content
qliff

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_gauges for 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. Every family whose code has an X/Z dual takes memory="Z" or memory="X" to run either basis. 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)

A memory is blind to noise that commutes with its own basis -- a Z-memory cannot see Z_ERROR or RZ, and reports a logical error rate of exactly zero at any p. qliff warns when you build one, and again if the detector error model comes out empty; run the dual basis instead:

c = rotated_surface_code(3, 3, 0.01, channel="Z_ERROR", memory="X")  # sees the noise

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.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qliff 0.4.1
File Size Uploaded
qliff-0.4.1.tar.gz 138.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for qliff 0.4.1
File
qliff-0.4.1-cp311-abi3-win_arm64.whl CPython 3.11 abi3 Windows ARM64 Details
qliff-0.4.1-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
qliff-0.4.1-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details
qliff-0.4.1-cp311-abi3-manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64 Details
qliff-0.4.1-cp311-abi3-macosx_11_0_x86_64.whl CPython 3.11 abi3 macOS 11.0+ x86-64 Details
qliff-0.4.1-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details

Total release size: 2.9 MB

Release files / qliff-0.4.1.tar.gz

Download URL qliff-0.4.1.tar.gz
Size 138.8 kB
Tags Source
SHA-256 checksum
How to use checksums
87249e94806b55b55dac4159d8da86e669258693f1c1c6efb7f9ab7d9bab2c0d
BLAKE2b-256 checksum
How to use checksums
4e6a813a577889c5e61a89a1bef07b414ec905d09238c98ecb34c575990062e5
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.4.1-cp311-abi3-win_arm64.whl

Download URL qliff-0.4.1-cp311-abi3-win_arm64.whl
Size 381.5 kB
Tags CPython 3.11 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
6f2ccd7f1b795d80170e240b23b0e30540e15bf54fa9e721ce92f87e2d83afcb
BLAKE2b-256 checksum
How to use checksums
57266324f0da6069d6c3c8a04b2a52c9b84d3c4ad7066f4172352d2ec1763946
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.4.1-cp311-abi3-win_amd64.whl

Download URL qliff-0.4.1-cp311-abi3-win_amd64.whl
Size 401.2 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
40865fbb1dd92ddb3c9543857264b7bd5edd64793b5760411e38ce8f0018f5dd
BLAKE2b-256 checksum
How to use checksums
0d1231a6bfb08e07ec0cac9952c0229ed049a4bba7dbd7d8d2d4118ce9213a49
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.4.1-cp311-abi3-manylinux_2_28_x86_64.whl

Download URL qliff-0.4.1-cp311-abi3-manylinux_2_28_x86_64.whl
Size 527.7 kB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
c9b48a31691124827c2895c945630e357cfff4e848ce42dd828161428c77e735
BLAKE2b-256 checksum
How to use checksums
9f6fa10b266b224c52562a91b646f6bc93867d9c066ced740464a8ede73c984e
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.4.1-cp311-abi3-manylinux_2_28_aarch64.whl

Download URL qliff-0.4.1-cp311-abi3-manylinux_2_28_aarch64.whl
Size 519.2 kB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
42057f0a57b0469f71fd64407a962f17e016d681ea02d018305b595afca51f43
BLAKE2b-256 checksum
How to use checksums
52084eb1b390b62a7dd1742cead73d87eb55d7b4a3f26c75d6528c03e3c1f7e9
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.4.1-cp311-abi3-macosx_11_0_x86_64.whl

Download URL qliff-0.4.1-cp311-abi3-macosx_11_0_x86_64.whl
Size 497.7 kB
Tags CPython 3.11 abi3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
ab13d13a0507d01f35ea5aac8d0e502c450ce323e0298da1bb5d65824cb6aea0
BLAKE2b-256 checksum
How to use checksums
f2e97385cba5025e7842a9a39e84cc59abcc9c756cf69223a12483d676d153ab
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.4.1-cp311-abi3-macosx_11_0_arm64.whl

Download URL qliff-0.4.1-cp311-abi3-macosx_11_0_arm64.whl
Size 474.3 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a9b7708c276159440802cb7d0071ab02b9796abf9dd403e299ce29d02006d8a8
BLAKE2b-256 checksum
How to use checksums
7f254d990dbbab578875fc30c327e4852cb5a38a8f44e53c75457a2fe2257c90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release history Release notifications | RSS feed

0.5.0

7 release files

0.4.3

7 release files

0.4.2

7 release files

This release

0.4.1 This release

7 release files

0.3.2

7 release files

0.3.1

7 release files

0.3.0

7 release files

0.2.2

7 release files

0.2.0

7 release files

0.0.2

5 release files

0.0.1

5 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page