Guides · 3 of 5 · 8 min read

Choosing a decoder

BP+OSD-CS, relay-BP, or BP+OTF — what each of the three paradigms is good at, and how to swap between them on one DEM.

Glean spans three decoder paradigms, all validated on the same gross-code circuit-level DEM. They differ in their post-processing strategy, their latency profile, and what they need set up ahead of time. This guide is the map.

Three paradigms

All three start from belief propagation (BP), which alone often fails to converge on degenerate qLDPC codes. What follows BP is the differentiator:

  • BP + OSD-CS — repairs a non-converged BP result by information-set inversion (ordered-statistics decoding with a combination sweep).
  • relay-BP — drops post-processing entirely; it uses disordered memory plus relaying and ensembling to make BP itself converge, in a real-time iteration budget.
  • BP + OTF — an inversion-free post-processor that builds a spanning forest (Ordered Tanner Forest) on which BP is exact, in almost-linear time.

At a glance

DecoderPost-processingBest forSource / bench
BP + OSD-CSinformation-set inversion (O(n³))the accurate general-purpose baseline, offline analysisRoffe 2020 · B1/B3
relay-BPnone — disordered memory + ensemblingreal-time / on-hardware decoding; bounded per-shot latencyMüller 2025 · B4
BP + OTFgraph-acyclication (O(n log n))asymptotic latency at large n (inversion-free)deMarti iOlius 2024 · B7

BP + OSD-CS

The validated baseline and Glean's default. It is the most accurate general-purpose choice and the right starting point for any new DEM. Its cost is the inversion step (O(n³) in the worst case), which makes it an offline / analysis decoder rather than a real-time one. You already used it in the previous guide via decode_batch(..., osd_order=10).

B3 — == Roffe's ldpc to 99.8% / <0.4σ on the gross code.

relay-BP

The OSD-free, real-time differentiator. Reach for it when you need a bounded per-shot latency (decoding has to keep up with ~µs QEC cycles) or when ensembling buys you accuracy. It is a drop-in swap on the same DEM — call decode_batch_relay instead:

decode_relay.py
# Same DEM 'g' and syndromes 'det' as the previous guide — just a different call.
pred, iters = g.decode_batch_relay(
    det.tolist(), gamma0=0.1, pre_iter=80, num_sets=60, set_max_iter=60,
    gamma_dist=(-0.24, 0.66), stop_nconv=5, alpha=1.0, seed=0, parallel=True)

# 'iters[i]' is the total BP iterations spent on shot i — the real-time budget metric.
import numpy as np
print("median iters", int(np.median(iters)), " p90", int(np.percentile(iters, 90)))

The headline real-time metric is the per-shot BP iteration count returned alongside the predictions — not wall-clock µs. stop_nconv is the "-S" in "Relay-BP-S": the number of converged relay legs to ensemble (higher = more accurate, more work in the rare tail). num_sets is the number of relay legs.

B4 — == the authors' relay_bp crate (<0.95σ); median 16 / p90 212 iters ≪ 600 budget.

BP + OTF

The inversion-free third paradigm. Its appeal is the almost-linear O(n log n) post-processor, an asymptotic latency edge that should show up at large n. It needs an offline-built sparsified DEM plus a transfer-matrix incidence, produced by benchmarks/otf_sparsify.py; build the decoder with glean.load_bp_otf(...). A single OTF decoder undershoots BP+OSD-0 by design — the published accuracy is recovered by a 23-member ensemble (see benchmarks/bp_otf_gross.py for the end-to-end build).

Honesty. At gross-code size (n ≈ 936 detectors) BP+OTF is 2.5× faster than BP+OSD-0 but slightly slower than the deployed OSD-CS-10 — the O(n log n) crossover is asymptotic and not yet realized at this n.

B7 — ensemble BP+OTF == Glean's BP+OSD-0, 0.33σ.

How to pick

  • Just want a correct, accurate answer? Start with BP + OSD-CS-10. It is the default for a reason.
  • Decoding in real time, or on hardware? Use relay-BP and watch the per-shot iteration budget rather than wall-clock.
  • Pushing to very large codes where inversion dominates? Evaluate BP + OTF; its scaling advantage grows with n.

Whichever you pick, the deepest logical error rates are out of reach for direct Monte-Carlo. The next guide shows how Glean's estimators get there — and they work with any of these three decoders unchanged.