Metadata-Version: 2.2
Name: qec-loss
Version: 0.1.3
Summary: Sample lossy quantum error correction code.
Keywords: stim,qec,loss,atom-loss
Author-Email: Victor Caro <victor.caro@polytechnique.org>
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Project-URL: homepage, https://github.com/Jaymun723/qec-loss/
Project-URL: documentation, https://github.com/Jaymun723/qec-loss/blob/main/docs/api.md
Project-URL: source, https://github.com/Jaymun723/qec-loss.git
Project-URL: issues, https://github.com/Jaymun723/qec-loss/issues
Requires-Python: >=3.10
Requires-Dist: stim>=1.16.0
Description-Content-Type: text/markdown

# Simulations of QEC codes with loss

[![Tests](https://github.com/Jaymun723/qec-loss/actions/workflows/test.yml/badge.svg)](https://github.com/Jaymun723/qec-loss/actions/workflows/test.yml)
[![Publish to PyPI](https://github.com/Jaymun723/qec-loss/actions/workflows/release.yml/badge.svg)](https://github.com/Jaymun723/qec-loss/actions/workflows/release.yml)
[![PyPI version](https://img.shields.io/pypi/v/qec-loss)](https://pypi.org/project/qec-loss/)
[![Python versions](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue)](https://pypi.org/project/qec-loss/)

Python package for sampling and decoding quantum error correction circuits with photon loss.

## Install

Requires Python 3.10 or newer.

From [pypi](https://pypi.org/project/qec-loss/):

```bash
pip install qec-loss
# or with uv
uv add qec-loss
```

### Local install

Please first install [uv](https://docs.astral.sh/uv/getting-started/installation/).

```bash
git submodule update --init --recursive
uv sync --dev
uv pip install -e . --no-build-isolation --group dev
uv run pre-commit install
```

The last command installs a git pre-commit hook that runs **ruff format** on Python and **clang-format** on C++ under `src/qec_loss/_native/`.

To format everything manually:

```bash
uv run pre-commit run --all-files
```

## Quick start

```python
import stim
from qec_loss import LossyCircuit, ForwardSampler, MonakaBuilder, add_loss_noise

stim_circuit = stim.Circuit.generated(
    "surface_code:rotated_memory_z", rounds=5, distance=5
)
circuit = add_loss_noise(stim_circuit, loss_after_2_qubit_gate=0.01)

sampler = ForwardSampler(circuit, seed=7)
batch = sampler.sample(1000)

builder = MonakaBuilder(circuit, model_path="/tmp/monaka")
predictions = builder.decode_batch(batch)
```

See [docs/api.md](docs/api.md) for the full API.

## Test

```bash
uv run pytest tests/
```
