Przejdź do treści
Biblioteka skilli
Nauka i badania · Budowanie i kod

quantum-error-correction

/quantum-error-correction

Buduje obwody korekcji błędów kwantowych w Stim i PyMatching, mierzy wskaźnik błędów logicznych i progi.

Repozytorium
agent-skills ↗
Licencja
MIT
Ostatnia zmiana repozytorium
10.11.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 10.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Buduje obwody korekcji błędów kwantowych w Stim i PyMatching, mierzy wskaźnik błędów logicznych i progi.

Wyzwalacze z opisu

stabilizer codesurface code circuitsyndrome extractiondecoderMWPMPyMatchingStimsimulate logical error rate
Oryginalny opis (EN)

Use this skill when the user says 'stabilizer code', 'surface code circuit', 'syndrome extraction', 'decoder', 'MWPM', 'PyMatching', 'Stim', 'simulate logical error rate', 'repetition code', 'detector error model', 'code distance experiment'. Hands-on QEC engineering: stabilizer formalism, repetition/Steane/surface codes, syndrome-extraction circuits, detectors and decoding with Stim + PyMatching, and threshold/logical-error-rate experiments. Do NOT use for: conceptual overhead and milestone interpretation (fundamental-truths/quantum-error-correction), basic gates (quantum-computing/qubits-and

Jak działa

  1. Purpose
  2. Agent Protocol
  3. Stabilizer Formalism
  4. Syndrome Extraction
  5. Simulation with Stim + PyMatching
  6. Repetition Code by Hand (to understand detectors)
  7. Decoders
  8. Anti-Patterns
  9. Checklist
  10. References
Sekcje z nagłówków SKILL.md, w oryginale · 132 linii, 908 słów
Podgląd SKILL.md
---
name: quantum-error-correction
description: >
  Use this skill when the user says 'stabilizer code', 'surface code circuit', 'syndrome extraction', 'decoder', 'MWPM', 'PyMatching', 'Stim', 'simulate logical error rate', 'repetition code', 'detector error model', 'code distance experiment'. Hands-on QEC engineering: stabilizer formalism, repetition/Steane/surface codes, syndrome-extraction circuits, detectors and decoding with Stim + PyMatching, and threshold/logical-error-rate experiments. Do NOT use for: conceptual overhead and milestone interpretation (fundamental-truths/quantum-error-correction), basic gates (quantum-computing/qubits-and-gates), or general Qiskit usage (quantum-computing/qiskit-framework).
version: "2.0.0"
author: "j4flmao"
license: "MIT"
tags: [quantum-computing, quantum-error-correction, surface-code, stim, pymatching, decoding]
---

# Quantum Error Correction: Codes, Circuits & Decoders

## Purpose
Build and evaluate error-correcting codes the way QEC researchers do: describe the code by its stabilizers, generate a noisy syndrome-extraction circuit, convert it into detectors and a detector error model, decode with a matching decoder, and measure the logical error rate versus distance and physical noise. Stim (fast Clifford simulation) and PyMatching (minimum-weight perfect matching) are the standard open-source tools.

## Agent Protocol

### Trigger
"stabilizer", "surface code", "repetition code", "Steane code", "syndrome extraction", "detector", "decoder", "MWPM", "PyMatching", "Stim", "logical error rate", "threshold plot".

### Input Context
- Code family and distances; noise model (circuit-level depolarizing rate p, measurement error).
- Rounds of syndrome extraction; memory (Z or X basis) experiment vs logical gates.
- Compute budget (shots).

### Output Artifact
Simulation script, logical-error-rate table/plot vs p and d, threshold estimate, and interpretation.

### Response Format
```
Code: {rotated surface code} d={3,5,7} rounds={d} basis={Z}
Noise: circuit-level depolarizing p={values}
Decoder: {PyMatching MWPM|union-find|BP-OSD}
Result: p_L per shot/round for each (d, p)
Threshold: curves cross near p ≈ {value}
```

### Completion Criteria
- [ ] Detectors and observables defined (or generated) correctly.
- [ ] Enough shots for statistically meaningful p_L (report error bars).
- [ ] Logical error normalized per round when comparing distances with different round counts.

## Stabilizer Formalism
- An [[n, k, d]] stabilizer code encodes k logical qubits into n physical qubits with distance d (corrects ⌊(d−1)/2⌋ arbitrary errors).
- The stabilizer group S is generated by commuting Pauli operators; code states are +1 eigenstates of all generators.
- Measuring generators yields the **syndrome**; errors anticommuting with a generator flip its outcome. Logical operators commute with S but are not in S.

| Code | Parameters | Notes |
|---|---|---|
| 3-qubit bit-flip (repetition) | [[3,1,1]] | Corrects one X error; Z errors go undetected (distance 1 as a quantum code) |
| Shor code | [[9,1,3]] | First full QEC code (1995) |
| Steane code | [[7,1,3]] | CSS code; transversal Clifford gates |
| Rotated surface code | [[d², 1, d]] | 2D nearest-neighbour; d² − 1 measure qubits; threshold ≈ 1% (circuit noise) |
| Toric code | [[2d², 2, d]] | Periodic boundaries; star (Aᵥ = ∏X) and plaquette (B_p = ∏Z) stabilizers |
| qLDPC (e.g. bivariate bicycle) | e.g. [[144,12,12]] | Lower overhead, needs long-range connectivity |

## Syndrome Extraction
- Z-type stabilizer: ancilla in |0⟩, CNOTs from each data qubit to the ancilla, measure Z.
- X-type stabilizer: ancilla in |+⟩ (H), CNOTs from ancilla to data, H, measure.
- CNOT ordering matters: the "hook" error ordering in surface codes is chosen so ancilla faults do not reduce effective distance.
- Repeat for ~d rounds; a **detector** is the XOR of consecutive measurements of the same stabilizer (should be 0 with no errors), which also handles measurement errors.

## Simulation with Stim + PyMatching

```python
from __future__ import annotations

import numpy as np
import pymatching
import stim


def logical_error_rate(distance: int, p: float, shots: int = 100_000) -> float:
    circuit = stim.Circuit.generated(
        "surface_code:rotated_memory_z",
        distance=distance,
        rounds=distance,
        after_clifford_depolarization=p,
        before_round_data_depolarization=p,
        before_measure_flip_probability=p,
        after_reset_flip_probability=p,
    )
    dem = circuit.detector_error_model(decompose_errors=True)
    matcher = pymatching.Matching.from_detector_error_model(dem)
    sampler = circuit.compile_detector_sampler()
    detections, observables = sampler.sample(shots, separate_observables=True)
    predictions = matcher.decode_batch(detections)
    failures = np.any(predictions != observables, axis=1)
    return float(failures.mean())


for p in (0.002, 0.005, 0.008, 0.012):
    row = {d: logical_error_rate(d, p) for d in (3, 5, 7)}
    print(p, row)
# Below threshold, p_L drops as d grows; above threshold it rises. The crossing estimates p_th.
```

For production-scale sweeps, use `sinter` (bundled with Stim's ecosystem) to parallelize sampling and stop at a target number of errors. Report per-round error: p_round = 1 − (1 − p_L)^(1/rounds).

## Repetition Code by Hand (to understand detectors)

```python
import stim

c = stim.Circuit.generated("repetition_code:memory", distance=5, rounds=5,
                           before_round_data_depolarization=0.03,
                           before_measure_flip_probability=0.01)
print(c.num_detectors, c.num_observables)    # detectors = stabilizer comparisons over rounds
print(c.diagram("timeline-text"))
```

## Decoders
| Decoder | Idea | Trade-off |
|---|---|---|
| MWPM (PyMatching) | Pair detection events with minimum total weight on the matching graph | Accurate for surface codes; fast implementations |
| Union-Find | Grow clusters, peel corrections | Near-linear time; slightly lower accuracy |
| Correlated / belief-matching | Uses X-Z correlations | Better accuracy, more compute |
| BP-OSD | Belief propagation + ordered statistics | Common for qLDPC codes |
| Neural decoders (e.g. AlphaQubit) | Learned from data | Adapt to real noise; latency/training cost |

Real hardware needs decoders that keep up with the syndrome rate (around a microsecond per round for superconducting qubits); otherwise a backlog grows.

## Anti-Patterns
- Comparing p_L across distances with different round counts without per-round normalization.
- Too few shots (zero observed failures is not p_L = 0).
- Code-capacity noise (data errors only) presented as realistic thresholds; circuit-level noise thresholds are lower.
- Forgetting measurement errors (single-round decoding).

## Checklist
- [ ] Noise model stated (code-capacity, phenomenological, or circuit-level).
- [ ] Detectors/observables validated (e.g. zero detections with p = 0).
- [ ] Sweep over d and p with error bars.
- [ ] Threshold and Λ reported with assumptions.
- [ ] Decoder choice and runtime noted.

## References
- Gottesman, "Stabilizer Codes and Quantum Error Correction" (PhD thesis, 1997).
- Dennis, Kitaev, Landahl & Preskill, "Topological quantum memory" (2002); Fowler et al., "Surface codes" (PRA 2012).
- Gidney, "Stim: a fast stabilizer circuit simulator" (Quantum, 2021); Higgott & Gidney, "Sparse Blossom" (PyMatching v2, 2023).
- Conceptual companion: `fundamental-truths/quantum-error-correction` skill.

Wersje

W bazie nie ma innych skilli o nazwie quantum-error-correction.

Migawka bazy z 13.11.2026 · wersja paczki 8f53a59d342e (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 95fundamental-quantum-error-correction
    Wyjaśnia podstawy korekcji błędów kwantowych: szumy, progi odporności, odległość kodu i koszt kubitów fizycznych na logiczny.
  • 90quantum-computing
    Projektuje i analizuje rozwiązania informatyki kwantowej: obwody kwantowe, algorytmy, korekcję błędów i ocenę przewagi kwantowej.
  • 100qubits-and-gates
    Wyjaśnia kubity, bramki jednokubitowe i dwukubitowe, pomiary i uniwersalność oraz sprawdza je w Qiskit.
  • 100quantum-information-computing
    Obejmuje informację i obliczenia kwantowe: kubity, bramki, obwody, splątanie, nierówności Bella, teleportację, algorytmy Grovera i Shora, korekcję błędów, kryptografię kwantową i platformy sprzętowe.
  • 100qiskit
    Pracuje z frameworkiem IBM Qiskit do obliczeń kwantowych na sprzęcie IBM Quantum, z Qiskit Runtime, ograniczaniem błędów kwantowych i narzędziami optymalizacji IBM.
  • 100alterlab-qiskit
    Buduje, transpiluje i uruchamia obwody kwantowe w Qiskit, frameworku IBM, z prymitywami Qiskit Runtime (Sampler i Estimator) i łagodzeniem błędów na sprzęcie IBM Quantum.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.