pre-1.0 · research-grade

Decode the quantum error-correction frontier.

Glean is a high-performance, open-source library for decoding quantum error-correcting codes — the “solver” companion to Stim. A fast Rust core with an ergonomic Python API. Stim simulates the noise; Glean infers the most likely error and how to correct it.

Build from source: maturin develop --release

quickstart.py
import glean

code = glean.toric_code(4)        # [[32, 2, 4]] toric code
error = [0] * code.n; error[5] = 1   # one X error
syndrome = code.hz_syndrome(error)
correction = code.decode(syndrome, p=0.05)  # BP + OSD-CS-10
assert code.hz_syndrome(correction) == syndrome

Correct

A wrong guess corrupts the computation. Every decoder, code, and noise model reproduces a specific published benchmark — the Iron Rule.

Fast

A zero-dependency Rust core with opt-in rayon parallelism under an ergonomic Python API. The performance-critical inner loops stay microsecond-fast.

qLDPC-ready

Built for the frontier that slashes qubit overhead: the bivariate-bicycle [[144, 12, 12]] gross code, decoded circuit-level — not just surface codes.

Three decoder paradigms

One DEM, three ways to solve it.

Glean spans three distinct decoder families, all validated on the same gross-code circuit-level detector error model.

BP + OSD-CS

B1 · B3

Belief propagation + ordered-statistics post-processing (information-set inversion).

Source · Roffe 2020 · Bravyi 2024

== Roffe’s ldpc to 99.8% / <0.4σ on the gross code; reproduces the toric threshold.

relay-BP

B4

Disordered-memory min-sum BP + relaying + ensembling. OSD-free and real-time.

Source · Müller 2025

== the authors’ relay_bp crate (<0.95σ); real-time iteration budget met (p90 212 < 600).

BP + OTF

B7

Belief propagation + Ordered Tanner Forest (graph-acyclication). Inversion-free, O(n log n).

Source · deMarti iOlius 2024

== Glean’s validated BP + OSD-0 oracle (0.33σ) on the gross-code DEM.

Rare-event estimators

Reach 10⁻⁷ without 10⁹ shots.

The deepest published logical-error rates are infeasible by direct Monte-Carlo. Glean ships two decoder-agnostic importance-sampling tools that reuse the same checks, observables, priors, and batched decode.

glean.dss

Dynamical Subset Sampling · Heußen 2024

Stratify faults by weight and sum the contributing classes analytically — the weight probabilities are exact and decoder-independent.

Unbiased on Glean’s pipeline (0.0σ vs direct Monte-Carlo).

glean.splitting

Splitting + Bennett acceptance ratio · Bravyi–Vargo 2013 · Mayer 2025

A telescoping product of Metropolis-sampled ratios with no resolution wall at depth — the deep-number pin.

Unbiased vs direct MC two decades into the rare regime; pins the gross-code deep point.

The moat

Validated against published numbers.

Each row reproduces a published number on the identical problem the source paper used. Rerun the whole suite in one command: python benchmarks/run_all.py.

IDWhatResult
B1Toric BP+OSD threshold (Roffe 2020, 9.9 ± 0.2%)≈10.0–10.1% crossing — in-band
B3Gross-code [[144,12,12]] circuit-level vs ldpc (Bravyi 2024)== ldpc 99.8% / <0.4σ; 0.8% threshold bracketed
B4relay-BP vs reference crate (Müller 2025)== ref crate; “factor of three” reproduced; p90 212 < 600
B5Decode speed vs ldpc / relay_bpon par with relay_bp; out-runs ldpc; rayon 4–5× on 10 cores
B7BP+OTF vs BP+OSD-0 oracle (deMarti iOlius 2024)ensemble BP+OTF == BP+OSD-0, 0.33σ
B9/B10Deep point pL ≈ 2×10⁻⁷ @ p=10⁻³ (Bravyi Nature)reproduced within convention + extrapolation uncertainty

Honesty. Glean reproduces these numbers; it does not claim to beat them. The deep Nature point is consistent with — slightly below — the headline once normalized to the paper’s per-cycle convention; relay-BP’s separation over BP+OSD tops out near 7× for XZ-decoding. Each write-up states what reproduces and what is deferred.

See the full benchmark story — charts & citations →

Grounded in the literature.

No code without a citation: every decoder and code traces to a peer-reviewed source and ships with a benchmark reproducing that source’s published numbers.