Skip to content

cuda: Flash Next refuses non-finite draft rows by name and never indexes past its ID table - #2753

Merged
ashhart merged 3 commits into
mainfrom
lead/s375-proposal-guard
Nov 11, 2026
Merged

ashhart merged 3 commits into
mainfrom
lead/s375-proposal-guard

Conversation

@ashhart

@ashhart ashhart commented Nov 10, 2026

Copy link
Copy Markdown
Owner

What this changes

Flash Next on CUDA reported ProposalPaddingPick when a draft-head row reduction came back non-finite (#2734). The name pointed at score padding, but the row was invalid: fn_row_best starts from negative infinity and INT_MAX and only moves on a strict greater-than, so an all-NaN or all-negative-infinity row keeps that sentinel, and its log-sum-exp is NaN whenever the row holds a NaN. The batched head also cast the unchecked column and indexed the compact ID table with it, which can read out of bounds in a fast build.

  • core/proposal_rows.zig gains Scores.pickBest: it takes the reduction (top value, log-sum-exp, signed column bits) and refuses a non-finite top, a non-finite log-sum-exp, a negative column or one past the logical row with ProposalNonfinite, then maps the column through the existing global(). Existing selectors are unchanged.
  • Both greedy head sites (lone and shared) pick through it; no direct column index is left.
  • Sampled head candidates are checked (count, finite values, column range) before mapping or sampling, and every main-model verify row is reduced and checked before any output token is written or a grammar mask applied. Masks may still add negative infinity on purpose.
  • On a refusal, one line names the stream, draft length and capacity, the top and log-sum-exp, pool or own ownership, batched mode and input/score finiteness. The error still propagates; there's no silent fallback to drafting off.

Finite rows pick exactly what they picked before: the same token mapping, probability formula and keyed sampler. The NaN's source isn't found yet; this makes it fail by its real name and never read out of bounds. No cache clearing or kernel arithmetic changes.

Checks

  • zig build test-flashnext-proposal-host test-flashnext-proposal-pack-host on this head (main cd6060a436): pass. New tests in families/flashnext/cuda_mtp_nonfinite_test.zig and zig/proposal_rows_host.zig cover {-inf, NaN, INT_MAX bits, 0}, finite maxima with NaN log-sum-exp, negative and end-of-row columns, both NaN signs and infinities in candidates, through the real lone Ops.pick, the shared head's selection, raw verify draws and the real top-k sampler with fake CUDA readbacks.
  • Seven planted removals each turn a test red (head guard, top finiteness, log-sum-exp finiteness, column range, raw main-row check, candidate finiteness, candidate range); restored, all pass.
  • zig build compile-cuda-tests -Dtarget=aarch64-linux-gnu: pass. Full host suite on the original base: 383/383 steps, 1436/1443 tests (7 skipped). Lean: 0 new. Files at most 600 lines.

Still to come

Sampled and masked verify rows now run the existing reduction kernel and a small readback, and that cost isn't measured yet. A GB10 A/B (Flash Next, main against this branch, prompt passes, a decode sweep and chat, sampled as served) is queued; this lands only if it reads level with tokens equal.

Refs #2734.

  • Synthena (Ash's Agent)

@ashhart

ashhart commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

A second read of this one found work before it lands: the new host tests aren't wired into any CI step yet, the sampled and masked verify paths gain a stream sync that can be folded into the one they already have, a few finite-path parity tests are missing, and the description should list three behaviour changes (a verify row that is non-finite only in grammar-masked columns is now refused, drawTopk refuses −inf candidates, and a new ProposalScoreShape refusal). A follow-up round is coming; the GB10 A/B waits for it.

  • Synthena (Ash's Agent)

@ashhart

ashhart commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

Follow-up round is in (5b0f14313):

  • Sampled and masked verify rows now share the path's one completion wait, so the extra stream sync is gone.
  • A row that is non-finite only in grammar-masked columns draws as on main (those columns are excluded before the check); a non-finite allowed column still refuses with ProposalNonfinite.
  • A verify refusal names itself as a verify row with its index, not a draft-head failure.
  • test-flashnext-nonfinite-host runs in the Linux host CI list, and the finite-path parity, two-lane and per-row verify tests asked for are added; seven planted removals each still turn a test red.

The GB10 A/B (greedy, sampled top-k, full-row, structured output, concurrent streams, tokens equal and decode level) runs on this head next; it lands only on that.

  • Synthena (Ash's Agent)

@ashhart

ashhart commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

The GB10 A/B on this head (5b0f14313) against main is in, Flash Next sampled as served, order base, new, new, base:

  • Prompt passes: level, at 32K and 64K from starts 0, 5,000 and 10,000, first and repeated (every cell within 0.3%). Tokens: 0 of 20 rows differ across runs.
  • Decode sweep: 1, 2, 4 and 8 streams, chat and code at temperatures 0 and 1.0. Every cell is within 0.7% and the repetitions overlap. The largest move is code at 1.0 with 8 streams, 168.1 to 166.9.

So the extra reduction and readback on sampled verify rows don't show up in decode. This goes on the landing queue once this head's CI finishes. A missed push event meant CI never started, so the PR was closed and reopened to start it.

  • Synthena (Ash's Agent)

Exercise the shared two-lane draft loop, per-row verify refusals and finite sampling and mask parity. Run the nonfinite host gate in the CUDA aggregate and Linux nightly shard.
@ashhart
ashhart force-pushed the lead/s375-proposal-guard branch from 5b0f143 to 3eb0e4b Compare November 11, 2026 07:57
@ashhart
ashhart merged commit baf5553 into main Nov 11, 2026
5 of 10 checks passed
@ashhart
ashhart deleted the lead/s375-proposal-guard branch November 11, 2026 07:57
ashhart added a commit that referenced this pull request Nov 11, 2026
#2721 added tf_qmmf_native_fp4_check and the e2m1 pair decode to qmmf.cu behind
-Dnative-fp-decode; default builds are byte-identical. #2753 refuses non-finite
Flash Next draft rows by name and checks verify rows after one completion wait,
with finite rows unchanged. #2802 pins that Flash Next declares no
chunk_invariant. Each row's note names the change.
ashhart added a commit that referenced this pull request Nov 11, 2026
#2721 added tf_qmmf_native_fp4_check and the e2m1 pair decode to qmmf.cu behind
-Dnative-fp-decode; default builds are byte-identical. #2753 refuses non-finite
Flash Next draft rows by name and checks verify rows after one completion wait,
with finite rows unchanged. #2802 pins that Flash Next declares no
chunk_invariant. Each row's note names the change.
ashhart added a commit that referenced this pull request Nov 11, 2026
Scope and figures corrected to the PRs (#2700, #2670, #2338, #2491,
#2680, #2557, #2597, #2760's load time, #2753's verify-row wait, #2681's
ledger row), #2831's and #2682's lines rewritten to what the code does,
#2709 given its own line above #2609's, the duplicate #2404, #2576,
#2597 and #2699 entries and the copy of #2609's line under 1.2.6
removed, entries spaced one blank line apart, and the released sections
restored to the v1.2.6 tag's text (#1651's 1.2.2 line and six blank
lines in 1.2.5 and older).
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