Three Shots at a Better lzply: GRAND-MO, RaptorQ, and the CRC Polynomials — Measured

The hot_house equation search ran ~27,500 candidates, fitted a burst model to real damage, and measured a RaptorQ outer layer on real decodes. One real win, one method that works but cannot deploy, one paper win that evaporates — and a dead end, reported as a dead end.

Three Shots at a Better lzply: GRAND-MO, RaptorQ, and the CRC Polynomials — Measured

lzply is a self-healing compression format: BCH error correction layered under lz compression, with Reed–Solomon and deep repair on top. Over the last month the question was whether anything better exists — a better decoder, a better code, a better outer layer. So we searched. Phase 1 threw ~27,500 random candidates at the problem. Phase 2 compared decoders head-to-head on the same damage. Then a file-level experiment measured a RaptorQ outer layer with real decodes, and a short-LDPC assessment ran to its end. All of it on hot_house, all of it in the experiments/randfec branch.

The bottom line, up front: one real win, one method that wins but cannot deploy, one paper win that evaporates under a real decoder, and one dead end. No deployment change is proposed. The deployed big-block BCH+BM structure stands — and this article says so plainly, with the numbers.

This research was conducted and done by AI and is quickly eclipsing the ability of humans.

1. GRAND-MO: the decoder that reads the damage

GRAND — Guessing Random Additive Noise Decoding — turns decoding upside down. Instead of correcting the received word, it guesses the noise: try the most likely error patterns first, subtract each from the received word, and stop at the first guess that lands on a valid codeword. Hard-decision GRAND orders its guesses by weight (ML within a 1M-guess budget, weight ≤ 4). GRAND-MO orders them by Markov burst-model likelihood instead (Viterbi-scored; bursts ≤ 12 + weight ≤ 4), so burst-shaped noise gets tried first.

Milestone 1 asked the control question first: at short blocks, is the BCH decoder the limit, or the code? Same polynomial, same (n, k, r) — only the decoder changes. The answer is the decoder. BCH+GRAND beats BCH+BM everywhere, by +1.6 to +13.5 points (repair rate, 10,000 trials per cell):

groupmodelBCH+BMBCH+GRAND
g1 (24,16,8)scattered p=0.0382.96%92.11%
g2 (32,16,16)scattered p=0.0393.07%99.38%
g3 (30,16,14)scattered p=0.0393.88%98.63%
g4 (64,48,16)scattered p=0.0369.50%83.01%

GRAND-MO is the burst winner. On Gilbert burst channels (mean burst L=8, BER 0.03): g1 goes 89.94% (BM) → 95.62% (GRAND-MO); g2 89.78% → 97.48%; g4 81.23% → 93.92% (+12.7 points). At BER 0.01, g4 goes 93.30% → 98.30%. But GRAND-MO is a liability on scattered errors: burst-first ordering miscorrects them, losing to plain GRAND by up to 13 points (g4 scattered p=0.03: 70.00% vs 83.01%; g1: 81.49% vs 92.11%). A practical decoder needs channel-matched ordering — model selection.

Milestone 2.1 built that selection on a model fitted to real damage. Real archives were built from the repo test corpus (mixed-e4.lzply, 1,065,235 B; big-e4.lzply, 52,431,127 B) and corrupted with the project's own corrupters — scattered bit flips and contiguous byte runs — at calibrated rates. The XOR of original vs corrupted archive is exactly the channel error pattern on the stored BCH codeword bits. A Gilbert 2-state model was fitted by matching 7 moments, then validated on window-weight histograms the fit never saw.

fit (50 MB archive)mean burstq1 (flip prob in burst)p0 (background)
FIT-RUN (4-byte runs)35.1 bits0.9999980.0000023
FIT-MIX (background + runs)29.5 bits0.9834760.000485

The fits recover the truth: 4-byte runs are 32-bit bursts, and the fit says 35.1 bits with q1 ≈ 1; the mix fit recovers the 0.0005 background almost exactly (p0 = 0.000485). Validation matches within ~15% on statistics the fit never saw.

The fitted prior recovers most of GRAND-MO's iid liability. On scattered p=0.03: g4 70.00% → 77.91% (+7.91), g5 92.30% → 96.91% (+4.61), g2 96.95% → 98.70% (+1.75), g1 81.49% → 82.42% (+0.93). On bursts it ties the oracle — GRAND-MO with the true per-channel parameters — within ±0.25 points everywhere (g2 burst-L8-BER0.03: 97.46% vs 97.48%; g4: 93.69% vs 93.92%). The fitted prior has a tiny burst frequency (f ≈ 0.0008) and q1 ≈ 1, so it is conservative about bursts: it behaves nearly like plain GRAND on scattered errors while still ranking true bursts first.

Model selection itself — a single list ordered by mixture likelihood (grandmix), or two passes arbitrated by it (grand2pass) — costs almost nothing. Worst-case regret against the best per-channel specialist is 1.84 points (g4 burst-L8-BER0.03: 93.92% → 92.08%); median regret across all 40 cells is ≤ 0.1 points; on the fitted channels it is 0.00–0.05 points. On g4 scattered p=0.03, grandmix (80.36%) even beats plain GRAND (79.96%) by 0.40 points, because its guess universe (bursts ≤ 12) includes weight-5/6 burst patterns that GRAND's W=4 list misses. grandmix and grand2pass are the same decoder in outcome — within 0.02 points in 39 of 40 cells — so prefer grandmix: one list, one scan, no arbitration logic.

Two more honest results. First, the oracle is not worth chasing: GRAND-MO with the true per-channel parameters is no better than the single fixed fitted prior on bursts, and much worse on iid. One fixed fitted prior suffices; no per-channel tuning is needed. Second, hard pre-decode model selection from the syndrome is not viable: syndrome weight is anti-correlated with burstiness (AUC 0.387 at g2 BER 0.01, 0.269 at 0.03; 0.309 and 0.184 at g4) — burst errors have lower syndrome weight, because burst channels leave most blocks clean. Conditional on the block being damaged, AUC is 0.68/0.64 at n=32 and 0.49/0.47 at n=64: weak, then none. The mixture architecture is justified precisely because it never needs a pre-decision.

The g2 and g4 matrices (repair rate %, 10,000 trials/cell)

g2 (32,16,16)BMGRANDGRAND-MOMO-fitMO-fitmixgrandmixgrand2passregret
scat-p0.0199.5399.9999.7799.9599.9299.9899.980.01
scat-p0.0393.0799.4796.9598.7098.7299.4499.440.03
burst-L8-BER0.0196.5197.2999.3099.3099.3099.0699.100.24
burst-L32-BER0.0198.1398.2598.7998.7998.7998.7198.710.08
burst-L8-BER0.0389.7891.9197.4897.4697.4597.0497.040.44
mix-L16-BER0.0198.0398.2899.1299.1299.1299.0499.040.08
burst-FITRUN-BER0.0198.2198.3098.7998.7998.7998.7998.790.00
burst-FITRUN-BER0.0394.8495.1096.8296.8296.8296.8296.820.00
burst-FITMIX-BER0.0198.0798.1998.8598.8598.8598.8098.800.05
burst-FITMIX-BER0.0394.6294.8896.7396.7396.7396.7196.710.02
g4 (64,48,16)BMGRANDGRAND-MOMO-fitMO-fitmixgrandmixgrand2passregret
scat-p0.0197.2398.6096.4398.0498.1198.6198.58-0.01
scat-p0.0369.5079.9670.0077.9177.7380.3680.21-0.40
burst-L8-BER0.0193.3094.0898.3098.1798.2897.5797.580.73
burst-L32-BER0.0197.1197.1998.0898.0298.0797.8697.860.22
burst-L8-BER0.0381.2382.8793.9293.6993.8992.0892.081.84
mix-L16-BER0.0196.2996.5298.0398.0098.0497.7597.750.28
burst-FITRUN-BER0.0197.3297.3798.1198.1198.1198.1098.100.01
burst-FITRUN-BER0.0392.0492.1794.5994.5994.5994.5494.540.05
burst-FITMIX-BER0.0197.0197.1098.0798.0798.0797.9897.980.09
burst-FITMIX-BER0.0391.6991.8894.5994.5894.5994.4294.420.17

And then the wall. GRAND is viable only at n ≤ ~128. Matching BM's t=32 at lzply's deployed n=32768 would need enumerating weight-≤8 patterns — C(32768,8), roughly 1e33 guesses. Any GRAND adoption in lzply would need a short-block format change, and the blob test rules that out on repair-rate grounds at equal overhead: one big BCH block (384 data bits + 384 parity bits) beats 24 short blocks on all six models — scattered p=0.03: 96.78% vs 46.26% for CRC-blocks+GRAND-MO, 30.92% for RLC-blocks, 17.00% for BCH-blocks+BM. Short blocks fragment the parity budget (all 24 must survive: 0.97²⁴ ≈ 0.48) and a burst landing inside one 32-bit block overwhelms it, while the big block pools t=32 across the whole blob. So GRAND-MO is a real decoder win that cannot deploy at lzply's sizes. The deployed big-block BCH+BM structure stands.

2. The CRC polynomials that won on paper

Phase 1 searched for a better code, not a better decoder: ~27,500 candidates across four families — random cyclic codes (random CRC polynomials), ROT/XOR mixes, 2D/3D product codes, and nonlinear hybrids — scored exactly on minimum distance, correction radius, and burst length. The headline: random CRC polynomials win. Everything else tried does not.

nkrbest polyd_mintb_maxbaseline at same (n,k)
16880x1d7523BCH m8t1: 3/1
241680x1f9413BCH m8t1: 3/1
2412120x1343626BCH m7t2 (r=14): 6/6 — same protection, 2 fewer parity bits
3216160x109b1737BCH m8t2: 6/6; CRC-16: 4/5
322480x1e3413BCH m8t1: 3/1
6448160x14669626BCH m8t2: 5/6; CRC-16: 4/5
645680x1cb412BCH m8t1: 3/1

Good random codes are common, not rare — 28 of 2,000 draws reach d_min 5 at n=16 r=8; 486 of 2,000 reach d_min 6 at n=24 r=12; 14 of 1,000 reach d_min 7 at n=32 r=16. This is the Gilbert–Varshamov bound doing its job at short lengths, where BCH's long-block structure is wasted by shortening. Encode cost is unchanged: table-driven CRC, ~500 MB/s single-threaded, the same as CRC-16.

The rejects all lost with numbers. ROT/XOR mixes (11,000 candidates) never beat plain cyclic at the same size — n=32 r=16: best d_min 6 vs cyclic 7 — and encode ~50× slower (bit-serial only, ~7 MB/s, no table form). Product codes (1,850 configs) reach d_min 9 at best, while random cyclic at the same sizes reaches 13. Nonlinear hybrids (~2,800 candidates) top out at d_min 4 at (16,8,8) against linear 5. And the polynomials do not carry up: 0x109b1 is d_min 7 at n=32 but 5 at n=64; 0x1d7 falls from 5 at n=16 to 2 at n=64. Search at the size you deploy; do not carry polynomials up.

Here is where the story turns. Phase 2 put the winners under a real ML decoder, and the d_min edge evaporated. CRC+GRAND vs BCH+GRAND at the same (n,k,r): within ±0.35 points at n ≤ 32 — and at (64,48,16) scattered p=0.03 the searched CRC is worse, 79.96% vs BCH 83.01% (−3.05 points, ~7 sigma). At g1 the gap is 0.80 points the other way (BCH-grand 92.11 vs CRC-grand 91.31, ~6 sigma paired). d_min is a weak predictor; the weight spectrum decides. The verdict is a negative result, stated plainly: do not swap the poly on distance grounds. The one actionable finding — a randomly-searched CRC polynomial beats the shortened-BCH polynomials lzply uses, at identical encode cost — is real, and it is worth exactly one extra correctable bit at small sizes. That is not worth a format change.

3. RaptorQ: the outer layer that only works on big files

The third thread is a file-level outer layer: a RaptorQ fountain code over lzply's BCH blocks, so a failed block becomes a lost symbol the outer layer can repair. Both free implementations were built and validated. libRaptorQ (Luca Fulchir, LGPL3, C++11 header-only, RFC 6330) needed Eigen3 and one missing-include fix; foxsen/raptorq (no dependencies, RFC 6330) passed its 54-test suite 54/54. The overhead curve agrees between them within noise: foxsen at K=100, 2,000 trials — K+0 99.65% (7 failures), K+1 and beyond 100.00%; libRaptorQ at K=101, 500 trials — K+0 99.00% (5 failures), K+1 and beyond 100.00%. Both sit inside the RFC 6330 allowance. The difference is speed: foxsen encodes/decodes at 74/83 MB/s at K=100 against libRaptorQ's ~8/8 MB/s — roughly 10× faster — so foxsen is the matrix primary and libRaptorQ the cross-check. One 50 MB encode+decode with foxsen took 3m26s single-threaded.

The experiment design turns on one fact: lzply's BCH block is ~512 KiB, not 4 KiB. Big blobs split into blocks of the m=22 polynomial (N = 2²²−1 = 4,194,303 bits, t=8), so one block holds ~512 KiB with 8 correctable bit errors. A 1 MiB file is 2 BCH blocks; 4 MiB is 8; 16 MiB is 32; 50 MiB is 100. One failed block erases a contiguous run of 512 symbols (at T=1024 B), so the outer layer's repair budget R must cover whole 512-symbol multiples to survive even one block failure: overhead ≥ 100/B%, where B is blocks per file (B=2: 50%; B=8: 12.5%; B=32: 3.1%; B=100: 1%). All schemes ran on the same erasure mask per trial (paired), with 95% Wilson confidence intervals.

Leg A — iid symbol loss, K=100, real decode (5,000 trials/cell)

File recovery %, RaptorQ-real vs RS (MDS bound) vs BCH-alone:

eBCHRQ-2%RQ-5%RQ-10%RS-10%
0.00190.3899.96100.00100.00100.00
0.00560.3498.40100.00100.00100.00
0.0136.1291.1299.90100.00100.00
0.0213.2665.8498.08100.00100.00
0.050.4610.9456.0298.1898.20
0.100.000.144.1845.9445.94

RaptorQ ties RS everywhere: max gap 0.06 points (e=0.01, R=2: 91.12 vs 91.18; all other cells ≤ 0.02). On iid loss the outer layer is a huge win over BCH-alone (e=0.01: 36% → 100% at 10% overhead).

Leg B — burst symbol loss, K=100, real decode (5,000 trials/cell)

bursteBCHRQ-2%RQ-5%RQ-10%
40.00587.6092.4296.5499.04
40.0176.5286.1892.6298.26
40.0259.1272.8286.6695.78
40.0526.0441.4062.0282.52
160.00597.0296.6097.5898.34
160.0192.9693.8094.9096.12
160.0286.5488.2889.4292.46
160.0568.4071.5675.4481.16

RaptorQ again ties RS (max gap 0.04 points). Long bursts (16) leave most files untouched, so BCH-alone is already high and the outer layer adds little; short bursts (4) spread damage across more files and the outer layer adds a lot (e=0.02: 59.12% → 95.78% at 10%).

Leg C — BCH-block failures (the lzply-real leg)

File recovery % (real decode where run, else the K+2 model as a lower bound):

K (B blocks)qBCHRQ-2%RQ-5%RQ-10%
1024 (2)0.0197.5598.0598.5597.90
1024 (2)0.0591.0090.6590.4589.75
4096 (8)0.0193.2091.7091.7092.20
4096 (8)0.0564.9065.1068.6065.50
16384 (32)0.0171.3071.5595.0599.85
16384 (32)0.0253.6053.1586.5599.75
16384 (32)0.0520.0019.2048.2589.35
51200 (100)0.0137.9573.35*99.40*100.00*
51200 (100)0.0213.3539.75*94.05*100.00*
51200 (100)0.050.753.20*37.35*95.55*

(* = K+2 model only; real spots below.) The threshold is exact and total: at B=2 and B=8 the outer layer is identical to BCH-alone in every cell — one block failure erases 512 symbols, more than the largest budget R=410. It only starts helping at B=32 (5%/10% overheads; 2% still ties BCH: 71.55 vs 71.30 at q=0.01, because R=328 < 512), and at B=100 every overhead helps. The rule is overhead ≥ 100/B% to survive a single block failure.

The K+2 model is a lower bound — real RaptorQ is closer to RS

The RFC rule of thumb (needs K+2 received symbols) understates real RaptorQ badly at small R, because real decode usually succeeds at K+0 (99.65%) and K+1 (100%). Leg A, e=0.02, R=2: model 13.16% vs real 65.84%; R=5: 84.02% vs 98.08%. Overall model==real agreement is 94.96% of 350,300 real-decode trials, but the disagreements concentrate exactly at the R boundary. Real-beats-RS: 0 trials; RS-beats-real: 18 trials (all K+0/K+1/K+2 boundary cases) — real RaptorQ never beat the MDS bound and lost to it by at most a handful of trials in 350,300. The K=51200 model columns are therefore lower bounds, and the 12-trial real spots at the three worst model-vs-RS cells confirm real RQ tracks RS, not the model: R=1024/q=0.01, real 11/12 = RS 11/12 (model 9/12); R=1024/q=0.02, real 8/12 = RS 8/12 (model 4/12 — the model understates by half here); R=2560/q=0.05, real 7/12 = RS 7/12 (model 5/12). Real RQ == RS at every scale tested.

Bit-level anchor: the BER → block-failure cliff, validated live

q(p) = P(Bin(n,p) > 8), Poisson:

BERm=22 block q (512 KiB)m=20 block q (128 KiB)
1e-77.6e-103.9e-15
5e-73.3e-45.2e-9
1e-60.02771.7e-6
2e-60.46153.3e-4
3e-60.87960.0051
5e-60.99890.0851
1e-5~1.00.7191

Real-archive check (damage + lzply_check, 50 MB archive, ~100 m=22 blocks, measured BERs): 8.82e-08 → PASS (37 bits corrected, exactly the 37 inflicted, 0 uncorrectable); 4.96e-07 → PASS (208 corrected, 0 uncorrectable); 1.01e-06 → FAIL (1 uncorrectable entry); 1.87e-06 → FAIL; 9.94e-06 → FAIL. The cliff sits between 5e-7 (pass) and 1e-6 (fail), exactly as the table says. In file terms: at BER 1e-6 a 50 MB file has q=0.028/block, so ~2–3 of its 100 blocks fail and the file is lost without an outer layer; with 10% RaptorQ it recovers — the RS column reads 100.00% at q=0.01 and 98.20% at q=0.05, and the spots show real RQ tracks RS, so q=0.028 interpolates to ~99.5%.

The findings, in short: the outer layer works, but only for big files — at B ≥ 32 blocks/file (16+ MB), 5–10% overhead buys +24 to +62 points of file recovery at q=0.01–0.02; at B ≤ 8 it buys exactly nothing at any overhead ≤ 10%. RaptorQ ties RS — the layer helps at large B, not RaptorQ specifically; a GF(2¹⁶) RS outer layer would do the same job, and RaptorQ's edge is only operational (no pre-commit to R, any K up to 56403, no 255-symbol cap). The K+2 model is a lower bound, not the truth — use real decodes, or RS as the upper bound, for headline numbers. And speed is a deployment question, not a recovery one: foxsen runs 43 MB/s at K=1024 down to ~15 MB/s at K=4096, so a 50 MB encode+decode is minutes, not seconds. No deployment change is proposed; if ever deployed, the gate would be files with ≥ 32 BCH blocks, 5–10% repair stream stored alongside, RaptorQ or RS equivalent.

4. LDPC: a dead end

The last thread was short LDPC — low-density parity-check codes, the workhorse of modern communications, where they beat BCH by ~2.5 dB. The question was whether that transfers to lzply's hard-decision channel. It does not, and the reason is structural: there is no per-bit reliability signal to manufacture. Six candidates for such a signal were assessed — the deep-repair level is per-block, syndrome weight is anti-correlated (see §1), re-reads return identical bits, LZ77 plausibility is block-level, the CRC oracle is binary, neighbour failures are block-level. None of them yields a per-bit soft value. Even with true soft information handed to the decoder, the gain is under 2 points at the fair test point and negative at rate 3/4.

The numbers (10,000 trials/cell; misc = converged to a wrong codeword):

(32,16) — the fair testLDPC bit-flipBCH+BMLDPC soft-BP*
scat-p0.0198.75 (misc 17)99.68 (0)99.67 (22)
scat-p0.0388.88 (152)93.04 (0)94.90 (177)
burst-L8-0.0196.55 (36)96.57 (0)—
burst-L32-0.0198.00 (53)97.99 (0)—
burst-L8-0.0389.57 (124)89.25 (1)—
mix-L16-0.0197.85 (36)97.81 (1)—
(64,48) — the rate-3/4 caseLDPC bit-flipBCH+BMLDPC soft-BP*
scat-p0.0190.75 (74)97.21 (10)93.85 (77)
scat-p0.0354.11 (290)70.23 (81)60.40 (189)
burst-L8-0.0192.56 (49)93.37 (9)—
burst-L32-0.0196.83 (17)96.90 (6)—
burst-L8-0.0379.02 (109)80.79 (21)—
mix-L16-0.0195.99 (19)96.65 (7)—

(* soft BP with TRUE LLRs, iid channels only — the upper bound.) Hard-decision LDPC loses to BCH+BM on scattered errors, and miscorrects far more: (32,16) at p=0.03 shows 152 miscorrections (177 with soft BP) against BM's 0. A PEG-constructed (32,16) code manages d_min 4 against BCH's 5, and girth 6 is impossible at (64,48) by counting — at least 72 4-cycles for any (3,12)-regular code — which is part of why belief propagation underperforms here. The verdict is clear: no further LDPC work is recommended.

What survives

One deployable finding: a RaptorQ (or equivalent RS) outer layer, gated on files with ≥ 32 BCH blocks — 16 MB and up — at 5–10% overhead, buying +24 to +62 points of file recovery where it matters. One method that works but cannot deploy: GRAND-MO with a fitted prior and mixture selection, which repairs bursts far better than Berlekamp–Massey at short blocks but needs n ≤ ~128 while lzply's blocks are 32,768 bits. One paper win that evaporates: randomly-searched CRC polynomials beat shortened BCH on distance, then lose the repair-rate test under a real decoder. And one dead end: LDPC, stopped with numbers.

Nothing here changes lzply's deployed format. The big-block BCH+BM structure stands, the RaptorQ layer is research until someone gates it on file size, and the GRAND-MO result is a decoder lesson, not a deployment. That is the honest outcome of the search — and a search that reports its negatives is worth more than one that hides them.

All of the code, harnesses, and write-ups are in the lzply repository, experiments/randfec branch: Phase 1 and the CRC winners (6ea6cf9, randfec/RANDFEC.md), GRAND-MO with model selection (8b501a0, randfec/PHASE2.md and randfec/PHASE3.md), and the RaptorQ outer layer plus the LDPC assessment (6af2105, randfec/PHASE4.md).

GitHub - cnmcdee/lzply: lz compression combined with BCH Polynomial FEC. Files/mounts that can repair themselves.
lz compression combined with BCH Polynomial FEC. Files/mounts that can repair themselves. - cnmcdee/lzply
Linux Rocks Every Day