Skip to content

Flash Next on CUDA: TF_FLASHNEXT_MTP_WEIGHTS selects how the drafter keeps its BF16 linears - #3218

Open
BadAd84 wants to merge 11 commits into
ashhart:mainfrom
BadAd84:flashnext-mtp-weights
Open

BadAd84 wants to merge 11 commits into
ashhart:mainfrom
BadAd84:flashnext-mtp-weights

Conversation

@BadAd84

@BadAd84 BadAd84 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

TF_FLASHNEXT_MTP_WEIGHTS=checkpoint|mxfp8 says how the Flash Next MTP drafter's linears are kept in memory. checkpoint, the default (unset or blank too), leaves the rows as stored and runs main's load. mxfp8 re-codes the drafter's BF16 linears at load into the MXFP8 projection the mixers already use, leaving its two
fusion projections (fc_embedding, fc_hidden) and the layer's shared expert as the checkpoint stores them: on the
NVFP4 checkpoint it logs 135 MiB re-coded and 34 MiB left as stored, so a draft pass reads about half of the 135 MiB
instead of all of it. It applies only on CUDA. Flash Next on Metal or HIP stops the start naming the setting before any checkpoint or device work: Metal right after its environment check, HIP in the flag refusal its backend runs on every rank before reading the checkpoint or opening a device. So does a CUDA drafter linear stored as anything but BF16. A draft is only a proposal the verify forward checks, so replies are the same and only the rounds a reply takes move.

Checks on this head

  • Measured head commit: b43b10f46, this pull request's own commits, the merges of 0900b484e and 4fda6a020, the narrow re-code (the mask the screen picked: the two fusion projections and the layer's shared expert stay as stored) and one line renaming the matcher's loop variable, which shadowed the file's name constant and stopped the tree compiling. The head aa35a60e4 adds the receipt files only.
  • Lean checker, base 4fda6a020 and head, each tree running its own copy: 6769 files and 191 problems against 6771 and 191, 0 new. python tools/pr_check.py --base 4fda6a020 --pr 3218: merge base 4fda6a020, 17 changed files, lean 191 against 191, 0 new; 0 errors, 1 warning (maintainer-owned CHANGELOG.md bullet).
  • Tests run on a 16-thread x86_64 host, Zig 0.17.0, on trees extracted from commit archives whose every blob was
    checked against git ls-tree -r (mismatches 0 extra_files 0 both):
    • zig fmt --check build.zig zig: rc 0.
    • zig build -Dfixed-cpu test-environment-host: rc 0.
    • zig build -Dfixed-cpu test-gradient-serving test-qwen-serving-host: rc 0 (the four re-pinned serving rows pass).
    • zig build compile-config-server -Dtarget=aarch64-linux-gnu and zig build compile-cuda-tests -Dtarget=aarch64-linux-gnu: rc 0 each.
    • python3 -m unittest discover -s tools/zig -p flashnext_batch_serve_test.py: 8 tests, OK.
    • zig build -Dfixed-cpu test-cuda-host --test-timeout 20m: rc 0 on this head, and rc 0 on main as the comparison arm; each prints the same 14 inner failed command lines from fixtures that fail a child on purpose.
    • python tools/pr_check.py --base 4fda6a020 --pr 3218: 0 errors.
  • The narrow change is one commit of 8 files (+58/-13): the matcher and its tests, denseFor and its kept count, the six loader call sites, the log line, the docs row and the four re-pinned serving rows. The refusal paths and their guard-removal mutants recorded on 5038aec and cc6fb6b are not among them and are unchanged.
  • CI on aa35a60e4 (the head), run on this pull request: fmt, zig, zig-b, zig-windows, pytest, benchmark-clients (ubuntu and windows), release-paths and zig-macos-dev-tools all completed successfully; host-nightly-linux and host-nightly-macos are skipped by their own conditions. The gates above were run on a 16-thread x86_64 host with Zig 0.17.0 under the same commands the workflows use.
  • Not run, and why: the HIP device build (-Dhip=true flashnext-hip-gpu-build needs hipcc), Metal hardware, and a checkpoint whose drafter is not BF16 (the checkpoint measured here keeps BF16 drafters). Host tests cover those refusals.

Receipt

  • Main against branch: docs/receipts/flashnext-mtp-weights/. Main 4fda6a020 against this head (b43b10f46),
    alternating M1 U1 X1 M2 X2 U2 (U unset, X mxfp8), a fresh server per arm, 18 boots. No cell of any comparison was
    flagged slower, so the noise rule's rerun was not taken.
  • Branch measured: b43b10f46df555b1eb9e2b7ba19832c0d4da78f0, this pull request's commits with upstream main merged
    twice. Both images were built inside the window from commit archives whose every blob was checked on the box
    (mismatches 0 extra_files 0), each build log carrying its own SOURCE line.
  • Resident memory: the engine allocator's device bytes after load (model N GiB) are 72.71 GiB on main and on the
    branch unset, and 72.64 GiB with mxfp8, at 8 slots (72.73 against 72.67 at 4), so mxfp8 holds 0.07 GiB less.
  • Boxes it reaches: Flash Next CUDA with BF16 drafter linears (the NVFP4 checkpoint's mtp.* rows). Anywhere else
    mxfp8 stops the start by name.
  • New switch? TF_FLASHNEXT_MTP_WEIGHTS, default checkpoint (unset or blank), accepted checkpoint or mxfp8; any
    other text stops the start by name.
  • Environment: TensorFold 4fda6a020 and this branch on it, Zig 0.17.0, one DGX Spark (GB10, sm_121, 128 GB unified
    memory), the recipe's CHECKPOINT=nvfp4, DRAFTS=1, bf16 KV, MEM_CHECK=0, a 32,768-token window and 8 slots for
    decode and the exactness boots, 131,072 and 4 slots with the prompt cache off for the cold prompts.
  • Exactness: on main, the branch unset and the branch with mxfp8, each with the prompt cache on and off, drafted
    equals "draft": false (8 of 8), resumed equals fresh (7 of 7, the resumed turns reporting cached prompt tokens and
    the fresh boots none), the golden prompts 5 alone and 8 serial equal, and concurrent equals solo (252 of 252 greedy
    and 252 of 252 sampled in every state). Every pass A reply's token ids equal main's, 552 an arm per state, and the
    cold prompts' 8.
  • Decode speed, tools/bench_openai.py and tools/bench_concurrent.py --alone --serial, 256 tokens, aggregate tok/s,
    the mean of each arm's two runs against main's two, with tokens a round:
cells mxfp8 against main tokens a round, main to mxfp8
the gate cell: chat, temperature 1.0, seed 1234, one stream +0.34% (level; 44.1 and 44.5 against 44.6 and 44.3) 2.393 to 2.349
greedy chat, 1/2/4/6/8 streams -0.54% (level), +2.03%, +2.05%, +1.33%, +1.22% 2.813 to 2.723, then 2.51 to 2.51
greedy code, 1/2/4/6/8 streams +4.28%, -0.07% (level), -0.29% (level), +3.65%, +3.51% 5.224 to 5.447, then 4.83 to 4.741, 4.491 to 4.414
temperature 1.0, seeds 1234/2234/3234, chat and code, 1/2/4 streams 22 faster and 10 level of 32, no cell slower -0.09 to +0.15
nine seeds, one stream, code and chat +2.44% (level), +5.60% 4.063 to 4.0, 2.56 to 2.612

mxfp8 against main is 22 faster, 10 level and 0 slower of 32; the branch unset is 32 level of 32 (gaps -0.90% to
+0.42%). At one stream mxfp8 proposes slightly fewer accepted tokens a round and still measures level or faster,
so the gain is in the draft and verify passes.

  • Prompt speed before and after: cold first requests, three reps: all ten cells level, 8k 4.021 against 3.996 and 4.025
    s, 32k 16.032 against 16.038 s, 64k 32.947 against 33.087 s, and bench_cache qualified on every boot.
  • Licence of any new weights or drafter: n/a. The drafter is the checkpoint's own mtp.* (NVIDIA Open Model Agreement).

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.

For a change that reaches inference:

  • 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. (Run on main, the branch unset and the branch with mxfp8; see Exactness above.)
  • No precision traded for speed in the output: the verify forward is unchanged, so replies are identical. The drafter's own logits change under mxfp8, which only 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. (Measured at 1, 2, 4, 6 and 8 streams, greedy and at three seeds plus a nine-seed single stream: 22 cells faster, 10 level, 0 slower of 32 against main, the gate cell chat at one stream with seed 1234 level at +0.34%, every cold cell level. --drafter does not apply, the drafter is the checkpoint's own head.)

@BadAd84

BadAd84 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Sampled decode, and the drafter on against off, measured after the PR was opened. Same GB10, the PR's base 6c5cef8, bf16 KV, --parallel 4, a fresh server per arm, upstream's tools/ from that base.

This family has no --drafter flag to drop, so "without the drafter" is the request field "draft": false.

Drafter on against "draft": false: faster in all 48 cells, in every arm. The ratio runs from 1.43x (sampled chat, 4 streams) to 2.79x (greedy code, 2 streams), and every "draft": false reply drafted 0 tokens.

Greedy, drafter on: with the setting unset the PR is level with main, and with mxfp8 it is +1.1% to +4.4% faster in all 6 cells.

Sampled (temperature 1.0), drafter on, against the mean of 4 boots of main (3 boots each for the PR unset and with mxfp8):

prompt streams PR unset PR mxfp8
code 1 -0.3% +1.9%
code 2 -0.4% +0.4%
code 4 -0.4% +0.9%
chat 1 -0.5% -2.0%
chat 2 -0.3% -1.2%
chat 4 -0.1% +0.2%

Main's own boots spread by 1.6% to 2.0% in these cells, so the unset arm is inside main's range everywhere. mxfp8 is slower than every main boot on sampled chat at 1 and 2 streams. In those cells the re-coded drafter's drafts were accepted slightly less often (2.31 tokens a chunk against 2.39 at one stream). Over 9 seeds at one stream (bench_openai) mxfp8 is faster, +2.2% on code and +1.9% on chat, so the loss depends on the seed.

So the last checklist box stays unticked: mxfp8 isn't shown to be no slower than main for sampled chat at 1 and 2 streams. The raw files and scripts are in my tree, and I can add them to the receipt directory if you want them.

@ashhart

ashhart commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Thanks @BadAd84. The host tests pass, and keeping checkpoint as the default looks good.

We will run the device check on our side with TF_FLASHNEXT_MTP_WEIGHTS unset, checkpoint and mxfp8. Each mode must preserve the plain target's complete generated tokens for greedy and seeded requests, including resumed turns and one and four streams. We will compare acceptance, resident memory, prompt speed and decode speed against main before merging.

  • Synthena (Ash's Agent)

@BadAd84

BadAd84 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. All six are in, as two new commits on top of e16ca9d (no force-push): 5038aec (the refusals, the blank test and the docs row) and 19224f8 (the receipt on main and the changelog line). One cell fails your noise rule, and it is reported below as a loss.

  1. Receipts on main. Main at 06bcb989 against this branch rebased onto it, alternating M1 U1 X1 M2 X2 U2 with a fresh server per arm, on the same checkpoint revision (b9ce18a6) throughout. U is the setting unset (U2 sets it blank) and X is mxfp8. The files are in docs/receipts/flashnext-mtp-weights/: README.md, cells.csv, rule5.md and exactness.md.
  2. Unset or blank means checkpoint. U1 (unset) and U2 (the container's environment holds TF_FLASHNEXT_MTP_WEIGHTS= empty) log no re-coding, and every reply hash their bench files record equals main's (672 of 672 an arm). The exactness table (drafted, resumed, concurrent) passes on main, unset and mxfp8, and the branch's replies equal main's. TF_FLASHNEXT_MTP_WEIGHTS=MXFP8 stops the start before any load with TF_FLASHNEXT_MTP_WEIGHTS="MXFP8": expected checkpoint or mxfp8 (unset or blank keeps checkpoint, the rows as stored; mxfp8 re-codes the drafter's BF16 linears on CUDA). The row in platform/environment.zig was there already; docs/environment.md now has the setting's row and counts 30 Flash Next settings. Host tests read unset, empty and whitespace-only text as checkpoint and refuse MXFP8, fp8, 1, mxfp8 (trailing space), bf16 and checkpoints by name.
  3. Acceptance per round, both arms. cells.csv has tokens a round beside tok/s for every cell (the tools' tokens a streamed chunk), accepted a round (that less one) and the server's accepted over drafted for each run. The greedy code cells keep main's tokens a round exactly (5.22, 4.83 and 4.83 at 1, 2 and 4 streams) and run 2.7%, 3.9% and 3.2% faster, so that gain is the shorter draft pass, not acceptance. Sampled cells move by -0.12 to +0.07 tokens a round depending on the seed.
  4. Where there is no MXFP8 projection. mxfp8 now stops the start by name on Flash Next on Metal and on HIP (each asks before its first checkpoint or device work), and on CUDA when a drafter linear the setting would re-code is stored as anything but BF16 (MXFP8 or affine already). That message names the setting, the tensor and its stored type. Each guard has a host test that fails with the guard removed: 9 of 9 mutants fail test-cuda-host or test-environment-host, and the unmutated tree passes both.
  5. The noise rule. Unset and blank against main: 0 of 28 cells slower. mxfp8 against main: 27 of 28 cells are level or faster, and one is slower. Chat at one stream, temperature 1.0, seed 1234: 43.4 and 43.4 against 43.6 and 44.1 tok/s (-1.0%). Its rerun gave 43.5 and 43.3 against 44.2 and 44.1 (-1.7%), so by your rule that cell is a loss. In it the re-coded drafter's proposals are accepted less often: 2.31 tokens a round against 2.39 in both pairs. The same cell is +2.3% at seed 2234 and +2.9% at seed 3234, and chat over nine seeds at one stream is +4.9%. Elsewhere greedy decode is 2.7 to 3.9% faster at 1, 2 and 4 streams, with chat at one stream level (+0.3% and +0.5%), and sampled decode is 1.4 to 5.3% faster in 17 of 20 cells. Cold 8k and 32k prompts are level in all arms.
  6. CHANGELOG. The line now quotes these served results, the loss included, and carries Flash Next on CUDA: TF_FLASHNEXT_MTP_WEIGHTS selects how the drafter keeps its BF16 linears #3218.

The default stays checkpoint, so nothing changes unless mxfp8 is set.

@ashhart

ashhart commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Thanks @BadAd84, this is a careful follow-up. The receipt on main is thorough: unset and blank match main's replies in every arm, drafted equals "draft": false for all three arms with the cache on and off, cells.csv reports tokens a round beside tok/s, and you reported the seed-1234 chat cell as a loss instead of averaging it away. The parser and its tests (zig/src/families/flashnext/mtp_weights.zig:14-34, zig/src/platform/environment_flashnext_test.zig:106-115) are what we wanted, and with the setting unset the load is main's: recodable and dense return at once on checkpoint (zig/src/families/flashnext/cuda_projection.zig:33, :46-47).

Where the head stands against your six points and our last comment:

  • Receipts on main, unset or blank as checkpoint, the refusal of a malformed value by name, the table and docs rows (zig/src/platform/environment.zig:198, docs/environment.md:124), acceptance per round, the noise rule and the CHANGELOG line: done.
  • Tokens kept for greedy and seeded requests, resumed turns, and one and four streams: done (exactness.md).
  • Acceptance, prompt speed and decode speed against main: done. Resident memory: still missing (item 4).
  • A refusal where there is no MXFP8 projection: done on CUDA (zig/src/families/flashnext/cuda_projection_load.zig:76, :104, zig/src/families/flashnext/cuda_prompt_wt.zig:479). Metal and HIP refuse by name, but later than the PR says (item 2).

Needed before it lands:

  1. Re-pin the serving files this changes. zig/src/families/flashnext/cuda_mtp.zig, cuda_projection.zig, cuda_projection_load.zig and cuda_prompt_wt.zig are pinned in zig/tests/fixtures/gradient-serving.tsv (rows 144, 153, 154, 160), and their hashes at this head no longer match, so zig build test-gradient-serving fails. Please update those four rows' hashes and add a note to each row, in the form the others use (#3218: ..., one clause saying what changed and that checkpoint keeps main's bytes).
  2. Refuse mxfp8 on Metal and HIP before any checkpoint or device work. HIP's check is at zig/src/families/flashnext/hip/load.zig:396, but Engine.load reaches it only after hip.Runtime.open() (zig/src/families/flashnext/hip/engine.zig:116), the context, the kernel images, RCCL (:130) and Checkpoint.openModel (:134). Metal's check (zig/src/families/flashnext/engine_load.zig:50) comes after load_admission.check (:49), which reads config.json and the safetensors index. Please move HIP's call to the top of Engine.load, before :116, and Metal's above :49. The test at zig/src/families/flashnext/mtp_weights.zig:39-41 only checks that each call is present somewhere, so please also make it check where the call sits (for example, before the first hip.Runtime.open and before load_admission.check). That keeps the comment on :39 true.
  3. Name the branch commit that was measured. docs/receipts/flashnext-mtp-weights/README.md gives main as 06bcb989… but the branch only as "this pull request's commits on that main". Please add the rebased branch commit's hash, and say whether its source is the same as 19224f8's.
  4. Resident memory, main against the branch. Please add the drafter's resident device memory after load for main, unset and mxfp8 from the same boots (the server's own memory line or the allocator's total). The startup line gives 170 MiB re-coded, but the receipt has no measured before and after.

One optional suggestion:

  • In the CHANGELOG line, "with the same tokens a round" holds only for the code cells. On greedy chat, tokens a round go from 2.81 to 2.75 at one stream and from 2.51 to 2.54 at two and four. Something like "with main's tokens a round on code" would match the receipt.

  • Synthena (Ash's Agent)

@BadAd84

BadAd84 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. All four are done, plus the wording you suggested, as new commits on top of 19224f8 (nothing force-pushed). The head is 8b5a008.

Main moved after this branch was cut: 1.2.8 and 1.2.9 were released, and main re-pinned cuda_mtp.zig itself. A pin taken on this branch's files would not have matched the merged file, so the branch now merges main at 2ba55ec in d29c2a7, a merge commit rather than a rebase, so nothing already pushed is rewritten. The merge also left the changelog line inside the 1.2.8 section; it now sits under a new ## Unreleased again.

  1. Serving pins (cfcc0e6). Rows 144, 153, 154 and 160 of zig/tests/fixtures/gradient-serving.tsv now hold the hashes of cuda_mtp.zig, cuda_projection.zig, cuda_projection_load.zig and cuda_prompt_wt.zig at this head. Each has a #3218: note saying what changed and that checkpoint keeps main's bytes. zig build test-gradient-serving passes on the head; it also passes on main at 2ba55ec, and on this branch it failed before the re-pin.

  2. Metal and HIP refuse first (c174b7d).

    • HIP now asks at the top of Engine.load (zig/src/families/flashnext/hip/engine.zig:108), before hip.Runtime.open(), and the call is gone from hip/load.zig.
    • Metal asks right after env_validate.startup() (zig/src/families/flashnext/engine_load.zig:48), ahead of window.validate and load_admission.check. The admission-order test in load_admission_test.zig now expects that line second.
    • The test in mtp_weights.zig checks position, not just presence: each call appears once, inside its function, before that function's first hip.Runtime.open() or load_admission.check(. Each of five mutants (moving either call back below its first runtime open or admission check, putting HIP's back in hip/load.zig, or dropping either) makes test-cuda-host fail, and the unmutated tree passes.
  3. The measured commit (8b5a008, receipt README). The branch measured was d3282c225db0224e472f10bc37ee25b5ae4d35d5: this pull request's commits through 19224f8, rebased onto main 06bcb989. Outside CHANGELOG.md and the receipt directory, its changes are 19224f8's line for line (11 files, 169 changed lines; only the hunk offsets differ). Its tree differs from 19224f8's only by main's own commits from a3aecd8 to 06bcb989 (the same 334 files, byte for byte). The commits since then change no line of the CUDA drafter code that was measured.

  4. Resident memory, from the receipt's own boots. The startup line's model N GiB is the engine allocator's device bytes after the weights load (zig/src/native/cuda.zig:344):

    arm model after load, two boots left for streams
    main 72.73, 72.73 GiB 28.0, 28.0 GiB
    unset, blank 72.73, 72.73 GiB 28.0, 28.0 GiB
    mxfp8 72.65, 72.65 GiB 28.1, 28.1 GiB

    mxfp8 holds 0.08 GiB less at the line's 0.01 GiB resolution. That matches 170 MiB of BF16 linears held as about 88 MiB of E4M3 codes and scales. The server does not print the drafter's share on its own.

The changelog line now says "with main's tokens a round on code", as you suggested.

Checks on 8b5a008, on Windows with Zig 0.17.0:

  • zig build test-gradient-serving, test-environment-host, test-cuda-host and -Dhip=true test-flashnext-proposal-hip-host: rc 0.
  • zig build compile-config-server -Dtarget=aarch64-linux-gnu: rc 0.
  • zig fmt --check build.zig zig and git diff --check origin/main HEAD: clean.
  • python tools/pr_check.py --base origin/main --pr 3218: 0 errors, 0 warnings.
  • Lean, base 2ba55ec against head: 6454 files and 341 problems against 6456 and 341, 0 new.

Not run: the HIP device build (-Dhip=true flashnext-hip-gpu-build needs hipcc, which this machine does not have) and Metal. The position test covers both moved calls.

BadAd84 added a commit to BadAd84/TensorFold that referenced this pull request Nov 14, 2026
…HTS changes

cuda_mtp.zig, cuda_projection.zig, cuda_projection_load.zig and cuda_prompt_wt.zig take their hashes at this head,
on main's files, each with a ashhart#3218 note: checkpoint keeps main's bytes.
@ashhart

ashhart commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Thanks @BadAd84. All four are in, and merging main rather than rebasing was the right call with cuda_mtp.zig re-pinned on main.

On 8b5a008:

  1. Serving pins: done. The rows for cuda_projection.zig, cuda_projection_load.zig and cuda_prompt_wt.zig match those files byte for byte. For cuda_mtp.zig, your change plus main's flashnext CUDA sampled draws: one launch and one wait a step, and #2753's check inside the top-k pass (#2920) #2927 change hashes to the new pin c7aea96c…. Each row has its #3218: note.
  2. The measured commit: done. The README names d3282c22… and says how its source relates to 19224f8.
  3. Resident memory: done. 72.73 GiB for main, unset and blank, and 72.65 GiB with mxfp8, in both boots each. The 0.08 GiB drop matches 170 MiB of BF16 held as about 88 MiB of E4M3 codes and scales.
  4. Metal and HIP: Metal done, HIP one step short. Metal now refuses right after the environment check (zig/src/families/flashnext/engine_load.zig:48), ahead of window.validate and load_admission.check, and the admission-order test expects that. HIP refuses at the top of Engine.load, which is where we asked, but we pointed you one step too late. On the served path, prepare in zig/src/families/flashnext/hip/native.zig:142 calls check (:86) before engineOf reaches Engine.load. check reads config.json and the safetensors index (:95, :97), then cardRoom (:76-83) opens a hip.Runtime and a context to read the card's memory. So with mxfp8 set, a HIP start still opens the device before it refuses.

Needed before it lands:

  • Move HIP's refusal to the top of check in hip/native.zig, ahead of config.Config.read, and drop it from Engine.load. prepare already sends a failed check to the other ranks through steps.refuse, so a refusal there stops every rank by name. Please point the position test in mtp_weights.zig at hip/native.zig, fn check( and config.Config.read(. Then the PR description's "before any checkpoint or device work" holds on HIP too.

On a tree with your commits applied, test-cuda-host fails only where main already fails, never in the new tests, and test-flashnext-proposal-hip-host, zig fmt --check and lean (341, 0 new) are clean.

  • Synthena (Ash's Agent)

@BadAd84

BadAd84 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. HIP is moved in one new commit, cc6fb6b, on top of 8b5a008; nothing is force-pushed.

Following the served path down from the HIP backend showed that the top of check would still be one step late. zig/src/native/hip.zig runs ready before it calls Flash Next's open (:285) or follow (:358). ready reads the checkpoint's context, then calls hip.Device.capsOf, which opens a hip.Runtime to read the card's architecture (zig/src/hip/device.zig), and under --tp it joins the ranks' group. So with mxfp8 refused at the top of check, a runtime would still be open before the refusal.

The one place ahead of all that is the family's flag refusal: fam.refused (zig/src/native/hip_families.zig) calls a family's refusal first, and hip.zig runs it before ready, on rank 0 (:281) and on every other rank (:354). glm_ocr and dots_mocr refuse their flags this way. Flash Next's HIP native now has refusal (zig/src/families/flashnext/hip/native.zig:249), which returns the setting's refusal text, and Engine.load no longer asks; check is unchanged. Each rank reads its own setting, so a run whose ranks all set mxfp8 stops on every rank, by name, before any checkpoint or device work. The drafter loads on rank 0 only, so rank 0 is the rank that must refuse. One difference from refusing in check: if only rank 0 sets it, the other ranks don't receive rank 0's text through steps.refuse; they stop when rank 0 never joins, as with any other HIP flag refusal.

The position test in mtp_weights.zig now checks that the call sits once, inside pub fn refusal( in hip/native.zig, and that hip/engine.zig and hip/load.zig no longer mention the setting; the Metal check is unchanged. Each of these makes test-cuda-host fail (6 of 6), and the unmutated tree passes: moving the call into check below config.Config.read, moving it below cardRoom, dropping it, leaving a copy in Engine.load, making the hook return null, and moving Metal's below load_admission.check. -Dhip=true test-native-hip-host compiles the HIP backend's flag checks with the hook in its registry.

Checks on cc6fb6b (Windows, Zig 0.17.0): zig build test-gradient-serving, test-environment-host and test-cuda-host, and with -Dhip=true test-flashnext-proposal-hip-host, test-native-hip-host and test-hip-family-offers-host: rc 0. zig build compile-config-server -Dtarget=aarch64-linux-gnu: rc 0. zig fmt --check build.zig zig and git diff --check origin/main HEAD: clean. python tools/pr_check.py --base origin/main --pr 3218: 0 errors, 0 warnings. Lean, base 2ba55ec against head, each side running its own copy of the checker (the two copies are byte-identical): 6454 files and 341 problems against 6456 and 341, 0 new. Not run: the HIP device build, which needs hipcc, and Metal.

@ashhart

ashhart commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Thanks @BadAd84. cc6fb6b is right, and thank you for following the served path one step further than we pointed you. The family flag refusal runs before ready on rank 0 and on every other rank (zig/src/native/hip.zig:281 and :354). So the new refusal in hip/native.zig stops a HIP start before any checkpoint read or device open, and the position test holds it there. Nothing more is needed on Metal or HIP.

Thanks too for merging main in fc8a5ff246. The settings table and docs/environment.md now both say 32, and your changelog line sits under ## Unreleased. Main has moved again since, so the branch conflicts once more. We can resolve that when it lands. The one red test on that head is in the cluster bring-up suite, which this change doesn't touch, and we'll re-run it.

One thing remains before our GB10 check: the seed-1234 chat cell. Your receipt marks chat at one stream, temperature 1.0, seed 1234 as a loss under the #3162 rule: -1.0%, then -1.7% on the rerun, with tokens a round down from 2.39 to 2.31. The gate there asks mxfp8 to be no slower than main at one stream. We can't loosen it after the results are in, so the setting can't land with that cell slower, even as an opt-in. We should have said that plainly in our last two comments, sorry. Thank you for reporting it as a loss rather than averaging it away. A narrower re-coding might keep that cell level, for example one that leaves some of the drafter's linears in BF16. If you try one, please post the same receipt for it on current main, every cell.

Once that's in, we'll run the device check we described on a GB10 with the setting unset, checkpoint and mxfp8. We'll also run an exactness check on two GB10s at --tp 2, since the drafter loads on rank 0 there too.

  • Synthena

BadAd84 added a commit to BadAd84/TensorFold that referenced this pull request Nov 19, 2026
The four files this pull request ships under docs/receipts/flashnext-mtp-weights/
carry the narrow variant's window: main 4fda6a0 against head b43b10f, one
GB10, 18 boots, 22 cells faster and 10 level of 32 for mxfp8, no cell slower,
the gate cell level, every cold cell level and every exactness contract equal.
@BadAd84

BadAd84 commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Narrow re-code: the receipt, on current main

The branch keeps fc_embedding, fc_hidden and the layer's shared expert as the checkpoint stores them and re-codes
the rest of the drafter's BF16 linears under TF_FLASHNEXT_MTP_WEIGHTS=mxfp8. That is the split a pre-window screen of
masks picked: in that screen, every mask that re-coded the two fusion projections lost at the gate cell and every mask
that kept them did not. The server states the split itself on every mxfp8 boot: re-coded 135 MiB of the drafter's BF16 linears and left 34 MiB as stored.

Measured head b43b10f46: the previous head fc8a5ff24 with the narrow re-code, upstream main merged at 0900b484e and
again at 4fda6a020, and the matcher's shadowed loop variable renamed. The head now on the branch, aa35a60e4, changes
only the receipt files under docs/receipts/flashnext-mtp-weights/. Main 4fda6a020, one GB10, a fresh server per arm,
main's own probes, 18 boots.

The gate cell: chat, temperature 1.0, seed 1234, one stream

arm run tok/s tokens a round
main 1 44.1 2.393
main 2 44.5 2.393
branch mxfp8 1 44.6 2.349
branch mxfp8 2 44.3 2.349

Level at +0.34%. Both branch runs sit between main's two (44.1, 44.5 and 44.6, 44.3), so the rule does not even get
to a direction. No cell of any comparison was flagged slower, so no rerun was taken (the rule allows one). The
branch with the setting unset reads 44.4 and 44.4 in the same cell.

Every other cell

mxfp8 against main: 22 faster, 10 level, 0 slower of 32. The branch unset against main: 32 level of 32 (gaps
-0.90% to +0.42%). Greedy, sampled at three seeds, 1 to 8 streams, one stream with nine seeds:

cells mxfp8 against main
greedy chat, 1/2/4/6/8 streams -0.54% (level), +2.03%, +2.05%, +1.33%, +1.22%
greedy code, 1/2/4/6/8 streams +4.28%, -0.07% (level), -0.29% (level), +3.65%, +3.51%
temperature 1.0 seed 1234, chat 1/2/4 +0.34% (level), +1.44%, +2.60%
temperature 1.0 seed 1234, code 1/2/4 +0.93% (level), +1.82%, +1.52%
temperature 1.0 seed 2234, chat and code, 1/2/4 +4.13%, +2.08%, +2.06%, +3.32%, +0.88% (level), +1.56%
temperature 1.0 seed 3234, chat 1/2/4 -0.23% (level), +1.17%, -0.39% (level)
temperature 1.0 seed 3234, code 1/2/4 +6.41%, +1.84%, +1.30%
nine seeds, one stream, code and chat +2.44% (level), +5.60%

At one stream mxfp8 proposes slightly fewer accepted tokens a round (chat 2.393 to 2.349, code 4.571 to 4.339) and is
still level or faster there, so the gain is in the draft and verify passes rather than in what the drafter proposes.

Cold prompts, exactness, refusals, memory

  • Cold first requests at a 131,072-token window with the cache off, three reps: all ten cells level (8k 4.021 to 4.025 s
    and 32k 16.032 to 16.038 s for main and mxfp8; 64k 32.947 and 33.087 s). bench_cache qualified on every boot.
  • Exactness on main, the branch unset and the branch with mxfp8, each with the prompt cache on and off: drafted
    equals "draft": false 8 of 8, resumed equals fresh 7 of 7, the golden prompts 5 alone and 8 serial equal, and
    concurrent equals solo 252 of 252 greedy and 252 of 252 sampled in every state. Every pass A reply's token ids equal
    main's for the same request, 552 an arm per state, and the cold prompts' 8.
  • MXFP8 stops the start by name before any load (boot_rc 1, the message quotes the setting's accepted forms);
    =mxfp8 with DRAFTS=0 starts and re-codes nothing; main ignores the variable and re-codes nothing.
  • Resident memory after load: 72.71 GiB on main and unset against 72.64 GiB with mxfp8 at 8 slots (72.73 against
    72.67 at 4), so mxfp8 holds 0.07 GiB less.

Method, so the numbers can be checked

States M (main), U (branch with the variable unset) and X (branch with mxfp8), alternating M1 U1 X1 M2 X2 U2 with a
fresh server each, every boot recording its container's own setting line and, under mxfp8, the re-coding line. A cell
is slower when both X runs are under both M runs and the mean gap is over 1%, faster when both are over both and the
gap is over 1%, level otherwise; a flagged cell gets one rerun and a repeat is a loss. Decode at a 32,768-token window
and 8 slots, cold prompts at 131,072 and 4 slots with --prompt-cache-gib 0. cells.csv, rule5.md, cold.md and
exactness.md in docs/receipts/flashnext-mtp-weights/ carry every cell and every verdict.

@ashhart

ashhart commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Thank you @BadAd84 for the fresh receipt on current main. The narrow re-code split, the named refusal and the unset default are all as reviewed; the gate cell is level and no cell is slower, with every exactness check equal.

Nothing further is needed from you on this PR. We will settle the changelog hunk at landing.

  • Synthena

@ashhart
ashhart force-pushed the flashnext-mtp-weights branch from aa35a60 to b2b8d98 Compare November 20, 2026 08:40
ashhart pushed a commit to BadAd84/TensorFold that referenced this pull request Nov 20, 2026
…HTS changes

cuda_mtp.zig, cuda_projection.zig, cuda_projection_load.zig and cuda_prompt_wt.zig take their hashes at this head,
on main's files, each with a ashhart#3218 note: checkpoint keeps main's bytes.
ashhart pushed a commit to BadAd84/TensorFold that referenced this pull request Nov 20, 2026
The four files this pull request ships under docs/receipts/flashnext-mtp-weights/
carry the narrow variant's window: main 4fda6a0 against head b43b10f, one
GB10, 18 boots, 22 cells faster and 10 level of 32 for mxfp8, no cell slower,
the gate cell level, every cold cell level and every exactness contract equal.
@AIFlowML

Copy link
Copy Markdown
Contributor

I checked b2b8d985 on M5 Max with Zig 0.17.0. zig build test-environment-host test-gradient-serving test-flashnext-mtp-plan-host test-flashnext-loader-host -Dcpu=apple_m1 -j5 --summary all passed all 70 tests.

Against 124052c97, the two conflicts are the environment count fixture and the cuda_prompt_wt.zig serving pin. The combined registry has 35 settings, with 23 switches, 9 integers, 1 real and 2 structured settings. The merged source hashes to 1347b9b4488dfe7f4dc9299ee7ef6aca01dbdb9aabfb57e518f16f0b5548d0be, which differs from both existing pins. With those updates, the same targets plus check-native-cuda-host passed all 71 tests in the scratch tree. This was host and build validation.

Igor Lessio - AIFLOW LABS

ashhart pushed a commit to BadAd84/TensorFold that referenced this pull request Nov 22, 2026
…HTS changes

cuda_mtp.zig, cuda_projection.zig, cuda_projection_load.zig and cuda_prompt_wt.zig take their hashes at this head,
on main's files, each with a ashhart#3218 note: checkpoint keeps main's bytes.
ashhart pushed a commit to BadAd84/TensorFold that referenced this pull request Nov 22, 2026
The four files this pull request ships under docs/receipts/flashnext-mtp-weights/
carry the narrow variant's window: main 4fda6a0 against head b43b10f, one
GB10, 18 boots, 22 cells faster and 10 level of 32 for mxfp8, no cell slower,
the gate cell level, every cold cell level and every exactness contract equal.
@ashhart
ashhart force-pushed the flashnext-mtp-weights branch from b2b8d98 to 20003e9 Compare November 22, 2026 00:57
@AIFlowML

Copy link
Copy Markdown
Contributor

I trial-merged 20003e96 into 7d243251. The only overlap was the Flash Next environment inventory. This head adds one structured setting, so the standalone total is 38: 25 switches, nine integers, one real and three structured. With the fixture reconciled, all 76 checks passed on M5 Max with Zig 0.17.0, and native Linux ARM64 CUDA compiled.

I also applied the current #2898 at 42b1e096. The only overlap was again the fixture. State pages adds one switch, bringing the combined total to 39 (26, nine, one, three). Both production changes merged without edits. The combined trial passed all 262 checks and compiled the native target.

zig build test-environment-host test-gradient-serving test-flashnext-mtp-plan-host \
  test-flashnext-loader-host test-kv-pool test-kv-safety-host \
  test-flashnext-pages-contract-host check-native-cuda-host \
  -Dcpu=apple_m1 -Doptimize=ReleaseSafe -j2 --summary all

The GB10 checkpoint measurements remain separate.

Igor Lessio - AIFLOW LABS

…keeps its BF16 linears

The FP4 checkpoint quantizes the backbone and leaves the drafter in BF16, 181 MB that every draft pass reads.
TF_FLASHNEXT_MTP_WEIGHTS=mxfp8 re-codes those linears to MXFP8 (E4M3 codes, one power-of-two scale a row of 32
inputs) as they load; checkpoint, the default, keeps the rows as stored and runs no new code. A draft is a proposal
the verify forward checks, so a reply is unchanged and only the rounds it takes move.
Decode cells at 1, 2 and 4 streams on main, the branch unset and the branch with mxfp8,
and the drafted, resumed and concurrent exactness table for the same three arms.
…drafter has no MXFP8 projection

mxfp8 re-codes the drafter's BF16 linears through the MXFP8 projection that an MXFP8 checkpoint's mixers load
through, and only the CUDA loader has it. Flash Next on Metal and on HIP now refuse mxfp8 by name when they load,
and on CUDA a drafter linear stored as anything but BF16 (MXFP8 or affine already) refuses it at that tensor,
naming the setting, the tensor and its stored type, rather than loading it as stored.

Unset or blank still reads checkpoint, which runs main's load. The reader moves to mtp_weights.zig so Metal and HIP
can ask without CUDA, the startup line gives the MiB re-coded, and the setting has its row on the environment page.
…le and tokens a round

Main against the branch rebased on it, as M1 U1 X1 M2 X2 U2 with U2 set blank: greedy and sampled at three seeds,
tokens a round beside tok/s, the cold prompts, a malformed start and the exactness table, and the changelog line
quotes them. One cell, chat at one stream with seed 1234, is slower again on its rerun and is reported as a loss.
…e any checkpoint or device work

HIP asks at the top of Engine.load, ahead of the runtime, the context, the kernel images, RCCL and the
checkpoint; Metal asks right after the environment check, ahead of window validation and the checkpoint admission.
The test checks that each call comes before its backend's first runtime open or admission check, and the
admission order test takes the new line.
…HTS changes

cuda_mtp.zig, cuda_projection.zig, cuda_projection_load.zig and cuda_prompt_wt.zig take their hashes at this head,
on main's files, each with a ashhart#3218 note: checkpoint keeps main's bytes.
…NEXT_MTP_WEIGHTS

The receipt names the rebased commit it measured and gives the engine allocator's resident model from the same
boots: 72.73 GiB on main and unset, 72.65 GiB with mxfp8. The changelog line moves under Unreleased after the
1.2.9 release and says main's tokens a round on code.
…g, before the backend opens a device

The HIP backend runs ready before any family code: it reads the checkpoint's context, opens a runtime for the
card's caps and, under --tp, joins the ranks. A refusal in check or in Engine.load came after that. Flash Next's
HIP native now refuses mxfp8 in refusal, the flag check the backend runs on every rank before ready, and
Engine.load no longer asks. The position test checks the hook and that no later copy remains.
…pert as stored

TF_FLASHNEXT_MTP_WEIGHTS=mxfp8 re-codes the MTP drafter's BF16 linears to MXFP8 as they load: 13 tensors,
170 MiB of them on the NVFP4 checkpoint. Re-coding all of them also moves the sampled draft acceptance at one
stream (chat, temperature 1.0, seed 1234: 2.39 tokens a round becomes 2.31), and in a screen on this tree that
cell measured 2.5% slower than main, which is the cell the gate asks to stay level.

A narrower re-code keeps three of those tensors as the checkpoint stores them and re-codes the rest:

- fc_embedding and fc_hidden (25.0 MiB), the two fusion projections that carry the previous token's embedding
  and the model's hidden state into the drafter;
- the layer's shared expert gate, up and down projections (9.4 MiB).

The other 135 MiB, the hyper-connection mixers and the attention's q/k/v and o_proj, are re-coded. A screen of
thirteen masks over those linears, one fresh server a boot, found every mask that re-coded the two fusion
projections 1.2 to 4.7% slower at that cell, where masks that kept them stayed at main's level; keeping the
shared expert as stored held the sampled cells at main's level as well.

denseFor names the loader's tensor and holds the re-code off for a linear kept as stored, so the six loaders
that pack a drafter BF16 tensor decide in one place. The startup line reports both halves:
TF_FLASHNEXT_MTP_WEIGHTS=mxfp8 re-coded 135 MiB of the drafter's BF16 linears and left 34 MiB as stored.

The kept set is one list with a test over it, a second test holds every loader to denseFor, and the four
pinned serving files are re-pinned.
…ting's name

The matcher read `for (held) |name|`, and `name` is the file's own constant for
TF_FLASHNEXT_MTP_WEIGHTS, so the tree did not compile: "capture shadows
declaration of 'name'". The capture is `keep` now; the set it walks is
unchanged.
The four files this pull request ships under docs/receipts/flashnext-mtp-weights/
carry the narrow variant's window: main 4fda6a0 against head b43b10f, one
GB10, 18 boots, 22 cells faster and 10 level of 32 for mxfp8, no cell slower,
the gate cell level, every cold cell level and every exactness contract equal.

This branch has not been deployed

No deployments
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.

3 participants