Skip to content

Certified int8 LM head: exact stock-head decisions, seeded sampling, kernels and evidence - #45

Merged
SamMausberg merged 64 commits into
mainfrom
kernel/certified-head
Oct 1, 2026
Merged

SamMausberg merged 64 commits into
mainfrom
kernel/certified-head

Conversation

@SamMausberg

@SamMausberg SamMausberg commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

What this adds

src/certified_head/ is a certified low-precision LM head for Qwen3.5-4B's tied head (248,320 x 2,560 BF16). For a batch of post-final-norm hidden states, it returns row by row the token that SGLang's own head returns for that batch: torch.matmul(H, W.T) (cuBLAS BF16 GEMM, FP32 accumulation, BF16 output), FP32 widening, then torch.argmax with first-index ties.

It works in four steps:

  1. Read an int8 copy of the head (half the bytes) and attach an outward-rounded error envelope to every approximate logit.
  2. Rescore the few candidates exactly (FP64) from the BF16 rows.
  3. Decide a row only when one token wins for every value the stock kernel could produce.
  4. Complete undecided rows with the stock kernel itself, so a fallback costs time and never changes the token.

gumbel_sample does the same for SGLang's seeded sampler. The SGLang integration notes are in src/certified_head/INTEGRATION.md; the engine patch itself will be a separate PR.

Status. All evidence is committed at the final configurations: evidence/certified_head/README.md has every result with its file, command and commit. The last shared-lock hold, x8s2, ran at the final code (9f7f369) and its results are committed in 85f48a5: compile 148 of 148 variants, 145 tests passed (121 GPU, 24 CPU), the stress test of all 10 default tile configurations under the margin rule (1.00–1.05 million row-checks each, 0 misses), the full TMA neighbourhood (misses only in the three non-default configurations x7b pointed to), and the SASS statistics at all three default tiles.

Exactness contract

reference='bf16' is R-stock. A row is certified only if its winner is the same for every FP32 accumulation of the exact products within a named model, after the stock kernel's BF16 round-to-nearest-even and first-index argmax. Interval endpoints are rounded to BF16, a monotone map, so BF16 ties that hold in every admissible accumulation are certified and broken by index, as stock does.

The two stock-kernel models are reported separately:

  • conservative: 2K roundings at 2^-23 of sum|w h|, in any order. This covers split-K with FP32 partials and truncating adders.
  • hopper-wgmma: the Khattak-Mikaitis model of Hopper BF16 wgmma plus an FP32 split-K allowance. It rests on that published hardware model.

The approximate pass needs a model too. The W8A16 and BF16 passes also accumulate on tensor cores (Triton tl.dot); their own envelope uses the conservative model for that accumulation, whichever model is chosen for the stock kernel, and candidate exclusion and the threshold check rely on it. W8A8 accumulates exactly in int32. With reference='fp32' these are the only model assumptions.

Undecided rows are completed in one of two ways:

  • batch (the default) reruns the stock matmul on the whole batch at the same shape. It needs no assumption.
  • columns finishes a near-tie row, whose candidate list is complete, with one stock matmul over its gathered candidate rows. It is exact under the stock kernel's measured row and column-subset invariance. The constructor does not accept it: only enable_column_fallback(batch_sizes) turns it on, and only for the batch sizes whose start-up self-test passed bitwise at the fallback's exact GEMM shape (M x min(capacity, 64) gathered rows). Other batch sizes keep batch.

Both fallbacks are conditional CUDA-graph nodes, so there is no host synchronization.

Seeded sampling (gumbel_sample, temperature only) follows SGLang's chain:

  • div_(T), then FP32 softmax and FP32 log;
  • multinomial_with_seed with MurmurHash3 noise keyed by seed, position and token id, an FP64 Gumbel draw, and first-index argmax.

The softmax shift is common to a row. The remaining rounding is bounded with CUDA's documented expf and logf accuracy, plus a subnormal clause.

For fixed-noise sampled verification, the guarantees are:

  • equal in law to target sampling;
  • drafter-invariant;
  • token-identical to SGLang's seeded sampler applied to the verify pass's own R-stock logits (not necessarily to plain decoding).

Seeded top-k (FP64 log over sorted columns), top-p and min-p stay on the stock path.

reference='fp32' targets --enable-fp32-lm-head. reference='real' is analysis only.

Kernels

  • quantize.py: symmetric per-row int8 with FP32 scales. The quantization error is computed exactly in FP64 from the stored values, checked with TwoSum, and cached with group norms under ~/vp-data/kernel/.
  • bounds.py: the error models and the envelope coefficients, all computed with exact rationals and rounded outward.
  • kernels.py: one Triton approximate pass with three arithmetics, selected per M (W8A16; W8A8 with exact int32 accumulation; BF16 as a certified dense head), optionally with TMA loads.
    • The epilogue uses PTX directed rounding.
    • It keeps per-tile top-4 summaries instead of writing the M x V logits; an overflowing tile expands into the candidate list.
    • Compaction, FP64 rescoring, a bucket-exact decision kernel and fallback routing follow.

Evidence (final run x7c, B4)

Every figure below is in evidence/certified_head/README.md with its file and command. The final run, x7c (46bcc84), reran what had changed and reused the rest; steps.tsv gives each step's commit and, for a reused one, why it stands:

Steps Commit Run
compile, GPU and CPU tests (145 passed), stress, TMA neighbourhood, SASS statistics 9f7f369 x8s2, run at this commit
micro, summarize, output check 46bcc84 x7c, run at this commit
W8A16 sweep, primitives, Nsight Compute d2712cb x7; the package's code and data are unchanged from d2712cb to 46bcc84
60,000-row replay, stock invariance, W8A8 sweep fff72dc x6; its passing steps stand: kernels unchanged, replay batches of at most 16 rows (tiles unchanged), stock head only, explicit tiles

Six commits after 46bcc84 change package code, and x8s2 ran the correctness checks on all of them:

  • a9f1793: the row's lower bound is now checked by the same margin rule as every other bound;
  • 2d1794a: new W8A8 and BF16 default tiles;
  • d3a2b13: the quantization data must belong to the supplied weight, and inputs must be contiguous (Codex P1 and P2);
  • eb6ef57: the row norm that seeded sampling uses is now inflated for all K squares, not one group (Codex P2);
  • 647427e: a freshly built head records its weight digest, and run_all.sh works with RUN_ALL_ONLY and no reuse directory (Codex);
  • 9f7f369: hidden sizes the probe and refine kernels do not tile (K not a multiple of 256) are refused (Codex P2).

After x8s2, 2ab57df adds two host-side refusals: build_quantized_head refuses a supplied head_sha256 that is not the digest of the weight it quantizes (Codex P1), and check_gemv_config refuses int8 TMA tiles with block_m >= 128 (reviewer). 09bf64e sends sampled rows whose temperature is not finite and positive to SGLang's chain (Codex P2). 3b137c0 refuses the column fallback for any reference but bf16 (Codex P1) and makes run_all.sh run all four test files, with check_outputs.py requiring at least 157 passed and none failed or skipped (Codex P2). ec46d55 and 2c36737 send a sampled row to SGLang's chain when its winner's lower bound is within 52 of ymax, where a winner or a competitor might have a subnormal or zero stock probability (Codex P1, reviewer). None changes a kernel's code or a default path, so all were checked by CPU tests only: tests/test_certified_head_inputs.py, 15 passed; 7 fail without 2ab57df, 1 without 09bf64e, 2 without 3b137c0 and the guard's test fails without ec46d55 and with its narrower gap.

d8b03ff merges main into the branch (no conflicts), so the host-identity guard from #111 runs on the evidence commit. None of the six changes the W8A16 pass's tiles or kernels, so x7c's timings stand for the W8A16 path. eb6ef57 changes nothing at the default group_size = K, which every recorded evidence result used.

Replay of 60,000 real decode rows (at the engine's batch shapes, at most 16 rows):

Contract Error model Rows certified Rows needing the fallback Certified plus fallback equal to the reference
bf16 conservative 59,122 878 (1.46%) 60,000
bf16 Hopper wgmma 59,834 166 (0.28%) 60,000
fp32 conservative 59,134 866 (1.44%) 60,000
real none 60,000 0 60,000

Seeded sampling at T = 0.7 and 1.0 equals SGLang's sampler on every row. The stock BF16 argmax differs from the exact argmax on 296 rows (0.49%).

Head-path runtime at M = 1, 8, 32. This is a microbenchmark of the head alone, not of decoding:

  • CUDA graphs, warm L2, 30 replays of 20 calls;
  • median ± std in µs;
  • runtime probes on;
  • decided real-row batches, checked at each batch size's own tiles.
M Stock head + argmax Certified No probes Probe cost Expected per call, whole-batch fallback, cons. / Hopper Expected, column fallback, cons. / Hopper
1 370.5 ± 0.2 239.6 ± 0.2 231.9 ± 0.8 7.7 244.9 / 240.6 249.3 / 248.7
8 382.2 ± 0.2 251.0 ± 1.2 243.9 ± 1.3 7.1 292.8 / 259.3 264.2 / 259.5
32 411.6 ± 0.3 305.5 ± 2.7 300.9 ± 6.6 4.6 443.4 / 337.3 331.8 / 316.2

Where it stops paying. The certified head beats stock only at small batches:

  • Whole-batch fallback, conservative model: loses from M = 32 (443.4 against 411.6).
  • Column fallback: stays ahead through M = 64 (420.5 against 451.6).
  • Hopper model with the whole-batch fallback: ties at M = 64 (447.2 against 451.6). With the column fallback it is ahead (400.2).
  • From M = 128, every mode loses (best 706.6 against 562.2).
  • The W8A16 pass alone crosses the stock GEMM between 64 and 128 rows.

The README has the table for M = 1–256, with both error models and both fallback modes.

Seeded sampling against SGLang's seeded sampler.

  • Up to M = 16: faster, 275–480 µs against 690–747.
  • From M = 32: slower, 1,049 against 799 at 32 and 7,341 against 2,013 at 256. The FP64 sampling epilogue's cost grows with the tile's rows, and the sampled kernel spills registers at the 32- and 64-row tiles.
  • Probe cost: at the 16-row tile the probes cost 107–121 µs at M = 2–16. The cause is not established; instruction-cache pressure is a hypothesis.
  • M = 1 is cheaper (275 µs) because Triton compiles that size separately.

Fixes for the sampled path are proposed for a follow-up PR.

Stress test of the default tiles (x8s2, 9f7f369, the margin rule for every bound including the row's lower bound): every default (pass, tile) configuration, at every batch size from 1 to 256 that dispatches to it, on real and peaked rows: 10 configurations, the W8A8 and BF16 defaults from 2d1794a included, 1.00–1.05 million row-checks each, 0 misses on lower bounds, upper bounds, tile summaries and the probe flag. That bounds the per-row miss rate below about 3e-6 at 95%, if calls are independent trials, which a race need not be. x7c's run of the earlier defaults under the lenient row-lower rule (46bcc84) also had 0 misses.

TMA faults. Two TMA tile families of the W8A16 pass miss exact logits on this machine:

  • The first: int8 TMA tiles with a 64-byte box. They are refused.
  • The second: block_m-128 TMA tiles with a 128-byte box: 64x128x128 with 4 warps and 3 stages, and 128x128x128 with 8 warps. Their miss counts vary between identical runs, and misses reach 4,875 times the envelope's half-width. x8s2 checked all 32 configurations around them (block_v, block_m, warps, stages, TMA or pointer loads, at M = 128 and 256, three runs each, tma_m128_neighbourhood.json): only these three missed. All three have block_m 128, and 128x128x128 with 8 warps and 4 stages had a run with no miss, which the self-test would pass, so int8 TMA tiles with block_m >= 128 are now refused (2ab57df). No default has block_m above 64.
  • Where it sits: the raw GEMM is within bound in every run, so the fault is in the envelope's values. None of these tiles is a default.
  • What caught it: the self-test gate rejected 64x128x128 in two separate sweeps, and the runtime probes caught it.

Defaults, by the rule fixed before the results:

  • W8A16: keeps TMA on the clean stress test; pointer loads cost 10–18%.
  • W8A8: moves to pointer loads up to 128 rows, where they are within 5%, and keeps TMA above.
  • BF16: moves to pointer loads everywhere. Its earlier, never-swept 128x128x64 TMA default was 1.95 times slower than the best TMA tile at M = 128.

Conditional-node memory. A deleted CUDA graph with a conditional node keeps what the node's body allocated: 160 MiB allocated and 630 MiB reserved per capture-and-delete of five M = 64 bodies, with or without a shared pool. INTEGRATION.md records the engine implication as a known limitation, to be measured in the engine follow-up.

Superseded: the earlier partial runtime table (second hold, x2). Its M = 32 and 64 rows used TMA tiles with block_k 64 (128x32x64, 128x64x64), the family of the first TMA fault. Treat them as suspect. Every runtime figure above comes from x7c.

Validation

  • 2ab57df, 09bf64e, 3b137c0 and ec46d55: the CPU tests of their refusals, 15 passed in tests/test_certified_head_inputs.py (7 fail without 2ab57df, 1 without 09bf64e, 2 without 3b137c0, the guard's test without ec46d55 or with its 64 gap); all 36 CPU tests pass at 2c36737.
  • x8s2 at 9f7f369: 145 tests passed, none skipped: 121 GPU tests in tests/test_certified_head.py (x7's 119 plus the weight digest and contiguity tests) and 24 CPU tests in tests/test_enclosure_margin.py, tests/test_certified_bounds.py and tests/test_certified_head_inputs.py (new). The weight digest check costs 0.96 s per head at start-up.
  • experiments/certified_head/compile_check.py compiles every kernel variant for sm_90 on the CPU before each hold.
  • check_outputs.py validates the outputs as well as the exit codes:
    • refusals and per-arm errors;
    • decided batches and fallback times;
    • the Nsight Compute launches;
    • the stress test.
  • pre-commit passes on all changed files.

Limitations

  • The certificate for R-stock depends on a named accumulation model for a closed-source kernel. The conservative model has 295x measured headroom on the FP32-output kernel, but it is still a model, and it is assumed for the BF16-output kernel.
  • The W8A16 and BF16 approximate passes depend on the conservative model for Triton's tensor-core accumulation.
  • The certificate assumes the compiled approximate pass computes the modelled arithmetic. A mandatory per-variant self-test at start-up and runtime probes on every call check this; it is not proved. Two TMA faults show it can fail. The defaults' clean record is empirical.
  • The column fallback depends on measured invariance of this cuBLAS build, re-checked at start-up for the deployed batch sizes.
  • The head pays only at small batches: see "Where it stops paying".
  • The sampled path is slower than SGLang's sampler from 32 rows.
  • Top-k greater than 1 for the drafter or DFlash, seeded top-k, and top-p are not certified.

Notes

  • A norm-bound stride mismatch introduced during a refactor was caught by the GPU tests before any commit. No reported number used the affected code.
  • An earlier version of this description said the partial table used pre-TMA tiles and that TMA would bring the pass from 228 to 197 us at M=1. Both were wrong: the table already used TMA tiles, and 197 us is the approximate pass alone in the sweep, not the complete path.
  • Installed nothing new; ncu ran under sudo for counter access.
  • x8s2's stress step held up to 36,102 MiB (35.3 GiB) of GPU memory, above 20 GiB from 15:19:43 to 15:36:25 UTC, against the shared lock's 20 GB budget (x8s2_gpu_memory.csv; the README states it). Just before that window the GPU ran out: three allocations of 350-450 MiB failed at 15:19:34-40 with 81-379 MiB free and were retried after the allocator released cached blocks (x8s2_stress.log); other jobs allocating then could have failed. The cause is not established (likely PyTorch's caching allocator across 224 batch shapes). The results stand. The memory cap is in a follow-up PR; until then the stress script runs under the exclusive lock.
  • The first attempt at the final hold (x8s, at 647427e) ran under the system Python instead of the SGLang environment (its script did not source it) and produced no results; x8s2 is the rerun.

Review comments

  • Integrator review (B1-B4 and suggestions):
    • B1, column mode without its self-test: fixed in d21b3c6. The constructor no longer accepts fallback_mode, enable_column_fallback enables only the batch sizes that passed, the self-test checks M x min(capacity, 64) gathered rows, and the graph test enables columns through it.
    • B2, the approximate pass's model: stated in the README contract and above (6d30754).
    • B3, omitted tokens and population: fallback_vs_model.py checks every token outside the top 64 against the winning bucket and counts the decided rows where one could compete (d21b3c6, 0c0bb7a). The README and this description state each figure's rows (6d30754). The 60,000-row CPU rerun is committed (fallback_vs_model.json).
    • B4, evidence: committed in c652f69 (see the last bullets).
    • Suggestions: integration notes moved to src/certified_head/INTEGRATION.md; the 2.07e-6 is attributed to the FP32-output kernel; stock_multinomial_with_seed raises without SGLang unless a test opts into the replica; ABS_FLOOR's docstring states the flush-to-zero case (d21b3c6, 6d30754).
  • Codex P2 on fallback_vs_model.py (top-64 only): correct. Fixed as in B3.
  • Hopper model radius (appendix editor): per-node errors were summed linearly, which gave 1.192097e-4, below the compounded error of 1.192164e-4. 90cc31a uses (1 + gamma_160(p))(1 + gamma_160(2^-23)) - 1 = 1.192216e-4, and the bound test requires the compounded product. The Hopper-model rates measured so far used the old value, about 1e-4 relative smaller. The final hold and the 60,000-row CPU rerun use the corrected one.
  • W8A8 activation scale (paper review): s_h = RN_fp32(max|h|/127) is not a power of two, and the envelope does not need one.
    • The kernel forms e_h = h - s_h q_h in FP64 from the stored FP32 s_h that the epilogue also uses. q s_h has at most 31 significant bits, and the subtraction is exact.
    • The group norms of e_h are rounded up.
    • The three FP32 roundings of s_i s_h acc are in scale_rel_error('w8a8').
    • 7a5a644 adds a test on adversarial activations: non-dyadic scales, half-codes, clamped codes, and subnormals next to a large maximum. It checks the bounds in exact rational arithmetic, the envelope, and the decisions.
  • Codex on the merged theory reference (src/precision_reference.py:250, raising on underflowing subnormal products): fixed in the separate PR Round underflowing leaves in the precision reference instead of raising #43. The GPU counterpart is in this PR: the rescoring radius adds 2^-100 for the stock kernel's FP32 underflow.
  • Integrator review of the contract, all applied here:
    • R-stock wording.
    • The candidate filter excludes only rows that round strictly below RN_bf16(max lo), and an adversarial test places a lower-index row within one BF16 spacing below the winner. The 20,000-row replay would probably not have caught a naive max lo filter, because the envelope of about 1 logit keeps such rows as candidates. The unit and adversarial tests are the real checks.
    • The column fallback is a checked precondition, with batch as the default.
    • The fixed-noise verification wording.
  • P8 (seeded-sampling reference semantics): the log precision of each path is stated, and P8's witnesses are GPU regressions. The first witness is resolved in the evidence README (b117320, experiments/certified_head/p8_witness_cpu.py):
    • SGLang's noise at seed 5, position 7 equals the audit's values exactly.
    • SGLang's chain (FP32 softmax and log) and an FP64 log of the same probabilities both give token 1 at both temperatures.
    • Exact arithmetic gives token 0 at the lower one (boundary T* = 1.02533410).
    • So the witness separates SGLang's FP32-softmax chain from exact arithmetic, not the two log precisions.
  • B4 (integrator), evidence: committed in c652f69 from x7c, with x6's passing steps standing (replay, invariance, W8A8 sweep) and every step's commit in steps.tsv. The x2 rows at M = 32 and 64 are marked suspect above (B4-6). x7 reran the GPU tests at d2712cb rather than reusing x6's. x7c reused that run, since the package was unchanged, so steps.tsv shows tests reused from d2712cb. x8s reruns them at the final code (647427e).
  • Reviewer, slack rule in tma_m128_check: the margin rule (a bound must clear the FP64 logit by 1e-9 (1 + |x|)) is the package's convention and stays. Checking it showed the row's lower bound used the margin as a tolerance in the self-test, the stress test and tma_candidates; a9f1793 makes it strict, and a CPU test pins the rule. Every check recorded before passed under the lenient rule; the README says why the strict one cannot change them on those inputs unless epilogue 3's arithmetic differs from the other epilogues'.
  • Codex P1 (head.py, from_quantized without checking that the quantization data belongs to the supplied weight): fixed in d3a2b13.
    • from_quantized compares the data's head_sha256 with the SHA-256 of the supplied weight, read from the device in row chunks; the time is recorded in head.weight_check.
    • On a mismatch, or with no digest, every batch takes the stock path (status refused).
    • A GPU test changes one bit of one weight element, and drops the digest, and checks both are refused.
  • Codex P2 (head.py, non-contiguous weight, q, scale): fixed in d3a2b13. The constructor rejects strided tensors, and a GPU test checks all three.
  • Reviewer, interim B4: the x8s results go in as their own commit. x8s also reruns the full TMA neighbourhood, including block_m 64, with the corrected script. The two wrong PR-body statements are corrected above. The README now explains the 30.3 MiB versus 32 MiB, states the tune_gemv.py refactor in the reuse reason, and says the BF16 rule was applied as declared above 64 rows.
  • Codex P2 (kernels.py, the row norm with group_size < K): fixed in eb6ef57. The row norm now uses the factor for all K squares. A CPU test shows the old factor failing on adversarial rows with 200 groups. No recorded evidence used group_size < K, and the README states this.
  • Codex on eb6ef57, two findings, both fixed in 647427e:
    • build_quantized_head did not record head_sha256, so from_quantized refused freshly built heads. It now records it.
    • run_all.sh's reuse read /steps.tsv when RUN_ALL_REUSE was empty. It now reuses nothing in that case, and a CPU dry run gets past every skip.
  • Codex P2 on 647427e (kernels.py, the refine and probe kernels read 256 coordinates per step without a K tail mask, while build_quantized_head accepts any K divisible by 128): fixed in 9f7f369 by refusing such shapes. The constructor rejects a hidden size that is not a multiple of 256, and each pass launch rejects a block_k that does not divide it. The kernels are unchanged, and a CPU test checks K = 128, 384 and 2688.
  • Codex P2 on 647427e (README, evidence not yet regenerated): done, x8s2's results are committed in 85f48a5.
  • Precision check of the float conversions (another workstream): fallback_vs_model.py's docstring rounded the Hopper constant to 1.19e-4, below the derived 1.19216e-4; fixed in 8aa8319. Every kernel-facing constant already rounds up.
  • Codex P1 on 85f48a5 (quantize.py:170, a supplied head_sha256 kept without checking it against w): fixed in 2ab57df. The digest is always computed from w, and a supplied one that differs is refused; a CPU test fails before and passes after.
  • Reviewer on 85f48a5, three blocking items, all fixed without a GPU rerun:
    • the Codex P1 above (2ab57df);
    • int8 TMA with block_m >= 128 refused in check_gemv_config (2ab57df), with a CPU test on the three configurations that missed; INTEGRATION.md now names all three and says one had a run the self-test would pass; the test comment on the refused 128x128x64 tile is corrected; tma_m128_check.py overrides the refusal for its own diagnosis runs; the README's commit table says 2ab57df was checked by CPU tests only;
    • the stress step's memory breach stated in the README (77c1b4d), with the figure in MiB and GiB and the cap placed in a follow-up; a9aa577 adds the three out-of-memory retries at 15:19:34-40 and commits x8s2_stress.log.
    • Suggestions taken: x8s2_compile.log (148 of 148) is committed and cited, and the README cites the SASS statistics for the greedy 64-row tile's spills (none).
  • Codex P2 on a9aa577 (head.py, non-positive temperatures accepted; a negative T reverses the score bounds): fixed in 09bf64e. Rows whose temperature is not finite and positive get status temperature (device ops, graph-safe, no host sync) and take SGLang's chain. Seeds and positions need no guard (SGLang hashes them as uint64 and uint32, as the kernel does). A CPU test fails without the fix; no kernel changed.
  • Codex P1 on c9f0440 (head.py, the column fallback computes BF16-output logits for reference='fp32'): fixed in 3b137c0 by refusing the combination in enable_column_fallback. No committed evidence or engine path used it (column heads are all bf16; the replay's FP32 contract uses the whole-batch fallback), so no GPU rerun. A CPU test fails without the fix.
  • Codex P2 on c9f0440 (run_all.sh ran only test_certified_head.py): fixed in 3b137c0. The tests step runs all four certified-head test files, and check_outputs.py checks the pytest summary (at least 156 passed, none failed, errored or skipped).
  • Codex P1 on ee29983 (kernels.py, a token whose FP32 softmax probability rounds to zero keeps a finite lower bound): fixed in ec46d55, host code only. Only the winner's lower bound enters the decision, and a zero-probability token's lower bound is below ymax - 65.1, so gumbel_sample sends a row whose winner's refined lower bound is at most ymax - 64 to the stock chain (status zero_probability, device ops, graph-safe). lo = -inf inside stock_score_bounds was not used: the approximate pass calls it with ymax = +inf, so every sampled batch would fall back. A CPU test fails without the fix; the kernels' code is unchanged (docstring only).
  • Reviewer on 37cf29d (a subnormal, nonzero probability also has absolute rounding error, so the winner's lower bound can fail there too): fixed in 2c36737. A subnormal or zero probability needs y < m - 74.84, and such a token's stock score is then below m - 52.66 in the bounds' units whatever the rounding; with the gap at 52 (was 64), a winner above it has a normal probability and a valid bound, and no small-probability token can reach its score. Renamed to small_probability / SMALL_PROBABILITY_GAP; docstrings and README state the model's limit. CPU-checked; no kernel code changes.
  • Codex P2 on 9597557 (run_all.sh recorded a reused step ok with a declared output missing, and check_outputs.py did not check every output): fixed in 0f51832. A reused step needs every declared output or is recorded missing (the run ends FAILED); every step clears its declared outputs before it runs, is reused or is skipped; run_all.sh writes outputs.tsv, and check_outputs.py requires every listed file and an ok status for every recorded step. A CPU test (tests/test_run_all_reuse.py) runs the script with every step reused from a fake run that lacks one output, and fails without the fix. No committed evidence is affected: x8s2 ran its steps directly, and x7c holds every declared output of its steps.

src/certified_head/ builds an int8 copy of Qwen3.5-4B's tied head from the
pinned checkpoint, with exact FP64 error metadata computed from the stored
values (quantize.py), and certifies greedy decisions against a named dense
reference (head.py):

- a W8A16 Triton GEMM whose epilogue attaches an outward-rounded envelope to
  every approximate logit (PTX directed rounding) and keeps per-tile top-4
  summaries instead of materializing M x V logits;
- candidate compaction, FP64 re-scoring of candidate rows from the BF16 head,
  and a decision kernel that applies the reference's BF16 rounding and
  first-index tie rule;
- a dense fallback that is the reference call itself, run as a conditional
  CUDA-graph node, so undecided rows cost time and never change the answer.

bounds.py states the error model (tensor-core FP32 accumulation within
gamma(2K, 2^-23) * sum|w h|, an assumption tested against cuBLAS) and computes
every constant with exact rationals. Contracts: 'bf16' (SGLang's default
head), 'fp32' (--enable-fp32-lm-head) and 'real' (exact real argmax, analysis
only, with an exact rule for bitwise-identical rows).

tests/test_certified_bounds.py checks the bound arithmetic on CPU;
tests/test_certified_head.py covers envelope validity, the cuBLAS error model,
equality with the reference for random, real and adversarial near-tie inputs,
forced fallback, nonfinite inputs and CUDA-graph capture and replay.
bench/micro_head.py times the complete certified path (all stages plus the
conditional fallback node), its stages, the int8 GEMM alone, SGLang's GPTQ-
Marlin W8A16 kernel and SGLang's BF16 head plus argmax, each captured in a
CUDA graph, with warm and cold L2 and per-trial variance. It also measures
the fraction of real decode batches that take the dense fallback.

bench/tune_gemv.py sweeps tile shapes of the W8A16 envelope GEMM per batch
size; micro_head.py can use its output.

experiments/certified_head/replay_decisions.py replays the geometry
workstream's captured decode head inputs step by step, at the engine's batch
shapes, and records candidate counts, undecided rows by reason, and agreement
with the engine's own argmax and with the dense references.
Sampling: gumbel_sample now reproduces SGLang's seeded sampler (no top-k,
top-p or min-p) token for token: logits.div_(T) in FP32, FP32 softmax and
log, then multinomial_with_seed with its MurmurHash3 field keyed by seed,
position and token id, FP64 Gumbel and first-index argmax. The softmax shift
is common to a row; the rest (expf 2 ulp, logf 1 ulp, the subtraction and
division, a subnormal-probability clause and the FP64 add) is bounded per
row with an upper bound of the row's largest stock logit collected by the
approximate pass. Undecided rows run SGLang's own sampler on the batch.

Fallback: fallback_mode='columns' completes a row undecided only by a near
tie among a complete candidate list with one stock matmul over its gathered
candidate rows. It is enabled only through enable_column_fallback(batch
sizes), which checks the gathered-GEMM shape bitwise first; 'batch' remains
the default. A tile summary that overflows now appends its whole tile to the
candidate list instead of forcing the fallback.

Arithmetic: the approximate pass has three variants chosen per batch size:
W8A16 (as before), W8A8 with per-row activation codes and exact int32
accumulation (envelope gains s_i ||q_i|| ||e_h||, loses the accumulation
term), and BF16 (a certified dense head without the logits write). Any of
them can load tiles through TMA descriptors. The stock accumulation model is
selectable: 'conservative' or 'hopper-wgmma' (published hardware model).

Soundness fixes: the rescoring radius adds 2^-100 for the stock kernel's
FP32 underflow; norm bounds are stored at the same row stride the GEMM reads
(a refactor-time mismatch caught by the tests before any commit).

Tests: norm-bound layout regressions, W8A8/BF16 envelopes, lower-index rows
within one BF16 spacing of the winner, column fallback with its self-test,
CUDA-graph capture in both modes, seeded sampling against SGLang's sampler
(including P8's witnesses over all 32,513 BF16 values in [-1, 1]), and the
noise field against SGLang's own computation. 65 pass on the GH200.
experiments/certified_head/stock_invariance.py records, per batch size, the
cuBLAS kernel the stock head runs, whether PyTorch's reduced-precision
reduction flag changes it, row- and column-subset bitwise invariance
(including the column fallback's gathered-GEMM shape), the observed
accumulation error against both error models, and the library versions.
experiments/certified_head/fallback_vs_model.py computes, on CPU in FP64, how
the undecided fraction depends on the assumed stock accumulation bound.

bench/head_primitives.py measures primitive costs for other workstreams'
predictions (stock chain, int8 pass, tile-restricted BF16 GEMM, gathered-row
rescoring, a draft-side tile-summary epilogue); bench/profile_gemv.py drives
Nsight Compute; bench/summarize_head.py turns micro_head.json into the
head-path CSV.

micro_head.py now times each arm on a batch of rows its own certificate
decides (row status does not depend on batch composition), measures fallback
rates per configuration from consecutive real batches, adds the W8A8, BF16,
column-fallback and seeded-sampling arms, releases each graph's memory pool,
and writes results after every batch size; tune_gemv.py sweeps TMA variants
and writes after every batch size. Default tiles are the sweep's winners.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1fdd347e6c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +76 to +78
top = torch.topk(x, TOP, dim=1).indices.sort(dim=1).values
xt = torch.gather(x, 1, top).numpy()
at = torch.gather(h.abs() @ w_abs.T, 1, top).numpy()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include all potentially competitive rows

Selecting candidates solely with topk(x, 64) is not valid for nonzero gamma: a row outside the exact-real top 64 can have a larger a_i and therefore an upper endpoint x_i + gamma * a_i that overlaps the winner. Such a row is never passed to decided, so the generated fallback_vs_model.json can undercount undecided rows and does not support the documented claim that this exactly reproduces the GPU certificate. Candidate selection must consider the upper bounds over the full vocabulary, or first prove that every omitted row's upper bound loses.

Useful? React with 👍 / 👎.

@SamMausberg SamMausberg Sep 30, 2026 •

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Fixed in d21b3c6 and 0c0bb7a. After the top-64 decision, fallback_vs_model.py bounds every omitted token from the full-vocabulary x and a it already computes. It checks each bound against the winning BF16 bucket with the kernel's threshold, and the JSON records the decided rows where an omitted token could compete (decided_rows_where_a_token_outside_the_top_could_compete, per gamma). Only there could a full-vocabulary decision differ. The docstring now says what the script decides, instead of claiming it reproduces the GPU decision exactly. The committed 20,000-row JSON predates the check, and a 60,000-row rerun with it is queued. The reviewer's independent check of 3,013 rows found no such token.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-01T18:44:07.965251Z 0f51832 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

Reviewed head acc415c (158 behind main; a trial merge into main is clean). This covers the code and contract, as the PR asks.

The certificate is sound in the kernel code, not only in the reference: I checked the outward rounding, the threshold, the underflow terms, the tie rule and the fallback routing (details under "Checked" below). Four items block merge:

  • column mode can be switched on without its self-test;
  • the contract text leaves out one assumption;
  • Codex's P2 on the fallback-rate script;
  • the evidence is not committed yet.

Blocking

B1. The invariance self-test does not gate column mode (src/certified_head/head.py, lines 173, 237 and 516).

  • How it is bypassed. CertifiedHead(..., fallback_mode='columns') is accepted by the constructor, and _column_batches starts as None. In argmax, cols_ok = self._column_batches is None or m in self._column_batches is then true for every M, so the column fallback runs with no self-test at all. test_cuda_graph_capture_and_replay does exactly this (fallback_mode=mode, capacity=8).
  • Second gap: the tested shape. The fallback gathers m * min(capacity, COLS_CAP) rows, but column_invariance_self_test always tests m * COLS_CAP. With capacity < 64, which the graph test uses, the fallback runs a GEMM shape that was never checked.
  • Consequence. The README and PR say the column fallback is "enabled only by enable_column_fallback(batch_sizes)" and that the self-test "must pass before it is enabled". The code does not enforce this. Column mode is exact only under the measured invariance, so an unchecked shape can return a token the stock head would not.
  • Fix.
    1. Do not accept 'columns' in the constructor, or run the self-test there.
    2. Make cols_ok = self._column_batches is not None and m in self._column_batches.
    3. Test m * min(self.capacity, COLS_CAP) in the self-test.
    4. Have the graph test enable columns through enable_column_fallback.

B2. The contract omits that the approximate pass relies on the same accumulation model (evidence/certified_head/README.md, "The contract"; PR body "Limitations").

  • The dependency. Candidate exclusion (hi < t(L)) and the threshold check (t(L) <= t(best)) are sound only if the approximate pass's own envelope holds. For the W8A16 and BF16 arithmetics, that envelope uses TENSOR_CORE_FP32.gamma(K) for Triton's tl.dot on tensor cores. bounds.py says this is an assumption, but the README's contract names the model only for the stock kernel. W8A8 accumulates exactly in int32 and needs no model for its own pass.
  • Consequence. If the model failed for the Triton kernel, an excluded row could be the stock winner. This is the paper's main positive result, so every assumption must be named where the contract is stated.
  • Fix. In the contract and Limitations, add: "The W8A16 and BF16 approximate passes also accumulate on tensor cores; their envelope uses the conservative model for that accumulation, whatever model is chosen for the stock kernel. W8A8 accumulates exactly." The same applies to reference='fp32', where this is the only model assumption.

B3. fallback_vs_model.py checks only each row's exact top-64 tokens, and its population differs from the other figures (Codex P2 on line 78).

  • Codex's point. It is correct as stated: a token outside the top 64 by exact logit can have a larger a_i, so x_i + gamma a_i could overlap the winner. The script would then call the row decided, while the GPU kernel would call it ambiguous. The docstring says this is "exactly the decision the GPU kernel makes".
  • What I checked. On the first 3,013 rows, at both gammas, no omitted token reaches best, so the effect is empirically zero. The script still has to show it, and it is cheap: x and a are already computed for the whole vocabulary before the gather.
  • Fix, part 1. Decide over all V, or record the number of rows in which an omitted token's upper bound reaches best (expected 0).
  • The population. The table (2.24% conservative, 0.45% Hopper) is the first 20,000 rows in capture order, both splits. The paper's figures for the same quantity are 1.40% and 0.35%, from geometry's held-out 6,005 rows with the bucket-exact rule. The PR body's GPU replay gives 1.46% and 0.28% on 60,000 rows.
  • Fix, part 2. State the population in the README. Either run on the same rows as the paper's figures, or say why the first 20,000 rows fall back more often.

B4. The evidence the PR relies on is not committed (README "Pending in this PR").

  • What is missing. The GPU test log at the final commit, the 60,000-row replay, the microbenchmark JSON and the runtime table exist only in the PR body or under ~/vp-data/kernel/runs/. The final commit (TMA default tiles) has not been through the GPU tests. I did not run them myself: the lock queue has more than ten older exclusive tickets, and your x3 hold is among them.
  • When the table lands. Please address the following.
    1. Label it partial if M = 128 and 256, the Hopper-model rates or the other arithmetics are still missing.
    2. State the expected-time formula with its per-M inputs. The body's numbers imply a whole-batch fallback cost that varies with M (about 367, 375 and 404 us at M = 1, 16 and 64). They also imply a column-mode no-fallback overhead that is not stated: at M = 1, 238.4 us cannot equal 228.5 + 0.021 x 57.
    3. In column mode, include the dense fallbacks that non-ambiguous undecided rows still need. micro_head.py already separates batch_columns_only_rate from batch_dense_rate.
    4. Say that the fallback rates come from batches of M consecutive real rows. The capture's engine batches were at most 16, so this is not the engine's batching at larger M.

Checked and correct

  • Envelope (bounds.py).
    • The decomposition s_ref - zt = (s_ref - x) + <e,h> + s(<q,h> - acc) + (s acc - zt) is exact, and each term is bounded by the stated coefficient.
    • W8A8 splits h = s_h q_h + e_h correctly and uses three roundings for its scale.
    • BF16 has no scale term.
    • All constants are exact rationals rounded outward. scale_rel_error(arith) is passed per arithmetic.
  • Kernel epilogue. beta is accumulated with mul.rp, fma.rp and add.rp from |z| rel_scale + 2^-100; lo uses add.rm and hi uses add.rp. The 2^-100 covers flush to zero of 2K products at 2^-126, for ours and for the stock kernel.
  • Threshold (candidate_threshold). It is the FP32 midpoint below RN_bf16(L), which I checked for positive, negative, power-of-two, zero and subnormal b. It is strictly monotone in the BF16 value, so t(L) <= t(best) with s_j < t(L) gives RN(s_j) < RN(s_k) strictly. An excluded lower-index row therefore cannot tie the winner.
  • Tile summaries. Each tile keeps its top 4 and the maximum of the rest. A tile whose remainder reaches t is expanded in full, so selection is complete. Duplicates are harmless.
  • Refinement.
    • BF16 x BF16 products are exact in FP64.
    • The radius is (g64 + gref)/(1 - g64) * ah + 2^-100, rounded up, then RD/RU to FP32, then BF16 rounding of the endpoints (monotone).
  • Decision.
    • The winner is the lowest index among the maximal lower bounds.
    • A lower index must be strictly below it; a higher index may tie.
    • Overflow, emptiness, a failed threshold and nonfinite inputs all route to the stock head.
  • Sampling.
    • Compaction uses the FP32 rule on scores.
    • ymax is a valid upper bound, from RN(z_hi/T) with RN division monotone.
    • The 2^-22 D + 2^-19 budget covers the subtraction, expf (2 ulp), the division or reciprocal, and logf (1 ulp) of |lp| <= D + log(1.02 V), given V <= 2^18.
  • Column fallback tie rule. It takes the minimum vocabulary id among candidates with the maximal stock BF16 logit, independent of list order. Completeness holds because STATUS_AMBIGUOUS alone implies the threshold passed and no overflow occurred.
  • Graph safety. Both fallbacks are _if_body conditional nodes, and the flags are reset or overwritten every call. test_cuda_graph_capture_and_replay replays a batch with an inf row in both modes and requires the stock tokens.
  • Stock-kernel evidence. stock_invariance.json passes every check at all 20 sizes: flag on and off bitwise equal, the same kernel, row and subset invariance, and gathered candidates at m * 64.
  • Timing harness. The sglang_head arm is matmul, then a copy into an FP32 buffer, then argmax, all in the graph at the same M. The certified arm includes its conditional node.
  • CPU tests and merge. tests/test_certified_bounds.py passes (13 tests), pre-commit passes on all changed files, and the branch merges into main without conflicts.
  • Attribution. There are no AI co-author lines, and no committed file cites ~/vp-coord.

Suggestions (not blocking)

  • Integration handoff. The PR body points to ~/vp-coord/notes/kernel.md for the SGLang handoff. Put it in the repo, for example src/certified_head/INTEGRATION.md, so reviewers can read it.
  • Which kernel the 2.07e-6 error comes from. The README states it for the FP32-output kernel, but the PR body presents it as "the largest observed accumulation error" of the stock kernel. The BF16-output kernel's internal FP32 accumulation cannot be observed directly, so the model is assumed for it. Say so in both places.
  • Silent replica. stock_multinomial_with_seed falls back to an eager replica without warning when SGLang cannot be imported. Inside the head's fallback path that would change which implementation defines the answer. Raise unless a test opts in.
  • ABS_FLOOR docstring. It says 2K x 2^-149 (gradual underflow), while the refine comment says flush to zero at 2^-126. Both are below 2^-100 for K <= 2^25; state the flush-to-zero case once.

Review of PR #45 (B1, B3 and suggestions):

- Column mode can no longer be selected in the constructor; only
  enable_column_fallback(batch_sizes) switches it on, and only for the batch
  sizes whose self-test passed (others keep the whole-batch fallback). The
  self-test now checks exactly the fallback's GEMM shape,
  M * min(capacity, COLS_CAP) gathered rows. The graph test enables columns
  through the self-test.
- fallback_vs_model.py also checks every token outside each row's top 64
  against the winning BF16 bucket and records the rows where one could
  compete, and states its population.
- stock_multinomial_with_seed raises when SGLang is unavailable unless a
  test opts into the eager replica.
- ABS_FLOOR's docstring states the flush-to-zero case it covers.
Review of PR #45 (B2, B3 wording and suggestions):

- The evidence README's contract now states that the W8A16 and BF16
  approximate passes rely on the conservative tensor-core model for their own
  accumulation, and that W8A8 accumulates exactly.
- The observed accumulation error is attributed to the FP32-output kernel;
  for the BF16-output kernel the model is assumed.
- The fallback-rate table states its population and how it compares with the
  GPU replay and the geometry workstream's held-out rows.
- src/certified_head/INTEGRATION.md carries the SGLang integration notes in
  the repository.
- run_all.sh records foreign CPU load around each timed step with the bench
  workstream's host-load helper.
micro_head.py timed batches and computed fallback rates over the first
16,384 real rows, which fall back more often than the 60,000 rows of the
decision replay. The evidence script now uses the same 60,000 rows, the JSON
records the pool size, and the summary states that its batches are
consecutive rows in capture order rather than the engine's own batches.
@SamMausberg

SamMausberg commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner Author

Thanks. Status of each item at 0c0bb7a:

  • B1. Fixed in d21b3c6. The constructor no longer accepts fallback_mode (a test checks the TypeError). _column_batches starts empty, so cols_ok holds only for batch sizes whose self-test passed through enable_column_fallback. The self-test checks m * min(capacity, COLS_CAP) gathered rows and reports that count. test_cuda_graph_capture_and_replay enables columns through enable_column_fallback([m]).
  • B2. Fixed in 6d30754, in the README contract and the PR description's contract and Limitations, in the wording you proposed.
  • B3. The script part is fixed in d21b3c6: omitted tokens are checked against the winning bucket over the full vocabulary, and decided rows where one could compete are counted (0c0bb7a restricts the count to decided rows and corrects the docstring). The population is stated in the README and the description (6d30754): the first 20,000 rows in capture order fall back more often than the 60,000 replay rows or geometry's held-out 6,005 rows. A 60,000-row rerun is queued under -s. Its JSON replaces the committed one.
  • B4. Waits on the final hold, which is still queued. Meanwhile:
    1. The description labels the table partial and lists what is missing.
    2. It states the expected-time formula with every per-M input: B, D, C, F, p, p_c, p_d. D is 362 to 404 us. The column path costs 3 to 9 us more than B without a fallback, which explains the 238.4 at M = 1.
    3. Column mode includes p_d D for batches that still need the whole-batch fallback.
    4. It says the batches are consecutive capture rows, not the engine's batches.
    • f5317bc makes the final hold take its fallback rates from the replay's 60,000 rows. The summary script states the caveat.
  • Suggestions. All four are applied (d21b3c6, 6d30754). The integration notes are now src/certified_head/INTEGRATION.md.

One correction to my own description: it said the partial table used pre-TMA tiles, and that TMA would bring the path from 228 to 197 us at M = 1. The table already used TMA tiles, and 197 us is the approximate pass alone in the sweep. The description now says so.

The full-vocabulary check in fallback_vs_model.py counted every row where a
token outside the top 64 reached the winning bucket, including rows that
already fall back. Only decided rows can change, so the count is now over
those, and the docstring says what the script decides instead of claiming it
reproduces the GPU kernel exactly.
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

This interim re-review covers head 0c0bb7a. B1 and B2 are fixed. B3 is fixed in code, but its evidence has not been regenerated. B4 is still pending.

  • B1 (fixed).
    • The constructor no longer accepts fallback_mode; passing it raises TypeError, and a test pins this.
    • The column path is used only when m in self._column_batches. That set starts empty and is filled only by enable_column_fallback after the self-test passes, so setting the public fallback_mode attribute cannot bypass the gate.
    • The self-test gathers m * min(capacity, 64) rows, which is exactly the fallback's shape, and reports it.
    • The graph test enables columns through the self-test.
  • B2 (fixed). The README contract now states that the W8A16 and BF16 passes rely on the conservative tensor-core model for their own accumulation, that W8A8 is exact, and that the same applies to reference='fp32'. The 2.07e-6 error is attributed to the FP32-output kernel, and the model is stated as assumed for the BF16-output kernel.
  • B3 (code fixed, evidence pending).
    • fallback_vs_model.py now bounds every token outside the top 64 against the midpoint below the winner's lower BF16 value, and counts the decided rows where such a token could compete.
    • The README states the population (the first 20,000 rows in capture order) and cites the other populations' rates.
    • The committed fallback_vs_model.json is still the old run (1fdd347), without that count, and the README says the 60,000-row rerun is pending. It has to be committed before merge.
  • Suggestions taken.
    • INTEGRATION.md is in the repo, and no committed file cites ~/vp-coord.
    • The eager sampler replica now needs allow_replica=True.
    • The ABS_FLOOR docstring states the flush-to-zero case.
  • Tests and hooks. tests/test_certified_bounds.py passes (14 tests, including the new brute-force check of the BF16 decision rule), and pre-commit passes on all changed files.

Still needed before merge (B4, plus B3's rerun):

  • the GPU test log at the final commit;
  • the 60,000-row replay and the fallback_vs_model rerun with the omitted-token count;
  • micro_head.json with the runtime table in the README, labelled partial where parts are missing.

The interim description's formula and per-M inputs, including the 3-9 us column-mode overhead and the dense share in column mode, address the table points, once they are backed by the committed JSON. I will re-review when the final hold's commit lands.

experiments/certified_head/p8_witness_cpu.py replicates SGLang's seeded
noise in pure Python and evaluates the witness under SGLang's chain, an
FP64 log of the same FP32 probabilities, and exact arithmetic. The noise
equals the audit's values exactly; both FP32 and FP64 logs give token 1 at
both temperatures, and only exact arithmetic gives token 0 at the lower one
(boundary T* = 1.02533410). The witness separates SGLang's FP32-softmax
chain from exact arithmetic, not the two log precisions; the README says so.
The W8A8 pass uses s_h = RN_fp32(max|h| / 127), which is not a power of
two. It needs none: the kernel forms e_h = h - s_h q_h in FP64 from the FP32
s_h that the epilogue also multiplies by, q s_h has at most 31 significant
bits, and the subtraction is exact (|x| >= 2^-16 s_h, or q = 0), so the
rounded-up group norms bound N2(e_h); the FP32 roundings of s_i s_h acc are
in scale_rel_error('w8a8').

The new test builds rows with non-dyadic scales, elements as close to
half-codes as BF16 allows over about a hundred codes, clamped codes where the
scale rounds down, subnormal elements next to a large maximum, and constant
rows. It checks the stored bounds against the exact rational error, and the
envelope and decisions against the exact logits.
BlockedTensorCoreModel.gamma summed the per-node errors linearly
(n * p + gamma_n(2^-23) = 1.192097e-4 at K = 2560), which is below the
compounded (1 + p)^n (1 + 2^-23)^n - 1 = 1.192164e-4 for n = 160 nodes. It
is now (1 + gamma_n(p)) (1 + gamma_n(2^-23)) - 1 = 1.192216e-4, an upper
bound of the compounded error (the appendix editor's report). The change is
1.0e-4 relative; the measured stock error is 58 times below either value.

The bound test now requires the compounded product, and
fallback_vs_model.py takes both model radii from the kernel's own models,
rounded up to FP32, instead of printed constants.
Brings in engine/sglang/README.md, which the stacked SGLang integration
(PR #52) documents its patches in.
The final evidence run found the W8A16 pass deciding almost no real rows
in chunks of 256 rows, which the GPU tests did not cover: no test checked
W8A16 envelope enclosure above M = 64. The new test runs every arithmetic
at its default tiles for M = 1 to 256 on real decode rows, requires the
envelope to enclose the exact logits, every decided row to equal the
stock token, and the undecided share to stay near the replay's rate.
large_m_check.py records the same per tile configuration (TMA and
pointer loads at the same shapes) with the failing status bits.
At M = 1 the certified sampling arm failed under capture: its warm-up ran
on a decided batch, so SGLang's torch.compile'd multinomial_with_seed was
first compiled inside the fallback's conditional node. The harness now
runs the stock sampler eagerly for each batch size first.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ee2998372a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +258 to +260
maybe_subnormal = y_lo <= ymax - 74.8
lo = add_rd64(add_rd64(y_lo, -eps), g)
hi = add_ru64(add_ru64(y_hi, eps + tl.where(maybe_subnormal, 1.0, 0.0)), g)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Treat zero softmax probabilities as unbounded below

When a logit is sufficiently far below the row maximum, FP32 softmax can round its probability to zero, so the stock torch.log(probs) score is -inf; however, the maybe_subnormal branch only adds slack to hi and leaves lo finite. For a legal seed that gives the surviving high-probability token very negative Gumbel noise, this phantom finite lower bound can raise the row threshold, exclude the actual winner, and let gumbel_sample certify a different token instead of falling back. Set the lower score bound to -inf whenever probability rounding to zero is possible.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct; fixed in ec46d55, in host code. A probability rounds to zero only when expf(y - m) is subnormal, so only for y < m - 87.33, and the stock score is then -inf while lo stays finite. With the clamped noise of a hash-0 top token (-709.8), such a token can hold the best lower bound.

Setting lo = -inf inside stock_score_bounds would also hit the approximate pass, which calls it without the row maximum (ymax = +inf). Every lower bound there would become -inf, so every sampled batch would fall back. Only the winner's lower bound enters the decision, though: other tokens are excluded through their upper bounds, which stay valid, and the row threshold is compared with the winner's refined lower bound. A zero-probability token has lo <= y + g < m - 87.33 + 22.18 <= ymax - 65.1, since Gumbel noise is at most 32 ln 2.

gumbel_sample therefore sends a row to the stock chain (new status zero_probability) when its best refined lower bound is at most ymax - 64. This uses device ops only, so it is graph-safe. An ordinary winner sits within a few units of ymax, so this almost never triggers. The docstring now states the exception, and the derivation is in ZERO_PROBABILITY_GAP. A CPU test stubs the kernel stages with the buffers such a call leaves and fails without the guard. No kernel code changed.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up in 2c36737 (reviewer): the same argument needs the winner's lower bound to hold for subnormal, nonzero probabilities too, and their absolute rounding error breaks the bound's model there. A subnormal or zero probability needs y < m - 74.84, and such a token's stock score is then below m - 52.66 in the bounds' units, whatever the rounding. The guard's gap is now 52, and it is renamed to small_probability / SMALL_PROBABILITY_GAP. Above the gap, the winner's probability is normal and its bound valid, and no small-probability token can reach its score.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES (ee29983, 1 blocking: Codex P1 r4158392867; both earlier items are fixed)

Fixed in 3b137c0 and ee29983.

  • enable_column_fallback refuses any reference other than bf16 before its self-test, and fallback_mode stays batch. The fp32 and real cases are tested.
  • run_all.sh's tests step runs all four certified-head test files.
  • check_outputs.test_log_problems fails on failed, error or skipped results, or on fewer than 156 passed.
  • The README's CPU-only row names 3b137c0. My CPU-test and pre-commit run for this range is queued in the CPU window.

Blocking: Codex r4158392867 (kernels.py:260, stock_score_bounds) is valid. The lower score bound of a token whose stock probability rounds to zero is finite, but its stock score is -inf.

  1. The docstring is false at low temperature. It says fl(expf(.) / S) "is a normal FP32 number". When y_i is more than about 91.5 below m (104 for expf underflow, less up to log(1.02 V) for the division by S), the FP32 probability is 0. The stock log then gives -inf, but lo = y_lo - eps + g stays finite. At low temperature such gaps are common: T = 0.1 turns a logit gap of 10 into 100.
  2. Why it can decide wrongly: the noise is not bounded below by -3.1. gumbel64 clamps log(x) to [-DBL_MAX, -2^-32], as SGLang does. A hash of 0 gives x = 0, so G = -log(DBL_MAX) = -709.8.
    • Take a row where only the top token has a nonzero probability (very peaked, low T) and that token's hash is 0.
    • The stock sampler still returns the top token, since m - 709.8 is greater than -inf.
    • The certificate's threshold is set by some zero-probability token's finite lo (up to about m - 69), which is above the top token's hi (about m - 709.8). The top token is excluded, and a zero-probability token can be certified.
    • This happens with probability about 2^-32 per row and position, under the right conditions: rare, but it breaks the guarantee.
  3. Fix: set lo = -inf wherever the probability may round to zero. maybe_subnormal (y_lo <= ymax - 74.8) already covers every zero case, so lo = tl.where(maybe_subnormal, -inf, lo) is a one-line change.
    • It keeps the top token as a candidate. At ordinary noise (G ≥ -3.1) it costs nothing: the top token's lo (about m - 3.1) stays above every such token's hi (at most about m - 51.6).
    • Correct the docstring: the probability may be subnormal or zero.
    • Add a test with a hash-0 noise value on the top token and zero-probability tokens below it. A CPU mirror of the bound arithmetic is enough if one exists; otherwise a small GPU case.
    • Because the sampled kernel changes, rerun the GPU tests that exercise sampling (shared lock). The greedy path's evidence is unaffected. Update the README's commit table to match.

Stock's FP32 softmax rounds a probability to zero when the token's scaled
logit is more than about 87.3 below the row's maximum, so its stock score is
log 0 = -inf, but stock_score_bounds keeps a finite lower bound (Codex P1). If
the top token's hash is 0, its Gumbel noise is the clamped -709.8, and such a
zero-probability token can hold the best lower bound and be certified,
although stock never returns it.

Only the winner's lower bound matters for the decision: every other token is
excluded through its upper bound, which stays valid, and the row threshold is
checked against the winner's refined lower bound. A zero-probability token
has lo <= y + g < m - 87.33 + 22.18 <= ymax - 65.1, while an ordinary winner
sits within a few units of ymax. gumbel_sample now sends a row to the stock
chain (status zero_probability) when its best refined lower bound is at most
ymax - 64, with device ops only (graph-safe, no host sync). No kernel code
changes: setting lo = -inf inside stock_score_bounds would also hit the
approximate pass, which calls it without the row maximum (ymax = +inf), and
send every sampled batch to the fallback. The docstring now states the
exception.

A CPU test stubs the kernel stages with the buffers such a call leaves and
fails without the guard; the temperature test's stub now leaves a decided row.
check_outputs.py expects 157 tests (36 CPU).
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES (37cf29d, 1 blocking: the guard should also cover subnormal winners; the zero-probability fix itself is sound)

ec46d55's approach is right, and better than the one I suggested.

  • My lo = tl.where(maybe_subnormal, -inf, lo) would have broken the approximate pass. That pass calls stock_score_bounds with ymax = +inf (kernels.py:555), so every token would count as maybe-subnormal and every sampled row would fall back.
  • The host-side guard works:
    • _decide_kernel (sampled) takes best = the maximum refined rlo64 and requires lower <= best. Every excluded token then has x_e ≤ hi_e < lower ≤ best = lo_w. So only the winner's lo must be a true lower bound, and a phantom finite lo elsewhere can only cause a fallback.
    • The zero-probability arithmetic checks: a normal expf divided by S < 2^19 is at least 2^-145, so a zero needs y < m - 87.33. With g ≤ 32 ln 2 = 22.18, lo_w < m - 65.1 ≤ ymax - 65.1, so a gap of 64 catches it.

Blocking: the same argument needs the winner's lo to be valid when its probability is subnormal but nonzero, and the code does not establish that.

  • stock_score_bounds widens only hi for a maybe-subnormal token (+1). Its lo is y_lo - eps + g, with eps = 2^-22 D + 2^-19.
  • A subnormal probability carries an absolute rounding error of up to 2^-150, and expf itself is accurate to 2 subnormal ulps there. The stock log(p) can therefore lie well below y - m - log S. At about 1.5 × 2^-149, rounding to nearest alone lowers it by ln 1.5 = 0.41, and lower still nearer the bottom. So lo can exceed the stock score.
  • When that token is the winner, the certificate could pick it over a token whose true score lies between. That needs the same hash-0 situation as before (every token with a normal probability drawing g = -709.8), so it is as rare as the zero case, but it is the same kind of gap.
  • Fix: widen the guard to every winner whose probability may be subnormal or zero.
    • A probability can be subnormal only if y < m - 87.34 + ln S ≤ m - 74.9 (the 74.8 that maybe_subnormal already uses), so lo_w < m - 74.9 + 22.18 = m - 52.7 ≤ ymax - 52.7.
    • A gap of 52 (constant renamed, docstring and README updated) catches it. False positives need ymax - m above about 36, so slightly more low-T fallbacks than at 64; still negligible.
    • Extend the CPU test's boundary cases to the new gap.
    • Alternatively, subtract a bounded log-error from lo for maybe-subnormal tokens. That needs an error bound for subnormal expf and the division, which the guard avoids.

Verified: ec46d55's guard code and the docstring exception. My CPU tests and pre-commit for c9f0440..37cf29d run in the CPU window (queued), and I will add the fix head to that run.

An end-to-end GPU regression (a seed inverted so the top token hashes to 0) would be welcome but is not required.

stock_score_bounds models a normal FP32 probability. A subnormal one also has
absolute rounding error (expf and the division round to multiples of 2^-149),
so near the underflow even a nonzero probability's lower bound can exceed the
stock score, and the upper bound's extra unit need not cover expf's error
there (reviewer, on ec46d55's zero-probability guard).

A subnormal or zero probability needs y < m - 87.34 + ln S <= m - 74.84, and
then the token's stock score is below m - 74.84 + 22.18 = m - 52.66 in the
bounds' units, whatever the rounding. So when the winner's lower bound exceeds
ymax - 52, its probability is normal and its bound valid, and no
small-probability token can reach its score. The guard's gap is now 52 instead
of 64, and the status bit, constant and method are renamed to
small_probability. Docstrings state the model's limit; the CPU test's
boundaries move (it fails with the 64 gap). No kernel code changes.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional, on 9597557: Codex is running on this head, and my CPU tests and pre-commit for c9f0440..9597557 are queued in the CPU window. I will confirm or withdraw once both finish.)

2c36737 and 9597557 resolve my item from 37cf29d.

  • The derivation in SMALL_PROBABILITY_GAP (52) checks out.
    • A subnormal or zero probability needs expf(y - m)/S < 2^-126, so y < m - 87.34 + ln S. With S ≤ 1.02 V and V ≤ 2^18 (gumbel_sample refuses larger vocabularies), ln S ≤ 12.50, so y < m - 74.84.
    • Such a token's stock score and its lo are then below m - 52.66 whatever the rounding, since G ≤ 32 ln 2 = 22.18.
    • A winner with lo_w > ymax - 52 ≥ m - 52 therefore has a normal probability, so its lo is valid, and no small-probability token can reach it.
    • Normal-probability competitors are excluded through valid upper bounds, whether in the candidate list or through lower.
  • Code and docs. The guard is unchanged in form (device ops; status bit 512, renamed small_probability). The stock_score_bounds docstring now limits its bounds to normal probabilities and points to the guard. The test boundaries (ymax - 60 and ymax - 52 fall back; ymax - 1.5 and ymax - 51.9 are certified) fail with ec46d55's gap of 64.
  • No kernel code changed, so x8s2's GPU evidence still applies. The README's CPU-only row lists 2ab57df, 09bf64e, 3b137c0, ec46d55 and 2c36737.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 95975572f6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +77 to +79
for f in ${OUTPUTS[$name]:-}; do
[ -e "$REUSE/$f" ] && cp -p "$REUSE/$f" "$OUT/$f"
done

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Refuse reuse when declared outputs are missing

When a selective run reuses a step whose steps.tsv entry is ok but one of its declared artifacts is absent, this conditional silently skips the copy and the function still records the step as successful. check_outputs.py does not validate every declared output—notably stock_invariance.json, the summarized head-path files, host-load records, and compile logs—so a clean output directory can finish with === done despite incomplete evidence, while an existing output directory can retain an unrelated stale artifact. Verify the required files before recording the reused step as ok and remove any pre-existing destinations before copying.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0f51832. A reused step now needs every output it declares; otherwise it is recorded missing and the run ends === FAILED. Every step removes its declared outputs before it runs, is reused or is skipped, so a stale file from an earlier run in the same directory cannot survive. run_all.sh writes the declared outputs to outputs.tsv, and check_outputs.py requires each of them and an ok status for every recorded step. A CPU test (tests/test_run_all_reuse.py) runs the script with every step reused from a fake earlier run that lacks stock_invariance.json (with nvidia-smi stubbed), and checks three things: the step is recorded missing, the stale copy is removed, and check_outputs names the file. It fails without the fix. No committed evidence is affected: x8s2 ran its steps directly, and x7c, the run that reused steps, holds every declared output of all its steps (checked).

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES (9597557; withdraws my provisional approval; 1 blocking: Codex r4158539791)

Codex finished on 9597557 with one comment, and it is valid.

  • run_all.sh's reuse() (lines 65-89) copies only the declared outputs that exist ([ -e "$REUSE/$f" ] && cp ...), but records the step as ok either way.
  • check_outputs.py does not check every declared output: stock_invariance.json, the head-path summaries, the host-load records and the compile log, for example. A selective run can therefore finish with === done and a missing file, or keep a stale file in a reused output directory.

Fix (shell only, no rerun):

  • In reuse(), record the step as missing (not ok) if any ${OUTPUTS[$name]} file is absent in $REUSE, and make the run's final status fail on it.
  • Remove each destination before copying.
  • Add a small test (a bats test, or a pytest driving the function with a fake steps.tsv) that a missing declared output is not recorded as ok.

Everything else on 9597557 stands as in my previous comment: the small-probability guard and its derivation, and no kernel change. My CPU tests and pre-commit for this range are queued, and I will retarget them to the fix head.

reuse() copied only the declared outputs that existed in the earlier run and
recorded the step as ok regardless, and check_outputs.py did not look at every
output a step declares (Codex P2). A reused step now needs every declared
output, or it is recorded "missing" and the run ends FAILED. Every step
removes its declared outputs before it runs, is reused or is skipped, so no
stale file from an earlier run in the same directory survives. run_all.sh
writes the declared outputs to outputs.tsv, and check_outputs.py requires
each of them and an ok status for every recorded step.

A CPU test runs run_all.sh with every step reused from a fake earlier run
that lacks stock_invariance.json (nvidia-smi stubbed): the step is recorded
missing, the stale copy in the output directory is removed, and
check_outputs names the missing file. It fails without the fix.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0f518324c3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +180 to +181
step tests 900 python -m pytest tests/test_certified_head.py tests/test_certified_bounds.py \
tests/test_certified_head_inputs.py tests/test_enclosure_margin.py -q -s -p no:cacheprovider

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include the reuse regression in the evidence test step

The newly added tests/test_run_all_reuse.py is still omitted from the explicit pytest invocation, so run_all.sh can report a successful evidence run even if its missing-output reuse safeguard regresses. This is fresh evidence beyond the earlier complete-suite comment because that regression file was added after the four-file test command was introduced; include it here and raise MIN_TESTS so the output check enforces its execution.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of scope for this PR; it is done in a follow-up. No committed evidence depends on it. tests/test_run_all_reuse.py is a CPU test of the evidence script itself and runs with the repository's CPU suite (python -m pytest tests/, as the README gives it); pre-commit lints it. The evidence run's test step covers the certified head's own tests. Adding this file to that step and raising MIN_TESTS to match is a one-line change on the follow-up branch, which also carries the stress test's memory cap.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (0f51832)

Re-review of 2c36737, 9597557 and 0f51832, with every check on this head complete.

  • Codex r4158539791 (run_all.sh reuse) is fixed in 0f51832.
    • reuse() checks every declared output in $REUSE first, and records the step as missing (not ok, so the run ends === FAILED) if any is absent.
    • clear_outputs removes a step's declared outputs before it runs, is reused or is skipped, so no stale file survives.
    • check_outputs.declared_output_problems requires every file in outputs.tsv and status ok for every step.
    • tests/test_run_all_reuse.py reproduces the case: a missing earlier output and a stale copy.
  • Codex r4159151398 (add that test to the evidence run's test step) has a scoped reply, which I accept. No committed evidence depends on it, the test runs in the repository's CPU suite, and the one-line change is on the follow-up branch.
  • The small-probability guard (2c36737) is as I reviewed it on 9597557: SMALL_PROBABILITY_GAP = 52 with its derivation, and no kernel change.
  • Tests (CPU window, SGLang venv): tests/test_run_all_reuse.py, test_certified_head_inputs.py, test_certified_bounds.py and test_enclosure_margin.py give 37 passed.
  • Pre-commit on c9f0440..0f51832 passes. Host identity: 0 hits over 85f48a5..0f51832. Attribution: clean. The branch merges cleanly into main.

Since x8s2, every change to the package (2ab57df, 09bf64e, 3b137c0, ec46d55, 2c36737) adds refusals or host-side guards, with no kernel code change. So x8s2's GPU evidence at 9f7f369 stands for every default path, as the README's commit table says.

@SamMausberg
SamMausberg merged commit 0f890a0 into main Oct 1, 2026
SamMausberg added a commit that referenced this pull request Oct 1, 2026
#52 was built on 9e3a39a, before the TMA-fault fix, the per-variant self-test
gate, the runtime probes, the weight digest and the sampling guards. This
merges main, which carries #45's final package, and resolves:

- head.py: #52's device-gated stages keep #45's self-test gate outside the
  gated node (as the engine checks' tree 01502cc did); both gumbel_sample
  guards (temperature, small_probability) run inside the gated stages, so a
  batch the gate skips sets no fallback flag; enable_column_fallback keeps
  #52's extend parameter and #45's bf16-only refusal; sibling() carries the
  parent's weight_check, so a refused head cannot yield an accepted sibling.
  Every #45 tile exclusion and default is kept (#52 sets no tile).
- engine.py, engine_validate.sh: 01502cc's changes (an unsafe head is refused
  at install; the stats record the self-test summary and probe stats; a check
  arm fails on refused or probe-tripped rows).
- tests: both sides' appended tests kept.
- evidence/certified_head/README.md: #45's files table plus #52's rows; the
  engine section says engine_v1.json ran on the pre-fix package and that the
  rerun, engine_v2.json, is the evidence for the merged package.
- engine/sglang/README.md: the kernel section placed before repair.
- evidence/README.md and experiments/README.md: certified_head rows.
SamMausberg added a commit that referenced this pull request Oct 1, 2026
evidence/certified_head (tma_repro.json and its README section) merged with #45,
so the README points to it instead of describing the runs.
SamMausberg added a commit that referenced this pull request Oct 1, 2026
Appendices: cite the certified-head kernel's evidence (#45)
SamMausberg added a commit that referenced this pull request Oct 1, 2026
#45's evidence (evidence/certified_head) resolves most of the pending kernel entries.

- Table 1 statuses:
  - The stock-error row is still assumed, now consistent with the FP32-output kernel's
    observed error, 58 times inside the Hopper model, and with the implemented 2^-100 floor.
  - Row invariance is measured at 20 batch sizes and re-checked at start-up.
  - The low-precision kernel is still not proved, but is checked per compiled variant at
    start-up and by runtime probes. The measured violation is named: int8 TMA tiles with a
    64-byte box gave wrong raw products under Triton 3.7.1 and are refused.
  - Re-scoring is implemented and tested.
  - The seeded chain's rounding is bounded by CUDA's documented expf and logf accuracy and
    matched on 60,000 replayed rows.
- Abstract and contributions: the TMA violation in contribution 2; the head-path runtime,
  timed alone, in place of "pending" (about 0.7 of the stock head's time up to 16 rows,
  slower from 128).
- Section 4.3: seeded agreement on 60,000 replayed rows; acceptance in the engine stays
  pending (kernel-seeded-engine).
- Section 4.4, reconciled with the held-out rates: the GPU kernel leaves 0.28% and 1.46% of
  the first 60,000 capture rows to the stock kernel (held-out: 0.35% and 1.40%), and with
  the fallback every token equals the engine's. On batches of 128 consecutive rows its
  measured fallback shares (27% and 77%) fall below what independent rows at its own rates
  give (30% and 85%).
- Section 4.5: the pipeline as implemented (self-test, runtime probes, refused tiles), then
  the microbenchmark. 239.6 against 370.5 us at M = 1. With the column fallback's expected
  cost the path takes 0.67-0.70 of the stock time up to 16 rows, 0.81 at 32 and 0.93 at
  64 (conservative model). Every mode loses from 128, where the int8 pass alone is slower
  than the stock chain. Head-only times; the served effect is pending.
- Discussion: the measured error, and the open question narrowed by the microbenchmark.
- Figure 3 gains panel (c), time per call over the stock head from head_path_time.csv. In
  (b), the kernel's measured per-M batch fallback rates replace the single capture-step
  markers.

Cuts to stay within ten pages:
- The candidate table and the fallback-share table move unchanged into Appendix A.3
  (agreed with the appendix editor). Figure 3 and Section 4.4's text keep their headline
  numbers.
- Section 4.5 loses the gather-size sentence.
- Figures 3 and 4 are slightly shorter.
SamMausberg added a commit that referenced this pull request Oct 1, 2026
Paper: fold the certified int8 head (#45) into the main text
SamMausberg added a commit that referenced this pull request Oct 1, 2026
…ull; at most five sessions

Codex on 84717d2: the certified-head package's fingerprint is now part of the identity the
equality hold's preflight records before any run, and build and every later check require
it unchanged. The reused stock references must match bench's declared configuration
(flags with and without Triton attention, c1 pass, concurrency 1, 256 new tokens, top-5
logprobs, 320 prompts, cold cache, S0's model and prompt set with the same prompt token
counts), as must every stack equality run; the prompt file is pinned by hash from preflight
to build. analyze.py accepts sessions stack-s1 to stack-s5 only (three and at most two
replacements). expected.py's H note and the engine README reflect the merged #45/#52
and #133. Tests for each (98 pass).
SamMausberg added a commit that referenced this pull request Oct 2, 2026
Sync TASKS.md with #45, #52, #91 and #120-#168; measured, derived and open per hypothesis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant