Repository navigation
glm cuda: --mtp-confidence sizes MTP windows by each draft's chance, as Nemotron's does - #1585
Merged
Merged
Conversation
Bizuayeu
marked this pull request as ready for review
October 29, 2026 09:22
…as Nemotron's does GLM's MTP head gave the lanes no chances, so every drafted row went to verify; a row costs about 5.6 ms at TP=3 and many deep drafts miss. With --mtp-confidence, every rank picks an MTP draft with tf_glm_top1_sums, which adds its slice's softmax sum to the 16-byte word the greedy gather already moves; rank 0 turns the ranks' sums into the pick's probability, and the lanes chain them and stop a chain where its chance falls under the floor (the lane core's draft_confidence, as for Nemotron). Sampled and structured drafts keep chance 1. Without the flag every path is main's.
…ernel The MTP draft's pick under --mtp-confidence: tf_glm_top1's scan and its slice's softmax sum. nvcc 13.0 usage measured on the five targets; later compilers pending, as for tf_glm_top1.
A confidence floor made every stream draft the most and left the cut to the head's chances. A sampled stream's drafts carry no head chance (GLM gives them 1), so it verified the deepest window each round: at TP=3 a sampled chat reply drafted 3 a round where its rates chose fewer, and lost 1.7 to 2.0% at one stream. headDepth and depth now keep the rates' depth for a sampled stream under a floor; greedy streams draft the most as before.
… and its sum against float64
ashhart
force-pushed
the
pr/glm-mtp-chance
branch
from
October 30, 2026 04:32
4cea13a to
9aee8ea
Compare
Contributor
Author
|
Thank you for landing it! I'll keep measuring the floor on real requests and report back if a different default looks better. |
Owner
|
Thank you @Bizuayeu. This is in TensorFold 1.2.0, released today: https://github.com/ashhart/TensorFold/releases/tag/v1.2.0 It landed with your commits under your own name, so you're listed as a TensorFold contributor, and it's credited to you in the release notes and the changelog. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On GB10 at TP=3 (GLM-5.3-Flash XSFP4, the drafts on, one binary served without the flag and with
--mtp-confidence 0.5, two launches each, the same tokens in every launch):--mtp-confidence 0.5bench_openai, mean of its two prompts' medians (tok/s)bench_concurrent, tok/s)The sampled one-stream rows draft the same windows with and without the flag (1.855 and 2.000 tokens a round in all
six launches); their spread is the launches', as the no-flag code row's 43.5 and 44.7 show.
At TP=2 (two GB10 joined by one QSFP cable, the same binary and benches, two runs of four launches, the same tokens
in all eight; each cell is the lowest and highest of an arm's four launches):
--mtp-confidence 0.5Four greedy code streams at TP=2 lose with the flag: every 0.5 launch was slower than every no-flag launch, −4.32% in
the first run and −2.98% in the second. I have not looked into why. Code's drafts are accepted more often than chat's
(the code prompt's decode is 44.2 to 44.6 tok/s with and without the flag), so a floor of 0.5 may cut rows that would
have been accepted, and four streams verify extra rows for little. The flag stays opt-in, and a code-heavy server at
TP=2 is better off without it or with a lower floor (not measured at TP=2).
What this changes
GLM's MTP head gave the lanes no chance for its drafts, so every drafted row went to verify. At TP=3 a verify row
costs about 5.6 ms (
TF_GLM_PROF, a window of 2, 3 and 4 rows: 37.64, 42.84 and 48.82 ms), and on mixed text manydeep drafts miss: over eight prose prompts at one stream, 563 of the drafted rows were refused in 970 rounds.
With
--mtp-confidence F, GLM serves the flag Nemotron already takes. Every rank picks an MTP draft withtf_glm_top1_sums,tf_glm_top1's scan with its vocabulary slice's sum of exp(logit - max) in the third word of the16-byte pair the greedy gather already moves, so the gather and its count do not change. Rank 0 reads the pick's
softmax probability over the whole vocabulary, 1 / sum over ranks of sum_r * exp(max_r - max), and the lanes chain
the drafts' probabilities and stop a chain where its chance falls under F (the lane core's
draft_confidence, as forNemotron).
Leader.drafttells the other ranks to sum with a bit in its step's flags. Sampled and structured draftskeep chance 1; the flag is refused beside
--drafter(DFlash2's chances size those windows) and GLM still refuses--mtp-drafts. Without the flag every path is main's, andtf_glm_top1's records stay current.One lane core change comes with it. A confidence floor made every stream draft the most and left the cut to the head's
chances, so a sampled stream, whose drafts carry none, verified the deepest window every round: in a first run of
this branch a sampled chat stream took 2.33 tokens a round in those windows against 1.86 in its rates' ones, with
rounds of 55 against 41 ms, and lost 1.7 to 2.0%.
headDepthanddepthnow keep the rates' depth for a sampledstream under a floor; greedy streams draft the most as before. This reaches Nemotron's sampled streams under
--mtp-confidencetoo.0.5 is the floor I would suggest for GLM: at TP=3, in the first run 0.2 gained less everywhere (decode +1.57%, four
distinct prompts +3.97%, eight +2.46%), and 0.7 gained less at every greedy row and lost 2.83% at four greedy chat
streams. At TP=2 only 0.5 ran.
Receipt
4cea13a40(main7c0688951and four commits, the fourth only the contract test below); thelaunches ran
05c433b45, whose tree differs only in where the lane core's new test sits and in that test. Three GB10(sm_121) at TP=3 in a ring of three QSFP cables with no switch, on NCCL, and two GB10 at TP=2 joined by one QSFP
cable; GLM-5.3-Flash XSFP4;
--parallel 8,--prompt-cache-gib 0,zig build nativefor sm_121 with nvcc 13.0.88.At TP=3, launches no flag, 0.5, 0.7, 0.7, 0.5, no flag; at TP=2, no flag, 0.5, 0.5, no flag, twice. Each ran
bench_openai(256 tokens, 3 repeats, temperature 0),bench_concurrent --alone --serial(one and four streams,temperatures 1.0 and 0) and four and eight distinct prompts at once (300 tokens, greedy). An earlier TP=3 run of the
first two commits (no flag, 0.2, 0.5) found the sampled loss that the third commit fixes.
token hashes and each distinct prompt's reply hash agree across them, and
--alone --serialfound every draftedreply equal to its
"draft": falsetwin and every concurrent one equal to it alone, greedy and seeded sampled, inall 48 cells at TP=3 and 64 at TP=2 (eight a launch). The flag changes which drafted rows are verified, never a sum.
against 13,264 without, 7,657 accepted against 7,825 (72.6% against 59.0%); at TP=2: 10,814 against 13,121, 7,810
against 7,977 (72.2% against 60.8%). At TP=3 every 0.5 launch beat both no-flag launches in every greedy row and in
the four-stream sampled chat row; at TP=2 every 0.5 launch beat every no-flag launch in decode, greedy chat at one
and four streams, the distinct prompts and the four-stream sampled rows, and lost to every one in four greedy code
streams. No launch waited on the heat guard.
zig/tests/cuda/contract_glm_top1.zigrunstf_glm_top1_sumsthrough gates 1-4 as two specs.Its pick (words 0 and 1) must equal
tf_glm_top1's words on the same logits bit for bit, and the host's scan (thefirst logit above every earlier one from -inf, so a NaN never wins; none above -inf gives -inf and the slice's first
row); it declares no sums. Its sum (word 2) is held to float64's sum of exp(a), a = x - max, within the fp32 bound
plus
__expf's error (CUDA's 2 + 1.173|a| ulp, taken as 2 + 1.2|a|). The served shapes are the TP=2, 3 and 4 slicesof the 154,880-row vocabulary (77,440, 51,648, 51,584 and 38,720 rows), k tiled by 1,024.
kernel-contract-limitsonnvcc 13.0.88's fatbins for sm_80, 86, 89, 120 and 121:
tf_glm_top1stays current on every SM (29, 30, 30, 36 and 36registers), and
tf_glm_top1_sumshas its new records, 32, 31, 31, 39 and 39 registers, 8,192 static shared bytes,bound 1024. On the GB10,
zig build kernel-contractwith kernel contract: the CUDA runner maps fp8_experts' image, so a run reaches its summary #1579's mapping (without it the run stops at fp8_experts):SUMMARY 435 kernels: 435 pass gates 1-4, 0 fail, 6 known findings; 316 controls: 316 red as planted, 0 missed; 183 limit problems, in 5,076 s with the build. Both new specs pass every gate they run: the pick's nonfinite, repeat andshapes (8 shapes exact), and all four of the sum's (8 shapes within the float64 bound, the worst at 0.034 of it; exact
sums at k 77,440, where fp16 would miss by 16,270,016x and bf16 by 39,625x). The live limits pass
tf_glm_top1_sums(1024 threads, 39 registers, 8,192 + 0 shared bytes, as recorded) and
tf_glm_top1(36, 8,192). The 183 are the samelines as on main with kernel contract: the CUDA runner maps fp8_experts' image, so a run reaches its summary #1579's mapping alone, none of them touched here.
tools/zig/cuda_sass_identity.pyagainstmain: none of
glm_glue's 235 functions changed and five were added (tf_glm_top1_sumson each SM), sotf_glm_top1's SASS is main's on every SM.zig build test436/439 steps andtest-cuda-host268/270 (in both the one failureQwen3.5's timing-dependent
cuda_cost_identity, which fails the same way on main; a run before the third commitpassed both whole),
compile-cuda-tests10/10,compile-config-server7/7,zig fmt --check, andtools/zig/lean_check.pywith nothing new (425 against main's 425). New host tests: the ranks' pick and its softmax(
cuda_mtp_chance.zig), GLM's refusals of--mtp-draftsand of the flag beside--drafter, GLM's facts with a floorthrough
lanes.Config.init, and a sampled stream's depth under a floor (depth.zig, which fails on main with 3 for1). New GPU tests: the kernel contract's two specs for
tf_glm_top1_sums(built bycompile-cuda-tests, run on theGB10 above).
reaches its sampled streams; no Nemotron checkpoint here); floors other than 0.5 at TP=2.
Checklist
only shortens drafted windows inside the lane rounds.)
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.(
--alone --serialin every cell of every launch at both TPs; the prompt cache was off, and resuming is untouched.)changes: the chance only decides which drafted rows are verified.)
SUMMARYline is in the receipt. (tf_glm_top1_sumshas nvcc 13.0 records and gate 1-4 specs incontract_glm_top1.zig; the GB10 run'sSUMMARY, both specs passing and the live check are in the receipt;tf_glm_top1's SASS is unchanged; CUDA is the only backend it touches.)TP=3 and TP=2, the host tests on Linux; the rest not run, as above.)
no device; the depth test fails on main, the refusal and facts tests fail without GLM's option; the contract specs run
on a GPU and name a kernel main does not have.)