Skip to content

glm/cuda: TF_GLM_DRAFT_SPLIT=1 splits the DFlash2 drafter's MLP at three ranks or more (for #3581) - #3616

Merged
ashhart merged 3 commits into
ashhart:mainfrom
ultradaoto:glm-draft-split
Nov 21, 2026
Merged

ashhart merged 3 commits into
ashhart:mainfrom
ultradaoto:glm-draft-split

Conversation

@ultradaoto

Copy link
Copy Markdown
Contributor

For #3581, as agreed there: its own opt-in, its own field in the rank fingerprint, and today's default unchanged.

  • Settings.draft_split reads TF_GLM_DRAFT_SPLIT: exactly 0 or 1, off by default, anything else refused by name.
  • Settings.draftWide() is what dflash.mlpSplit's wide takes at both call sites in dflash_load.zig: TF_ROCE=1 or TF_GLM_DRAFT_SPLIT=1. The 256-alignment rule and the two-rank split are untouched, and TF_ROCE=1 still splits as before.
  • The rank fingerprint carries draft_split, set from three ranks up like roce_wide, with its name in the mismatch message; the layout number goes 21 to 22. A rank without the setting refuses the others instead of loading a different weight layout.
  • Tests, in cuda_ranks_roce_test.zig: the setting's values; mlpSplit over worlds 1, 2, 3, 4, 5, 6 and 8 with neither setting and with each; the fingerprint at three ranks and at two. The every-field test in cuda_ranks_test.zig takes the new field.
  • CHANGELOG, under Unreleased.

With the variable unset, draftWide() is roce_wide, so the drafter loads as on main; only the fingerprint's layout number moves, on every rank alike.

zig build test-cuda-host on main 077998f plus this diff: 6,919 of 6,953 pass and 33 skip. The one failure, cli_config_test's serve --config: expand reads the file ..., fails the same way on main on this host. zig fmt --check is clean on the family's folder; pr_check: 0 errors, 0 new lean findings. The branch is cut from a437511, main just before 40a46d6: that commit changes a workflow file, which my token may not push. The five Zig files here are the same on a437511 and 077998f.

Receipts: three GB10s on a switchless triangle, TP=3, GLM-5.3-Flash EXL3, one build (main 077998f plus this diff), --parallel 4 --kv-cache fp8, --drafter incoai/GLM-5.3-Flash-DFlash2 at 6cc6c481, TF_GLM_DENSE_BITS=8 TF_GLM_HEAD_BITS=8 TF_GLM_KDA_PAD=1, greedy. NCCL carries every gather in every start; under TF_ROCE=1 the log says RoCE all-gather: NoHca (); NCCL carries every gather. Five starts in one session, in this order: unset, 1, 1, unset, TF_ROCE=1. One number per start:

unset TF_GLM_DRAFT_SPLIT=1 TF_ROCE=1
drafter on rank 0, from the startup log 0.93 GiB 0.44 GiB 0.44 GiB
16 varied greedy requests, aggregate tok/s 55.90 / 55.70 58.47 / 58.56 (+4.9%) 58.63
tokens a round over those requests 3.058 / 3.058 3.058 / 3.058 3.058
tools/bench_openai.py --tokens 256 --reps 3 --temperatures 0, code, median tok/s 59.10 / 58.44 62.24 / 62.37 (+6.0%) 62.09
the same, chat with thinking off 47.57 / 47.24 49.12 / 49.77 (+4.3%) 49.59
tools/bench_concurrent.py --tokens 256 --reps 3 --temperatures 0 --levels 1,4 --alone --serial, 4 streams, code, aggregate 122.9 / 122.9 119.0 / 127.9 128.3
the same, chat 104.7 / 105.7 102.3 / 109.3 109.7

Tokens: 13 greedy replies (8 prompts alone, 4 at once, one prompt of about 8K tokens) hash the same in all five starts. Drafts: the tokens a round are the same in all five.

The first =1 start's four-stream numbers came in low, here and in a second four-stream client (84.5 tok/s against 86.8 in the next start), while its one-stream numbers did not. I do not know why; the endpoint is not closed to other clients, which may be it. The second =1 start and the TF_ROCE=1 start agree with each other.

One question: #3495 puts TF_ROCE in the window-cost cache's key. If the drafter split moves anything that table prices, this setting belongs beside it; I can add it here or after #3495 lands, whichever you prefer.

@ashhart

ashhart commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thanks @ultradaoto, this is a tidy change. The new setting has its own fingerprint field and a named mismatch, draftWide() is the only thing the two load sites in dflash_load.zig (lines 148 and 159) read, and with the variable unset the drafter loads exactly as on main. The mlpSplit walk over worlds 1 to 8 in cuda_ranks_roce_test.zig is a good test. The receipts are clear too: the drafter goes from 0.93 to 0.44 GiB on rank 0, bench_openai code is 59.10/58.44 against 62.24/62.37 tok/s, and the 13 reply hashes and 3.058 tokens a round are the same in all five starts.

What the split does to the drafter's own numbers, for the record: gate and up are split by rows, so those values don't change. Down is split along K, though. Each rank writes fp32 partials over its FF/world share, and df_sumn adds them in rank order before the one bf16 rounding (dflash_block.zig:147-156, glm_dflash.cu:263-271). Unsplit, one GEMM covers all of FF (dflash_block.zig:157). The precision is the same, but the sum order isn't, so the drafter's hidden state can differ in the last bits and its top-16 proposals can change at near-ties. The result also depends on the world size. Replies don't change, because the target's verify decides every token. This is the same path TF_ROCE=1 and the two-rank default already take on main.

Must fix:

  1. CHANGELOG: "with the same replies and drafts" claims more than the receipts show. Equal tokens a round don't prove equal proposals, and the split does reorder the drafter's down sum. Please write "with the same replies and the same tokens a round on these prompts" or similar. Please also say the ~5% is at one stream: your four-stream starts were 119.0 and 127.9 against 122.9 unset.

Optional:

  1. Please add one start of main itself to the table, with the reply hashes and the drafter's GiB line. Then "unset is main" is shown directly and doesn't rest on the branch's unset start alone.
  2. On your glm/cuda: key the window-cost cache by TF_GLM_KDA_PAD, TF_ROCE, TF_GLM_PDL and TF_GLM_DSEL #3495 question: yes, if glm/cuda: key the window-cost cache by TF_GLM_KDA_PAD, TF_ROCE, TF_GLM_PDL and TF_GLM_DSEL #3495 lands first, TF_GLM_DRAFT_SPLIT belongs beside TF_ROCE in the window-cost key, because the split changes the drafter's time a round. A follow-up after glm/cuda: key the window-cost cache by TF_GLM_KDA_PAD, TF_ROCE, TF_GLM_PDL and TF_GLM_DSEL #3495 is fine.

Please also post CI green for the head once the runs have gone through. We will run the device check on our side: GLM-5.3-Flash with the drafter on GB10 (CUDA) at TP=2, branch against main with the variable unset and set to 1. The split doesn't change there, so every hash and the drafter's size must match main.

  • Synthena

@ultradaoto

Copy link
Copy Markdown
Contributor Author

Thanks. In 9a48360 (CHANGELOG only) the line now reads: "… decode with --drafter is about 5% faster at one stream (four streams within their start-to-start spread), with the same replies and the same tokens a round on the measured prompts. As with TF_ROCE=1, the split drafter adds its down projection's rank shares in another order, so its proposals can differ at near-ties (#3616, for #3581)." You're right that equal tokens a round don't show equal proposals, so "drafts" is gone.

Main itself, with the table's settings, in a new session: main 077998f (the base the table was measured on), then the branch with the variable unset again, one start each:

main 077998f branch, unset
drafter on rank 0, from the startup log 0.93 GiB 0.93 GiB
16 varied greedy requests, aggregate tok/s 55.48 56.02
tokens a round over those requests 3.057 3.058
bench_openai, code / chat, median tok/s 58.48 / 47.06 59.27 / 47.71
bench_concurrent, 4 streams, code / chat, aggregate 121.5 / 104.7 119.4 / 103.3
13 reply hashes against the table's first unset start 13/13 equal 13/13 equal

The two differ by about 1% in either direction, as the table's two unset starts do from each other. The last digit of the tokens a round also moves between starts of one build (#3659's receipts have 3.058 and 3.057 from one binary); the window prices are timed at each start.

On #3495: agreed. Once it lands I'll add TF_GLM_DRAFT_SPLIT beside TF_ROCE in the window-cost key as a follow-up.

The CI runs for 9a48360 will wait at action_required like the earlier ones.

@ashhart

ashhart commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Hi @ultradaoto, thanks for the main-start table and for agreeing to the #3495 follow-up. The new column shows "unset is main" directly, with the drafter at 0.93 GiB and 13/13 equal hashes, and TF_GLM_DRAFT_SPLIT belongs beside TF_ROCE in the window-cost key once #3495 lands. One thing to confirm before this lands: the corrected CHANGELOG wording you quoted is not in the diff at the head we have (2ff9ce1), so please make sure that line is on the head we review. CI is still at action_required, and we'll run the device check on our side at TP=2 with the drafter, branch against main with the setting unset and set to 1; every reply hash and the drafter's size must match main. Nothing else is needed from you.

  • Synthena

@ultradaoto

Copy link
Copy Markdown
Contributor Author

Thanks for checking. The rebase onto 8cbef97 left the CHANGELOG commit behind, so the line is back as one commit on top of your head: 64b4027 adds only the corrected entry under Unreleased (one stream; the same replies and tokens a round on the measured prompts; proposals can differ at near-ties). 2ff9ce1 is unchanged under it.

CI for 64b4027 will wait at action_required like the earlier runs.

@ashhart

ashhart commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Thanks @ultradaoto. The corrected CHANGELOG wording on 64b4027 answers our last ask. The only thing left was a conflict with a line we had added under Unreleased, so we rebased the branch onto current main ourselves, keeping both of your commits as they were and leaving CHANGELOG.md as main has it; we will place your entry when it lands. Nothing else is needed from you. We will run our device check on our side and post the result here.

  • Synthena

@AIFlowML

Copy link
Copy Markdown
Contributor

I made a clean trial merge of 5bf28ec6 onto 124052c97 and ran these on M5 Max with Zig 0.17.0:

zig build test-environment-host test-glm-dflash-host test-glm-tp3-host \
  test-glm-prompt-taps-host compile-glm-native-open test-gradient-serving \
  -Dcpu=apple_m1 -j5 --summary all

The first test detail worth calling out is that test-glm-tp3-host filters on GLM TP3:, so it misses the three new draft-split cases in cuda_ranks_roce_test.zig. In the scratch build I added a host target using the existing GLM module and filtered on TF_GLM_DRAFT_SPLIT: off by default, three ranks or more split the drafter, and is in the ranks' agreement. I verified the three cases passed by name. The combined run with the local target passed 69 tests, including 11 from that target.

This verifies the settings, alignment, and rank agreement on the host. The planned TP=2 hardware comparison is still needed for reply hashes and drafter size.

Igor Lessio - AIFLOW LABS

@ashhart

ashhart commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Thanks @ultradaoto. Every ask is answered:

The rebased head 5bf28ec622 applies cleanly to today's main, and every touched file is within 600 lines. With the variable unset, draftWide() is roce_wide, so both load sites in dflash_load.zig (lines 148 and 159) read what main reads.

One note: #3495 has now landed, and TF_ROCE is in the window-cost key at cuda_lane_costs.zig:179. Your agreed follow-up, TF_GLM_DRAFT_SPLIT beside it, can go ahead whenever suits you.

Nothing else is needed from you. What's left before it lands is CI green at this head and the two-rank device check with the drafter, branch against main with the setting unset and set to 1.

  • Synthena

@ashhart

ashhart commented Nov 21, 2026

Copy link
Copy Markdown
Owner

@ultradaoto, the device check for this one is done. GLM-5.3-Flash at TP=2 on two GB10s, --context 65536 --parallel 2, main against this head with TF_GLM_DRAFT_SPLIT unset, runs in the order base, new, new, base:

  • tokens: 52 equal, 0 unequal, 0 unverified, with no cell whose streams differ;
  • resumed chat with thinking off and on: qualified on both builds, the same cached counts;
  • speed: prompt 2k to 32k within 0.9%, decode within 0.3 to 1.9%, inside run-to-run spread for an unchanged default path.

So the default is unchanged, as the PR says. We have no third GB10 in that pair, so the opt-in at three ranks stays on your receipt. It is in the landing queue.

  • Synthena

ultradaoto and others added 3 commits November 21, 2026 05:49
…e ranks or more

At three ranks or more the drafter's MLP split was switched on by TF_ROCE=1 alone. TF_GLM_DRAFT_SPLIT=1 asks for
it by itself, for 256-aligned shares, and has its own field in the rank fingerprint so every rank agrees on the
weight layout. Unset keeps today's default, and TF_ROCE=1 still splits as before.

For ashhart#3581.
… stream; replies and tokens a round, not drafts)
@ashhart
ashhart merged commit 09e1ffd into ashhart:main Nov 21, 2026
2 of 11 checks passed
@ashhart

ashhart commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Thank you @ultradaoto. 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.

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