qalgora-Q Docs Hub量子文档 ✦ Ask AI✦ 问问文档

qalgora-QX · Quantum Error Correction

○ Planned · Not yet implemented
The capabilities described on this page are planned and not yet implemented or released. They explain future design directions and should not be interpreted as delivered features.

The QEC library provides encoders, syndrome measurement, and decoders for stabilizer codes — the building blocks of fault-tolerant quantum computing.

Planned extension library
qalgora-QX is a planned extension library; qalgora-qec is not yet published and cannot be installed today; the APIs below are planned interfaces.

Installation

# python3 -m pip install qalgora-qec   # planned — not yet installable

A repetition-code memory experiment

The snippet below is a planned/specification interface — it sketches the intended encode → noise → syndrome → decode flow rather than a runnable reference build.

import qalgora_qec as qec

# 3-qubit bit-flip repetition code (planned / spec interface)
code = qec.get_code("repetition", distance=3)

# encode -> noise -> syndrome-extraction
noise = qec.NoiseModel.bit_flip(p=0.01)
state = code.encode_logical_zero()
syndromes = code.measure_syndromes(state, rounds=5, noise_model=noise)

decoder = qec.get_decoder("lookup", code)
corrections = decoder.decode(syndromes)
ler = code.logical_error_rate(syndromes=syndromes, corrections=corrections)
print("logical error rate:", ler)
Specification API — not in the open reference build yet
This example shows a qalgora-Q specification API (or a third-party library) that the open reference build does not bundle today. It documents the intended interface; to run code now, use the reference build’s supported core API.

Codes & decoders

CodeNotes
"repetition"Bit-flip-only, the simplest distance-d memory
"steane"[[7,1,3]] CSS code, corrects any single error
"surface"2D topological code, distance-configurable
DecoderMethodBest forStatus
"lookup"syndrome → correction lookup table for small codes or low-weight errorssmall codes, fastestplanned interface
"matching"minimum-weight perfect matching (MWPM)surface / matchable codesplanned interface
"bposd"belief propagation + ordered-statistics decodinggeneral qLDPC codesplanned interface
"qldpc-gpu"GPU-accelerated BP + OSD, batched over shotslarge qLDPC at scaleplanned interface
"tensor-network"contracts the error tensor network for near-ML accuracyhighest accuracy, small/medium codesplanned interface
"sliding-window"decodes a streaming window of rounds for low latencyreal-time / continuous syndrome streamsplanned interface

Real-time decoding

For a fault-tolerant control loop the decoder runs while syndromes arrive. Feed rounds in as they are measured and pull corrections back without waiting for the full experiment, then reset between logical operations.

Pauli frame
Real-time systems usually update a Pauli frame — a running record of inferred corrections carried in software — rather than physically applying every correction each round; the frame is only resolved into real gates when it must affect a measurement or a non-Clifford operation.
decoder = qec.get_decoder("sliding-window", code, window=3)

for round_syndromes in syndrome_stream:        # arriving each QEC cycle
    decoder.enqueue_syndromes(round_syndromes)
    correction = decoder.get_corrections()      # latest frame correction
    apply_feedback(correction)

decoder.reset_decoder()                         # clear state for the next logical block

Decoding from a detector error model

Decoders consume a Detector Error Model — the graph of how noise flips detectors — which you can extract straight from a noisy syndrome circuit.

dem = qalgora.dem_from_kernel(code.syndrome_circuit, noise_model=noise)
decoder = qec.get_decoder("matching", dem)
logical_errors = decoder.decode_batch(detector_samples)
Specification API — not in the open reference build yet
This example shows a qalgora-Q specification API (or a third-party library) that the open reference build does not bundle today. It documents the intended interface; to run code now, use the reference build’s supported core API.

Tools

  • Parity-check matrices, Tanner graphs, and stabilizer generators.
  • Threshold estimation by sweeping physical error rate across code distances.
  • Logical error-rate analysis to confirm the below-threshold regime.
Scaling
Surface-code simulation is memory-hungry. When a GPU target becomes available in a future build, you could run syndrome sampling on it and decode in batches to study larger distances; the current public reference build does not include this capability.

qalgora-QX · 量子纠错

○ 规划中
本页所述能力属于规划功能,当前尚未发布或尚未实现。相关内容仅用于说明未来设计方向,不应理解为已交付能力。

QEC 库提供稳定子码所需的编码器、校验子测量与解码器——这些是构建容错量子计算的基础模块。

规划中的扩展库
qalgora-QX 属规划中扩展库;qalgora-qec 尚未发布,当前不可安装;以下 API 为规划接口。

安装

# python3 -m pip install qalgora-qec   # 规划中,暂不可安装

重复码存储实验

下面这段属于规划/规范接口,仅勾勒「编码 → 噪声 → 校验子 → 解码」的预期流程,并非可运行的参考实现。

import qalgora_qec as qec

# 3 比特比特翻转重复码(规划/规范接口)
code = qec.get_code("repetition", distance=3)

# 编码 -> 噪声 -> 校验子提取
noise = qec.NoiseModel.bit_flip(p=0.01)
state = code.encode_logical_zero()
syndromes = code.measure_syndromes(state, rounds=5, noise_model=noise)

decoder = qec.get_decoder("lookup", code)
corrections = decoder.decode(syndromes)
ler = code.logical_error_rate(syndromes=syndromes, corrections=corrections)
print("logical error rate:", ler)
规范接口 · 参考实现暂未包含
此示例展示的是 qalgora-Q 规范中的接口(或第三方库),开放参考实现目前尚未内置,仅用于说明预期用法;如需立即运行,请使用参考实现已支持的核心 API。

纠错码与解码器

纠错码说明
"repetition"仅处理比特翻转,码距为 d 的最简存储码
"steane"[[7,1,3]] CSS 码,可纠正任意单量子比特错误
"surface"二维拓扑码,码距可配置
解码器方法适用状态
"lookup"小码或低权重错误的校验子到纠正查找表小码 最快规划接口
"matching"最小权完美匹配 MWPM表面码 / 可匹配码规划接口
"bposd"置信传播 + 有序统计解码通用 qLDPC 码规划接口
"qldpc-gpu"GPU 加速的 BP + OSD 跨 shot 批处理大规模 qLDPC规划接口
"tensor-network"收缩误差张量网络 逼近最大似然精度最高精度 中小码规划接口
"sliding-window"对滚动的若干轮窗口解码 低延迟实时 / 连续校验子流规划接口

实时解码

在容错控制回路里,解码器在校验子到达的同时就开始运行:各轮一边测量一边喂进来,不必等整个实验结束就能取回纠正,随后在逻辑操作之间复位。

泡利帧
实时系统通常是更新一个泡利帧——在软件里维护一份累积的推断纠正记录——而不是每一轮都把所有纠正物理地施加到线路上;只有当它必须影响测量或非 Clifford 操作时,才把泡利帧落实为真正的门。
decoder = qec.get_decoder("sliding-window", code, window=3)

for round_syndromes in syndrome_stream:        # 每个 QEC 周期到达
    decoder.enqueue_syndromes(round_syndromes)
    correction = decoder.get_corrections()      # 最新帧的纠正
    apply_feedback(correction)

decoder.reset_decoder()                         # 为下一个逻辑块清空状态

从探测器错误模型解码

解码器以探测器错误模型为输入——该图描述了噪声如何翻转探测器——可直接从含噪校验子线路中提取。

dem = qalgora.dem_from_kernel(code.syndrome_circuit, noise_model=noise)
decoder = qec.get_decoder("matching", dem)
logical_errors = decoder.decode_batch(detector_samples)
规范接口 · 参考实现暂未包含
此示例展示的是 qalgora-Q 规范中的接口(或第三方库),开放参考实现目前尚未内置,仅用于说明预期用法;如需立即运行,请使用参考实现已支持的核心 API。

工具

  • 校验矩阵、Tanner 图与稳定子生成元。
  • 通过扫描不同码距下的物理错误率来估算阈值。
  • 逻辑错误率分析,用于确认系统处于低于阈值的工作区间。
扩展性
表面码仿真对内存需求较高。未来 GPU 目标可用时,可在其上进行校验子采样并分批解码,以支持更大码距的研究;当前公开参考实现不包含该能力。