Repository navigation
Flash Next on CUDA: a prompt pass holds 3,072 rows - #3726
Conversation
fdb5e83 to
eea3887
Compare
eea3887 to
3b27d36
Compare
|
Thanks @BadAd84. Please update cuda_chunk.zig:47: the empty-setting test still expects 1,536 after the default becomes 3,072. The environment help at environment.zig:208 also names the old default. Keep an explicit 1,536 override case and rerun the covering host checks. The supplied performance receipt records the larger memory cost and equal replies.
|
|
Thanks @BadAd84. The empty-setting case now uses the resolved default, the explicit 1,536 override stays, and the help says 3,072. That answers both asks, and CI is green at this head, so it's ready to land; the host steps run again in the landing train. The description's checks still cite 052e72a, from before these corrections, if you'd like to refresh them.
|
|
Thank you @BadAd84. The empty-setting case now uses the resolved 3,072 default, the explicit 1,536 override stays, and the help names the new value. With CI green at this head, there is nothing further we need from you.
|
The default pass held 1,536 rows while another stream decoded, so a long prompt ran in passes of 1,536 and each lane admitted 1,536 rows a pass. It holds 3,072 now: a long prompt takes about half the passes, and each one holds twice the rows. A row's bits do not depend on how many rows a pass holds. splitK reads the weight's shape alone, planSlices gives both sizes the fused plan with one K-slice order because the fused floor is 256 rows, and every other prompt kernel computes a row from its own inputs and its absolute position. The change moves launch grouping and the pass's device scratch, not the arithmetic. The scratch at the default grows with the rows, so the test that bounded it at two gigabytes bounds it at three and names the default it prices. The startup line's default pass and the serving pin file follow, and a server started at one stream keeps its 8,192-row passes, so only a server with more than one stream changes.
…tests and docs The empty-setting test expected 1536 and the environment table, its help and the recipe still named it as the default. The test now expects default_chunk for an empty setting and keeps an explicit 1536 case.
ad1f677 to
4eab582
Compare
|
Thank you @BadAd84. 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. |
Terms used below: "main" is upstream TensorFold at
077998f7d9b14adebec3a2acc2caa47ff7ae6ec7(its tip of 2026-11-16T15:26:10Z, read withgit fetch origin mainat 17:44:40Z), and "the measured head" is1fdbd5570b95c258862cc0dd9cb420c82f694de5, that main plus the change commit and the receipt commit, the commit the checks and the receipt below name as measured. The pull request's head isad1f677976910157d4871385afbbf3be18a4a8c2("the head"): the maintainer rebased those two commits onto upstreammainat8cbef9777b9a05dfaff99d5aa9c2ce52fe2b00f8(asfdc5ca23b34cba77e5080de6b05ca4697639c59b, the change, and3b27d360938c85c2277be2c1f057a63c935db260, the receipt), and two commits of ours follow:eb9feecaa297df3093c492becc07eed1852c50af, which answers the review (the empty-setting test expectsdefault_chunkand an explicit 1,536 case is kept; the environment table, its help line and the recipe name 3,072 as the default), andad1f677976910157d4871385afbbf3be18a4a8c2, the Unreleased bullet naming this pull request. Where a check below says "this head", it means the measured head unless the bullet names the head.What this changes
A Flash Next on CUDA prompt pass held 1,536 rows at most while another stream decoded (
cuda_batch_state.zig'sdefault_chunk), so a long prompt on a server with more than one stream ran in passes of 1,536 and each lane admitted 1,536 prompt rows a pass. It holds 3,072 now: a long prompt takes about half the passes (a 64k prompt is 22 instead of 43), each pass holds twice the rows, and each lane's prompt admission is the same 3,072. A server started at one stream is untouched: it takes 8,192-row passes throughcuda_chunk.zig's solo rule, on both sides.A row's bits do not depend on how many rows a pass holds, from the code:
splitK(zig/src/cuda/qmmf.zig) reads the weight's shape alone, and its own comment says so: "K slices for an (n, k) weight, from the shape alone so a row's bits never depend on the row count".planSlicesgives both sizes the same plan:fusedat 256 rows and above whenever the split is wider than one slice, with the same slice order, and neither size falls into the row-bucketed form (16, 32 or 64 rows) that the sub-256 case takes.att_rowsat a time), the norms, the MoE routing and the n-gram gather.So the change moves how many rows a launch covers, one pass's device scratch and each lane's admission. It moves no arithmetic. The scratch at the default grows with the rows, which is why the test that bounded it says what it now measures:
Scratch.bytes(default_chunk, .{ .head_rows = default_chunk })is 2,753,048,104 bytes at 3,072 rows on this head and 1,397,558,248 bytes at 1,536 rows on main, both printed by the lane's own probe of each tree (an exact expectation instead of a bound, so the test binary reports the figure), so the test that asserted "under two gigabytes" asserts "under three" and names the default it prices: at 1,536 rows the old ceiling held, and at 3,072 rows it does not. The cost is that device memory: each startup line shows 0.79 GiB more model and 0.8 to 0.9 GiB less left for streams, and every setting the receipt measured admits the same number of streams on both sides.TF_FLASHNEXT_CHUNKstill overrides it as today, and 1,536 stays reachable.mainat8cbef9777b9a05dfaff99d5aa9c2ce52fe2b00f8. The branch is the maintainer's rebase of the measured head's two commits (the changefdc5ca23b, which was052e72a9c, and the receipt3b27d3609, which was1fdbd5570, four files, no code), theneb9feecaaandad1f67797as named above.atc overlap --json: run last, on the headad1f677976910157d4871385afbbf3be18a4a8c2withup/mainate63f26f0e6ae75f76fc2617c1f841af7adbde6e2, 00:11 to 00:12 UTC: incomplete (complete: false, with its own four limits,otherPullRequestsLimit,pullFilesUnavailable,pullRequestsLimitandtimeLimit), 13 changed files and 38 overlap rows, of which 28 are working-tree rows (8clean, 1conflicts, 19unknown) and 10 are the fork's trunk (PR 2044) listed against other pull requests, allunknown. The oneconflictsentry is dsv41 metal: image prompts #1722, and the only file it shares with this change isCHANGELOG.md(checked against the files of both): the ordinary case of two pull requests inserting their Unreleased bullets in the same place.Checks on this head
1fdbd5570b95c258862cc0dd9cb420c82f694de5(tree902ce69615f5e785c7637227877b8da29be82eec; 9 files, 352 insertions and 6 deletions against main), the receipt commit on the change commit052e72a9c3eb6025b0f6a6095f06194fdc9a3313(treed542f131a8208b89462b204b56cb50881a2a4c73; 5 files, 7 insertions and 6 deletions against main); both signed (%G?isG), author and committerBadAd84 <BadAd84@users.noreply.github.com>. Every check below ran on052e72a9c, whose code the head carries unchanged;git diff --check 077998f7d..1fdbd5570is clean.python tools/zig/lean_check.py, each tree scanned by its own copy from its own root (the three copies byte-identical, sha256a08d2a424e01b16a): base077998f76,575 files, 221 problems; this head 6,575 files, 221 problems;tools/zig/lean_new.py:lean: 221 problems, 221 on the base, 0 new. The two file counts are equal because the change adds no file and removes none; that they are two trees is shown by the base-versus-head diff above and by each run's own root.python tools/pr_check.py --base 077998f7d9b14adebec3a2acc2caa47ff7ae6ec7:merge base 077998f7d9b14adebec3a2acc2caa47ff7ae6ec7; 5 changed files; lean 221 vs 221, 0 new,0 error(s), 1 warning(s). On the head with the receipt commit:9 changed files; lean 221 vs 221, 0 new, the same one advisory warning. The warning is the advisory--prone: the branch has no pull request number yet, and the Unreleased bullet's#XXXXbecomes it.zig fmt --check build.zig zig: rc 0, no output, on the checked tree of this head.-j4 --maxrss 6000000000, umask 022, no GPU visible), on a freshgit archivetree of this head checked blob by blob against its commit (11,832 entries, 0 mismatches):-Dfixed-cpu test-gradient-servingrc 0, 4/4 steps, 1/1 test;-Dfixed-cpu test-gradient-serving test-qwen-serving-hostrc 0, 7/7 steps, 2/2 tests;compile-config-server -Dtarget=aarch64-linux-gnurc 0, 7/7 steps;compile-cuda-tests -Dtarget=aarch64-linux-gnurc 0, 10/10 steps;-Dfixed-cpu test-cuda-host -j4rc 1, 408/410 steps and 6,916/6,950 tests passed, 33 skipped, 1 failed;-Dfixed-cpu test-environment-host -j4rc 0, 3/3 steps, 25/25 tests;-Dfixed-cpu test-host --test-timeout 20mrc 1, 2,125/2,132 steps and 18,645/18,771 tests passed, 125 skipped, 1 failed. The one failure in both suites islistener.test.accepted IPv4 and IPv6 TCP streams disable Nagle for incremental responses, which fails on this machine for every tree because it boots withipv6.disable=1; the sibling branch's head fails that same single test, and the two runs' totals differ only in how much of the suite the cache served (this run executed 522 of the 622 test steps and reused 100; the sibling executed 507 and reused 115), which is why the gate is scored on the failing names and not the counts.Build Summaryand each against this head's own unmutatedtest-cuda-hostrun (rc 1, 408/410 steps, 6,916/6,950 tests, one failing test, the machine's).b/default-1536failscuda_startup_test.test.CUDA startup: unset Flash Next chunk reports the default stored pass;b/default-4096andb/bound-twoeach failcuda_batch.test.a pass's scratch at the default chunk stays under three gigabytes. The scratch's own bytes at 3,072 rows are 2,753,048,104, over the two-gigabyte ceiling the test carried and under the three this change sets, which is what makes the ceiling move load-bearing rather than cosmetic;gates-B.mdcarries each run's rc, step and test counts.python3 tools/pr_check.py --base 8cbef9777b9a05dfaff99d5aa9c2ce52fe2b00f8 --pr 3726:merge base 8cbef9777b9a05dfaff99d5aa9c2ce52fe2b00f8; 13 changed files; lean 221 vs 221, 0 new,0 error(s), 0 warning(s). On a clean x86_64 Linux machine (16 threads, Zig 0.17.0, umask 022, no GPU), on a freshgit archivetree of the head before its changelog commit:zig fmt --check build.zig zigrc 0;-Dfixed-cpu test-environment-hostrc 0, 3/3 steps, 26/26 tests;-Dfixed-cpu test-gradient-serving test-qwen-serving-hostrc 0, 7/7 steps, 3/3 tests;compile-config-server -Dtarget=aarch64-linux-gnurc 0, 7/7 steps;compile-cuda-tests -Dtarget=aarch64-linux-gnurc 0, 10/10 steps;-Dfixed-cpu test-cuda-host -j4rc 0, 418/418 steps, 7,092 of 7,125 tests passed, 33 skipped.ad1f677976910157d4871385afbbf3be18a4a8c2(the head), run on this pull request:fmt,zig,zig-b,zig-windows,pytest,benchmark-clients(ubuntu and windows),release-pathsandzig-macos-dev-toolsall completed successfully;host-nightly-linuxandhost-nightly-macosare skipped by their own conditions.kernel-contractsuites, because this change adds and changes no kernel.Receipt
M1 B1 B2 M2with a fresh server each and nothing set on either arm, so the 3,072-row default is the only difference. Cold prompts 9 faster, 0 level, 0 slower; decode 0 faster, 12 level, 0 slower; the one-stream control 0 faster, 5 level, 0 slower.default_chunkis the value the setting reads when it is unset,TF_FLASHNEXT_CHUNKstill overrides it (1 to 16,384, refused otherwise), andTF_FLASHNEXT_CHUNK_SOLOstill governs a one-stream server. No new environment row, so no profile row either.077998f7d9b1(main) against052e72a9c3eb(this head), both built from source with Zig 0.17.0 and nvcc 13.3 in thenvcr.io/nvidia/pytorch:26.07-py3image; one GB10 (sm_121), driver 580.178.04; checkpointnvidia/Qwen3.8-Flash-Next-FP4-Localatb9ce18a6887e18c089fdea8509a33e63429a3300.tools/bench_concurrent.py --alone --serialandtoken_shaagainst"draft": false: every contract equal on both arms, with the prompt cache on and off. Drafted output equals"draft": false(192 equal, 0 unequal, over both arms); a resumed prompt equals a fresh one (14 equal, 0 unequal); concurrent equals solo (338 equal, 0 unequal). Across the arms, 528 greedy decode replies and 12 cold-prompt replies (the same prompt bytes sent to every boot, 2k to 64k, idle and beside three decoders, and the one-stream control) carry identical token ids, so a different pass boundary changed no bit.docs/receipts/flashnext-prompt-chunk3072/(README.md, cells.csv, noise-rule.md, exactness.md) in this diff.tools/bench_openai.py(one stream, both built-in prompts) andtools/bench_concurrent.py(1, 2, 4, 6 and 8 streams, both prompts, eight being the widest admitted at 32,768 tokens), greedy, two fresh boots an arm: 0 faster, 12 level, 0 slower, the per-cell changes running from -0.5% to -0.1%. The tokens a round are identical in every cell (2.51, 2.81, 4.49, 4.83, 5.22) and so is the server's own acceptance ratio (0.6242, 0.6884). Sampled (temperature 1.0) at 1 to 6 streams, measured once an arm in the exactness boots: -0.2% to +0.7%.ttft_sat 2k, 8k, 32k and 64k, idle and beside three decoders, the prompt cache off, a 131,072-token window at four slots, two fresh boots an arm: 9 faster, 0 level, 0 slower. Time to the first token, branch against main: idle 2k -9.8%, 8k -8.4%, 32k -6.4%, 64k -7.4%; beside three decoders 2k -17.2%, 8k -14.1%, 32k -12.2%, 64k -12.9%;bench_cache's first cold request -7.2%. The 64k cells'ttft_s(M1, M2, B1, B2) are idle 33.058, 33.175, 30.665, 30.682 (-7.4%); beside three decoders 37.582, 37.718, 32.780, 32.786 (-12.9%). The one-stream control, where both arms take 8,192-row passes, is 0 faster, 5 level, 0 slower, which is what says the gain is the default chunk and nothing else.docs/receipts/flashnext-prompt-chunk3072/README.mdcarries it with every number; 20 boots, 0 arm retries, no arm failed.--parallel 8at start (needs 32.86 GiB for its streams, the budget leaves 27.85 GiB, it names 6 streams); branch refused--parallel 8at start (needs 33.1 GiB for its streams, the budget leaves 27.01 GiB, it names 6 streams).Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo: measured on both arms with the prompt cache on and off, 544 contract comparisons equal and 0 unequal, 528 greedy pass-A replies and 12 cold cells identical across the arms.--drafter, no slower than without it, greedy and sampled: greedy decode 0 faster, 12 level, 0 slower at 1 to 8 streams, sampled decode -0.2% to +0.7% at 1 to 6 streams (one run an arm), cold prompts 9 faster, 0 level, 0 slower, the one-stream control 0 faster, 5 level, 0 slower, drafts off level with identical token ids; this change touches no--drafterpath.