Repository navigation
Flash Next on CUDA: the draft head's rows are affine4 unless TF_FLASHNEXT_DRAFT_HEAD=bf16 - #3477
Conversation
|
Thanks @BadAd84. Target verification remains in place when the proposal rows use affine4. The forty receipt cells support the speed gain; final replies must still equal main and drafts-off output token for token. We will run the device check on our side for Flash Next's FP4-Local checkpoint, covering unset, blank and explicit bf16, seeded replies, shared streams and resumes. We will include the default settings alongside the measured recipe. The final head also needs green zig, zig-windows, pytest and fmt jobs.
|
|
Thanks @BadAd84 and @jschmied. No new code request follows from this exchange. Target verification remains unchanged, and the forty timing cells for the new default still show no slower cell under the stated rule. The explicit bf16 comparison remains level. Our GB10 check is still owed for unset, blank and explicit bf16, with both default settings and the measured recipe. Complete replies must equal main and output with drafts off, including seeded, concurrent and resumed requests. A repeatable slowdown in any default cell would block the default change.
|
|
Thank you @BadAd84. No new code request came out of the exchange with @jschmied, and the head keeps target verification with the affine4 draft rows, the bf16 opt-out and strict parsing of the setting. The 40 timing cells still show no slower cell, and the explicit bf16 arm stays level with main. Nothing further is needed from you. We still owe the GB10 check here, covering unset, blank and explicit bf16 with both default settings and the measured recipe; complete replies must equal main and drafts-off output, including seeded, concurrent and resumed requests. We settle the CHANGELOG placement on our side at landing.
|
2894dfe to
e782527
Compare
|
I checked For the three conflicts against Igor Lessio - AIFLOW LABS |
e782527 to
01fc963
Compare
…NEXT_DRAFT_HEAD=bf16 TF_FLASHNEXT_DRAFT_HEAD now reads through the environment table. Unset or blank selects affine4, so a bf16 language head's draft rows are held as 4-bit affine groups of 32; bf16 keeps them as stored; any other text stops the start by name before the engine loads. Before, unset meant bf16 and a blank value stopped the head's load with BadDraftHead. A draft is a proposal the verify forward checks, so replies are unchanged and only the rounds a reply takes move. The setting gets its row in the Flash Next table, now 30 settings, and on the environment page.
…e noise rule and tokens a round
…files) The gradient-serving pin holds the byte identity of the maintained serving sources. This branch changes the draft head's loader and adds its test import, so both files are re-pinned at main 3a56d4e: the kernels, their launch counts and the verify path are unchanged.
…aming the pull request -- 2.43.0 -- 2.43.0 -- 2.54.0 (Apple Git-157)
01fc963 to
41aee66
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 the commit named beside it:
d2b37227a8b4431a71d87bf093786aadcfa35b62for the checks on this head,d6c4cce602and41a72fd257for the two receipt windows. "The branch" is that main plus the one change this pull request adds.What this changes
On main (
d2b37227a8), Flash Next on CUDA keeps a bf16 language head's draft rows as bf16 unlessTF_FLASHNEXT_DRAFT_HEAD=affine4is set, and a blank value stops the start withBadDraftHead(zig/src/families/flashnext/cuda_mtp_load.zig:9-14). On the branch, unset or blank selectsaffine4: the head's rows for the 79,591-token draft vocabulary load as 4-bit affine groups of 32, through the codeaffine4already runs on main, andTF_FLASHNEXT_DRAFT_HEAD=bf16keeps main's rows. The setting is read throughplatform/environment.zig, so any other text stops the start by name. A draft is a proposal the verify forward checks, so replies are unchanged and only the rounds a reply takes move.d2b37227a8b4431a71d87bf093786aadcfa35b62, merged in with no conflicts: none of main's 26 commits since5c82ef28a6, the main merged before it, touches a file this change touches.atc overlap --json: run asatc overlap --base up/main --jsonon this head, against main atd2b37227a8(22:02 UTC): 12 changed files, and 18 open pull requests share at least one of them. 7 merge cleanly, 8 areunknown, and 3 are hard textual conflicts: GLM on CUDA: the latent split's per-rank page book and owner (TF_GLM_KV_SPLIT, #1431 part 1; stacked on #1411) #2415, idol: Idol's denoiser on CUDA (stacked on #1766) #1767 and Ling-3.1-flash on CUDA, on one or two GB10s #2340.completeis false (otherPullRequestsLimit,pullFilesUnavailable,pullRequestsLimit,timeLimit), so pull requests it couldn't read aren't shown clear. None of the conflicts comes from this branch. I fetched the heads of all 18 and merged each (git merge-tree) with main alone and with this head: for every one, the 8unknownincluded, the same files conflict in both merges, and none conflicts only with this head. Where a conflicting file is one this branch changes (docs/environment.mdandzig/src/platform/environment.zigfor GLM on CUDA: the latent split's per-rank page book and owner (TF_GLM_KV_SPLIT, #1431 part 1; stacked on #1411) #2415;zig/tests/fixtures/gradient-serving.tsvfor idol: Idol's denoiser on CUDA (stacked on #1766) #1767, Ling-3.1-flash on CUDA, on one or two GB10s #2340, MiMo-V2.6-Flash on CUDA (2x GB10) with DFlash as the drafter #728 and Muse Spark Open on CUDA, on two GB10s #1295), both merges have the same number of conflict blocks and no line this branch adds sits inside one, so each conflict is already there between that pull request and main. ATC's 9 worktree overlaps are other local checkouts of mine, not pull requests. It doesn't list Flash Next on CUDA: TF_FLASHNEXT_MTP_WEIGHTS selects how the drafter keeps its BF16 linears #3218, which is mine too; its overlap with this branch is under "Compatibility".Problem
d2b37227a8),cuda_mtp_load.zig:10readsTF_FLASHNEXT_DRAFT_HEADwithstd.c.getenv, outside the environment table, andtools/zig/lean_check.pycounts that line as a directgetenvof a setting. Unset isbf16, and a blank value, like any text but the two words, stops the start withBadDraftHeadwhen the head loads (:13).affine4, already on main as an opt-in, holds them at 0.625 bytes a weight: 4-bit codes with one bf16 scale and one bf16 bias for each group of 32, fitted at load from the group's minimum and maximum (zig/src/families/flashnext/cuda_draft_affine.zig:22-46on main).964f98b0b, 1, 4 and 8 streams, greedy and sampled) found min/max affine-4 3.9% to 9.2% faster than the bf16 head in every cell, with identical replies. RFC: one load-time fit for every affine-4 draft head, weighted by diag(H) (Flash-Next: affine-4 head near bf16's acceptance, 7.8 % less time) #1870 closed without the weighted fit and left moving the default as a separate step. This is that step.Proposed behaviour and how to verify
affine4, andbf16keeps the stored rows (cuda_mtp_load.zig:15and:22-24on this head,2278974ebe).zig/src/platform/environment.zig:200) and its row on the environment page (docs/environment.md:125; the page's count at:91goes from 29 to 30 Flash Next settings), so a malformed value stops the start before any load, naming the variable, the text and the accepted forms.cuda_mtp_load.zig:62-67: unset, blank, both words and malformed text through the reader;zig/src/platform/environment_flashnext_test.zig:106-114: the table's words and their order; the count test at:36-43), each shown failing with its part of the change undone, under "Checks on this head". Then the receipt under "Receipt", taken to the gate set on RFC: one load-time fit for every affine-4 draft head, weighted by diag(H) (Flash-Next: affine-4 head near bf16's acceptance, 7.8 % less time) #1870 (never slower than the current head at 1, 4 and 8 streams, greedy and sampled, with the accepted fraction, rounds and time) and to the additions the maintainer set on Flash Next on CUDA: an opt-in MXFP8 coding for the drafter's BF16 linears (TF_FLASHNEXT_MTP_WEIGHTS) #3162 for the drafter's other setting: receipts on main with alternating arms, unset or blank meaning the default, the opt-out byte-identical to main, accepted tokens a round beside tok/s, a malformed value stopping the start by name, the noise rule, and a CHANGELOG line quoting served results.TF_FLASHNEXT_MTP_WEIGHTS) #3162, a change to the drafter's proposals alone is a speed setting so long as drafted equals"draft": falseeverywhere. Here drafted equals"draft": false, token for token, in every arm, and only the rounds a reply takes move.Scope
language_model.lm_head.weightis bf16, such as NVIDIA's FP4-Local checkpoint.Head.initreads the mode (zig/src/families/flashnext/cuda_mtp.zig:254on this head) and loads the draft rows with it (:260), and only a bf16 head uses the mode (cuda_mtp_load.zig:30-37). A checkpoint with an affine language head keeps its stored rows, as on main (:38-48).affine4already runs on main. Nothing on disk changes, and the language head the verify forward reads keeps its stored rows.2594f26637): the reader incuda_mtp_load.zig, the table rule, the page row, the host tests and the test import incuda_mtp.zig. The rest of the branch is the receipt, the merges of main and the serving-source re-pin.Compatibility
TF_FLASHNEXT_DRAFT_HEAD=bf16keeps main's rows: level with main in all 40 cells of the receipt, at main's tokens a round, with every reply equal to main's.TF_FLASHNEXT_DRAFT_HEAD=affine4reads as it does on main.BadDraftHeadwhen the head loads.cc6fb6bd5f) addsTF_FLASHNEXT_MTP_WEIGHTSto the same table, page and tests. Merged with this head (git merge-tree), the two conflict indocs/environment.md,zig/src/platform/environment.zigandzig/src/platform/environment_flashnext_test.zig, where each adds its row or test at the same place, and inzig/tests/fixtures/gradient-serving.tsv, where both re-pincuda_mtp.zig. Both also make the same 29 to 30 edit on the page and in the count test's title and expected counts, which merges without a conflict. Whichever lands second keeps both rows and both tests, moves the count to 31 settings with 3 structured, and re-pinscuda_mtp.zig.Alternatives
bf16as the default andaffine4opt-in, as on main. That's main in the receipt, and the branch is faster than it in all 40 cells, by 3.7% to 16.5%.TF_FLASHNEXT_DRAFT_HEADandaffine4on 2026-11-15).Checks on this head
2278974ebedfd55b0cf80180741f75e189e9ff0c, signed, as are the other nine:2594f26637, the change (on maind6c4cce602);f1fa1ce349, the first receipt;ae7393f57b, the merge of main41a72fd257;83d138c6c3, the 8-stream receipt on that main;fa88e80008, the merge of main3a56d4eb92;d9701b633d, the re-pin of the two serving sources this change edits;ed2a1345fd,01e523bf85and859e80cede, the merges of main964174ea05,5c82ef28a6andd2b37227a8; and2278974ebe, the CHANGELOG entry naming this pull request, Flash Next on CUDA: the draft head's rows are affine4 unless TF_FLASHNEXT_DRAFT_HEAD=bf16 #3477.python3 tools/zig/lean_check.py, on the base and on this head: main 6,511 files and 341 problems, this head 6,511 files and 340 problems, andtools/zig/lean_new.pyfinds 0 new (rc 0). It ran as the workflow runs it: main's tree with this head's checker copied in, then this head (the two checkers are byte-identical). The file counts are equal because the branch adds no file underzig/ortools/zig/. The one problem fewer is main's directgetenvofTF_FLASHNEXT_DRAFT_HEADatcuda_mtp_load.zig:10, which the branch removes.python tools/pr_check.py --basemain (d2b37227a8) with--pr 3477, on this head: 13 changed files, lean 340 against 341, 0 new; 0 errors and 0 warnings, the Unreleased entry naming this pull request.859e80cede, which differs from this head only by the CHANGELOG entry, as the no-GPU workflow runs them, natively on an aarch64 Ubuntu 24.04.5 machine (NVIDIA GB10, 20 CPUs, Zig 0.17.0,-j8 --maxrss 6000000000unless the table says-j4, umask 022 as on the workflow's runner, no GPU visible to the tests), on freshgit archivetrees of main (d2b37227a8) and of this head, each checked file by file against its commit (11,628 and 11,634 files, 0 missing, 0 extra, 0 different):d2b37227a8zig build -Dfixed-cpu test-gradient-serving test-qwen-serving-hostzig build -Dfixed-cpu test-host --test-timeout 20m-j4: 2,087 of 2,092 steps, 8,671 of 8,757 tests passed, 85 skipped, 1 failed: the IPv6 testzig build -Dfixed-cpu test-kernel-contractzig build -Dfixed-cpu test-goldenzig build -Dfixed-cpu test-server-security test-pull-securityzig build -Dfixed-cpu fuzz-cortheonzig build -Dfixed-cpu test --test-timeout 10m(the Windows job's step, run on Linux)zig build -Dfixed-cpu check-release-pathszig build test-environment-hostzig build test-cuda-hostzig build compile-cuda-tests -Dtarget=aarch64-linux-gnuzig build compile-config-server -Dtarget=aarch64-linux-gnu(the CUDA server with this change, no nvcc)zig fmt --check build.zig ziggit diff --checkagainst mainpython3 -m unittest discover -s tools/tests -p "test_bench*.py" -vand-p "test_evidence*.py" -vpython3 tools/zig/cuda_common_check.py,python3 tools/zig/cuda_fragment_check.py,python3 -m unittest discover -s tools/zig -p cuda_common_check_test.py -vpython3 -m unittest discover -s tools/zig -p flashnext_batch_serve_test.pypython3 -m unittest discover -s tools/zig -p build_options_test.pypytestjob:python3 -m unittest discoverovertools/zig,tools/testsandtoolslistener.zig's "accepted IPv4 and IPv6 TCP streams disable Nagle for incremental responses": the machine boots with IPv6 disabled, so the test can't open its socket there, on main or on this head.test-hostfails that one test on both trees and nothing else. Its test counts differ because this head's tree had already run many of the same test binaries in the steps before it, and a cached run reports no count; the step counts match. On this head it ran at-j4, the runner's four cores, because a-j8run under the 12 GiB memory limit I gave each build was stopped for memory before it finished.tools/zigunittest failures arezig_cache_restat_test'stest_only_a_real_change_missesandtest_prune_keeps_one_build, the CI cache tool's own tests, and they fail on main too. The workflow runs them only when that tool, the workflow,.zig-versionorbuild.zig.zonchanges, and none of those differ between main and this head.zig build test-cuda-hostthere fails only the IPv6 test;zig build test-environment-hostpasses, 24 of 24). Withdefault_modeset back tobf16, main's default (cuda_mtp_load.zig:15),zig build test-cuda-hostalso failscuda_mtp_load.test.unset and blank read affine4, the two words read as themselves, and other text is refused(405 of 408 steps, 6,747 of 6,782 tests passed, 2 failed). With the table's two words swapped (environment.zig:200),zig build test-environment-hostfailsenvironment_flashnext_test.test.Flash Next strict env: the draft head keeps bf16 and affine4 in the reader's order and refuses other text(23 of 24 tests passed). With the table's rule line removed, as on main, it fails the count test,environment_flashnext_test.test.Flash Next strict env: the table holds all 30 settings: 20 switches, 7 integers, 1 real, 2 structured, and the draft head test stops on the unregistered name (22 of 24 tests passed, 1 failed, 1 crashed). Each anchor matched exactly once.2278974ebe(this head), run on this pull request:fmt,zig,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.zig-windowsjob on Windows (no Windows build machine here; its four steps ran on Linux above) andzig-macos-dev-tools(no macOS machine); the two NFKD steps (they need Python 3.14, which the machine doesn't have, and this change touches no NFKD file); thepytestjob as written (pytest isn't installed on the machine, so stdlibunittestdiscovery ran in its place, above). The restored-cache and host-test-graph regression steps skip by their own conditions: none of their inputs changed (git diff --quietagainst main, rc 0).Receipt
docs/receipts/flashnext-draft-head/. Two windows, each with both arms built from the same main, alternating M1 U1 X1 M2 X2 U2 (U unset, U2 blank, Xbf16), a fresh server per arm: 1, 2 and 4 streams at 131,072 tokens on maind6c4cce602(cells.csv,rule5.md,exactness.md), and 1, 4 and 8 streams at 65,536 tokens on main41a72fd257(cells-8.csv,rule5-8.md), where--parallel 8starts. No cell was slower, so the noise rule's rerun didn't run.language_model.lm_head.weightis bf16 (NVIDIA's FP4-Local checkpoint here). An affine language head keeps its stored rows, as on main. Metal and HIP don't read the setting.TF_FLASHNEXT_DRAFT_HEADis on main. Its default moves frombf16toaffine4(unset or blank), acceptedbf16oraffine4, and any other text stops the start by name. It gets its row in the environment table and on the environment page. No profile sets it.d6c4cce602and41a72fd257, with the branch on each; Zig 0.17.0, CUDA 13.3, Linux, one DGX Spark (GB10, sm_121, 128 GB unified memory),nvidia/Qwen3.8-Flash-Next-FP4-Localat revisionb9ce18a6887e18c089fdea8509a33e63429a3300with its own MTP head, bf16 KV, prompt cache on. The serve recipe sets the same environment for every arm; of the settings main reads,TF_FLASHNEXT_KEEP_LATE=1,TF_FLASHNEXT_WARM_AHEAD=1andTENSORFOLD_MEMORY_RESERVE_GIB=9differ from main's defaults. The receipt lists the rest.cuda_mtp.zig,Head.init, throughmode()anddraft()), for one stream and shared rounds alike; ran on GB10. Not run: other CUDA SMs, two-GPU tensor parallel, a checkpoint with an affine language head (its path doesn't change), Metal and HIP (they don't read it).bf16, each with the prompt cache on and off, drafted equals"draft": false(8 of 8, the drafted replies accepting 12 to 237 tokens each), resumed equals fresh (7 of 7 turns; 4 of 4 cache repeats), concurrent equals solo (42 of 42 greedy and 42 of 42 at temperature 1.0 at 1, 2 and 4 streams; 13 of 13 golden at 1, 2, 4 and 6), and every reply of the branch equals main's. At 1, 4 and 8 streams,tools/bench_concurrent.py --alone --serialfinds every concurrent reply equal to the same request alone in every arm (0 unequal).tools/bench_openai.pyandtools/bench_concurrent.py --alone --serial, 256 tokens, aggregate tok/s, the mean of the branch's two runs against main's two, with tokens a round. 1, 2 and 4 streams at 131,072 tokens on maind6c4cce602:affine4) against mainbench_openai), code and chatbench_openai), code and chat1, 4 and 8 streams at 65,536 tokens on main
41a72fd257:affine4) against mainBy the noise rule no cell is slower: in all 40 both runs of the branch are above both main runs. With
bf16the branch is level with main in all 40 (-0.5% to +1.8%), at main's tokens a round and main's server acceptance. Server acceptance, main to unset: greedy 0.624 to 0.629, 0.679 to 0.697 and 0.686 to 0.713; temperature 1.0 from -0.022 to +0.009 depending on the seed. The server holds 267 MiB less device memory (75,038 against 75,305 MiB after load at 131,072 tokens, 75,022 against 75,289 MiB at 65,536), the draft rows' bytes.tools/bench_cache.py --require-cold; the draft head isn't in prompt processing.Checklist
The title and description match the head commit, including the receipt and the stack.
New tests fail before the change, pass after it, and skip cleanly without their dependency.
Comments and docstrings are one line. No measurements or history in the source.
No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
Drafted output equals
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (On main, the branch unset and the branch withbf16.)No precision traded for speed. If the bits change, the description says which sums change and why. (The verify forward is unchanged. Only the draft head's own copy of its rows is 4-bit, which changes which tokens it proposes.)
Decode and prompt processing are no slower than main at one stream and the widest admitted; with
--drafter, no slower than without it, greedy and sampled. (1, 2 and 4 streams at 131,072 tokens, and 1, 4 and 8 at 65,536, where 8 starts. There's no--drafterhere: the draft head is the checkpoint's own.)