Guides · 5 of 5 · 6 min read

sinter integration

Plug Glean into Stim’s sinter.collect(...) pipeline as a drop-in, picklable decoder.

Stim's sinter is the de-facto framework for running large QEC sampling campaigns — parallel workers, automatic shot batching, early stopping. glean.SinterDecoder drops Glean straight into that pipeline, so you get Glean's decoders with sinter's orchestration and no glue code.

What sinter does

sinter.collect(...) takes a list of tasks (each a circuit + metadata), fans them out across worker processes, samples shots, decodes them, and aggregates logical error rates with confidence intervals — stopping early once a target precision is hit. It talks to decoders through a small interface: compile_decoder_for_dem → decode_shots_bit_packed.

The SinterDecoder

glean.SinterDecoder(method="bp_osd", *, parallel=False, **params) is a pure-Python adapter that conforms to exactly that interface. It compiles a Glean decoder for each task's DEM and decodes sinter's bit-packed shot batches — wrapping the same decode_batch / decode_batch_relay path you have already used.

B6 — bit-exact vs the direct decode path; reproduces B3/B4 LER through sinter.collect.

Run a collection

Register the decoder under a name in custom_decoders and reference that name in decoders:

collect.py
import sinter, glean

results = sinter.collect(
    num_workers=8, tasks=tasks,
    decoders=["glean_bp_osd"],
    custom_decoders={"glean_bp_osd": glean.SinterDecoder(method="bp_osd")},
)

Build tasks with sinter.Task(circuit=..., json_metadata=...) as you would for any sinter run — Glean does not change that part.

Method & options

  • method: "bp_osd" → BP+OSD-CS (the B3 baseline); "relay" → relay-BP (B4).
  • parallel: spread shots across cores with rayon inside each decode (output identical to serial). Usually leave this off and let sinter parallelize across workers instead — pick one level of parallelism.
  • **params: forwarded to the batch decode — osd_order, max_iter, alpha for bp_osd; num_sets, stop_nconv, gamma_dist, seed for relay.

Lazy import & pickling

import glean stays sinter-free: the adapter is imported lazily on first access of glean.SinterDecoder, so the base package never pulls in sinter. Instances are picklable, which is what lets sinter ship them to worker processes. Install the framework with pip install sinter.

That's the tour. You can now decode toric and qLDPC codes, choose among three paradigms, reach rare-event depths, and run it all at scale through sinter. For the exhaustive parameter list, see the API reference; for the validated numbers, the benchmarks.