Vendor-portable GPU decoders for quantum LDPC codes: Triton min-sum BP and Relay-BP on NVIDIA (CUDA) and AMD (ROCm), with CPU reference implementations, consuming any stim DetectorErrorModel or raw parity-check matrices.
Project description
tridec
An open, vendor-portable GPU decoder library for quantum LDPC codes — Triton
min-sum BP and Relay-BP decoders that consume any stim DetectorErrorModel or
raw parity-check matrices, with CPU reference implementations, validated
against the standard CPU references (ldpc, relay-bp), running on NVIDIA
(CUDA) and AMD (ROCm) GPUs.
The same Triton kernels run unmodified on both vendors: the Relay-BP kernel
reproduces its logical-error-rate validation numbers identically on an NVIDIA
H200 (CUDA 12.4, triton 3.0) and an AMD MI300X (ROCm 7.0, triton 3.4) — see
docs/benchmark.md and the raw receipts in
bench/receipts/. Scope is NVIDIA + AMD only.
Install
pip install tridec # numpy CPU reference only
pip install "tridec[torch]" # + batched torch backend (CPU/GPU)
pip install "tridec[gpu]" # + Triton GPU kernels (CUDA or ROCm)
pip install "tridec[decoders]" # + ldpc / relay-bp reference adapters
(Not yet on PyPI — install from source with pip install -e . for now.)
Quickstart
import stim
import tridec
circuit = stim.Circuit.from_file("memory.stim")
dem = circuit.detector_error_model(decompose_errors=False)
decoder = tridec.from_dem(dem, backend="auto") # triton > torch > numpy
dets, obs = circuit.compile_detector_sampler(seed=0).sample(
100_000, separate_observables=True)
pred = decoder.decode_batch(dets) # (shots, n_obs) bool
print("logical error rate:", (pred != obs).any(axis=1).mean())
Raw matrices work too: tridec.from_matrices(H, priors, observables=Lo).
Relay-BP: tridec.from_dem(dem, algorithm="relay") (Triton backend only).
Backend × algorithm matrix (honest availability)
| Algorithm | numpy |
torch |
triton |
|---|---|---|---|
| min-sum BP | yes (CPU reference) | yes (CPU + CUDA/ROCm) | yes (CUDA + ROCm) |
| Relay-BP | no | no | yes (CUDA + ROCm) |
There is no in-package CPU Relay-BP; its CPU reference is IBM's relay-bp
Rust decoder, wrapped in tridec.adapters and used as the validation
oracle for the Triton path.
What's validated where
| Environment | Status |
|---|---|
| CPU (any) | numpy BP reference; torch BP bit-identical to numpy at fp64 (one iteration), LER-identical full decode |
| NVIDIA H200, CUDA 12.4, torch 2.4.1, triton 3.0.0 | Triton BP: ≥99.5% hard-decision agreement vs fp64 references, LER-identical (156 = 156 = 156 fails / 2000 shots vs numpy/torch). Triton Relay-BP: LER-matches the relay-bp Rust oracle (31 vs 38 fails / 2000, overlapping Wilson CIs) |
| AMD MI300X, ROCm 7.0.0, torch 2.9, triton 3.4.0 | Same kernels, unmodified: identical primitive-identity numbers (pre-leg posterior max-diff 1.8e-15) and the same oracle-vs-Triton LER identity |
| Apple / Metal | out of scope |
Compatibility floors in pyproject.toml; known-good pins: stim 1.15.0,
ldpc 2.4.1, relay-bp 0.2.2, torch 2.4.1 / 2.9, triton 3.0 / 3.4.
Validation discipline
tridec.validation ships the matched-protocol harness the numbers were
produced with: dem_hash (sha256 of the DEM's canonical bytes), run_matched
(one shared DEM, one shot set, fail-fast DEM-identity and tie-break gates),
Wilson/TOST statistics and a paired per-shot gap-to-MLE bootstrap. The test
suite pins the extraction byte-for-byte: 8 canonical BB-code fixture circuits
must hash to the exact DEM sha256s recorded in the carried zoo_grid.json
receipt, and a full 16,667-shot cell must reproduce the recorded
logical-failure counts of the ldpc reference adapters exactly.
Status
v0.1.0-dev — APIs may move. The kernels and their validation receipts are
stable; the packaging, public API surface and docs are young. GPU paths
require triton + a CUDA/ROCm GPU and skip cleanly in tests where unavailable.
License
Apache-2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tridec-0.1.0a1.tar.gz.
File metadata
- Download URL: tridec-0.1.0a1.tar.gz
- Upload date:
- Size: 54.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
224ccc0d0bce761351d8b670137ff4f999235238afecc1cc2cb7dcd5369897d9
|
|
| MD5 |
4f7e3dbc224974b007938657210010b0
|
|
| BLAKE2b-256 |
1ba3c5f0de3d2f07890a30d8b722e8ddd0dfddb0266be0db1a2f6562dcfe7065
|
File details
Details for the file tridec-0.1.0a1-py3-none-any.whl.
File metadata
- Download URL: tridec-0.1.0a1-py3-none-any.whl
- Upload date:
- Size: 52.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20f0c1428d2fee7c10699863900db83bb7754e8a860a135c993a738f04df5f73
|
|
| MD5 |
2d5c62cb48debb4a2db2a980b43cd0c4
|
|
| BLAKE2b-256 |
c99a19e4f6b06e159e9555d2d09ab606fea04e6e24059dedd6b18c6073319cff
|