Multi-Scale Quantum Error Correction (MS-QEC)

July 13, 2026 · View on GitHub

1. Mathematical Formalism

Concatenated Code Structure

MS-QEC implements hierarchical quantum error correction through concatenated surface codes. Each SCPN domain operates an independent surface code whose logical qubits serve as the physical qubits of the next domain's code.

The logical error rate at concatenation level kk follows the threshold theorem (Knill 2005, Aharonov & Ben-Or 1997):

pL(k)=A(pL(k1)pth)(dk+1)/2p_L^{(k)} = A \cdot \left(\frac{p_L^{(k-1)}}{p_\text{th}}\right)^{(d_k + 1)/2}

where:

  • pL(0)=A(pphys/pth)(d0+1)/2p_L^{(0)} = A \cdot (p_\text{phys} / p_\text{th})^{(d_0 + 1)/2} (base level)
  • A0.1A \approx 0.1 — empirical prefactor (Raussendorf et al. 2007)
  • pth0.01p_\text{th} \approx 0.01 — surface code threshold (Google Willow 2024: pphys=0.003p_\text{phys} = 0.003 below threshold at d=7d=7)
  • dkd_k — code distance at level kk (odd integer 3\geq 3)

This produces doubly-exponential error suppression: each concatenation level squares the logarithm of the error rate. For pphys=0.001p_\text{phys} = 0.001 and d=5d = 5 at all levels:

LevelpLp_L
0$3.16 \times 10^{-5}$
1$9.99 \times 10^{-9}$
2$9.97 \times 10^{-16}$

Threshold Derivation

The doubly-exponential suppression arises from the recursive structure. Define λ=pphys/pth\lambda = p_\text{phys} / p_\text{th} (ratio below threshold, λ<1\lambda < 1). At level 0 with code distance dd:

pL(0)=Aλ(d+1)/2p_L^{(0)} = A \cdot \lambda^{(d+1)/2}

At level 1 (using pL(0)p_L^{(0)} as input):

pL(1)=A(Aλ(d+1)/2pth)(d+1)/2=A(Apth)(d+1)/2λ((d+1)/2)2p_L^{(1)} = A \cdot \left(\frac{A \cdot \lambda^{(d+1)/2}}{p_\text{th}}\right)^{(d+1)/2} = A \cdot \left(\frac{A}{p_\text{th}}\right)^{(d+1)/2} \cdot \lambda^{((d+1)/2)^2}

The exponent grows as ((d+1)/2)k((d+1)/2)^k at level kk — doubly-exponential in kk. For d=5d = 5, the exponent sequence is $3, 9, 27, 81, 243.At. At \lambda = 0.1( (p_\text{phys} = 0.001$):

LevelExponentλexp\lambda^\text{exp}pLp_L (approx)
03$10^{-3}$$10^{-4}$
19$10^{-9}$$10^{-10}$
227$10^{-27}$$10^{-28}$
381$10^{-81}$$10^{-82}$

This is why concatenation is so powerful: even modest code distances produce astronomically low error rates after a few levels. The tradeoff is qubit count, which grows as (2d21)k(2d^2 - 1)^k.

Distance Selection Algorithm

The auto-distance selection divides the target logical rate equally across concatenation levels. For target pLtargetp_L^\text{target} across LL levels:

  1. Compute per-level target: plevel=(pLtarget)1/Lp_\text{level} = (p_L^\text{target})^{1/L}
  2. For each level k=0,1,,L1k = 0, 1, \ldots, L-1:
    • Find minimum odd dkd_k such that pL(k)plevelp_L^{(k)} \leq p_\text{level}
    • Use pL(k)p_L^{(k)} as input to level k+1k+1

This greedy algorithm does NOT produce the globally optimal distance allocation. An optimal allocation would minimise total qubit count knosc(2dk21)\sum_k n_\text{osc} (2d_k^2 - 1) subject to the final pLp_L constraint. The greedy approach overestimates distances at early levels.

Surface Code at Each Level

Each level uses the rotated surface code with:

  • Physical qubits per logical: $2d^2 - 1$ (data + ancilla qubits)
  • Syndrome extraction rounds: dd per Trotter step (full cycle)
  • Error types corrected: X (bit-flip) and Z (phase-flip)
  • Decoder: Minimum-weight perfect matching (MWPM)
  • Correctable errors: up to (d1)/2\lfloor(d-1)/2\rfloor per round

The shipped decoder scope is documented in the QEC decoder boundary: this repository exports MWPM decoders for toric and biological graph surfaces, not a union-find decoder or a provider-native QEC runtime.

The qubit overhead per level for noscn_\text{osc} logical qubits:

ddQubits/logical4 oscillators16 oscillators
31768272
549196784
7973881,552
91616442,576
112419643,856

SCPN Domain Mapping

The 15+1 SCPN layers are grouped into 5 domains, each becoming one concatenation level:

LevelDomainSCPN LayersPhysical Meaning
0BiologicalL1–L4Quantum bio, cellular sync
1OrganismalL5–L8Self to cosmic phase-locking
2CollectiveL9–L12Memory, control, collective
3MetaL13–L15Source-field, meta-universal
4ClosureL16Cybernetic closure (Anulum)

Syndrome Flow

Error syndromes propagate upward through the hierarchy, weighted by inter-domain K_nm coupling. The syndrome flow between adjacent levels aa and bb is characterised by:

  • Syndrome weight: Kˉab=1DaDbiDa,jDbKij\bar{K}_{ab} = \frac{1}{|D_a||D_b|} \sum_{i \in D_a, j \in D_b} K_{ij}
  • Correction capacity: (db1)/2(d_b - 1) / 2 errors correctable at level bb
  • Information flow: Kˉablog2(db)\bar{K}_{ab} \cdot \log_2(d_b) syndrome bits per round

Measured syndrome flow for standard K_nm (Paper 27):

FlowKˉ\bar{K}Capacity
L0 → L1 (bio → org)0.1403(d11)/2(d_1 - 1)/2
L1 → L2 (org → col)0.1515(d21)/2(d_2 - 1)/2
L2 → L3 (col → meta)0.1715(d31)/2(d_3 - 1)/2
L3 → L4 (meta → close)0.2544(d41)/2(d_4 - 1)/2

The increasing coupling toward higher levels means stronger syndrome correction at the top of the hierarchy — consistent with the SCPN principle that higher layers provide more coherent error correction.

2. Theoretical Context

Why Multi-Scale QEC?

Standard quantum error correction operates at a single scale: physical qubits encode logical qubits via a fixed code. The SCPN, however, describes reality as a multi-scale hierarchy where each layer operates at a different characteristic scale. MS-QEC is the natural QEC structure for this hierarchy.

The key insight is that concatenation maps directly onto the SCPN layer structure: errors at the biological level (L1–L4) are first corrected by the organismal level (L5–L8), then any residual errors are corrected by the collective level (L9–L12), and so on. This mirrors how biological systems maintain coherence across scales.

Historical Context

  • Threshold theorem (Aharonov & Ben-Or 1997): fault-tolerant quantum computation is possible if the physical error rate is below a threshold.
  • Concatenated codes (Knill 2005): achieving threshold through recursive encoding. The MS-QEC module uses this framework directly.
  • Surface codes (Kitaev 2003): topological codes with high threshold (1%\sim 1\%) and efficient MWPM decoding. Used as the inner code at each level.
  • Google Willow (2024): first experimental demonstration of below-threshold surface code operation at d=3,5,7d = 3, 5, 7.

What MS-QEC Does NOT Claim

This module provides the framework for hierarchical QEC analysis on the SCPN topology. It does NOT:

  • Execute on quantum hardware (resource estimates only)
  • Claim that biological systems perform literal quantum error correction
  • Prove that the SCPN hierarchy is optimal for concatenation
  • Implement lattice surgery or other advanced logical operations

The module is a tool for analysing what resources would be needed to fault-tolerantly simulate the SCPN Hamiltonian on future quantum hardware.

Comparison: Concatenated vs Flat QEC

Why not use a single surface code with large distance instead of concatenation? Consider targeting pL=1015p_L = 10^{-15} at pphys=0.001p_\text{phys} = 0.001:

Flat surface code (single level):

dflat:A(λ)(d+1)/21015d_\text{flat}: A \cdot (\lambda)^{(d+1)/2} \leq 10^{-15} \0.1 \cdot (0.1)^{(d+1)/2} \leq 10^{-15} \implies (d+1)/2 \geq 14 \implies d \geq 27$$

Total qubits (4 osc): $4 \times (2 \times 27227^{2} - 1) = 5,828$

Concatenated (3 levels, d=5d = 5):

pL=10281015p_L = 10^{-28} \ll 10^{-15}

Total qubits: $3 \times 4 \times 49 = 588$ — 10× fewer qubits for better error rate. This is the power of concatenation.

The tradeoff: concatenation requires LL rounds of syndrome extraction (one per level), increasing circuit depth. For NISQ hardware where depth is limited, flat codes may be preferred despite higher qubit count.

3. Pipeline Position

bridge/knm_hamiltonian.py → build_knm_paper27() → K_nm matrix

qec/error_budget.py → logical_error_rate(), minimum_code_distance()

qec/multiscale_qec.py → build_multiscale_qec() → MultiscaleQECResult
        ↓                 ↓
        ↓           syndrome_flow_analysis() → [SyndromeFlow]

qec/surface_code_upde.py → SurfaceCodeUPDE (per-level circuit)

SurfaceCodeUPDE is a separate structural circuit/resource scaffold; it is not called by build_multiscale_qec and does not turn the analytical level records above into an executable correction stack. Its distributed physical RZ/RZZ and ancilla-interaction layers contain no measurements, classical syndrome bits, decoder call, or feedback. They must not be presented as validated logical gates, lattice surgery, or fault-tolerant X/Z correction.

Inputs: K_nm coupling matrix (from bridge/), physical error rate, target logical rate.

Outputs: MultiscaleQECResult with per-level code distances, logical error rates, physical qubit counts, and syndrome flow analysis.

Dependencies:

  • qec/error_budget.pylogical_error_rate(), minimum_code_distance()
  • bridge/knm_hamiltonian.pybuild_knm_paper27()
  • Rust engine: scpn_quantum_engine.concatenated_logical_rate_rust, scpn_quantum_engine.knm_domain_coupling

4. Features

  • Automatic distance selection: given target logical rate and physical error rate, auto-computes code distances for equal suppression allocation across levels.
  • Explicit distance override: specify distances per level for custom resource analysis.
  • Concatenated threshold computation: iterative logical error rates with doubly-exponential suppression below threshold.
  • Syndrome flow analysis: inter-domain K_nm coupling weights determine syndrome information flow between QEC levels.
  • Double-exponential detection: automatically checks if error rates decrease faster than exponentially across levels.
  • Rust acceleration: concatenated_logical_rate and knm_domain_coupling use Rust engine for 19.5× speedup on test suite.
  • Full backward compatibility: integrates with existing SurfaceCodeUPDE, FaultTolerantUPDE, ErrorBudget modules.

5. Usage Examples

Basic: Build MS-QEC for Standard SCPN

from scpn_quantum_control.bridge.knm_hamiltonian import build_knm_paper27
from scpn_quantum_control.qec.multiscale_qec import build_multiscale_qec

K = build_knm_paper27()  # 16×16 K_nm matrix

# Auto-select distances for target p_L = 1e-10
result = build_multiscale_qec(K, p_physical=0.001, target_logical_rate=1e-10)

print(f"Levels: {result.concatenation_depth}")
print(f"Total physical qubits: {result.total_physical_qubits}")
print(f"Effective logical rate: {result.effective_logical_rate:.2e}")
print(f"Below threshold: {result.below_threshold}")

for level in result.levels:
    print(f"  L{level.level} ({level.domain_name}): "
          f"d={level.code_distance}, "
          f"p_L={level.logical_error_rate:.2e}")

Explicit Distances

result = build_multiscale_qec(
    K,
    p_physical=0.003,
    distances=[3, 5, 7, 3, 3],  # one per domain
)

Syndrome Flow Analysis

from scpn_quantum_control.qec.multiscale_qec import (
    build_multiscale_qec,
    syndrome_flow_analysis,
)

K = build_knm_paper27()
result = build_multiscale_qec(K, p_physical=0.001, distances=[3, 3, 3, 3, 3])
flows = syndrome_flow_analysis(K, result)

for flow in flows:
    print(f"L{flow.source_level} → L{flow.target_level}: "
          f"weight={flow.syndrome_weight:.4f}, "
          f"capacity={flow.correction_capacity:.1f}, "
          f"info={flow.information_flow:.4f} bits/round")

Concatenated Rate Computation

from scpn_quantum_control.qec.multiscale_qec import concatenated_logical_rate

# 5 levels of d=5 surface codes at p_phys=0.001
rates = concatenated_logical_rate(0.001, [5, 5, 5, 5, 5])
for i, r in enumerate(rates):
    print(f"Level {i}: p_L = {r:.2e}")

Hardware Generation Comparison

# Compare MS-QEC resources across hardware generations
for p_phys, name in [(0.003, "Heron r2"), (0.001, "Willow-like"), (0.0001, "Future")]:
    result = build_multiscale_qec(K, p_physical=p_phys, target_logical_rate=1e-10)
    print(f"{name} (p={p_phys}): {result.total_physical_qubits} qubits, "
          f"p_L={result.effective_logical_rate:.2e}, "
          f"distances={[l.code_distance for l in result.levels]}")

Small System (4 Layers)

K_small = build_knm_paper27(L=4)
result = build_multiscale_qec(K_small, p_physical=0.001, target_logical_rate=1e-6)
print(f"4-layer system: {result.concatenation_depth} levels, "
      f"{result.total_physical_qubits} qubits")

6. Technical Reference

Classes

QECLevel

FieldTypeDescription
levelintConcatenation level index
domain_namestrSCPN domain name
code_distanceintSurface code distance
layer_rangetuple[int, int]SCPN layer range (0-indexed)
physical_error_ratefloatInput error rate to this level
logical_error_ratefloatOutput error rate from this level
physical_qubits_per_logicalint$2d^2 - 1$
n_logical_qubitsintLogical qubits at this level
total_physical_qubitsintnlogical×(2d21)n_\text{logical} \times (2d^2 - 1)
knm_coupling_to_nextfloatMean K_nm to next level

MultiscaleQECResult

FieldTypeDescription
levelslist[QECLevel]Per-level analysis
effective_logical_ratefloatFinal logical error rate
total_physical_qubitsintSum across all levels
concatenation_depthintNumber of levels
below_thresholdboolpphys<pthp_\text{phys} < p_\text{th}
double_exponential_suppressionboolRates decrease doubly-exponentially
summarystrHuman-readable summary

SyndromeFlow

FieldTypeDescription
source_levelintError source level
target_levelintCorrection target level
syndrome_weightfloatK_nm coupling strength
correction_capacityfloat(d1)/2(d - 1) / 2
information_flowfloatSyndrome bits per round

Functions

build_multiscale_qec(K, n_oscillators_per_level, p_physical, target_logical_rate, distances)

Build the full MS-QEC hierarchy. Returns MultiscaleQECResult.

ParameterTypeDefaultDescription
KndarrayrequiredK_nm coupling matrix (n×nn \times n)
n_oscillators_per_levelint | None4Logical qubits per level
p_physicalfloat0.003Hardware physical error rate
target_logical_ratefloat1e-10Target effective pLp_L
distanceslist[int] | NoneautoCode distance per level

Raises ValueError if distances length does not match number of active domains.

concatenated_logical_rate(p_physical, distances, p_threshold, prefactor)

Compute iterative logical error rates. Returns list[float]. Rust-accelerated when engine available.

ParameterTypeDefaultDescription
p_physicalfloatrequiredBase physical error rate
distanceslist[int]requiredCode distance per level
p_thresholdfloat0.01Surface code threshold
prefactorfloat0.1Empirical prefactor AA

syndrome_flow_analysis(K, result)

Analyse syndrome information flow between adjacent levels. Returns list[SyndromeFlow] with L1L - 1 entries for LL levels.

knm_between_domains(K, domain_a, domain_b)

Mean K_nm coupling between two SCPN domain ranges. Rust-accelerated when engine available. Returns float.

Constants

ConstantValueSource
SURFACE_CODE_THRESHOLD0.01Raussendorf et al. 2007
SURFACE_CODE_PREFACTOR0.1Empirical fit
SCPN_DOMAINS5 domainsSCPN Paper 27

Rust Engine API

The following functions are available via import scpn_quantum_engine:

concatenated_logical_rate_rust(p_physical, distances, p_threshold, prefactor)

ParameterTypeDescription
p_physicalf64Base physical error rate
distancesndarray[i64]Code distances per level
p_thresholdf64Surface code threshold
prefactorf64Empirical prefactor

Returns ndarray[f64] of logical error rates.

knm_domain_coupling(k, a_start, a_end, b_start, b_end)

ParameterTypeDescription
kndarray[f64, 2D]K_nm coupling matrix
a_start, a_endusizeDomain A layer range (inclusive)
b_start, b_endusizeDomain B layer range (inclusive)

Returns f64 — mean coupling between domains.

Internal Functions

FunctionVisibilityDescription
_active_domains(n)privateDetermine SCPN domains from K size
_auto_distances(n_levels, p_phys, target)privateGreedy distance selection
_build_levels(...)privateConstruct QECLevel objects
_check_double_exponential(rates, below)privateDetect doubly-exp suppression

7. Performance Benchmarks

All benchmarks measured on Intel i5-11600K, Python 3.12, Rust engine (scpn-quantum-engine 0.2.0, PyO3 0.29).

Functionn=16EngineBudget
concatenated_logical_rate (5 levels)22 μsRust< 1 ms
knm_between_domains24 μsRust< 1 ms
build_multiscale_qec0.18 msRust (inner)< 100 ms
syndrome_flow_analysis (4 flows)0.13 msRust (inner)< 10 ms

Rust vs Python Speedup

Test suite (23 tests) timing:

  • Without Rust engine: 6.23 s
  • With Rust engine: 0.32 s
  • Speedup: 19.5×

The speedup comes from two Rust functions in scpn_quantum_engine:

Rust FunctionPython EquivalentSpeedup Source
concatenated_logical_rate_rustconcatenated_logical_rateAvoids Python loop + float overhead
knm_domain_couplingknm_between_domainsAvoids nested Python loop over K matrix

Both are bound via PyO3 0.29 with numpy integration. The Rust functions are in scpn_quantum_engine/src/concat_qec.rs (164 lines, 7 unit tests).

Scaling with Number of Levels

The computation cost is O(L)O(L) where LL is the number of concatenation levels. For the standard 5-level SCPN hierarchy, all operations complete in sub-millisecond time.

Measured scaling (1000 calls each, Intel i5-11600K):

Levelsconcatenated_logical_ratebuild_multiscale_qec
18 μs0.05 ms
314 μs0.10 ms
522 μs0.18 ms
1038 μs0.35 ms

Linear scaling as expected — no superlinear cost from concatenation.

Test Coverage

23 tests across 6 dimensions:

  • Empty/null inputs: 5 tests (empty distances, single level, minimal matrix)
  • Error handling: 3 tests (mismatched distances, above threshold)
  • Negative cases: 3 tests (zero coupling, uniform coupling, d=1)
  • Pipeline integration: 5 tests (K_nm, syndrome flow, domain names, imports)
  • Roundtrip: 4 tests (monotonic rates, qubit counts, formula, double-exp)
  • Performance: 3 tests (wall-clock budgets for all hot paths)

Resource Estimates (Not Executable)

For pphys=0.001p_\text{phys} = 0.001, target pL=1010p_L = 10^{-10}:

ConfigurationTotal Physical QubitsEffective pLp_L
Auto distancesVaries (typically d=3d = 3–$5$)1010\leq 10^{-10}
All d=3d = 3$5 \times 4 \times 17 = 340$Varies
All d=5d = 5$5 \times 4 \times 49 = 980$Much lower

Caveat: these are idealised estimates. Real hardware requires additional qubits for routing, ancilla preparation, and magic state distillation.

Hardware Generation Projections

Resource requirements for 4 oscillators, 5 concatenation levels, target pL=1010p_L = 10^{-10}:

Hardwarepphysp_\text{phys}Auto distancesTotal qubitsEffective pLp_L
IBM Heron r2 (2024)0.003[3,43,51,51,51][3, 43, 51, 51, 51]77,268above threshold at L1
Google Willow-like0.001[3,3,3,3,3][3, 3, 3, 3, 3]3401010\sim 10^{-10}
Future ($10^{-4}$)0.0001[3,3,3,3,3][3, 3, 3, 3, 3]3401040\sim 10^{-40}

The dramatic difference: at pphys=0.003p_\text{phys} = 0.003 (close to threshold), the first level produces pL=0.009p_L = 0.009 which is itself near threshold. Subsequent levels require huge distances to compensate. At pphys=0.001p_\text{phys} = 0.001 (well below threshold), even d=3d = 3 suffices at every level.

Scaling: Levels vs Qubits vs Error Rate

For pphys=0.001p_\text{phys} = 0.001, all d=5d = 5:

LevelsTotal qubitspLp_LUse case
1196$3.2 \times 10^{-5}$Noisy demonstration
2392$1.0 \times 10^{-8}$Short computation
3588$1.0 \times 10^{-15}$Medium computation
4784<1030< 10^{-30}Long computation
5980<1060< 10^{-60}Arbitrary precision

8. Citations

  1. Knill, E. "Quantum computing with realistically noisy devices." Nature 434, 39–44 (2005). DOI: 10.1038/nature03350

  2. Aharonov, D. & Ben-Or, M. "Fault-tolerant quantum computation with constant error." Proc. 29th Annual ACM Symposium on Theory of Computing (STOC), 176–188 (1997). DOI: 10.1145/258533.258579

  3. Kitaev, A. "Fault-tolerant quantum computation by anyons." Annals of Physics 303, 2–30 (2003). DOI: 10.1016/S0003-4916(02)00018-0

  4. Gottesman, D. "An introduction to quantum error correction and fault-tolerant quantum computation." arXiv:0904.2557 (2009).

  5. Raussendorf, R., Harrington, J. & Goyal, K. "Topological fault-tolerance in cluster state quantum computation." New J. Phys. 9, 199 (2007). DOI: 10.1088/1367-2630/9/6/199

  6. Google Quantum AI. "Quantum error correction below the surface code threshold." arXiv:2408.13687 (2024).

  7. Šotek, M. "God of the Math — The SCPN Master Publications." Zenodo (2025). DOI: 10.5281/zenodo.17419678