Skip to main content

Pelagos

Pelagos

GPU-accelerated Relay-BP decoder for qLDPC codes, implemented in Triton.

CI License: Apache 2.0 Python 3.11 | 3.12 | 3.13 Paper: IEEE QSW 2026

Triton PyTorch AMD ROCm NVIDIA CUDA stim Tutorials: Jupyter

Pelagos implements min-sum belief propagation with disordered memory strengths (Relay-BP-S), batched across syndromes and executed as fused Triton kernels. It is interface-compatible with (and cross-validated against) the relay-bp Rust reference implementation, available on PyPI.

Hardware support

Pelagos is vendor-neutral: the kernels are written in Triton, which targets both NVIDIA (CUDA), AMD (ROCm/HIP) and Intel (SPIR-V) GPUs. The decoder detects the active backend at construction time and adapts launch parameters accordingly.

Install

pip install pelagos-decoder[gpu]           # decoder + torch/triton
pip install pelagos-decoder[gpu,rust]      # + the Rust CPU reference, side by side
pip install pelagos-decoder[gpu,stim]      # + stim / DEM support

Development uses uv:

uv sync --extra all
uv run pytest

A GPU is required to decode; there is no CPU fallback (see Known limitations). The package imports and its structural tests run anywhere.

Quickstart

import numpy as np
import torch
from scipy.sparse import csr_matrix
from pelagos import RelayBPDecoder

# A tiny code: 3 checks over 3 variables.
H = csr_matrix(np.array([[1, 1, 0],
                          [0, 1, 1],
                          [1, 0, 1]], dtype=np.uint8))
priors = np.full(3, 0.05)

decoder = RelayBPDecoder(
    H_csr=H,
    error_priors=priors,
    pre_iter=80,          # T0: ordered-memory iterations
    num_sets=100,         # R: relay legs
    set_max_iter=60,      # Tr: iterations per leg
    gamma0=0.65,          # ordered memory strength
    gamma_dist_interval=(-0.24, 0.66),
    stop_nconv=5,         # stop after 5 valid solutions
    data_type="float32",
    algo="relay",         # required: "relay" or "plain"
)

# decode() takes a torch GPU tensor, not a numpy array.
syndrome = np.array([[1, 0, 1]], dtype=np.uint8)
syndrome_gpu = torch.from_numpy(syndrome).to("cuda:0")
result = decoder.decode(syndrome_gpu)

# The decoded error pattern is under the "errors" key.
e_hat = result["errors"].cpu().numpy()
print(e_hat)

Three details that are easy to get wrong (all enforced by tests/test_smoke.py):

  • algo must be passed explicitly — algo="relay" or algo="plain". Omitting it raises ValueError: Unknown algo 'None'.
  • decode() requires a torch tensor already on the GPU (torch.from_numpy(...).to("cuda:0") — PyTorch uses the "cuda" device type for ROCm builds as well, so the same call works on AMD), not a numpy array.
  • The result dict's error-pattern key is "errors", not "e_hat".

From a stim detector error model

import stim
from pelagos.stim.sinter.check_matrices import CheckMatrices
from pelagos import RelayBPDecoder

dem = stim.Circuit.generated(
    "surface_code:rotated_memory_x", distance=3, rounds=3,
    after_clifford_depolarization=0.001,
).detector_error_model(decompose_errors=False)

cm = CheckMatrices.from_dem(dem)
decoder = RelayBPDecoder(H_csr=cm.check_matrix, error_priors=cm.error_priors, algo="relay")

Note the field is cm.error_priors, not cm.priors. This path requires the stim extra (pip install pelagos-decoder[stim]), which pulls in beliefmatching.

Tutorials

Step-by-step Jupyter notebooks live in tutorials/. Start with Tutorial 1: single-GPU quickstart. It goes from a stim circuit to a logical error rate on the [[72,12,6]] bivariate bicycle code, compares plain BP with Relay-BP, and measures throughput:

uv sync --extra tutorials            # or: pip install -e ".[tutorials]"
uv run jupyter lab tutorials/

Continue with Tutorial 2: multi-GPU quickstart to decode on up to eight GPUs using the process backend, check decoding quality, and compare GPU counts with 1,024 shots per GPU.

Benchmarking

pelagos_benchmark.py is a full-featured benchmark CLI. Run python pelagos_benchmark.py --help for the complete flag list; the important ones are --backend {rust,triton}, --circuit, --basis, --distance, --rounds, --error-rate, --data-type, and --gpus. It needs pandas, which ships in the bench extra:

pip install "pelagos-decoder[gpu,bench]"     # or: uv sync --extra gpu --extra bench
python pelagos_benchmark.py --backend triton \
    --circuit bicycle_bivariate_144_12_12_memory_X --basis x \
    --distance 12 --rounds 12 --error-rate 0.003 --data-type float32

There is no single --compare-rust flag; to cross-check against the Rust reference, run the same command twice with --backend rust and --backend triton (the rust extra must be installed for the former).

Included circuits

tests/testdata/bicycle_bivariate/ ships gzipped stim circuits for the bivariate bicycle codes [[18,4,3]], [[72,12,6]], [[144,12,12]], and [[288,12,18]], in X and choi_XZ bases, at physical error rates 0.002, 0.003, and 0.005 (24 files, 2.4 MB total).

stim.Circuit.from_file does not transparently decompress gzip, so the bundled loader in tests/testdata/circuits.py handles both forms:

import sys; sys.path.insert(0, "tests")
from testdata import get_test_circuit

circuit = get_test_circuit(
    "bicycle_bivariate_144_12_12_memory_X", 0.003, distance=12, rounds=12
)
dem = circuit.detector_error_model(decompose_errors=False)

Testing

Continuous integration runs on GitHub-hosted runners, which have no GPU. On every pull request, CI checks packaging, imports, lint (syntax errors and undefined names), the CPU-side code (input validation, bit packing, the conversion from a stim DEM to check matrices) and the well-formedness of the tutorial notebooks. The decoder tests, including the bit-exact comparison against the Rust reference, are skipped in CI.

Before each release, and for any pull request that touches the kernels or the decoder, a maintainer runs the full suite on a GPU:

uv sync --extra gpu --extra rust --extra stim --extra test
uv run pytest tests/ -v -rs          # nothing should be reported as skipped

Known limitations

  • A GPU is required. There is no CPU fallback; use the Rust implementation (relay-bp on PyPI) for CPU decoding.
  • Multi-GPU support is limited to one node. The default multi-device path (device=[0, 1, ...], --gpus) runs one thread per GPU in a single process and does not scale linearly with the number of GPUs. The opt-in process-per-GPU backend runs one worker process per GPU instead; its smoke test checks results against the single-GPU decoder on two GPUs. Scaling across nodes is not supported.

Contributing

Contributions are welcome! See CONTRIBUTING.md for the development setup, testing, and sign-off requirements. Everyone taking part is expected to follow the Code of Conduct. Please report security issues privately, as described in SECURITY.md. Release notes are in CHANGELOG.md.

Governance

Pelagos is maintained by contributors from IBM and AMD under a lightweight, maintainer-led model. See GOVERNANCE.md for how decisions are made and MAINTAINERS.md for the current maintainers.

Citation

If you use Pelagos in your research, please cite:

D. Diamantopoulos, L. von Niederhäusern, A. S. Anghel, A. Kayi, R. Pletka, T. Müller, N. Papandreou, J. Blanusa, S. Sarafijanovic, N. M. Gonzalez, F. Abel, C. Hagleitner, S. Seelam, B. Johnson, R. Haas, and H. Pozidis, "Pêlagos: An Adaptive GPU Decoder for Error Correction Simulations of Quantum LDPC Codes," in 2026 IEEE International Conference on Quantum Software (QSW), 2026, pp. 152–165. IEEE Xplore

@INPROCEEDINGS{11662198,
  author={Diamantopoulos, Dionysios and von Niederhäusern, Luc and Anghel, Andreea Simona and Pletka, Roman and Kayi, Apo and Müller, Tristan and Papandreou, Nikolaos and Blanusa, Jovan and Sarafijanovic, Slavisa and Gonzalez, Nelson Mimura and Abel, Francois and Hagleitner, Christoph and Seelam, Seetharami and Johnson, Blake and Haas, Robert and Pozidis, Haralampos},
  booktitle={2026 IEEE International Conference on Quantum Software (QSW)},
  title={Pêlαγos: An Adaptive GPU Decoder for Error Correction Simulations of Quantum LDPC Codes},
  year={2026},
  pages={152-165},
  doi={10.1109/QSW72780.2026.00025}}

License

Pelagos is jointly owned by IBM and AMD.

Licensed under the Apache License, Version 2.0. See LICENSE.

Metadata

Release files for pelagos-decoder 0.1.0

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

Source distribution (sdist)

Source distribution for pelagos-decoder 0.1.0
File Size Uploaded Provenance Actions
pelagos_decoder-0.1.0.tar.gz 1.7 MB With provenance Details for pelagos_decoder-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pelagos-decoder 0.1.0
File Interpreter ABI Platform Actions
pelagos_decoder-0.1.0-py3-none-any.whl Python 3 none any Details for pelagos_decoder-0.1.0-py3-none-any.whl

Total release size: 1.8 MB

Release files / pelagos_decoder-0.1.0.tar.gz

Download URL pelagos_decoder-0.1.0.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
32458f29ccd72e128d6ca5d39c6a7a309e6ab3de59cbfd1dfe1542285b5f800e
BLAKE2b-256 checksum
How to use checksums
337e70631c8232a085878e0e6907e3b97cd081af5e9f13f9a7eb80d23673883c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / pelagos_decoder-0.1.0-py3-none-any.whl

Download URL pelagos_decoder-0.1.0-py3-none-any.whl
Size 104.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a4742977872f715b72c874571a05a2650e75085608856443e672623f71c4a54b
BLAKE2b-256 checksum
How to use checksums
1769bb635dec75ca804a8baae5b05421ed2b88430bb1007eb07339f128bb32db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Security for pelagos-decoder 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pelagos_decoder-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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