Repository navigation
GLM-5.3-Flash on CUDA: a decode window's DSA index scores on tf_glm_index_scores (TF_GLM_DSCORES) - #3689
Conversation
ba21a91 to
757cb75
Compare
|
A note on the CI state of this head (
The CI is not green, and we are leaving it as it is: no further close and reopen from our side. If you would like it run again once the queue is free, say so here. |
|
Thanks @Bizuayeu. The red check on this head isn't from your change. The only failure is one test in There is nothing to change on your side: a rerun of that check, or a rebase onto current main, clears it. The flake itself is being fixed separately, by moving those tests to a lockstep clock.
|
Thanks. The rerun of the failed jobs passed on 757cb75. Since then #3776 has landed, and this head now conflicts with it in two launch lines ( |
|
Thanks @Bizuayeu. The rerun cleared the red check, so that point is resolved: the failure was in cluster bring-up, not in your diff, and there is nothing to change there. One thing remains. Against current main the head conflicts in
|
… (rebase-1120/)
757cb75 to
50c6634
Compare
|
At The latest red Zig jobs ran on the older CI merge into On the current trial stack with #3697, the Linux index emulator and PDL scan passed. The SM120 build (nvcc 13.1) ran Igor Lessio - AIFLOW LABS |
…se-1120/tp4, tp2), and the cold prompts' token checks at TP=3
TP=4 and TP=2 on this head ( Receipt: Bizuayeu/TensorFold@5a1bd38fc ( |
… stream; replies and tokens a round, not drafts)
…x_scores (TF_GLM_DSCORES) MiaAI-Lab's patch 0091 (attn5-0070-glm-decode-index-scores-on-glm-index-scores, in MiaAI-Lab/GLM-5.3-Flash-DGX-Sparks-1104 0049d7c, Apache-2.0), moved onto the decode select (TF_GLM_DSEL). A decode window under rows_from rows, of 8 rows or more (or 4 from 2,048 64-pool blocks) on an aligned key cache, takes tf_glm_index_scores (8 rows a CTA, each key tile staged once for the window's rows, decodeLoop tiles a CTA) instead of tf_glm_scores (a CTA a row and block); the kernel writes tf_glm_scores' bytes. Prompt chunks keep TF_GLM_INDEX_CUDA's rule and one-row windows keep tf_glm_scores. glm_index's scores load unless TF_GLM_DSCORES=0, a glm row of platform/environment.zig (a flag, default on) with its docs/environment.md row, read as TF_GLM_DSEL is; the comments are one line each. glm-index-check's decode section runs selectTokens with the decode scores in the new set.
…iles, and glm-index-check counts the windows that take them contract_glm_index.zig's index scores also run at a decode window's tiling (glm.index.decodeLoop tiles a CTA, cuda_sparse's grid) as a replacement of tf_glm_scores, at three served decode shapes (8 x 4,096, 16 x 51,200 and 4 x 131,072 pools: 1, 2 and 5 tiles a CTA) with up to 8,192 visible pools. Its planted control, the same launch told one 64-pool tile fewer, goes red at the shapes gate. Both sit in Fast beside the prompt indexer's kernels; the launch is glm_index tf_glm_index_scores, already in the records. glm-index-check counts the windows whose decode scores take glm_index_scores and fails when none does, so its byte checks cannot pass by skipping them. The docs' GLM paragraph names the decode scores.
decodeLoop chose a window's 64-pool tiles a CTA from its blocks alone (about 376 CTAs a row group). On GB10 the fastest tiles also follow the rows: a tile a CTA up to 4 rows, 2 up to 8, then rows / 4 a 1,024 blocks (rounded up), at most score_tiles and never under 32 CTAs a row group. The rule is fit to a sweep of glm_index_scores by rows and blocks; it changes speed only. The contract's served decode shapes keep 2, 4 and 1 tiles a CTA.
On GB10 glm_index_scores at a decode window's tiles is slower than tf_glm_scores for 8 and 16 rows up to 8K tokens (0.02 to 0.045 ms a pass of 11 layers, in a one-GPU bench of the two kernels), level at 16K (64 blocks) and faster from 64K (0.10 ms a pass at 8 rows, 0.31 ms at 16). A window of 8 or more rows takes it from 64 64-pool blocks (16K tokens); 4 to 7 rows keep 2,048 blocks. Speed only: both kernels write the same scores. The contract's served decode shapes still take it (8 rows over 4,096 pools is 64 blocks), and glm-index-check counts its windows by selectTokens' blocks (the visible pools) instead of the bucket's.
50c6634 to
0f3fc2a
Compare
|
Thank you @Bizuayeu. 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. |
Rebased onto #3776 (20 Nov). This head is this change's four commits on #3776, which made GLM's decode kernels dependent launches and changed
glm_index_scores.cuh, the kernel this change sends decode windows to, so the receipts were taken again on the new base: TP=3 on 20 Nov, TP=4 and TP=2 on the night to 21 Nov. The TP=4, TP=2 and TP=3 tables below and On the head rebased onto #3776 are this head's; the details that name another binary (the switch's runs, the first three commits, the one-GPU bench) are as before. The earlier base's sets (maine86a0bed1d) are folded at the end of Checks on the earlier head, where "this head" names the earlier head, as those checks say. All three are on mainb0b17e8962. Since then main has taken #3249, which keeps each decode window width's faster expert form; this head merges onto today's main (46c6ee229d) without a conflict. If you want the receipts on today's main, I'll take them again there.On GB10 (sm_121), a decode window of 8 to 63 rows over 64 or more 64-pool blocks (from about 16K tokens), or of 4 to 7 rows over 2,048 or more (from about 512K tokens), now computes its DSA index scores with
tf_glm_index_scores, the prompt indexer's kernel (8 rows a CTA, each key tile staged once for all of them), instead oftf_glm_scores(a CTA for each row and 64-pool block). Drafted decode's verify rounds are such windows. The scores aretf_glm_scores' bytes. Against main at TP=4 on the same boxes, checkpoint and settings, drafted decode after a 1,040,384-token prompt is 13.5% faster, in the same rounds and with the same tokens:Each rep resumes the cached prompt and decodes 512 greedy tokens with drafts on (MTP and copies). This head's median, 171.55 tok/s, is 13.5% above the median of main's 12 reps, 151.16; this head's slowest rep, 170.84, is above main's fastest, 152.81. Every rep took 32 rounds, and every rep's tokens are the same, in the two uncounted timed starts too. Every rep drafted 508 tokens and accepted 480 but one of main's, the first of its second run, which drafted 507 and accepted 479 (the record doesn't say in which round); without it, main's median is 151.12 and this head is 13.5% above it. Main's slowest reps, 141.85 and 141.53, are the first two of its fourth run; without that run, this head is 13.4% above main. Without drafts every decode window is one row, which keeps
tf_glm_scoresin both binaries: the grid of long contexts (4K to 1016K, 1, 4 and 8 streams,"draft": false) is the rest of the step, its geometric mean over the 12 cells 47.838, 47.806 and 47.814 ms in this head's runs against main's 47.851, 47.861, 47.831 and 47.856 (the cells in the details).Why a rep can draft one token fewer
How many tokens a round drafts is priced as the server runs, not only from the prices timed at a binary's first start.
lanes/config.zig'stimed, on by default and left on by GLM's serving, says what turning it off gives: "rounds priced from the cost tables alone, no wall clock (a request drafts the same whatever the load or the requests before it)". With it on,lanes/engine.zighands each drafted round's measured time to the depth rule (observeOverhead), andRule.overheadMsinlanes/depth.zigprices the next rounds' drafts from it. These runs aligned the prices timed at start (main's record in every counted start), but the part learned from measured rounds lives in the running server and can't be aligned between starts, so a round whose choice sits at a border can draft one fewer after rounds that ran a little long. The target verifies every draft greedily, so the drafts change how much a round does, never the tokens: the 27 reps have onetoken_sha256. The record doesn't say which round of main's second run's first rep drafted one fewer, so this is how it can happen, not a measured cause. On the earlier base, the second rep drafted 507 and accepted 479 in every run of both binaries.The first three commits took every window of 8 rows or more. At TP=3, at the release's settings, they ran 4 drafted streams of short prompts about 1% slower than main in each of three sets of five runs, with the same tokens a round and a longer round. A one-GPU bench of the two kernels (a pass reads 11 key caches in turn, as GLM-5.3-Flash's 11 MLA layers do) then found
tf_glm_index_scoresat a decode window's tiling slower thantf_glm_scoresfor 8 and 16 rows up to 8K tokens, by 0.02 to 0.045 ms a pass, level at 16K, and faster from 64K (table in the details). The fourth commit keeps windows under 64 blocks (16K tokens) ontf_glm_scores.On this head, at TP=2 and TP=3 at the release's settings, seven counted runs each (main, this head, main, this head, main, this head, main, each a fresh start, 60 s apart), after one uncounted start of each binary that timed its own window and draft prices; every counted start of both binaries kept main's record, so the binaries differ only in code (Receipt, below). TP=3 ran on 20 Nov and TP=2 on the night to 21 Nov. By the rule below, no row of either is slower. At TP=2 one row the gate counts is below main's lowest run and inside the threshold, so not slower by the rule: decode at 4 streams, a stream's tok/s, 17.8, 17.9 and 17.6 against main's 17.8 to 18.0 (+0.74%, against main's range of 1.12%). That cell is the median of 12 values (3 reps of 4 streams), rounded to 0.1 tok/s; the reps' means of their four streams are 17.52 to 18.25 for this head against main's 17.82 to 18.32, the lowest in this head's third run, and all streams' tok/s at 4 streams is level with main's, 68.9 against 68.9 (+0.04%). Every cell, greedy row and cold prompt gave the same tokens in all nine starts of each set:
ttft_s(two prompts' mean)ttft_sbench_openai, t=0, code / chat (tok/s)bench_openai, t=1, code / chat (tok/s)ttft_s(two prompts' mean)ttft_sbench_openai, t=0, code / chat (tok/s)bench_openai, t=1, code / chat (tok/s)The rule, set before the runs, calls a row slower when this head's mean loses more than main's range or 0.25%, whichever is larger. The decode, edit and
bench_openaiprompts run 14 to 1,648 tokens with 256 tokens of reply: their windows stay under 64 blocks, so in both binaries they keeptf_glm_scores, and their rows show the rest of the step; the cold rows show the prompt pass. These gates show that this head loses nothing where the new path doesn't run; the gain is at the long contexts of the TP=4 table at the top.TP=2 and TP=3 on this head, in run order
ttft_s(two prompts' mean)ttft_sbench_openai, t=0, code / chat (tok/s)bench_openai, t=1, code / chat (tok/s)ttft_s(two prompts' mean)ttft_sbench_openai, t=0, code / chat (tok/s)bench_openai, t=1, code / chat (tok/s)Each set's chain first timed both binaries' prices, uncounted, this head's start before main's, and then put main's record under this head's key and read it back by sha before its counted runs. At TP=2 the two timed starts named one expert form (factored), and one chain ran all nine starts. At TP=3 they named different forms (this head classic, main factored), a choice made at load time; that stopped the first chain before its counted starts, and the second went on from the table the first left. The timed starts gave the same tokens as the counted ones in every cell, greedy row and cold prompt. Each run's edit list (prompts of 768 to 1,648 tokens that copy from their prompt): at TP=2, a stream's tok/s 119.3, 117.2 and 103.3 against main's 108.7 to 117.5 at one stream, and at 4 streams 22.8, 23.2 and 22.9 against 22.8 to 23.2; at TP=3, 161.7, 157.5 and 157.3 against 157.2 to 159.5, and 30.8 in all three against 30.7 to 31.3.
TP=4's grid without drafts, each run, and the switch's runs
A cell is the median of 3 reps: the median gap between a stream's text chunks while every stream of the rep decodes, with
"draft": false,ignore_eosand greedy, after a shared prompt of the cell's length (4,096, 65,536, 262,144 and 1,040,384 tokens). Every stream'stoken_shais the same in every run, in every cell.By the rule above, one cell is slower: 64K at 4 streams, a round of 48.438 ms against main's 48.009 (+0.89%, against main's range of 0.28%), this head's three runs 48.925, 48.321 and 48.066 against main's 47.920 to 48.055. The other eleven are within main's runs or faster, four of them faster (4K at 1 and 8 streams, 1016K at 1 and 4). Every GPU function is the same in both builds (
cuobjdump -sass, in the section on this head), and a one-row window keepstf_glm_scores, so I read that cell as run-to-run spread where the new path doesn't run.The switch's runs: one binary of a local branch (this change's first three commits on an earlier main, with a bench and an unrelated setting, off), at TP=4, the same drafted reps after 1,040,384 tokens, alternated as default,
TF_GLM_DSCORES=0, default, each a fresh start. Every rep took 32 rounds, drafted 508 and accepted 480 tokens, with the same tokens in the three runs.TF_GLM_DSCORES=0The first three commits at TP=3, and the one-GPU bench behind the fourth
At TP=3, at the release's settings (
tools/bench_*as in the gate above), each set five runs (main, the branch, main, the branch, main). In the first two sets each binary kept its own window and draft prices (both factored; the branch's 28.45 ms at one row and 45.27 at four, main's 28.59 and 44.64); in the third, main's record served both. Decode at 4 streams, all streams' tok/s: main 91.4, 90.3 and 90.6 against the branch's 88.9 and 90.8 in the first set, 91.0, 90.4 and 91.2 against 90.5 and 89.4 in the second, 89.5, 91.1 and 90.7 against 90.6 and 88.0 in the third: the branch's mean 1.01%, 1.01% and 1.25% below main's, where main's own runs span 1.21%, 0.88% and 1.77%. In the third set, the pooled decode at 4 streams took 2.934 tokens a round in both binaries, and its median round was 121.96 ms on main against 124.31 on the branch.The bench:
tf-cuda-test glm-score-benchon one GB10, 11 key caches of the context's length read in turn as one pass (GLM-5.3-Flash's 11 MLA layers), the median of 15 reps by GPU events,tf_glm_scores(two runs, 0.00% to 3.12% apart) againsttf_glm_index_scoresatdecodeLoop's tiles. Every arm wrotetf_glm_scores' bytes. ms a pass:tf_glm_scores/tf_glm_index_scoresBelow 16K a pass takes a few microseconds a layer, and the timings fall on steps of about 0.0225 ms a pass: the kernels there differ by one or two steps, so the cells give the direction, not a ratio. 32 rows at 8K is the one cell under 64 blocks where
tf_glm_index_scoresran ahead, by one step (0.02 ms); the floor keeps it ontf_glm_scorestoo.decodeLoop: the sweep behind the tiles a CTA
The patch chose a window's tiles a CTA from its blocks alone (blocks / 376, at least one). On GB10 the fastest tiling also follows the rows. The third commit's rule,
decodeLoop(rows, nb): a tile a CTA up to 4 rows, 2 up to 8, then rows / 4 for every 1,024 blocks (rounded up), at mostscore_tiles(16) and never fewer than 32 CTAs a row group. It changes speed only: every tiling writes the same scores. The same bench, median of 15 reps, three runs (each cell the runs' median), ms a pass, at the windows the path takes:tf_glm_scoresdecodeLoopThe rule runs behind blocks / 376 in two of these cells: 16 rows at 16K (0.226 against 0.209 ms, about one step, level with
tf_glm_scores) and at 1016K (4.953 against 4.890, +1.3%).On the head rebased onto #3776
In this section, "this head" is the rebased head.
Head commit:
50c6634539, on mainb0b17e8962: this change's four commits with code, rebased onto glm cuda: decode kernels as dependent launches (carries #3673), +3.7% decode at TP=3, same tokens #3776. Two lines conflicted,cuda_index.zig's andcuda_sparse.zig's launches of the index scores; each keeps this change's arguments and branch with glm cuda: decode kernels as dependent launches (carries #3673), +3.7% decode at TP=3, same tokens #3776'scuda_pdl.launch. The diff against main is this change's 11 files, +107 −17, as before. A merge onto main9e2a9bd7a9shows no conflict.Checks on this head:
python3 tools/pr_check.py --base b0b17e8962 --pr 3689: 0 errors, lean 168 problems on main and on this head, 0 new, 1 warning (no Unreleased bullet naming this PR). In WSL (Ubuntu, x86_64), Zig 0.17.0:zig fmt --check build.zig zigpasses;test-environment-host26/26,test-glm-index-host14/14,test-glm-index-emulate, the GLM module unfiltered 250/250,test-glm-contract-host7/7,test-kernel-contract257/257,check-native-cuda-hostandcompile-cuda-testspass, and so do glm cuda: decode kernels as dependent launches (carries #3673), +3.7% decode at TP=3, same tokens #3776'stest-glm-pdl-scan(3/3) andtools/test_pdl_early_loads.py(17 tests). pytest from the root: 650 passed, 89 skipped, 1 failed:tools/zig/zig_cache_restat_test.py, whosezig buildtimed out at 300 s here; run alone, that file fails on main's tree here too.CI on this head (the run of 20 Nov, on its merge with main
9e2a9bd7a9): 6 checks pass (fmt,pytest,release-paths,benchmark-clientson Ubuntu and Windows,zig-macos-dev-tools), the twohost-nightlyjobs skipped, andzig,zig-bandzig-windowseach fail one step, the same one: a test compile that stops atzig/src/families/qwen3_5/cuda_train.zig(no module named 'living'), a file this change doesn't touch; their other steps pass. Main's own scheduled run on9e2a9bd7a9(44668091696) fails the same three jobs on the same error. Main fixed that compile in its next commit,f3b4fa5dd4, after this run. pytest: 652 passed, 88 skipped, 670 subtests passed.On a GB10 (sm_121), this head's
tf-cuda-test(nvcc 13.3.73):glm-index-checkPASS, scores, pools and token lists byte-equal at 10 cases, tied scores through both selects, 2 of its 7 decode windows onglm_index_scores; kernel-contract "decode scores" 1 pass with the planted control red, "tf_glm_index_scores" 2 pass, "decode select" 1 pass with the planted control red. glm cuda: decode kernels as dependent launches (carries #3673), +3.7% decode at TP=3, same tokens #3776'szig build check-pdl-loadsin each build's tree: 0 early reads in 201 functions of 9 images, main's and this head's.cuobjdump -sassof the 157 fatbins found in both builds' caches: 2,089 functions, every one the same in both.TP=3 on this head, at the release's settings as below, main against this head: nine fresh starts, 60 s apart. Each binary first timed its own window and draft prices, uncounted; then seven counted runs, main and this head in turn from main, every one kept on main's record, so the binaries differ only in code. The two timed starts named different expert forms (this head classic, main factored), a choice made at load time, and gave the same tokens in every cell, greedy row and cold prompt. By the rule above, no row is slower: every row is within main's range.
tools/fsum.py's exactness checks hold over all nine starts: every cell, greedy row and cold prompt.TP=4 on this head, four boxes in a ring as below, main against this head, on the night to 21 Nov: nine fresh starts, 60 s apart. Each binary first timed its own window and draft prices, uncounted, and both named the factored form; then seven counted runs, main and this head in turn from main, every one kept on main's record. Each start ran the grid of long contexts without drafts and then three drafted reps after the kept 1,040,384-token prompt. Drafted decode is 13.5% faster than main's, in the same 32 rounds and with the same tokens in all nine starts; one of main's 12 reps drafted one token fewer and accepted one fewer (507 and 479 against 508 and 480), and
tools/dsum.pystops on any difference in drafts. By the rule above, one grid cell is slower, 64K at 4 streams (+0.89%, against main's range of 0.28%), and the other eleven are within main's runs or faster; every stream's tokens are the same in every counted run, in all 12 cells. The TP=4 tables are at the top and in the details.TP=2 on this head, at the release's settings as below, main against this head, on the night to 21 Nov: nine fresh starts, 60 s apart. Each binary first timed its own window and draft prices, uncounted, and both named the factored form; then seven counted runs, main and this head in turn from main, every one kept on main's record. By the rule above, no row is slower. One row the gate counts is below main's lowest run and inside the threshold: decode at 4 streams, a stream's tok/s, 17.8, 17.9 and 17.6 against main's 17.8 to 18.0 (+0.74%, against main's range of 1.12%); all streams' tok/s there is +0.04%.
tools/fsum.py's exactness checks hold over all nine starts: every cell, greedy row and cold prompt. The TP=2 and TP=3 tables are at the top, with each run in their details.Receipt for this section: Bizuayeu/TensorFold@5a1bd38fc (
rebase-1120/; its README's last section lists the files and the commands).What this changes
cuda_sparse.selectTokensscores a window's rows against its visible pools before the select. For a decode window (underrows_from, 64, rows) on an aligned key cache, whenSet.dscoreholds the loadedglm_indexkernels andKernels.takesDecode(rows, np, nb, pk, ps)holds (8 rows or more from 64 64-pool blocks, or 4 or more from 2,048), the scores now come fromtf_glm_index_scoresthroughKernels.scoresTilesatdecodeLoop(rows, nb)tiles a CTA, with the grid's second axis in runs of that many tiles; any other window keepstf_glm_scores, and prompt chunks keepTF_GLM_INDEX_CUDA's rule (Kernels.takes).cuda_forward.Modules.dscoreloadsglm_index's scores unlessTF_GLM_DSCORES=0; the setting is a GLM row ofplatform/environment.zig(a flag, default on) with itsdocs/environment.mdrow, so a malformed value is refused by name when the model opens, and aglm_indexthat fails to load warns and keepstf_glm_scores.Why the bytes cannot change: it is the prompt indexer's kernel, which the contract already holds bit-equal to
tf_glm_scores; the tiles a CTA only decide which CTA computes which 64-pool tile, and every tiling writes the same scores. The contract now also runs it at a decode window's tiling, andtf-cuda-test glm-index-checkcomparesselectTokens' scores, pools and token lists byte for byte with the decode scores on.The series, on this head:
5f97b85b81is the port with the switch,ceb9844897registers the decode tiling with the kernel contract (three served decode shapes and a planted control) and makesglm-index-checkcount the windows that take it,65a9e3c4e6fitsdecodeLoopto the rows and blocks (the sweep above), and50c6634539keeps windows under 64 blocks ontf_glm_scores(the bench above), with its host test and the check's count onselectTokens' blocks. Before the rebases they weref3e6f2c4ce,e43dd96cd0,cc457382c9anda4da5a4eb2, the names the earlier checks use; the two CHANGELOG commits are not on this head.Issue: n/a: a byte-identical replacement of a decode kernel's launch, no arithmetic change and no new family or backend.
Related: GLM-5.3-Flash on CUDA: a decode window's DSA select on many CTAs #2722, merged, the decode select these windows' pools then go through.
Stacked on: main (
b0b17e8962, which has glm cuda: decode kernels as dependent launches (carries #3673), +3.7% decode at TP=3, same tokens #3776).atc overlap --json(atc 0.9.4): taken ona4da5a4eb2at 2026-11-17 03:18 UTC,--base e86a0bed1d. It reports a partial check (otherPullRequestsLimit,pullFilesUnavailable,pullRequestsLimit,timeLimit) and names one open pull request sharing files, lfm2_moe CUDA: attention pages from the shared KV pool, and the prompt cache (stacked on #1492) #1503,clean. So I test-merged each open pull request that shares this change's files, by GitHub's file lists of the 452 open at 03:19 UTC (43 of them list 100 files, the most it lists), against that main (3f1290ffe7) and against this change merged onto it (git merge-tree, clean). Of the 157 that share files, 27 merge cleanly either way and 125 conflict with main already, in the same files with and without this change. It adds a conflict to five, each where both sides add lines at one place, and both keep: glm cuda: TF_GLM_GRAPHS=1 replays verify windows as CUDA graphs (#1490) #2279 (TF_GLM_GRAPHS) adds its row beside this one inplatform/environment.zig,docs/environment.mdandcuda_env_test.zig; GLM on CUDA: the latent split's per-rank page book and owner (TF_GLM_KV_SPLIT, #1431 part 1; stacked on #1411) #2415 (TF_GLM_KV_SPLIT, part 1) adds its fields and names to the same lines ofcontract_glm_index.zig'sScores; the three drafts stacked on it (GLM on CUDA: owner-only latent rows and owner-computed attention (TF_GLM_KV_SPLIT, #1431 part 2; stacked on #2415) #2935, GLM on CUDA: the prompt history fetch under the latent split (TF_GLM_KV_SPLIT, #1431 part 3; stacked on #2935) #2937 and GLM on CUDA: kept states, carries and prompt twins under the latent split (TF_GLM_KV_SPLIT, #1431 part 4; stacked on #2937) #2938) meet this change there and indocs/kernel-contract.md's GLM paragraph. Of the 21 opened since and still open, test-merged the same way on333126e749against main9489c38179(11-17), 13 share files by GitHub's lists (glm cuda: decode kernels as dependent launches, +6.8% decode at TP=2, same tokens #3673 lists 100 of its 157, and meets this change in two more): 4 merge cleanly either way, 6 conflict with main already, in the same files with and without this change, and it adds a conflict to three. glm/cuda: TF_GLM_MOE_DIRECT=1 runs a decode window's EXL3 MoE without its row copies and put_slot (for #3570) #3659 (TF_GLM_MOE_DIRECT) adds its row beside this one in those three files and its field and switch besidedscoreincuda_forward.zig'sModules. glm cuda: decode kernels as dependent launches, +6.8% decode at TP=2, same tokens #3673 (the decode kernels as dependent launches) changes the launch call on two lines this change edits:cuda_index.zig's onetf_glm_index_scoreslaunch, where this change passes the tiles a CTA, andcuda_sparse.zig's scores line, where this change adds the decode branch before thetf_glm_scoreslaunch. Both keep; merged, the decode scores take glm cuda: decode kernels as dependent launches, +6.8% decode at TP=2, same tokens #3673's dependent launch with the prompt indexer's. kv classes (#2444 C1): admission by owner class, the owner chosen once inside the reservation #3676 is stacked on GLM on CUDA: the latent split's per-rank page book and owner (TF_GLM_KV_SPLIT, #1431 part 1; stacked on #1411) #2415 and meets this change where GLM on CUDA: the latent split's per-rank page book and owner (TF_GLM_KV_SPLIT, #1431 part 1; stacked on #1411) #2415 does.Checks on the earlier head (
757cb7516d)757cb7516d, on main8cbef9777b: the maintainer's rebase (11-18) of this change's four commits with code. Bygit range-diffits commits65a0e99df4,a39bac485d,fd67ceb1f9and757cb7516dare the same patches asf3e6f2c4ce,e43dd96cd0,cc457382c9anda4da5a4eb2; the two CHANGELOG commits are not on it. The receipts and the checks below were made before the rebase, ona4da5a4eb2on maine86a0bed1d, which "this head" names below; a line made on the rebased head names757cb7516d. TP=4's runs used binaries built fromcc457382c9, the first three commits, and main'se86a0bed1d; TP=2's and TP=3's gate and the TP=3 retake, this head's and main's; the TP=3 sets and the bench in the details,cc457382c9and a local branch with the bench on it. nvcc names its internal symbols afresh on every build, so two builds of one tree differ in bytes: the served binaries are the ones built for these runs, each in an empty global cache (by sha256: this head's native3bfb718d39a304e4,cc457382c9's529d728d99655ee9, main's1cfdb8a0c81eb7c0).python3 tools/pr_check.py --base e86a0bed1d --pr 3689onba21a91a53, the head before the rebase, with the two CHANGELOG commits (12 files): lean 221 problems on main and on this head, 0 new; 0 errors and 0 warnings.git diff --checkpasses.zig fmt --check build.zig zigpasses.zig build test-glm-index-host14 passed (the floor's cases fail on the third commit'stakesDecode: 13 of 14);test-glm-index-emulatepassed;test-environment-host25,test-glm-fp8-kv-host17,test-glm-prompt-profile-host12,test-glm-pages-host13,test-glm-tp3-host9,test-glm-startup-host7,test-glm-contract-host7 andtest-kernel-contract244 passed;check-native-cuda-host(7/7 steps) andcompile-cuda-tests(10/10 steps) pass. The GLM family module's tests with no filter (a local build step): 245 passed, 243 on main. CI's pytest from the root: 520 passed and 86 skipped, as on main, for the same 35 reasons. Merged onto today's main (25de9d70b0,git merge-treeclean; this change and main's 22 commits since sharedocs/environment.mdandplatform/environment.zig): lean 221 on that main and on the merge, 0 new;test-environment-host26,test-glm-index-host14 and the GLM module's 245 passed,check-native-cuda-hostpasses. On the rebased head757cb7516d, in the same WSL: lean 221 on main8cbef9777band on the head, 0 new;zig fmt --check build.zig zigpasses;test-environment-host26,test-glm-index-host14,test-glm-contract-host7,test-kernel-contract247 and the GLM module's 249 passed;test-glm-index-emulate,check-native-cuda-host(7/7 steps) andcompile-cuda-tests(10/10 steps) pass.tf-cuda-test(nvcc 13.3.73):glm-index-checkPASS (scores, pools and token lists byte-equal at 10 cases, tied scores through both selects; the decode select at 7 windows; decode scores onglm_index_scoresat 2 of the 7, the two 16-row windows);kernel-contract "decode scores": 1 pass gates 1-4, 0 fail, 1 known finding, its control red at the shapes gate as planted;kernel-contract "tf_glm_index_scores": 2 pass, 0 fail, 2 known findings;kernel-contract "decode select": 1 pass, its control red as planted.cuobjdump -sassof the 115 fatbins found in both caches, 1,176 functions, every one the same in both (Receipt:sass/).757cb7516d, in the run of 11-18, 5 checks pass (fmt,pytest,zig-windows,zig-macos-dev-tools,release-paths), the twohost-nightlyjobs skipped, and 4 fail, on three tests in files this change doesn't touch.zig(1 of 16,198 tests) andzig-b(1 of 14,375) each fail one ofzig/src/cluster/bringup_test.zig's two real-clock tests, the two that tests: the drafter-auto benchmark test and two cluster bring-up tests stop flaking #3750 moves to a lockstep clock.benchmark-clientson Ubuntu and Windows failstest_bench_cache_agents'test_ttft_starts_at_content_not_headers_role_or_final_usage, a test main gained in99db5bc6fe, three minutes before the rebase; run alone in WSL it passes 20 of 20 times on main's tree and 20 of 20 on757cb7516d's. A second run on the same head, started on 11-19 by closing and reopening this PR, was cancelled by the maintainer after 45 minutes, before any job finished; the checks this page shows are that run's cancelled jobs. Before the rebase, onba21a91a53, 9 checks passed (fmt,zig,zig-b,zig-windows,zig-macos-dev-tools,pytest,benchmark-clientson Ubuntu and Windows,release-paths) and the twohost-nightlyjobs skipped; its pytest's 522 passed, 84 skipped and 616 subtests passed were the counts of main's own run on9489c38179.The earlier base's sets: TP=2, TP=3, the TP=3 retake and TP=4's grid (main `e86a0bed1d`)
In this block, as in the checks above, "this head" is
a4da5a4eb2and "the branch" the third commit,cc457382c9.On this head, at TP=2 and TP=3 at the release's settings, five runs each (main, this change, main, this change, main, each a fresh start), after one uncounted start of this change that timed its own window and draft prices; every counted start of both binaries kept main's record, so the binaries differ only in code (Receipt, below). At TP=2 no row the gate counts is slower. At TP=3 one is, by one stream of one rep: decode at 4 streams, a stream's tok/s, 24.1 and 24.4 against main's 24.4 in all three runs (+0.61%, against main's range of 0.00%). That cell is the median of 12 values (3 reps of 4 streams), rounded to 0.1 tok/s; in this head's first run one stream of one rep decoded at 24.0 (25.1 and 25.3 in its other reps), and the reps' means of their four streams are 24.57 to 25.00 for this head against main's 24.44 to 24.99. All streams' tok/s at 4 streams is 0.09% above main's, and the pooled decode round 0.51% shorter (122.19 ms against 122.81, at 2.939 and 2.931 tokens a round), where the first three commits ran all streams 1.01% to 1.25% below main in three sets and, in the set on main's prices, a round 1.93% longer:
ttft_s(two prompts' mean)ttft_sbench_openai, t=0, code / chat (tok/s)bench_openai, t=1, code / chat (tok/s)ttft_s(two prompts' mean)ttft_sbench_openai, t=0, code / chat (tok/s)bench_openai, t=1, code / chat (tok/s)The rule, set before the runs, calls a row slower when this head's mean loses more than main's range or 0.25%, whichever is larger. The decode, edit and
bench_openaiprompts run 14 to 1,648 tokens with 256 tokens of reply: their windows stay under 64 blocks, so in both binaries they keeptf_glm_scores, and their rows show the rest of the step; the cold rows show the prompt pass. These gates show that this head loses nothing where the new path doesn't run; the gain is at the long contexts of the TP=4 table at the top.Of the rows the gate doesn't count, two are slower by the rule. I read both as run-to-run spread where the new path doesn't run: at these prompts no window takes the new launch, both binaries launch
tf_glm_scoreson the same grid (this head adds one comparison a window), and every run gave the same tokens.bench_openaichat at t=0: 35.9 and 37.7 tok/s against main's 37.0 to 37.3 (+1.14%, against main's range of 0.93%). The row is each run's median of 3 reps. Over the reps, this head's six average 37.01 tok/s and main's nine 37.03; this head's first run's three are 37.8, 35.9 and 35.7, and main's nine run 35.6 to 37.5.bench_openaicode at t=0: 61.1 and 61.7 tok/s against main's 62.9 to 63.9 (+3.14%, against 1.65%). In this set the difference holds through both runs: every rep of both binaries took 83 to 85 rounds, and this head's rounds are longer, 49.46 and 48.85 ms on average (decode time over rounds, from rank 0'sdonelines) against main's 47.58 to 48.39; all six of this head's reps are below eight of main's nine. Across sets, main's twelve runs of this row at TP=3 (these three and the nine of the first three commits' sets, in the details) ran 61.2 to 63.9 tok/s, and the first three commits, which hold all of this head's code but the floor, 62.4 to 64.0 in their six; this head's uncounted start, on its own prices, ran it at 62.8.TP=3's code row at t=0 was then taken again, once, as a set of its own, with its arms, their order and the rule above fixed before it ran (Receipt, below:
tp3-retake/; TP=2's chat row was not taken again). Nine fresh starts: main four times and this head three, alternated, and among them two starts of this head withTF_GLM_DSCORES=0in every rank's environment, not counted. Each ran the cold prompts and thenbench_openai, as in the gate, and stopped there (nobench_concurrent), from the price table the first TP=3 set ended with: all nine kept main's prices, and the table was the same after each start. In this set this head's mean is within main's runs:TF_GLM_DSCORES=0starts, not counted: 62.6 and 62.2 tok/s (+1.58%), below main's lowest run and inside main's range, so not slower by the rule. Their reps took 84 or 85 rounds, averaging 48.34 and 48.70 ms a run, the longest of the nine. Every rank of both logged the switch's warning once; no other start did.token_shaover its reps, the same in all nine starts.TP=2 and TP=3 in run order
ttft_s(two prompts' mean)ttft_sbench_openai, t=0, code / chat (tok/s)bench_openai, t=1, code / chat (tok/s)ttft_s(two prompts' mean)ttft_sbench_openai, t=0, code / chat (tok/s)bench_openai, t=1, code / chat (tok/s)Each set's chain put main's record under both binaries' keys before its counted runs, and each stopped once on its own checks of that step and went on from there. At TP=2 the uncounted start left two new records, its own and the price reference's (that box's table held no reference), where the chain expected one; the five counted runs then ran in a second chain, 16 minutes later, 60 s apart. At TP=3 the chain took the reference's record for main's (both held main's bytes before this head's timed start rewrote the reference): main's first run kept its own record and counted, and this head's next start kept its own prices, so the chain's check of its start-up line stopped it before that run's benchmarks. The other four ran in a second chain 14 minutes after main's first run, with main's own record under this head's key. Each run's edit list (prompts of 768 to 1,648 tokens that copy from their prompt): at TP=2, a stream's tok/s 114.4 and 114.4 against main's 114.6 to 117.5 at one stream, and at 4 streams 22.6 and 23.0 against 22.5 to 22.6; at TP=3, 160.1 and 156.5 against 149.6 to 160.0, and 30.4 and 30.4 against 29.8 to 30.5.
Three cells ran above both of main's runs by more than main's spread: 256K at 8 streams (+0.37%), 1016K at 4 (+0.65%) and at 8 (+0.39%), where main's two runs lie 0.00% to 0.10% apart and the branch's reps 0.66% to 0.80%. These windows are one row, the same kernel in both binaries. Taken again in five more runs (main, the branch, main, the branch, main), 256K and 1016K only:
In these runs the first runs' three cells are within main's three runs (1016K at 4 streams) or above them by less than 0.25% (256K and 1016K at 8). 1016K at one stream is the branch's first run, 30.770 ms, against 30.501 to 30.542 in the other four. The six cells' geometric means: main 51.701, 51.745 and 51.799 ms, the branch 51.856 and 51.771.
Receipt
rebase-1120/.tf_glm_scores.TF_GLM_DSCORES: default 1 (on), accepted 0 or 1, a GLM row indocs/environment.md; any other value is refused when the model opens.50c6634539and mainb0b17e8962; the earlier base's sets,a4da5a4eb2(TP=2, TP=3),cc457382c9(TP=4) and maine86a0bed1d. Each was built for its runs with CUDA 13.3 (nvcc V13.3.73, sm_121) in an empty Zig global cache; Zig 0.17.0; NCCL 2.30.7; NVIDIA GB10 (128 GB unified memory), driver 580.178.04;Bizuayeu/GLM-5.3-Flash-XSFP4at88736f9; the release settings for each size, with drafts MTP and copies and a 1,048,576-token window: TP=2 on two boxes over one cable (split), 4 streams; TP=3 on three in a switchless ring, 8 streams. TP=4: four boxes in a ring (TF_GLM_PREFILL_REDUCE=gather,NCCL_CUMEM_ENABLE=1,TF_GLM_PROMPT_TAIL=1, astools/grid.py's shared prompt resumes only with it), 8 streams.tools/fsum.py): in every celltools/bench_concurrent.py --alone --serial's concurrent replies equal to their requests alone and every alone run equal to"draft": false, each stream onetoken_sha256over the reps and the same in every start;tools/bench_openai.py's greedy rows onetoken_shaover their reps and the same in every start, and its sampled rows (t=1, seeded) agreed as well. The 16 greedy tokens after each of the eight cold prompts: one hash over the nine starts (tools/ccold.py); at each TP, the 126 resumed requeststools/bench_cache.pysends after the cold ones of 8K and more (6,144 to 63,488 tokens cached) each gave its cold request's tokens (tools/cwarm.py). At TP=4, the grid (tools/grid.py): every stream'stoken_shathe same in every counted run, in all 12 cells; the drafted reps: the same 512 tokens in all 27, the two timed starts' included. The earlier base's sets, as before:tools/bench_concurrent.py --alone --serial: every concurrent reply equal to its request alone, and every alone run equal to"draft": false, in every cell of every counted gate run at TP=2 and TP=3.tools/bench_openai.py's greedy rows: onetoken_shaover their reps and the same in every run, the TP=3 retake's nine included; its sampled rows (t=1, seeded) agreed as well. The 16 greedy tokens after each of the eight cold prompts: one hash over the six runs of each TP, the uncounted one included, and over the retake's nine; the two resumed requeststools/bench_cache.pysends after each cold one of 8K and more (8,192 to 63,488 tokens cached) gave the cold request's tokens in every run (84 a TP, and 126 in the retake). TP=4's grids (tools/grid.py): every stream'stoken_shathe same in every run, in all 12 cells of the first runs and the six taken again; the drafted reps: the same 512 tokens in all nine.TF_GLM_DSCORES=0, uncounted).Kernel contract
cuda glm decode scores tf_glm_index_scores on pages out of order(zig/tests/cuda/contract_glm_index.zig, in the GLM index group beside the prompt indexer), a replacement oftf_glm_scoreson the prompt indexer's scores, host rule and checks, launched at a decode window's tiles (glm.index.decodeLoop,cuda_sparse's grid). Served shapes: 8 x 4,096, 16 x 51,200 and 4 x 131,072 pools (2, 4 and 1 tiles a CTA), with up to 8,192 visible pools; the 8-row shape is 64 blocks, the floor.control: GLM decode scores write one tile short, the same launch told it has one 64-pool tile fewer: red at the shapes gate, as planted ((filtered) SUMMARY 1 kernels: 1 pass gates 1-4, 0 fail, 1 known findings; 1 controls: 1 red as planted, 0 missed; 0 limit problems,tf-cuda-test kernel-contract "decode scores"). The known finding is the prompt indexer's (relu isfmaxf(x, 0), as Triton'stl.maximum: a NaN dot scores 0 where float64 keeps the NaN).glm_index'stf_glm_index_scores, already in the records; this change adds no kernel.Checklist
50c6634539on mainb0b17e8962, rebased onto glm cuda: decode kernels as dependent launches (carries #3673), +3.7% decode at TP=3, same tokens #3776, with TP=2, TP=3, TP=4 and the checks taken on it; the earlier head was757cb7516don main8cbef9777b, the maintainer's rebase of the four commits with code; before it the last wasa4da5a4eb2on maine86a0bed1d, whose sets are folded above)takesDecode;glm-index-checkfails when no window takes the decode scores; the device checks build only with-Dnvccand run intf-cuda-teston a GPU)"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (every concurrent reply equals its request alone, and every alone run"draft": false, in every cell of every counted gate run; the resumed requests after each cold prompt of 8K and more give the cold request's tokens; TP=4's grids and drafted reps give main's tokens)tf_glm_scores' bytes; no sums; greedy tokens equal main's)--drafter, no slower than without it, greedy and sampled. (TP=4: drafted decode after 1M tokens 13.5% faster; the grid's one-row windows, which keeptf_glm_scores, within main's runs or faster in 11 of 12 cells, and 64K at 4 streams slower by the rule, +0.89% against main's range of 0.28%, which I read as run-to-run spread where the new path doesn't run, as in the details. TP=2 and TP=3 at one stream and the widest admitted, 4 and 8: no row slower by the rule; at TP=2 one row the gate counts, a stream's tok/s at 4 streams, below main's lowest run and inside the threshold, +0.74% against 1.12%, where all streams' tok/s is level, +0.04%; drafts as the release runs them, MTP and copies, and the change doesn't touch the drafter)This is MiaAI-Lab's patch 0091 (
attn5-0070-glm-decode-index-scores-on-glm-index-scoresin MiaAI-Lab/GLM-5.3-Flash-DGX-Sparks-1104 at0049d7c, Apache-2.0), moved onto the decode select; credit to @MiaAI-Lab for the kernel's decode launch. What I added: the settings-table row, the comments to the lean rules, the contract's decode tiling, served shapes and control,glm-index-check's count, thedecodeLooprule and the floor, each from the bench on GB10.