Skip to content

flash_forward earns its checked run, and the run finds the epilogue dropped the head term (#85) - #182

Merged
feitreim merged 2 commits into
mainfrom
feat/flash-forward-reference
Aug 4, 2026
Merged

feitreim merged 2 commits into
mainfrom
feat/flash-forward-reference

Conversation

@feitreim

@feitreim feitreim commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Closes the #85 gap: flash_forward gets a launcher, an f64 causal reference, and a check — and the first checked run in this kernel's life found its second real bug.

The harness (first commit): the reference is the straightforward stable softmax in f64 over bf16-rounded inputs, deliberately not the kernel's exp2/LOG2E folding or its online rescale. The seed puts a carrier ramp on the key axis so the running max moves at nearly every key block — the online rescale is exercised, not merely compiled — and the keys above the diagonal are the best-scored ones a broken mask could admit. The check runs four key blocks (one past STAGES, so the ring wraps and free's recycled phase is waited on for real) by two heads (so a head plane in the wrong place is a wrong number, not a coincidence). V sits in [1, 3) so outputs are a convex combination in [1, 3) and relative error is never against a cancellation.

The bug (second commit): the fp32 epilogue's store_rows cursor dropped the head term — the TMA input maps take the head as a plane coordinate and cannot get it wrong, but the output cursor takes the address it is handed, and every head wrote query block x's rows of panel zero. Demonstrated on B200 before fixing: 50,885 of 65,536 outputs wrong (head 1's panel never written, head 0's holding whichever CTA wrote last), every other check passing. At one head it would have passed — which is why the check runs two.

After the fix: all checks pass, flash_forward worst relative error 1.66e-3 = 0.85 × 2⁻⁹ — the floor is P's trip to bf16 as the second MMA's A operand, scale-free in the sequence since the weights sum to one. Tolerance 2⁻⁸, one doubling above, measured rather than inherited (it was provisionally 2⁻⁷ before the number existed). Argument in docs/kernels/flash_forward.md, which also records the bug.

This kernel's #175 band overwrite was found by inspection; this one by the reference. Both lived exactly as long as nothing compared O to a known-good answer.

Validation: build green; examples fail-before (predicted signature, everything else passing) and pass-after on B200; regcount all gates green (flash_forward 165 regs, unchanged 1824 B census entry — its map-walk story is #166's remaining item and untouched here). The status table, occupancy row (1 block/SM at the 147,532 B plan, as documented) and experiments' SKIPPED note updated; a timed bench case is deliberately left out until a causal-FLOP denominator is argued.

…the seed's key-axis ramp is what makes the online rescale a tested path
… what saw it: 50885 of 65536 outputs, now 1.66e-3 worst
@feitreim feitreim added the gpu-ci Run the B200 device-test tier on this PR (costs GPU minutes) label Aug 4, 2026
@feitreim
feitreim merged commit c648c67 into main Aug 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gpu-ci Run the B200 device-test tier on this PR (costs GPU minutes)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant