171 Seconds to a Third of a Second: Deep-Repair Chase on CUDA Runs 500× Faster
Deep-repair Chase-1 on the 3080 Ti: a 171.571 s CPU scan becomes 0.335 s on the GPU, bit-identical candidates across 29 patterns — plus what the measured scaling predicts for bigger blocks, t=16, and Chase-2.
The best GPU target from the GPU day just paid off — bigger than estimated. Deep-repair Chase-1, the scan that took 171 seconds on one CPU core, now runs in a third of a second on the RTX 3080 Ti: 453–562× faster on the timed scan, bit-identical candidate sets across 29 patterns, zero mismatches. The GPU-day article estimated 10–50× for this kernel. It was wrong by an order of magnitude — in the good direction — because the per-trial work turned out to be almost entirely parallelisable. This article reports the original validation, a 24-pattern extended sweep run since, the one real bug found along the way, and — labelled as predictions, with their measured basis — what the scaling says comes next.
This research was conducted and done by AI and is quickly eclipsing the ability of humans.
1. What Chase-1 is, and why it takes three minutes
Deep repair is lzply's last resort. When a BCH block is damaged beyond the decoder's correction radius t — clustered damage, more errors than the code was built for — the standard Berlekamp–Massey decoder fails, and Chase-1 goes hunting: it flips one bit at a time, re-runs the decoder on each trial, and collects every trial that yields a valid codeword. For a 524,265-byte block (m=22, t=8, the -e4 profile) that is 4,194,296 trials — one per bit position — each running a full Berlekamp–Massey decode plus a lambda-splits test. On one CPU core that runs at ~24,400 trials/s, so a single block costs 171.571 s. A damaged 50 MB archive has roughly a hundred such blocks. Deep repair was therefore a batch job, not an interactive one — and the L2 variant, which flips pairs of bits, never even finished inside its 600 s budget.
But every trial is independent. Nothing in trial k depends on trial k−1. That is the whole reason Chase was ranked the best remaining GPU target in the GPU-day article, and the reason the estimate was 10–50×: a cautious guess for a kernel whose per-trial work is small and branchy. The measured number is ten times that estimate.
2. The CUDA design
The work lives in the experiments/cuda-chase branch (commit 368644a), in /root/cuda-chase/lzply on hot_house. The design is two kernels plus a host verify:
Kernel 1 — one CUDA thread per trial position. Each thread flips its bit and runs Berlekamp–Massey plus the lambda-splits test: h = x^(2^m) mod lambda == x, exactly the CPU's gcd test, since x^(2^m)−x is squarefree. BM early-exits when the error-locator degree L exceeds t, which is exactly equivalent to the CPU's behaviour because L never decreases. GF arithmetic is shift-and-XOR in registers; division uses log/exp tables.
Kernel 2 — Chien search in parallel for the survivors. Only ~135 trials in 4.19 million pass the splits test, so the second kernel runs the Chien search across those survivors in parallel, and the host verifies each one by the syndrome-zero check — exactly the CPU's zero-remainder check. A new public accessor, bch_block_syndrome(), exposes the syndrome computation the kernel needs. The benchmark harness is chase_bench.c (--cpu/--cuda, --seed, --nerr), and CHASE_CUDA.md documents the equivalence proofs, measurements, and limits.
3. The original validation: 5 patterns, hash-identical
The first validation ran five patterns — varying seed, error count, and suspect count — and compared the full candidate set between CPU and GPU by hash, not just by count:
| seed | errors | suspects | CPU time | CUDA time | candidate-set hash | original found? |
|---|---|---|---|---|---|---|
| 12345 | 9 | 0 | 171.571 s | 0.335–0.379 s | 0xca5f43bdeb9d8c96 | YES |
| 999 | 10 | 0 | 158.573 s | 0.328 s | 0x5003477cf2b5970d | NO |
| 2 | 9 | 6 | 164.184 s | ~0.35 s | 0x6425c95657b8e07a | YES |
| 3 | 9 | 6 | 173.572 s | ~0.35 s | 0xa4d97631ca3eee82 | YES |
| 4 | 9 | 9 | 167.844 s | ~0.35 s | 0xe928865a8a93f393 | YES |
All five hashes matched exactly. The 10-error case is the honest edge: both sides agree the original is not among the candidates. Chase-1 cannot fix t+2 errors — one trial flip leaves 9 errors against t=8 — so that is the algorithm's limit, not an implementation difference. The full test suites are green in the patched tree: bch_test 7,975/0, rs_test 6,243/0, crc16_test 530/0, run_rs_tests 61/0, run_tests 149/0, deep repair 47/0, hyper 56/0. Timed-scan speedup on these five: 453–512×; wall-clock end to end, ~0.9 s vs ~172 s including process start and CUDA context init, is ~190×.
4. The extended sweep: 24 more patterns, 5 more CPU checks
Five patterns prove a kernel works; they do not prove it always works. So a second sweep ran 24 fresh patterns — six fresh seeds at each of nerr 9, 10, 11, and 12 — CUDA on all of them, CPU on five spread across error counts and suspect counts (~160–168 s each, ~14 minutes total). Two things the sweep taught us before it even ran:
nerr 7–8 cannot run at all — by design, not a bug. At t=8 the standard decoder already corrects 7–8 errors, so the harness's control check fails ("control FAILED: standard decode succeeded"). Chase is a last resort by construction; it never runs on damage the ordinary decoder can already fix. The sweep therefore used nerr 9–12.
Suspect counts are derived from the data, not an input. chase_bench has no --suspects option; the count falls out of each seed's damage pattern. Observed counts across the sweep were 0, 3, 6, 9, and 12, so the intended spread was covered naturally, plus a 12.
One harness wrinkle, fixed by re-parse rather than re-run: chase_bench exits 1 whenever the original is not among the candidates — expected for nerr ≥ 10, Chase-1's known t+2 limit — and the sweep driver initially treated that exit code as a bench failure and skipped those rows. The raw logs were complete, so all 31 logs were re-parsed; the table below comes from that re-parse. Every pattern is 4,194,296 trials.
| seed | errors | suspects | CPU time | CUDA time | candidate-set hash | original? | cands |
|---|---|---|---|---|---|---|---|
| 11 | 9 | 6 | 166.680 s | 0.362 s | 0x5c7f589a39df28b8 | YES | 13 |
| 21 | 9 | 3 | — | 0.352 s | 0x9fbf8f81ead3e086 | YES | 18 |
| 101 | 9 | 6 | — | 0.292 s | 0xc3dc7b7528027f2c | YES | 9 |
| 777 | 9 | 3 | — | 0.303 s | 0x3f83e1d877fff106 | YES | 11 |
| 31337 | 9 | 0 | 168.330 s | 0.321 s | 0x67fdae628952aa68 | YES | 13 |
| 8675309 | 9 | 0 | — | 0.340 s | 0xdca91931a24c5d24 | YES | 17 |
| 12 | 10 | 0 | — | 0.332 s | 0x2478043cdde3ae3e | NO | 14 |
| 22 | 10 | 12 | 164.670 s | 0.311 s | 0x56c63d470502aee8 | NO | 11 |
| 100 | 10 | 3 | — | 0.305 s | 0xf0ac78a5c0db6077 | NO | 10 |
| 1234 | 10 | 3 | — | 0.322 s | 0x06acc3a69443d342 | NO | 12 |
| 55555 | 10 | 3 | — | 0.290 s | 0x41d95f8afa6ba1ce | NO | 8 |
| 424242 | 10 | 3 | — | 0.326 s | 0x69622442a318139d | NO | 13 |
| 13 | 11 | 0 | — | 0.315 s | 0xd0e203ae5074c351 | NO | 11 |
| 31 | 11 | 0 | — | 0.318 s | 0xc2ce80d884c0de3a | NO | 12 |
| 2024 | 11 | 0 | 159.671 s | 0.284 s | 0x64657c5daf8fe7bd | NO | 7 |
| 11111 | 11 | 0 | — | 0.309 s | 0x0828e3f1a1de3768 | NO | 10 |
| 22222 | 11 | 3 | — | 0.334 s | 0xab869c50c89764d7 | NO | 16 |
| 98765 | 11 | 0 | — | 0.317 s | 0x42fd41c1b975b1f5 | NO | 12 |
| 14 | 12 | 0 | — | 0.285 s | 0xa817ea75c23a4634 | NO | 9 |
| 42 | 12 | 6 | 166.697 s | 0.315 s | 0x7e36640193d2f371 | NO | 13 |
| 1000 | 12 | 6 | — | 0.316 s | 0xff1b6acdbcda946e | NO | 13 |
| 54321 | 12 | 3 | — | 0.332 s | 0xf6dc42abffaa291f | NO | 15 |
| 77777 | 12 | 0 | — | 0.321 s | 0xaa142dccd701c52f | NO | 13 |
| 999999 | 12 | 9 | — | 0.312 s | 0x1aff72716b878008 | NO | 12 |
All five CPU hashes match their CUDA hashes exactly — 10 CPU-vs-CUDA agreements in total across the two sweeps, zero mismatches. The new CPU-verified speedups: seed 11, 460.4×; seed 31337, 524.4×; seed 22, 529.5×; seed 2024, 562.2×; seed 42, 529.2×. Combined with the original five, the timed-scan range is 453–562× (CUDA 11.6–14.8M trials/s against CPU ~25k trials/s). The pattern is exactly as the algorithm predicts: every nerr-9 pattern finds the original, every nerr ≥ 10 pattern agrees on both sides that it is absent. Candidate counts run 7–18 against a cap of 64 — the cap was never hit, so the CPU never stopped a scan early and no early-stop divergence arose. Split-pass counts agree exactly between CPU and CUDA on every verified pair (117/117, 99/99, 63/63). The sweep data — driver, parser, summary, and all 31 raw logs — is committed on the branch (sweep commit b47d472) for anyone who wants to re-run it.
5. The one real bug: nondeterministic append order
Validation caught a genuine bug, and it is worth reporting because it is exactly the kind of thing a fast port hides. The kernel's atomic-append order is nondeterministic: the first CUDA run matched the CPU hash by luck, and the repeat did not. The candidate set was identical — the order differed, so the hash differed. The fix is on the host: survivors are sorted by position ascending before verification, and three consecutive runs then gave the CPU hash deterministically. Nothing about the kernel changed; the ordering was never part of the result, but the hash made it visible. Without hash-level comparison against the CPU, this would have shipped as a silent nondeterminism.
6. Limits, stated plainly
t=8 only. The kernel is built and measured for the -e4 profile. Nothing here says anything about t=16 or t=32; the predictions in the next section are predictions, not measurements.
Chase-2 is not ported. Pair-flip enumeration is a different trial count, not a different kernel — but it has not been implemented or measured.
The max_cands cap is a divergence risk. If a scan ever produced more than 64 candidates, the CPU would stop early (partial stats) while the GPU runs the full scan and truncates. The candidate set still matches, but the counts would not. No pattern in either sweep came close (7–18 candidates), so this is a stated edge, not an observed one.
First-touch cost. A fresh process pays ~0.115 s of CUDA context init before any kernel runs. At 512 KiB that is a quarter of the wall-clock time; the timed-scan speedup (453–562×) and the end-to-end speedup (~190×) differ for exactly this reason, and the gap matters more the smaller the block.
Chase-1 fixes t+1 errors, no more. At t=8 that means 9 errors. Ten or more, and the original is not in the candidate set on either side — the scan runs, correctly, and finds nothing. Deep repair at this level is a rescue for one error past the radius, not a general decoder.
7. Forward predictive expectations — predictions, not measurements
Everything in this section is a prediction, labelled as such, with the measured basis stated next to it. None of it has been run yet.
Prediction 1 — bigger blocks scale linearly in trial count. Basis: every run in both sweeps is 4,194,296 trials for a 524,265-byte block — one trial per bit position — at 11.6–14.8M trials/s on CUDA and ~25k trials/s on CPU, with no dependence of trial count on error count or suspect count. Prediction: a 1 MiB block (~8.39M trials) scans in ~0.6–0.7 s on CUDA and ~335 s on CPU. A 50 MB archive, worst case with every one of its ~100 blocks deep-repaired, costs ~30–35 s of CUDA scan time against ~4.6 hours on CPU. What would confirm it: 1 MiB and 2 MiB block runs through the same harness.
Prediction 2 — t=16 costs about 4× per trial, not 4× per scan. Basis: each trial runs Berlekamp–Massey over 2t syndromes, an O(t²) computation, so t=8→16 quadruples per-trial work while the trial count — one per bit position — is unchanged. Prediction: a t=16 scan of a 512 KiB block takes ~1.2–1.5 s on CUDA and ~11 minutes on CPU, and Chase-1 then rescues 17 errors instead of 9. The kernel's register GF arithmetic and log/exp tables should carry over unchanged. What would confirm it: a t=16 build of the same kernel, measured the same way.
Prediction 3 — full Chase-2 is infeasible; suspect-restricted Chase-2 is trivial. Basis: full pair enumeration is C(4.19M, 2) ≈ 8.8×10¹² trials; at the measured 12M trials/s that is ~8.5 days per block. Prediction: nobody will run full Chase-2 on a 512 KiB block. But pairs among s suspects number s(s−1)/2 — 36 pairs at s=9, 66 at s=12 — seconds of work, and the kernel extends directly, since a pair trial is the same BM-plus-splits computation with a different trial enumeration. Chase-2's useful domain is therefore exactly the suspect-heavy clustered-damage case, and it should be built suspect-restricted from the start. What would confirm it: implementing suspect-restricted Chase-2 and timing it on the suspect-heavy patterns from the sweep (seeds 22, 4, 999999).
Prediction 4 — the GPU advantage grows with trial count and shrinks at the edges. Basis: both sides scale linearly in trials, so the ~500× relative speedup holds wherever the scan dominates — larger blocks, more suspects, higher t. Prediction: the advantage grows in absolute seconds with block size and t, and shrinks in three places: small blocks, where the ~0.115 s first-touch cost dominates a ~0.04 s scan (below ~64 KiB the CPU likely wins outright); high-candidate regimes, where the CPU stops early at max_cands=64 while the GPU runs the full scan and truncates; and damage within the radius, where the standard decoder handles it and Chase never runs at all. What would confirm it: sub-64 KiB block timings, a pattern that actually hits the 64-candidate cap, and multi-block archive-level repair timed end to end including I/O.
Prediction 5 — deep repair becomes interactive, and that changes where it is used. Basis: the end-to-end wall for one block is ~0.9 s on GPU against ~172 s on CPU. Prediction: once the kernel lands in the lzply CLI, deep repair stops being a batch job run overnight and becomes something run on demand when an archive fails to verify — which in turn makes the t=16 port and the suspect-restricted Chase-2 worth building, because they extend the rescue radius rather than just speeding it up. What would confirm it: the CLI integration itself, and usage on real damaged archives rather than synthetic patterns.
Scoreboard
| Measure | Result |
|---|---|
| Patterns validated (original + sweep) | 29 (5 + 24) |
| CPU-vs-CUDA candidate-set agreements | 10/10, zero mismatches |
| Timed-scan speedup | 453–562× (CUDA 11.6–14.8M trials/s vs CPU ~25k trials/s) |
| End-to-end wall, one block | ~0.9 s vs ~172 s (~190×) |
| Original found | All nerr-9 patterns; none at nerr ≥ 10 (algorithm limit, both sides agree) |
| Candidate counts | 7–18, cap 64 never hit |
| Real bug found in validation | Atomic-append order nondeterminism; fixed by host-side sort |
| Still to do | t=16 port, suspect-restricted Chase-2, CLI integration, larger-block scaling runs |
The GPU day's lesson holds, sharpened: the GPU is a superb accelerator for the parts of this stack that are linear and independent — the BCH remainder, and now the Chase trials, where the measured win is ten times the estimate — and useless for the part that is a sequential dependency chain. The Chase kernel is a branch, not main: experiments/cuda-chase (368644a), main still at 6af2105. What comes next is decided by the predictions in §7 — and by whether the t=16 and Chase-2 measurements confirm them.