Command Palette

Search for a command to run...

Назад к скиллам
скилл № 29108

quantum-error-correction

Use this skill when the user says 'stabilizer code', 'surface code circuit', 'syndrome extraction', 'decoder', 'MWPM', 'PyMatching', 'Stim', 'simulate logical…

БесплатноБез исполняемых скриптов
j4flmaoот j4flmao★ 47 звёзд на GitHub

Установить quantum-error-correction в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

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

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)

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 we
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • references/merged-fundamental-quantum-error-correction.md

FAQ

Что делает скилл quantum-error-correction?

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).

Как установить скилл quantum-error-correction?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл quantum-error-correction запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить quantum-error-correction с