Spaces:
Sleeping
Sleeping
Download app/decoder.py from Rohith9059/quantum-qec: direct link, hf CLI and curl.
- Browser
- Download file 833 Bytes
-
https://huggingface.co/spaces/Rohith9059/quantum-qec/resolve/main/app/decoder.py
- Command line
-
hf download hf://spaces/Rohith9059/quantum-qec/app/decoder.py
-
curl -L -o decoder.py https://huggingface.co/spaces/Rohith9059/quantum-qec/resolve/main/app/decoder.py
833 Bytes
| from __future__ import annotations | |
| from typing import Dict, List | |
| def baseline_decoder(syndrome: List[int], n_qubits: int) -> Dict[int, str]: | |
| """ | |
| Simple deterministic decoder used for /baseline. | |
| It maps active syndrome bits to nearby qubit indices and applies alternating | |
| X/Z corrections, which creates a stable non-adaptive reference policy. | |
| """ | |
| corrections: Dict[int, str] = {} | |
| if not syndrome: | |
| return corrections | |
| for idx, bit in enumerate(syndrome): | |
| if bit != 1: | |
| continue | |
| q = idx % max(1, n_qubits) | |
| corrections[q] = "X" if (idx % 2 == 0) else "Z" | |
| # Cap correction count to keep action bounded and low latency. | |
| if len(corrections) > 12: | |
| items = list(corrections.items())[:12] | |
| corrections = dict(items) | |
| return corrections | |