Research-grade, hardware-aware QEC stack for surface codes.
Project description
Aegis – Hardware-Aware Quantum Error Correction Toolkit
Aegis is a modular toolkit for simulated quantum error correction with a focus on clarity, performance, and smooth automation from local dev to PyPI release.
Features
- Decoders: Greedy (+ OSD fallback) and MWPM
- Reusable decoding graphs for performance experiments
- Metrics & threshold plots (CSV/PNG)
- Ready-to-use CLI:
aegis-run,aegis-metrics,aegis-threshold,aegis-export-header - Quality gate: CI on Win/Ubuntu (Py 3.9/3.12),
pre-commit(black + ruff), Dependabot - Releases: Tagged publishes to TestPyPI / PyPI via GitHub Actions
Requires Python 3.9+.
Installation
Minimal runtime
pip install aegis-qec==1.0.6
Full (plots & dev extras)
pip install "aegis-qec[full]==1.0.6"
Extras:
full→matplotlib,pyarrow,pytestmwpm→networkx(already required by core)
Quickstart (CLI)
Outputs are written to
./out/by default.
# Fast sample decode
aegis-run
# -> "Decode complete. X(avg_cost)=..., Z(avg_cost)=..."
# Metrics + plot
aegis-metrics
# -> out/metrics.csv, out/metrics.png
# Threshold plot
aegis-threshold
# -> out/threshold.png
# Export a LUT header (example: GKP)
aegis-export-header
# -> out/gkp_lut.h
Windows PowerShell one-liner:
aegis-run; aegis-metrics; aegis-threshold; aegis-export-header
Quickstart (Python)
import a3d
print("Aegis imported from:", a3d.__file__)
# Low-level decoder APIs live under the `a3d` package.
Outputs
- Metrics:
out/metrics.csv,out/metrics.png - Threshold:
out/threshold.png - Artifacts:
out/gkp_lut.h
Development
# 1) Clone
git clone https://github.com/hamidbahri92/Aegis.git
cd Aegis
# 2) Virtualenv
python -m venv .venv
# Linux/macOS:
source .venv/bin/activate
# Windows PowerShell:
.\.venv\Scripts\Activate
# 3) Editable install with extras
pip install -e ".[full]" --prefer-binary
# 4) Pre-commit
pre-commit install
pre-commit run --all-files
# 5) Tests
pytest -q
# 6) Sanity check (CLI)
aegis-run
aegis-metrics
aegis-threshold
aegis-export-header
CI / Support Matrix
- OS: Windows, Ubuntu
- Python: 3.9, 3.12
- Linting/formatting:
ruff,blackviapre-commit - Dependency updates: Dependabot
Releasing
- Bump
versioninpyproject.toml. - Commit via PR (CI must be green).
- Tag the commit:
git tag vX.Y.Z && git push origin vX.Y.Z. - GitHub Actions workflow Release (PyPI) builds and uploads to PyPI.
Required secret
Add a repository Actions secret:
- Name:
PYPI_API_TOKEN - Value: PyPI API token for the project (Repo → Settings → Secrets and variables → Actions → New repository secret)
For staging, the Release (TestPyPI) workflow targets TestPyPI.
Project Layout
a3d/ # Core package & decoders (MWPM, ...)
main.py # CLI: aegis-run
main_metrics.py # CLI: aegis-metrics
main_threshold.py # CLI: aegis-threshold
main_export_header.py # CLI: aegis-export-header
.github/workflows/ # CI + TestPyPI/PyPI releases
pyproject.toml # Packaging + entry points
README.md # This file
LICENSE # MIT
License
MIT — see LICENSE.
Links
- PyPI: https://pypi.org/project/aegis-qec/
- GitHub: https://github.com/hamidbahri92/Aegis
- Releases/Changelog: https://github.com/hamidbahri92/Aegis/releases
---
### PowerShell: write README, commit, push
Run this from the repo root (`C:\Users\admin\Desktop\aegis`):
```powershell
$utf8NoBom = New-Object System.Text.UTF8Encoding $false
$readme = @'
# Aegis – Hardware-Aware Quantum Error Correction Toolkit
[](https://pypi.org/project/aegis-qec/)

[](LICENSE)

Aegis is a modular toolkit for simulated quantum error correction with a focus on clarity, performance, and smooth automation from local dev to PyPI release.
## Features
- Decoders: Greedy (+ OSD fallback) and MWPM
- Reusable decoding graphs
- Metrics & threshold plots (CSV/PNG)
- CLI: aegis-run, aegis-metrics, aegis-threshold, aegis-export-header
- CI (Win/Ubuntu, Py 3.9/3.12), pre-commit (black+ruff), Dependabot
- Tagged releases to TestPyPI/PyPI via GitHub Actions
> Python 3.9+ required.
## Installation
```bash
pip install aegis-qec==1.0.6
pip install "aegis-qec[full]==1.0.6"
Quickstart (CLI)
aegis-run
aegis-metrics
aegis-threshold
aegis-export-header
Quickstart (Python)
import a3d
print("Aegis imported from:", a3d.__file__)
Outputs
- out/metrics.csv, out/metrics.png
- out/threshold.png
- out/gkp_lut.h
Development
git clone https://github.com/hamidbahri92/Aegis.git
cd Aegis
python -m venv .venv
.\.venv\Scripts\Activate # on Windows
pip install -e ".[full]" --prefer-binary
pre-commit install
pre-commit run --all-files
pytest -q
Releasing
- Bump
versioninpyproject.toml - Merge via PR (CI green)
- Tag & push:
git tag vX.Y.Z && git push origin vX.Y.Z - Release (PyPI) workflow publishes to PyPI
Secret required: PYPI_API_TOKEN (Repo → Settings → Secrets → Actions)
License
MIT
Links
- PyPI: https://pypi.org/project/aegis-qec/
- GitHub: https://github.com/hamidbahri92/Aegis
- Releases: https://github.com/hamidbahri92/Aegis/releases '@
[IO.File]::WriteAllText("$PWD\README.md", $readme, $utf8NoBom) git add README.md git commit -m "docs: English README (install, CLI, dev, release)" git push -u origin HEAD
New in this build
- Union‑Find‑with‑Erasures decoder (UF‑E): fast baseline with erasure‑aware edge ordering.
- LLR/NLL weighting for Greedy & MWPM via a shared stats module.
Transformer reweighter (optional, no hard dependency)
Set reweighter_type="transformer" in AegisConfig to enable an edge-cost reweighting pass using a compact Transformer.
If PyTorch is unavailable, Aegis silently falls back to base costs.
New features
- UF‑E decoder with erasure peeling.
- Pipelined MWPM (two-pass with local correlation reweighting).
- Stim/DEM adapter for minimal detector-error-model demos.
- Transformer reweighter and tiny training script (optional Torch).
- One‑click CI via
KITTY_RUN_CI.pyandaegis-ciconsole script. - Dockerfile for containerized runs.
Quick starts
-
UF‑E: set
decoder_type="uf". -
Pipelined MWPM: set
decoder_type="mwpm2". -
Transformer reweighter:
cfg.reweighter_type="transformer". -
Bench:
python bench/run_threshold.py. -
Train transformer (optional Torch):
python -m scripts.train_transformer.
Advanced features
-
Correlation-aware MWPM (
decoder_type="mwpm_corr") applying motif-based local correlation costs before MWPM. -
Fuller Stim/DEM adapter with
shift_detectorstime-slicing for demos. -
Educational Notebook:
notebooks/educational_demo.ipynb. -
BP reweighter:
cfg.reweighter_type="bp"for Torch-free, principled cost refinement.
Certificates, Confidence & Profiling
- Enable post-decode OSD polish with
cfg.run_certificate=True(default) andcfg.certificate_mode="osd". - Each
DecodeResultnow has aconfidencefield derived from avg cost (logit mapping). - Set
cfg.profile=Trueto log per-decode timing tologs/profile.csv. - Batch API:
DecoderRuntime.decode_batch_from_syndromes_uniform([...],[...])for throughput benchmarks. - Plots:
python -m bench.generate_plotswrites CSVs and PNGs (if matplotlib is available). - DEM cross-validation:
python -m scripts.dem_cross_validate path/to/model.dem(uses optional PyMatching/Stim).
GUI Dashboard
- Launch with
aegis-gui(afterpip install ".[gui]") orpython -m scripts.run_gui. - Adjust decoders/reweighters; run demo decodes and see quick sweep charts inline.
Soft Information (LLR) & Leakage
- Use
a3d.llr_schema.SoftSyndromeandvalidate_soft(). - Decode via
DecoderRuntime.decode_from_softinfo(llr_X, llr_Z, ...). - Leakage adaptivity is applied via boundary-friendly pregrowth.
Unified benchmarking CLI
Use aegis-bench for all sweeps and plots. Legacy scripts delegate to it internally.
Speed path (optional)
- Set
cfg.prefer_pymatching = Trueand usedecode_from_dem_text(...)to leverage PyMatching+Stim when available. - For general graphs, our internal decoders run; DEM interop path uses PyMatching's optimized kernels if present.
Acceleration
- Optional Numba jit is used for small hot kernels in UF‑E when installed (
pip install numba).
DEM parity
- When
stimandpymatchingare installed,tests/test_dem_structural_parity_optional.pyperforms structural sanity checks.
Project details
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 aegis_qec-1.0.22.tar.gz.
File metadata
- Download URL: aegis_qec-1.0.22.tar.gz
- Upload date:
- Size: 43.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8cb02cdd80206f9c6f7156361e58ab1fe37a8c243051935210fd2d49dc3d04bd
|
|
| MD5 |
5bbf78529b604fa9ca44d14a9083180b
|
|
| BLAKE2b-256 |
479cb2adcd2a171c76db6c88111710a7357726c568be94651c2114cadff1b47f
|
File details
Details for the file aegis_qec-1.0.22-py3-none-any.whl.
File metadata
- Download URL: aegis_qec-1.0.22-py3-none-any.whl
- Upload date:
- Size: 48.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df118750baa8c5995c2725d0cb900513ec7df0a8bc8697b28db8919f0f8fb2bb
|
|
| MD5 |
81b33bfe3061306576f4149cc4283ff0
|
|
| BLAKE2b-256 |
028c4be82d2d67a4c44e171926dd4b7654aa84ec7be445caae20b9c7b4987b4e
|