GraphQEC is a Python package for neural-network decoding of stabilizer-based quantum error correction codes, accompanying the paper Efficient and Universal Neural-Network Decoder for Stabilizer-Based Quantum Error Correction.
This repository is organized around result reproduction: benchmark configs, benchmark entrypoints, pretrained checkpoints, and example workflows for the code families used in the paper.
Supported code families:
Integrated classical decoders:
Neural decoders used in this repository:
GraphRNNDecoderV5AGraphLinearAttnDecoderV2A
Use the locked environment when reproducing benchmarks:
git clone git@github.com:Fadelis98/graphqec-paper.git
cd graphqec-paper
uv sync --frozenThis uses the versions pinned by uv.lock and is the installation path assumed by the reproducibility notes below.
Optional acceleration step for environments matching the pinned stack:
.venv/bin/python scripts/install_causal_conv1d.pyThis installs the causal-conv1d wheel used with the pinned Python 3.12 / Torch 2.5 / CUDA 12 environment. The package is not part of the default locked environment because the wheel is platform-specific.
If uv is not available, install with a CUDA-matched PyTorch wheel source:
git clone git@github.com:Fadelis98/graphqec-paper.git
cd graphqec-paper
pip install --extra-index-url https://download.pytorch.org/whl/cu124 -e .For CUDA 11.8, use:
pip install --extra-index-url https://download.pytorch.org/whl/cu118 -e .Pretrained weights are distributed through the GitHub Releases page.
Experimental-data workflows are not fully bundled in the repository. In particular, Sycamore experiments require the external dataset referenced at 10.5281/zenodo.6804040.
The notebook test_decoder.ipynb contains a minimal decoder example and a benchmark-oriented example workflow.
The benchmark entrypoint used by configs in configs/benchmark/ is implemented in graphqec/benchmark/evaluate.py.
The repository-level helper scripts that are intended to be used directly are:
scripts/check_reproducibility.pyvalidates benchmark configs, checkpoint paths, and basic code initialization before a runscripts/run_benchmark.pyruns a benchmark config through the repository benchmark entrypoint in local debug mode or submitit modescripts/reproduce_bb72_time.pyruns one local BBCode timing benchmark task and can download the BBCode release checkpoint automaticallyscripts/run_bbcode_graphqec_time.pyprofiles, schedules, runs, and post-processes the multi-GPU BBCode timing workflowscripts/run_bbcode_graphqec_time_background.shstarts, stops, and checks a detachedrun_bbcode_graphqec_time.pyprocess
The repository does not keep shell-wrapper duplicates for Python entrypoints. Use the Python scripts directly unless a shell script provides additional process-management behavior.
Run these commands before any long benchmark job:
uv sync --frozen
.venv/bin/python -c "import torch; print(torch.__version__, torch.cuda.is_available())"
nvidia-smiIf the benchmark path uses linear-attention kernels and the environment matches the pinned stack, install causal-conv1d after uv sync --frozen:
.venv/bin/python scripts/install_causal_conv1d.pyThe expected baseline is:
- Python
>=3.11 - PyTorch
2.5.1 - a CUDA-capable NVIDIA driver visible through
nvidia-smi - the environment materialized from
uv.lock
This repository uses two benchmark config standards.
For time benchmarks, dataset must contain:
error_ratermaxesseed
For acc benchmarks, dataset must contain:
error_ratesrmaxesseed
The benchmark loader accepts alternate field names for compatibility with existing files, and the canonical standard is the one listed above.
Each benchmark run writes:
config.json: the user-provided configresolved_config.json: the normalized config actually used at runtime
The directory configs/benchmark/repro/ contains compact configs intended for direct result reproduction.
Included files:
BB72_time_release.jsonBB144_time_release.jsonBB72_acc_release.jsonTCd3_acc_release.json
Use these files as the default starting point for reproduction work. They are intended to be copied and edited locally rather than used as exploratory sweep templates.
The shortest end-to-end validation path in this repository is the BB72 timing smoke test.
- Validate the target config only:
.venv/bin/python scripts/check_reproducibility.py --config configs/benchmark/repro/BB72_time_release.json- Run a minimal local timing smoke test:
.venv/bin/python scripts/reproduce_bb72_time.py \
--config configs/benchmark/repro/BB72_time_release.json \
--rmaxes 0 \
--num-evaluation 2 \
--batch-size 1This command exercises the real benchmark entrypoint, resolves the BBCode release checkpoint automatically, and writes a run directory under runs/.
Neural decoder benchmarks require a checkpoint directory unless a dedicated helper script resolves the checkpoint automatically.
The checkpoint field is:
"decoder": {
"chkpt": "..."
}Valid values are either:
- an absolute path such as
/absolute/path/to/pretrain_latest - a repository-relative path such as
checkpoints/releases/BBcode/BB72/pretrain_latest
The checkpoint directory should be the stage directory used by the decoder loader, typically a path named pretrain_latest, finetune-p*_val_best, or another model checkpoint directory containing the weights and metadata expected by build_neural_decoder.
Recommended workflow for accuracy benchmarks:
- Copy a config from
configs/benchmark/repro/. - Set
decoder.chkptin the config, or pass--checkpoint-dir checkpoints/releases/BBcode/BB72/pretrain_lateston the CLI. - Run
.venv/bin/python scripts/check_reproducibility.py --config <your-config.json>. - Launch the benchmark only after the self-check reports no missing or placeholder checkpoint paths for the target config.
Recommended entrypoint for accuracy benchmarks:
.venv/bin/python scripts/run_benchmark.py \
--config path/to/your-acc-config.json \
--checkpoint-dir path/to/your-checkpoint-dir \
--run-path runs/your_acc_runMinimal local accuracy smoke test pattern:
- Copy
configs/benchmark/repro/BB72_acc_release.json. - Set
decoder.chkptin the config, or pass--checkpoint-dir checkpoints/releases/BBcode/BB72/pretrain_lateston the CLI. - Reduce
metrics.num_fails_required,metrics.chunk_size, andmetrics.batch_sizefor a short smoke test. - Increase the temporary smoke-test error rate so the local debug run terminates quickly.
- Validate the edited config with
scripts/check_reproducibility.py. - Run the config with
scripts/run_benchmark.py.
Example command sequence:
.venv/bin/python scripts/check_reproducibility.py --config path/to/your-bb72-acc-smoke.json
.venv/bin/python scripts/run_benchmark.py \
--config path/to/your-bb72-acc-smoke.json \
--checkpoint-dir checkpoints/releases/BBcode/BB72/pretrain_latest \
--run-path runs/your_bb72_acc_smokeFor BBCode timing reproduction, prefer the helper scripts in scripts/, because they already resolve the release checkpoint layout automatically.
Recommended entrypoints:
- single local timing task:
.venv/bin/python scripts/reproduce_bb72_time.py --config configs/benchmark/repro/BB72_time_release.json- multi-GPU timing workflow:
.venv/bin/python scripts/run_bbcode_graphqec_time.py --skip-smoke --gpus 0 1 2 3 4 5 6 7- detached multi-GPU timing workflow:
bash scripts/run_bbcode_graphqec_time_background.sh start --skip-smoke --gpus 0 1 2 3 4 5 6 7If installation or runtime fails, check the following in order.
-
PyTorch / CUDA mismatch
If
torch.cuda.is_available()isFalsewhilenvidia-smisucceeds, reinstall the environment and confirm the CUDA wheel source inpyproject.tomlmatches the local driver/runtime setup. -
flash-linear-attention/ Triton issuesIf compiled kernels fail, verify that the installed package set matches
uv.lock. Timing and compilation behavior are sensitive to the exact PyTorch, Triton, and flash-attention stack. -
causal-conv1dissues
Some device and package combinations are incompatible with causal-conv1d. On the pinned Python 3.12 / Torch 2.5 / CUDA 12 stack, install it with .venv/bin/python scripts/install_causal_conv1d.py. See the dedicated note below for unsupported environments.
-
External experimental data missing
Sycamore and related experimental-data workflows require datasets that are not stored in this repository.
-
Checkpoint path errors
If a benchmark config contains
path/to/your/checkpointor points to a missing directory,scripts/check_reproducibility.pywill report it before the benchmark starts.
For paper-style timing comparisons, record at least:
- GPU model
- CUDA driver version
- PyTorch version
- benchmark dtype policy
- whether timing is end-to-end or model-only
causal-conv1d is not compatible with every environment. A common failure mode is:
RuntimeError: Please either install causal-conv1d>=1.4.0 to enable fast causal short convolution CUDA kernel or set use_fast_conv1d to False.
If this occurs:
-
on the pinned Python 3.12 / Torch 2.5 / CUDA 12 environment, run:
.venv/bin/python scripts/install_causal_conv1d.py
-
check package compatibility against the upstream repository: Dao-AILab/causal-conv1d
-
if installation itself fails, remove or comment the package from the environment specification, install the rest of the environment, and then test whether the benchmark path in use actually requires it
uv sync --frozen does not preserve a manually installed causal-conv1d wheel. Re-run scripts/install_causal_conv1d.py after recreating or resyncing the environment.
Some versions of flash-linear-attention miss @torch.compiler.disable on Triton kernels. If torch.compile fails, inspect the fused_recurrent_gated_delta_rule kernel under fla/ops/delta_rule/fused_recurrent and confirm the package version matches the expected environment.
@article{hu2025efficient,
title={Efficient and Universal Neural-Network Decoder for Stabilizer-Based Quantum Error Correction},
author={Hu, Gengyuan and Ouyang, Wanli and Lu, Chao-Yang and Lin, Chen and Zhong, Han-Sen},
journal={arXiv preprint arXiv:2502.19971},
year={2025}
}