Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: mit
|
| 4 |
+
tags:
|
| 5 |
+
- qec
|
| 6 |
+
- surface-code
|
| 7 |
+
- quantum
|
| 8 |
+
- pytorch
|
| 9 |
+
- quantum-error-correction
|
| 10 |
+
- neural-decoder
|
| 11 |
+
pipeline_tag: other
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# NTU Surface Code Decoder (AlphaQubit V2)
|
| 15 |
+
|
| 16 |
+
Pre-trained neural decoder checkpoints for rotated surface codes, based on the
|
| 17 |
+
**Neural Transfer Unification (NTU)** framework.
|
| 18 |
+
|
| 19 |
+
📄 **Paper**: *Transfer Learning is All You Need for Scalable Neural Decoder*
|
| 20 |
+
|
| 21 |
+
## Model Architecture
|
| 22 |
+
|
| 23 |
+
**AlphaQubit V2** — A high-capacity neural decoder (~58M parameters) featuring:
|
| 24 |
+
|
| 25 |
+
- **Interleaved RNN-Transformer backbone** (5 GRU + 6 self-attention layers)
|
| 26 |
+
- **2D Rotary Position Embedding (RoPE)** based on physical detector coordinates
|
| 27 |
+
- **Joint X+Z stabilizer processing** with spatial hint connections
|
| 28 |
+
- **Cross-attention readout** with learnable logical query tokens
|
| 29 |
+
- Trained with **progressive knowledge distillation** from MWPM pseudo-labels
|
| 30 |
+
|
| 31 |
+
## Checkpoints
|
| 32 |
+
|
| 33 |
+
| File | Distance | Size | Training Step |
|
| 34 |
+
|------|----------|------|---------------|
|
| 35 |
+
| `d7.pth` | d=7 | ~121 MB | scratch |
|
| 36 |
+
| `d11.pth` | d=11 | ~121 MB | transfer from d7 |
|
| 37 |
+
| `d15.pth` | d=15 | ~121 MB | transfer from d11 |
|
| 38 |
+
| `d19.pth` | d=19 | ~121 MB | transfer from d15 |
|
| 39 |
+
| `d23.pth` | d=23 | ~121 MB | transfer from d19 |
|
| 40 |
+
| `d25.pth` | d=25 | ~122 MB | transfer from d23 |
|
| 41 |
+
|
| 42 |
+
Each checkpoint contains:
|
| 43 |
+
- `model_state` — OrderedDict of model weights
|
| 44 |
+
- `d` — code distance (int)
|
| 45 |
+
- `rounds` — decoding rounds (int)
|
| 46 |
+
- `step` — training step (int)
|
| 47 |
+
|
| 48 |
+
## Usage
|
| 49 |
+
|
| 50 |
+
```python
|
| 51 |
+
import torch
|
| 52 |
+
from huggingface_hub import hf_hub_download
|
| 53 |
+
|
| 54 |
+
# Download checkpoint
|
| 55 |
+
ckpt_path = hf_hub_download(
|
| 56 |
+
repo_id="Dreamworldsmile/ntu-surface-code-decoder",
|
| 57 |
+
filename="d7.pth",
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
# Load into AlphaQubit V2
|
| 61 |
+
ckpt = torch.load(ckpt_path, map_location="cpu", weights_only=False)
|
| 62 |
+
model.load_state_dict(
|
| 63 |
+
{k.replace("_orig_mod.", "").replace("module.", ""): v
|
| 64 |
+
for k, v in ckpt["model_state"].items()},
|
| 65 |
+
strict=False,
|
| 66 |
+
)
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
### With the official code
|
| 70 |
+
|
| 71 |
+
```bash
|
| 72 |
+
# Inference
|
| 73 |
+
python inference.py --hf_repo Dreamworldsmile/ntu-surface-code-decoder --d 7 --shots 100000
|
| 74 |
+
|
| 75 |
+
# Transfer learning
|
| 76 |
+
python transformer.py --mode train --d 11 \
|
| 77 |
+
--hf_resume Dreamworldsmile/ntu-surface-code-decoder/d7.pth
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
## Authors
|
| 81 |
+
|
| 82 |
+
Ge Yan, Shanchuan Li, **Shiyi Xiao**, Pengyue Ma, Hanyan Cao, Feng Pan, Yuxuan Du
|
| 83 |
+
|
| 84 |
+
*Nanyang Technological University · TUAT · Shanghai Jiao Tong University · SUTD*
|
| 85 |
+
|
| 86 |
+
## Citation
|
| 87 |
+
|
| 88 |
+
```bibtex
|
| 89 |
+
@article{ntu2024,
|
| 90 |
+
title={Transfer Learning is All You Need for Scalable Neural Decoder},
|
| 91 |
+
author={Yan, Ge and Li, Shanchuan and Xiao, Shiyi and Ma, Pengyue and
|
| 92 |
+
Cao, Hanyan and Pan, Feng and Du, Yuxuan},
|
| 93 |
+
year={2024},
|
| 94 |
+
}
|
| 95 |
+
```
|