Repository navigation
flashnext cuda: the MTP rows' row best runs over 32 blocks a row, fn_row_best's bits - #4632
Merged
Merged
Conversation
jayleaton
force-pushed
the
up/flashnext-row-best-split
branch
5 times, most recently
from
November 22, 2026 21:21
1fbd2e0 to
f2876ce
Compare
Owner
|
Thanks @jayleaton. The split reduction looks sound, but its new persistent device scratch buffer is missing from the CUDA MTP head's memory accounting. Please add those 24,832 bytes to
|
jayleaton
force-pushed
the
up/flashnext-row-best-split
branch
from
November 23, 2026 15:51
a3956eb to
aec2a7f
Compare
…row_best's bits fn_row_best runs one 1024-thread block per row, so a one-row draft step fills one SM. fn_row_best_max and fn_row_best_sum do the same two passes over (row, warp) blocks of 32 threads: each thread reads the same strided values and each warp does the same shuffles, so the best, its first id and the log-sum-exp keep their bits. The row's last block (an atomic ticket) folds the 32 warp sums as warp 0 did. Head.best takes the split for rows up to round_rows. The kernel contract registers it as a replacement of fn_row_best (byte equality on every served shape), with a planted control (the split over V - 1 values) that goes red at shapes. The gradient-serving pins take the two sources.
The split row best keeps a persistent device buffer of split_bytes (24,832 bytes at round_rows = 64) for each warp's best and id, each warp's exponent sum and a counter a row. headBytes adds it, so the placement estimate covers it, and the exact-accounting test pins it.
ashhart
force-pushed
the
up/flashnext-row-best-split
branch
from
November 24, 2026 04:30
aec2a7f to
e03f416
Compare
Owner
|
Thank you @jayleaton. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
ashhart
added a commit
to jayleaton/TensorFold
that referenced
this pull request
Nov 24, 2026
ashhart
added a commit
that referenced
this pull request
Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Flash Next's MTP row best (best value, its first id and the row's log-sum-exp) ran as one 1024-thread block a row.
It now runs as two passes of 32 one-warp blocks a row. fn_row_best_max writes each warp's best, and fn_row_best_sum
re-reduces those maxima, sums its warp's exp terms, and the row's last block folds the 32 sums in fn_row_best's
order. The output bytes equal fn_row_best's.
equality against fn_row_best.
atc overlap --json(run 2026-11-22T14:17Z on this head against main 14951bc; ATC marks it incomplete: PR file listsunavailable and its time and PR limits): MiMo-V2.6-Flash on CUDA (2x GB10) with DFlash as the drafter #728 clean. Unlimited-OCR-2 on CUDA: the family's steps on NVIDIA GPUs (sm_89 and up) #2077, CUDA: #1764's BF16 prompt tile for Qwen ModelOpt, Nemotron and Dory, plus two exact Qwen prompt kernels (#1762) #2008, MoE route tap: optional TF_ROUTE_TAP trace of global top-k #1886 and lfm3 CUDA: serve the block FP8 export weight-only and the MLX 4-bit export as stored (stacked on #1508) #1634 each conflict in one file, the
shared pin registry
zig/tests/fixtures/gradient-serving.tsv, where both sides change pin lines (CUDA: #1764's BF16 prompt tile for Qwen ModelOpt, Nemotron and Dory, plus two exact Qwen prompt kernels (#1762) #2008 also sharescontract_tests.zig, which merges cleanly). lfm3: add native Metal vision support above the text decoder #1502 conflicts inCHANGELOG.md's Unreleased bullets; qwen27: serve the 27B pair, refuse what a pair cannot keep, and die with the peer #1434 and Implement GLP control vectors with a fused Metal kernel for Qwen3.8-27B #1835share only
CHANGELOG.mdand merge cleanly.Checks on this head
commit (6e9c341a4). Main has not changed any of this PR's kernel or Flash Next source files since then; the rebase
only moved the base, and the code merged onto current main without conflicts.
python3 tools/pr_check.py --base origin/main --pr 4632: 0 errors, 0 warnings (8 changed files, lean 165 vs 165, 0 new)zig fmt --check build.zig zigandgit diff --check origin/main HEAD: pass.zig build test test-golden --test-timeout 20m: 824/827 steps, 12,149/12,239 passed, 89 skipped, 1 failed:request_admission_http_test"every way an n-choices request ends returns its places" (engine.cancellednot yet set; server code this PR does not touch). The same test binary rerun alone passed 6 of 6 times.test-goldenpassed.zig build test-cuda-host: 470/470 steps, 2,014/2,027 passed, 13 skipped.zig build -Dfixed-cpu test-host --test-timeout 20m: 2344/2344 steps, 23,167/23,326 passed, 159 skipped, 0 failed, the same counts as main;zig build test-cuda-host: 146/146;zig build test(x86_64): exit 0, like main.fatbins with kernel-contract-limits, below). The whole-registry kernel contract on sm_121 (see Kernel contract).
Receipt
Main against branch (2x DGX Spark, GB10 sm_121, --tp 2 over RoCE, NVFP4, --context 49152 --parallel 16
--prompt-cache-gib 0; cells A B B A, main's first cell dropped as a cold start; aggregate tok/s):
Pre-rebase fork evidence, not this head: on 2x RTX PRO 6000 (sm_120, FP8, a fork carrying other changes) the same
kernel pair gave +1.6% at one stream, +3.6% / +4.3% at 8 / 16 streams, level prompt speed, hashes equal.
Boxes it reaches: every CUDA box that drafts with Flash Next's MTP head.
New switch? No.
Environment: TensorFold 1587c8c + this commit, Zig 0.17.0, CUDA 13.0 (nvcc 13.0.88), driver 580.178.04,
2x NVIDIA GB10 (sm_121), NCCL 2.30.7 over both ConnectX-7 RDMA devices, nvidia/Qwen3.8-Flash-Next-NVFP4.
Paths and platforms: CUDA only. Contract gates ran on sm_121; records for sm_80, 86, 89, 120 and 121 were checked
with kernel-contract-limits. Metal and HIP are untouched.
Exactness: every arm gives main's token hashes (greedy code 4e759dbd859c, chat 764da77fbd3f, and the same seeded
sets).
bench_concurrent.py --alone --serialat 1 / 8 / 16 streams: every concurrent reply equals its alone run,and every alone run equals its
"draft": falsereply.Main against this branch, same machine and checkpoint: the table above.
Decode speed before and after, from
tools/bench_openai.py: the table above.Prompt speed before and after: cold first request from
tools/bench_cache.py --require-coldat 8K and 32K, level(table). Prompt passes do not call the row best.
Licence of any new weights or drafter: n/a
Kernel contract
replacedhook).FAIL shapes control: the split row best over V - 1 values posing as fn_row_best: at 12x4x31 its bytes differ from fn_row_best's from byte 4,and the control is reported red at shapes, as planted.
tf-cuda-test kernel-contract fn_row_best, exit 0):(filtered) SUMMARY 2 kernels: 2 pass gates 1-4, 0 fail, 0 known findings; 1 controls: 1 red as planted, 0 missed; 0 limit problems. The split is reported "16 shapes bit-equal to the kernel it replaces". Main, same command:1 kernel passes.
(
zig build kernel-contract -Dsm=121) on main is incomplete: I stopped it at 2 h 28 min with 2,892 PASS, 480 FAIL,9 KNOWN and 0 SKIP lines, fn_row_best among the passes. Those 480 FAIL lines come from main without this change;
this PR touches none of those kernels. I did not run the whole registry on this branch.
kernel-contract-limitsover sm_80, 86, 89, 120 and 121 fatbins: fn_row_best, fn_row_best_max andfn_row_best_sum are "record current" on all five. The run reports 91 problems, all from main: the 10 planted
controls, red as planted, and records main marks stale or absent (for example fn_row_topk's
registry.none).What I have not established
--tp 2, including one GPU. FP8 at TP2 was not measuredagainst main, because main could not serve it on the boxes I had.
Checklist
cannot exist before the kernels do; the planted control shows the byte-equality gate is not vacuous.
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. Draftedequals
"draft": falseand concurrent equals solo (above); resumed against fresh was not measured.--drafter, no slower than without it, greedy and sampled. (No--drafterhere: the MTP head drafts.)