QEC 互动教程 · 系列目录QEC Interactive Tutorials · Series Index
QEC-Bank · 互动教程系列QEC-Bank · Interactive tutorial series

从 1 + 1 到
量子纠错码
From 1 + 1 to
quantum error-correcting codes

量子计算机里的量子比特会出错。量子纠错码把一份信息分散存进许多个物理比特,再用一组「检查」发现错误、把它修掉,而检查本身不读出存的信息。这是一套按码组织的互动教程:环面码、表面码(Surface Code)、BB 码、qLDPC 码,外加一组开放问题。每个码先有从零讲起的直觉教程;表面码与 BB 码另有十篇条目导读对照 QEC-Bank 里这个码的记录逐项核对的进阶篇:每个数字从哪来、谁核对过、适用范围在哪。要先读过这个码的直觉教程。,每篇对应 QEC-Bank本系列依托的纠错码知识库。每个码(或一族码)是一个「条目」,条目里的知识按问题分成十一个「侧面」:直觉、译码器、逻辑操作、参数、证书、实现、关系、推导、参考文献、导览、表示方式。(本系列依托的纠错码知识库)里这个码的一个「侧面」:参数、译码器、逻辑门、硬件实验、证书、参考文献等。每篇都是单个 HTML 文件,中英文一键切换;所有格点实验和蒙特卡洛模拟按给定的出错概率随机抽出成千上万次噪声,逐次跑一遍纠错,数失败了多少次,用失败的比例估计失败概率。(随机抽很多次噪声、数失败的比例)都在你的浏览器本地运行。教程之间凡提到别处的内容都直接链接到原处,新符号在首次出现处即有解释。 The qubits inside a quantum computer pick up errors. A quantum error-correcting code spreads one piece of information over many physical qubits and uses a set of “checks” to find errors and undo them, without the checks reading out the stored information. This is a set of interactive tutorials organised by code: the toric code, the surface code, BB codes, qLDPC codes, plus a set of open problems. Each code starts with an intuition guide taught from zero; the surface code and the BB codes also have ten entry guidesAdvanced guides that check the QEC-Bank records for one code item by item: where each number comes from, who checked it, and where it stops applying. Read the code's intuition guide first. each, one per “facet” of the code in the QEC-BankThe knowledge base of error-correcting codes this series is built on. Each code (or code family) is an “entry”, and an entry's knowledge is split by question into eleven “facets”: intuition, decoders, logical operations, parameters, certificates, realizations, relations, derivations, references, guided tour, representations. (the knowledge base of codes this series is built on): parameters, decoders, logical gates, hardware experiments, certificates, references and so on. Each guide is a single HTML file, switchable between Chinese and English; every lattice experiment and Monte-Carlo simulationDraw thousands of random noise patterns at a given error probability, run the correction on each, count the failures, and use the failure fraction as an estimate of the failure probability. (sample the noise many times at random, count the fraction of failures) runs locally in your browser. Wherever a guide refers to material elsewhere it links straight to the spot, and every new symbol is explained where it first appears.

选择一个码 ↓Choose a code ↓ 两条难度线:零基础只需算术,每一步现场推导;高中数学假定高三水平(向量、复数、排列组合与概率,后面几篇用到对数),矩阵等新工具现场现教,所以走得更快。Two difficulty tracks: no prerequisites needs only arithmetic and derives every step on the spot; high-school math assumes final-year school mathematics (vectors, complex numbers, counting and probability, logarithms in the later guides) and teaches new tools such as matrices on the spot, so it moves faster.
目录Contents
目录Catalogue

按码浏览By code

每张卡片是一个码;倒数第二张讲 qLDPC 码最常用的译码器 BP-OSD,最后一张是开放问题。卡片底部的标签说明难度:零基础 = 只用算术;高中数学 = 高三水平的数学;条目导读 = 对照 QEC-Bank 的记录逐项核对的进阶篇,要先读过这个码的直觉教程。QEC-Bank 把一个码的知识分成十一个侧面(直觉、译码器、逻辑操作……每个侧面回答一类问题)。表面码与 BB 码每个侧面一篇;环面码与 qLDPC 码目前只有直觉篇,之后按同样的结构补齐。 One card per code; the second-to-last covers BP-OSD, the workhorse decoder of qLDPC codes, and the last card is the open problems. The tags at the bottom of a card give the level: no prerequisites = arithmetic only; high-school = final-year school mathematics; entry guides = advanced guides that check the QEC-Bank records item by item, to be read after that code's intuition guide. The QEC-Bank splits what is known about a code into eleven facets (intuition, decoders, logical operations…; each facet answers one kind of question). The surface code and the BB codes have one guide per facet; the toric code and qLDPC codes have their intuition guide so far and will be filled in with the same structure.

  • Toric Code · 环面码The toric code→ 量子纠错从这里开始。先学奇偶检查只问一组比特里 1 的个数是奇数还是偶数,得到一个「过 / 不过」的答案,不读出每个比特各是什么。:挑好的检查对每个合法的编码状态都给出同样的答案,所以只问奇偶就能发现错误,却不泄露存的是什么。例如 3 比特重复码把 0 存成 000、1 存成 111:「第 1、2 位一样吗」「第 2、3 位一样吗」对两者都答「一样」,只有出错才答「不一样」;而「三位里 1 的个数是偶数吗」会把 000(偶)和 111(奇)分开,等于读出了存的比特,所以不能拿来当检查;再学量子比特和测量。然后把比特放在网格的边上,每个顶点一条「星」检查、每个方格一条「面」检查(这种检查的正式名字叫稳定子一条检查:作用在几个比特上的一串翻转操作,存好信息的状态经过它保持不变。测它只得到「过 / 不过」,不泄露存的信息。),网格上下、左右各自首尾相接,成为一个环面。信息存在绕环面一整圈的操作里(逻辑算符改写存储的信息、却不触发任何检查的操作。在环面码上,它是绕环面一整圈的一串翻转。),局部的小错误改不了它。最后玩译码只根据哪些检查没通过(警报),推断发生了什么错误并把它修掉。游戏:只看警报,猜出错误并修复。零基础版 · 高中数学版Where quantum error correction starts. First parity checksAsk only whether a group of bits contains an odd or an even number of 1s: a pass / fail answer that does not reveal what each bit is.: well-chosen checks give the same answer on every valid encoded state, so asking only for parities finds errors without revealing what is stored. The 3-bit repetition code, for instance, stores 0 as 000 and 1 as 111: “are bits 1 and 2 equal?” and “are bits 2 and 3 equal?” answer “yes” for both and “no” only after an error, whereas “is the number of 1s among all three even?” tells 000 (even) from 111 (odd), reads out the stored bit, and so cannot serve as a check; then qubits and measurement. Next the qubits go on the edges of a grid, with one “star” check at every vertex and one “face” check on every square (the formal name for such a check is a stabilizerA check: a string of flips on a few qubits that leaves the encoded state unchanged. Measuring it only returns pass / fail and reveals nothing about the stored information.), and the grid's top and bottom, left and right edges are glued together into a torus. The information lives in operations that wind once around the torus (logical operatorsOperations that rewrite the stored information without setting off any check. On the toric code, a string of flips that winds once around the torus.), which small local errors cannot change. Last, the decodingWorking out, only from which checks failed (the alarms), what error happened, and undoing it. game: see only the alarms, guess the error and repair it. No-prerequisites · high-school edition 零基础no prerequisites高中数学high-school
  • Surface Code · 表面码The surface code→ 芯片是平的,所以把环面码剪开铺平:得到今天各大团队在芯片上真正在造的码。直觉教程(零基础版 · 高中数学版)讲两种边界怎样分工、一轮纠错怎样用帮手比特测检查、平面上的译码游戏,最后在浏览器里现场测出阈值物理错误率的一条临界线:低于它,把码做大,信息被改写的概率就下降;高于它,做大反而更糟。它的数值取决于噪声模型和译码器。。另外十篇条目导读各讲一个侧面:译码器、格点手术(逻辑门)、参数、硬件实验、证书、关系、推导、参考文献、导览、表示方式。从条目总览进入。Chips are flat, so cut the toric code open and lay it flat: the result is the code major teams are actually building on chips today. The intuition guides (no-prerequisites · high-school) cover how the two kinds of boundary divide the work, how one round of correction measures the checks with helper qubits, the decoding game on a flat patch, and finally a live measurement of the thresholdA critical physical error rate: below it, making the code bigger lowers the chance that the information is rewritten; above it, bigger is worse. Its value depends on the noise model and the decoder. in your browser. Ten further entry guides cover one facet each: decoders, lattice surgery (logical gates), parameters, hardware experiments, certificates, relations, derivations, references, guided tour, representations. Enter via the entry overview. 零基础no prerequisites高中数学high-school条目导读entry guides
  • BB 码 · 双变量自行车码Bivariate bicycle codes→ 为什么值得学:码距最少要同时错几个比特,才能在不触发任何检查的情况下改写信息。码距越大,信息越安全。为 12 的表面码(12 × 12 的旋转版)用 144 个数据比特只存 1 个逻辑比特被保护起来的那份信息的单位。一个码用 n 个物理比特存 k 个逻辑比特。;BB 码家族里的 gross 码用同样 144 个比特存 12 个,码距也是 12。代价是每条检查要碰到芯片上相隔较远的比特。直觉教程(高中数学)从零推导它怎样由两个多项式造出、12 从哪里来;另外十篇条目导读各讲一个侧面:译码器(置信传播加有序统计译码,简称 BP-OSD)、逻辑门、参数、硬件实验、证书、关系、推导、参考文献、导览、表示方式。从条目总览进入。Why it is worth learning: a surface code of distanceThe smallest number of qubits that must go wrong together to rewrite the information without setting off any check. The larger the distance, the safer the information. 12 (the rotated 12 × 12 version) spends 144 data qubits on a single logical qubitThe unit of protected information. A code stores k logical qubits in n physical qubits.; the gross code, one member of the BB family, stores 12 in the same 144 qubits, also at distance 12. The price is that each check has to reach qubits that sit far apart on the chip. The intuition guide (high-school) derives from zero how the code is built from two polynomials and where the 12 comes from; ten further entry guides cover one facet each: decoders (belief propagation plus ordered-statistics decoding, BP-OSD for short), logical gates, parameters, hardware experiments, certificates, relations, derivations, references, guided tour, representations. Enter via the entry overview. 高中数学high-school条目导读entry guides
  • qLDPC 码qLDPC codes→ LDPC(低密度奇偶检查)码:每条检查只碰几个比特,每个比特只进几条检查。「好」码:逻辑比特数和码距都与比特总数成正比地增长。表面码的检查是稀疏的,但这两条增长性质都没有:一块旋转表面码只存 k = 1 个逻辑比特,码距 d = √n。检查保持稀疏、同时两条都做到的量子码(渐近好的 qLDPC 码)直到 2021–2022 年才造出来:Panteleev 与 Kalachev 的提升积码(arXiv:2111.03654),以及 Leverrier 与 Zémor 的量子 Tanner 码(arXiv:2202.13641)。本篇讲两种造法:超图积(把两条经典码「相乘」,重复码乘重复码就是表面码)与提升积(把矩阵里的 0/1 换成多项式,BB 码是它最小的例子),沿途读 QEC-Bank 里的重要条目,从 [[7,2,2]]码参数的记法 [[n, k, d]]:n 个物理比特、k 个逻辑比特、码距 d。[[7,2,2]] 就是 7 个比特存 2 个逻辑比特、码距 2。 到量子 Tanner 码;最后讲怎样译码:置信传播(BP,比特与检查之间来回传「我错了吗」的消息)卡住的两个原因,有序统计译码(OSD)怎样收尾,以及只看局部的翻转译码。LDPC (low-density parity-check) codes: each check touches only a few qubits and each qubit sits in only a few checks. “Good” codes: the number of logical qubits and the distance both grow in proportion to the total number of qubits. The surface code has sparse checks, but neither of these two growth properties: one rotated surface-code patch stores k = 1 logical qubit at distance d = √n. Quantum codes that keep their checks sparse and still have both properties (asymptotically good qLDPC codes) were first built in 2021–2022: the lifted-product codes of Panteleev and Kalachev (arXiv:2111.03654) and the quantum Tanner codes of Leverrier and Zémor (arXiv:2202.13641). This guide covers two constructions: the hypergraph product (“multiply” two classical codes; repetition code times repetition code is the surface code) and the lifted product (replace the 0s and 1s of a matrix by polynomials; the BB code is its smallest example), reading the important QEC-Bank entries along the way, from [[7,2,2]]The notation [[n, k, d]] for a code: n physical qubits, k logical qubits, distance d. So [[7,2,2]] stores 2 logical qubits in 7 qubits at distance 2. to quantum Tanner codes; last, decoding: the two reasons belief propagation (BP, bits and checks passing “am I wrong?” messages back and forth) gets stuck, how ordered-statistics decoding (OSD) finishes the job, and decoders that flip bits using only local information. 高中数学high-school
  • BP-OSD 译码器The BP-OSD decoder→ qLDPC 码最常用的译码器,从零讲起:先把译码写成概率推断,推出置信传播(BP)的两条消息规则,并在没有圈的图上验证它精确;再看圈、min-sum、阻尼,以及量子码的退化为什么会让 BP 卡住;然后是 OSD:按 BP 给出的可靠度排序,在二元域上做高斯消元,解出一个满足症状的修复;最后是实际使用的参数、一个蒙特卡洛实验台,以及电路级的探测器错误模型。The workhorse decoder of qLDPC codes, from scratch: decoding as probabilistic inference; the two message rules of belief propagation (BP), exact on graphs without cycles; cycles, min-sum and damping, and why quantum degeneracy stalls BP; then OSD, which ranks bits by BP’s reliabilities and solves for a syndrome-consistent repair by Gaussian elimination over GF(2); finally the parameters used in practice, a Monte Carlo bench and circuit-level detector error models. 高中数学high-school
  • Wanted · 十个开放问题Wanted · ten open problems→ QEC-Bank 记账时凡是只能写「不知道」的地方,都集中挂在一块「Wanted 板」上,其中十个问题仍然完全开放,例如:怎样快速而可靠地算出一个大码的码距;怎样高效地找到并证明:两份检查清单在给比特重新编号、在单个比特上换基之后是同一个码(比特编号固定、只是换了一组生成元时,做一遍消元就能判定,这部分不难)。每个问题一篇:用人话说它在问什么、QEC-Bank 现在怎么凑合、有了答案能多知道什么、合格的答案长什么样、为什么难。大多只要求读过《从高考数学到 Toric Code》。从开放问题总览进入。Wherever the QEC-Bank can only record “unknown”, the gap goes onto a “Wanted board”; ten of its problems are still fully open, for example how to compute the distance of a large code quickly and reliably, or how to find and certify, efficiently, that two check lists are the same code after renumbering the qubits and changing the basis on single qubits (with the qubit labels fixed, deciding whether two lists merely use different generators takes one round of elimination and is not the hard part). One guide per problem: what it asks in plain words, how the QEC-Bank copes today, what an answer would let us know, what a qualifying answer looks like, and why it is hard. Most need only “From High-School Math to the Toric Code”. Enter via the open-problems overview. 高中数学high-school
路线Routes

两条阅读路线Two reading routes

零基础路线。只假定算术,每一步都现场推导:

No-prerequisites route. Assumes only arithmetic; everything is derived on the spot:

  1. 《从 1+1 到 Toric Code》“From 1+1 to the Toric Code”
  2. 《从 Toric Code 到 Surface Code》“From Toric Code to Surface Code”

高中数学路线。用矩阵、复数、排列组合与对数,从环面码一路走到「好」码(逻辑比特数和码距都与比特总数成正比地增长的码)。每篇的开头写着它承接哪一篇:

High-school route. Uses matrices, complex numbers, counting and logarithms to go from the toric code all the way to “good” codes (codes whose number of logical qubits and distance both grow in proportion to the total number of qubits). Each guide says at the top which guide it follows:

  1. 《从高考数学到 Toric Code》“From High-School Math to the Toric Code”
  2. 《Surface Code · 高中数学版》“The Surface Code · High-School Edition”
  3. 《译码器 · 高中数学版》“Decoders · High-School Edition”
  4. 《格点手术 · 高中数学版》“Lattice Surgery · High-School Edition”
  5. 《BB 码 · 高中数学版》“BB Codes · High-School Edition”
  6. 《qLDPC 码 · 高中数学版》“qLDPC Codes · High-School Edition”
  7. 《BP-OSD 译码器 · 高中数学版》“The BP-OSD Decoder · High-School Edition”

两条路线在表面码处汇合。读完任一版表面码教程,就可以读 Surface Code 条目总览里的参数、硬件实验、证书、关系、推导、参考文献、导览、表示方式八篇条目导读(证书篇还要求先读参数篇);译码器与格点手术两篇用到对数和排列组合,属于上面的高中数学路线。《BP-OSD 译码器》只要求读过环面码教程里的奇偶检查与症状(2.3 节)和「逻辑比特数 = 比特数 − 独立检查数」(4.4 节),先读表面码的译码器篇会更顺。BB 码的条目导读都要求先读《BB 码 · 高中数学版》;其中译码器篇还要求表面码的译码器篇,逻辑门篇还要求格点手术篇,证书篇还要求《BB 码 · 参数与实例》。

The two routes meet at the surface code. After either surface-code guide you can read eight of the entry guides in the surface-code entry overview: parameters, hardware experiments, certificates, relations, derivations, references, guided tour, representations (the certificates guide also assumes the parameters guide). The decoders and lattice-surgery guides use logarithms and counting and belong to the high-school route above. “The BP-OSD Decoder” assumes only parity checks and syndromes (toric-code tutorial, §2.3) and the count “logical qubits = qubits − independent checks” (§4.4); the surface-code decoders guide first makes it easier. The BB entry guides all assume “BB Codes · High-School Edition”; the BB decoders guide also assumes the surface-code decoders guide, the BB logical-gates guide the lattice-surgery guide, and the BB certificates guide “BB Codes · Parameters & Instances”.

尾声Epilogue

关于这套教程About these guides

文件按 <码>/<侧面>/<侧面>.html 存放,同一侧面有两个版本时,高中数学版在文件名后加 -hs;只有一种版本时不加后缀。所有教程共用同一套页面样式与交互部件。QEC-Bank 站点在 a85tract.github.io/QEC-Bank,可从各篇直接跳转。

Files live at <code>/<facet>/<facet>.html; when a facet has two editions, the high-school one has -hs appended to the file name, and a facet with a single edition has no suffix. All guides share the same page style and interactive components. The QEC-Bank site is at a85tract.github.io/QEC-Bank and is linked from every guide.

QEC-Bank 在每个数字和每条说法旁边写一个证据词,说明它是怎么来的;各篇教程沿用这几个词:

Next to every number and every statement the QEC-Bank writes an evidence word saying how it was obtained; the guides keep these words:

  • verified:QEC-Bank 的验证程序独立重算过,结果与登记的一致。verified: the QEC-Bank verifier recomputed it independently and got the recorded value.
  • bounded:只登记了一个下界和一个上界(例如下界来自定理或文献,上界来自找到的一个具体例子),没有一台机器把两者合成精确值。bounded: only a lower and an upper bound are recorded (for example a lower bound from a theorem or a paper and an upper bound from one concrete example that was found); no machine has closed the two into an exact value.
  • claimed:文献这样说,QEC-Bank 没有重算。claimed: a paper says so; the QEC-Bank has not recomputed it.
  • demonstrated:有被引用的实验论文在真实硬件上报告过。demonstrated: a cited experimental paper has reported it on real hardware.
  • proposed:设计已具体到可以模拟或估算成本,但还没有物理系统执行过。proposed: the design is concrete enough to simulate or cost, but no physical system has run it.