Repository navigation
glm cuda: each decode window width keeps its faster expert form - #3249
Conversation
|
Thanks @Bizuayeu. The host tests cover the width mapping, calibration order and saved cost reuse, and they pass. We will run the device check on our side for classic, factored and automatic selection at one and two ranks, including first and cached loads. We will check that both ranks receive the same effective mask, complete tokens match the plain target with each drafter, and decode stays within main's measured range. Startup calibration time will be reported separately.
|
Thanks. One note before that run: this head ( |
|
Thanks @Bizuayeu. The 35 focused host checks pass, and no new code ask is open. We will run the device check on our side for automatic, classic and factored selection at one and two ranks, including first and cached loads. We will carry the reuses() integration forward with #3151 before landing.
|
Thanks. One addition you could carry with it: a record raced by width in #3151's test of var factored = classic;
factored.fact = measurements.every(true);
try std.testing.expect(reuses(factored, false, true) and !reuses(factored, false, false));
// a record raced by width stands for the race alone, not for either named form
var mixed = classic;
mixed.fact = 1;
try std.testing.expect(reuses(mixed, false, null) and !reuses(mixed, false, true) and !reuses(mixed, false, false));On main |
|
Our GB10 check is in: GLM-5.3-Flash NVFP4 at TP=2 on two GB10s, main against bc63491, fresh launches base, new, new, base, plus a chat pair, with automatic expert-form selection.
It now conflicts with main and needs a rebase onto main once #3151 lands (#3151 is in the landing queue). With that rebase and CI green, it's ready to queue.
|
Thanks for the run. I'll do that rebase: once #3151 lands, I'll rebase this onto main with the form check in |
|
Thanks @Bizuayeu. Please go ahead with the rebase once #3151 lands, keeping the full per-width form comparison in Our automatic TP=2 run already matched all 52 cells, resumed cache counts included, and that result stands. With the rebase and green CI it's ready to queue; no one-rank run is needed, since the model can't fit on one GB10.
|
bc63491 to
cd560c8
Compare
Rebased onto main |
|
Thanks @Bizuayeu. Everything we asked on 16 Nov is in:
Our TP=2 GB10 run (tokens equal in all 52 cells, resumed cache counts included) stands. Nothing more from us.
|
Since that comment The resolution is to keep both sides: this PR's One more thing the merge does without a conflict: this PR's The branch is left at |
cd560c8 to
8d60877
Compare
|
Thanks @Bizuayeu. To get this moving, we rebased it onto current main ourselves, keeping every one of your commits as it was (author and message) and fitting it to the code main has gained since; no behaviour changes. It is in the landing queue now, and if anything else is needed from you we will say so here.
|
GLM's load-time race summed the 2-, 4- and 8-row windows and one draft step of its classic and factored NVFP4 expert forms, then ran every decode window on the winner. A sum hides the widths it loses: at TP=4 the factored form wins at 1 and 8 rows but loses at 4 and 6, so four streams without drafts decode about 2% slower than on classic. Both forms give the same bits (the NVFP4 fact contract holds the factored tiles and waves to the decode form's sums), so each window can take either. The race now times both forms at all ten widths, keeps classic at a width unless factored is more than 1% faster there, and prices each width at its kept form's time instead of timing the table again. A window runs on the form of the narrowest timed width that holds it: rank 0 sends the forms as a bit a row count, and the record keeps a bit a width. Records carry the build's hash in their key, so no record of a single-form build is read for its forms. The race sweeps every width five times on both forms, untimed, before it times a window, then each width's timed windows take the two forms in turn, classic first on even rounds and factored first on odd ones. Timed one form after the other, the order picked the form: on four GB10s at TP=4 a log of every run showed classic's narrow widths up to 60% over their later time in a load's first 4 s, and a 4 to 6% drift through the race on one form, so two launches of one build kept different forms at 3, 4, 6 and 12 rows. Five sweeps of both forms take about 5.4 s there. TF_GLM_EXPERT_FORM now names one form for every width: the warm-up sweeps that form ten times and the load times the windows and the draft step at it, and a load that times nothing sends it to every rank for every row count. The startup line names one form when every width shares it, else the more common form and the widths where the other runs (experts factored, classic at 4 and 6 rows).
8d60877 to
976ef04
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. |
What this changes
GLM's CUDA load now races its classic and factored NVFP4 expert forms, which give the same bits, at each of its ten timed window widths and keeps the faster form at each, where it kept one form for every width. This is not a complete fix: where factored's lead at a width sits near the race's 1% margin, two launches of one build can keep different forms there. On four GB10s at TP=4 this receipt's two racing launches did so at 12 and 32 rows (
factored, classic at 3, 4, 6 and 24 rowsandclassic, factored at 1, 2, 8 and 16 rows; across the two records, factored's time there is 1.1 and 1.2% under classic's), and two launches of a diagnostic build of the same race did at 8, 12, 16 and 32 rows. At 8 rows the two forms' decode rounds differ by about 2% in serving (the first table's 8-stream cell below), so a launch that keeps classic there gives that back.TF_GLM_EXPERT_FORM(#3151) names one form for every width when a comparison needs one.Main's race sums the 2-, 4- and 8-row windows and one draft step on each form and runs every decode window on the winner. A sum hides the widths it loses: on TP=4, #3151's receipt timed each form on its own, and against classic, factored's rounds are 4.82% shorter at one stream, 1.67% longer at four and 2.18% shorter at eight. This head times both forms at 1, 2, 3, 4, 6, 8, 12, 16, 24 and 32 rows, keeps classic at a width unless factored is more than 1% faster there, and prices each width at its kept form's time. A window runs on the form of the narrowest timed width that holds it: rank 0 sends the forms to every rank as a bit a row count, and the price record keeps a bit a width. The record's key carries the build's hash, so no single-form build's record is read for its forms.
The race sweeps every width five times on both forms, untimed, before it times a window; then each width's timed windows take the two forms in turn, classic first on even rounds and factored first on odd ones. Timed one form after the other, the order picked the form: on TP=4, a log of every run showed classic's narrow widths up to 60% over their later time in a load's first 4 s, and a 4 to 6% drift through the race on one form. From an empty price cache, this head's two racing loads loaded in 57.9 and 58.1 s, and #3151's head's first launch in #3151's receipt, on the same ring and racing as main does, in 56.7 s; loads that read a record loaded in 43.0 to 43.8 s here.
TF_GLM_EXPERT_FORMnow names one form for every width: the warm-up sweeps that form ten times, the load times the windows and the draft step at it, and a load that times nothing sends it to every rank for every row count. The startup line names one form when every width shares it, else the more common form and the widths where the other runs, as inglm: windows (timed): … experts factored, classic at 4 and 6 rows.On four GB10s at TP=4 (GLM-5.3-Flash XSFP4,
--context 1048576 --parallel 8), round time in ms from our own grid client ("draft": false, greedy, 256 tokens, each launch's median of six reps), lower is faster, two launches each:Here #3151's head raced to classic for every width (
glm: windows (timed): … experts classic), and this head's launches read the second race's record, factored at 1, 2, 8 and 16 rows. Taking a cell as different only where both launch pairs lean the same way by more than the larger of the two builds' launch-to-launch gaps, this head's rounds are 4.87% shorter at one stream and 2.27% shorter at eight, where the forms differ, and at four streams, where both keep classic, the two can't be separated (-0.33%). In #3151's receipt main and #3151's head raced to factored, and against that draw the forms differ at four streams instead, where that receipt timed factored's rounds 1.67% longer than classic's. So the grid ran again: #3151's head withTF_GLM_EXPERT_FORM=factored, which runs factored at every width, and two more launches of this head, which read the second race's record:factorednamedBy the same rule, this head's rounds are 2.70% shorter at four streams, where it keeps classic against factored: #3151's head's two launches there sit 1.5% apart, and every rep of this head's two is under every rep of theirs. At one and eight streams, where both run factored, the two can't be separated (-0.58% and +0.01%). Every launch's replies are the same.
684458101e, its CHANGELOG line9e4363faaaand its test150bea7cc1), and this PR is rebased onto maine7ff97e132: the change (b31a7f4ffc) and its CHANGELOG line (cd560c8079). The rebase conflicted infamilies/glm/cuda_lane_costs.zigalone, in two places, both with glm cuda: TF_GLM_EXPERT_FORM names the expert form, so launches compare at one form #3151's test commit, which was written after this PR's last head.reuses(), which that commit split out ofprice(), carries the condition this PR had there inline, the kept record compared with the named form at every width:measurements.reusable(kept, block) and (pin == null or kept.fact == measurements.every(pin.?)). glm cuda: TF_GLM_EXPERT_FORM names the expert form, so launches compare at one form #3151's test "a record kept at one named form is not reused at the other" stays, its factored record written asmeasurements.every(true), and gains the mixed-record case: a record raced by width (fact = 1) is reused when no form is named and at neither named form. Outside that file the change's added and removed lines aree259495f26's, the head before this rebase. The receipt was taken before the first rebase, from main6c5cef8941, where glm cuda: TF_GLM_EXPERT_FORM names the expert form, so launches compare at one form #3151's head wasb92072b06dand this change4f9832ca00; in the figures above and the receipt below, "this head" means that build. It was not retaken: the reuse condition is the one that build ran, the tests below cover where it now sits, and the automatic TP=2 run onbc6349146dmatched all 52 cells (glm cuda: each decode window width keeps its faster expert form #3249 (comment)). Main has since taken glm cuda: under --mtp-confidence a greedy stream drafts its rates' depth, not fifteen a round #2864, which changes how deep a temperature-0 stream drafts under--mtp-confidence(this receipt runs at 0.5), so on today's main a T=0 stream can draft to other depths and its windows take other widths. Merged with today's main8cbef9777b,git merge-treeis clean, the CHANGELOG lines included.atc overlap --jsonagainst mainaf9777b494, after the CHANGELOG line: its listing shows twenty-seven open pull requests sharing a file with this head, twenty-three of them byCHANGELOG.mdalone, and marks dsv41 metal: image prompts #1722, deepseek_v41: reply logprobs normalize over all TP head columns (#1324) #2125, gemma4 Metal: Gemma 4 E4B (NVIDIA Nemotron 3.5 Bolt E4B) on M1 to M4, per-layer inputs and shared KV #2273, ocr: GLM-OCR reader on /v1/ocr (#2440 step 3) #2572, ocr: POST /ocr in LiteParse's contract (#2440 step 4) #2573, ocr: POST /ocr in docTR's contract (#2440 step 5) #2574 and ocr: POST /ocr in PaddleX's contract (#2440 step 6) #2575 as conflicting.git merge-treeof main, and of main merged with this head, against each of them: all twenty-seven already conflict with main, in the same files and with as many conflict hunks with this head. Of those the listing leaves out, 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) conflicts with main in eight files, with as many hunks with this head, and gains one:families/glm/cuda_follow.zig, where the order's field comments take this head's note on whatacarries for the forms and GLM on CUDA: the latent split's per-rank page book and owner (TF_GLM_KV_SPLIT, #1431 part 1; stacked on #1411) #2415's on whatdepthandflagscarry for its split. It resolves by keeping both sides, so whichever lands second takes the other's lines. qwen3-asr: host slice, the shared tower and Qwen3 schedules over a backend binding (#2105) #2239 conflicts with main inCHANGELOG.md, the same with this head, and qwen27: serve the 27B pair, refuse what a pair cannot keep, and die with the peer #1434 and glm cuda: the L2 prefetch's ffn-head site also reads a MoE layer's shared gate-up, after its router #3156 merge cleanly with both. The listing stops at its limits (complete: false).Tests:
glm_lane_costs_host.zig): "each width keeps the form its windows ran faster on, and classic inside the margin", "a dip is timed again at each width's own form, not the last raced one", "a slow start outlasting the old warm-up decides no width's form and sets no price", "a drift through the race falls on both forms alike", "a window run slow right after the other form decides no width's form" and "a window takes the form of the narrowest timed width that holds it"; and incuda_lane_costs.zig, "a raced line names the more common form and the widths where the other runs".test-glm-lane-costs-host(10 tests) unless named. One form for every width, the more common one, as main keeps: "each width keeps…" (expected 998, found 1023) and "a dip is timed again…" fail. The kept forms not set before the prices are smoothed and the rows sent: the same two. No sweeps: "a slow start…" (actual 36,expected 21). Classic first in every round: "a window run slow right after the other form…" (expected 1023, found 0). Each form's table timed in one block, as main times its forms: "a drift through the race…" (expected 0, found 1023). Every width priced at classic's time: the MTP price test and the three others that read prices. Only the 2-, 4- and 8-row widths raced, as main races: six, the DFlash2 and MTP race tests among them. A window on the widest timed width under it instead of the narrowest that holds it: "a window takes the form…" (expected 8, found 24). The startup line's majority counted at half the widths: only "a raced line names the more common form…" fails, intest-cuda-host(6,365 of 6,396). A copy that ignores the name in four places (as glm cuda: TF_GLM_EXPERT_FORM names the expert form, so launches compare at one form #3151's red copy did, at this head's code) fails exactly glm cuda: TF_GLM_EXPERT_FORM names the expert form, so launches compare at one form #3151's four naming tests intest-cuda-host(6,362 of 6,396) and the named-form test intest-glm-lane-costs-host(9 of 10,expected 1, found 241). On the rebased tree, the GLM cost identity tests (11): with glm cuda: TF_GLM_EXPERT_FORM names the expert form, so launches compare at one form #3151's first check back inreuses(), where a record with any factored width reads as the factored form, only "a record kept at one named form is not reused at the other" fails, at the mixed-record line (10 of 11); as written, 11 of 11.Checks on this head
cd560c8079, the CHANGELOG line on top ofb31a7f4ffc. It changes no code. The gate, the lean checker and the overlap below ran on this head; the receipt ran the change before the first rebase,4f9832ca00.python3 tools/zig/lean_check.py, on the base (e7ff97e132) and on this head: 221 and 221, no new findings. On mainaf9777b494and this head merged with it: 221 and 221, the same findings.zig buildwithtest -Dfixed-cpu,test-kernel-contract,test-golden,test-cuda-host,compile-cuda-tests(x86_64 and aarch64),check-native-cuda-host,test-glm-lane-costs-host,test-glm-window-prices-host,test-glm-fact-contract-host,test-cuda-startup-costs-host,test-glm-startup-hostandtest-glm-link-transport-host:test10,237 of 10,315 with 78 skipped,test-kernel-contract244 of 244,test-glm-lane-costs-host10 of 10.test-cuda-hostfirst ran 7,117 of 7,151 with 33 skipped and one failure, the server'scortheon fuzz: every reader takes linear time on long inputs, a timing test this change does not reach; run again on the same tree the step passed, the test binaries that had not passed running 1,683 of 1,691 with 8 skipped. pytest from the root with the CI's options plus-rs(-q -rs -p no:cacheprovider): 522 passed, 86 skipped and one failure,tools/zig/zig_cache_restat_test.py'stest_prune_keeps_one_build, whose ownzig buildhit its 300 s limit while another build held this machine's one-build-at-a-time lock; run again alone, that file's two tests passed. Main's CI pytest ate7ff97e132has 525 passed and 84 skipped, the same 609 tests, and prints no skip reasons. Two of the skips here aretools/zig/test_nfkd_tables.py's, which want Unicode 16.0.0 (this Python 3.12 has 15.0.0).zig,zig-b,zig-windows,zig-macos-dev-tools,pytest(583 passed, 87 skipped),release-paths, bothbenchmark-clientsjobs andfmtpassed; the two nightly host jobs report skipped.priceinfamilies/glm/cuda_lane_costs.zig), and only GLM's CUDA decode windows read them (cuda_moe.zig).Receipt
factored) and the drafted figures below. Unset, glm cuda: TF_GLM_EXPERT_FORM names the expert form, so launches compare at one form #3151's head races and keeps one form as main does (its own receipt: within 0.1% of main in every cell).TF_GLM_EXPERT_FORM(glm cuda: TF_GLM_EXPERT_FORM names the expert form, so launches compare at one form #3151) now names one form for every width; its row inplatform/environment.ziganddocs/environment.mdsays so.4f9832ca00(the change before the first rebase;e259495f26, rebased once, differs only in context, andb31a7f4ffc, rebased again, only in where the reuse condition sits) and glm cuda: TF_GLM_EXPERT_FORM names the expert form, so launches compare at one form #3151's head before its rebase,b92072b06d, each built from an empty Zig global cache with Zig 0.17.0 andzig build native -Dnvcc=<its nvcc> -Dsm=121in a CUDA 13.3.1 build container; GLM-5.3-Flash XSFP4 at88736f91with its MTP head drafting;--context 1048576 --parallel 8 --mtp-confidence 0.5,TF_KV_SHARE=32, a 14 GiB reserve,TF_GLM_PREFILL_REDUCE=gatherandNCCL_CUMEM_ENABLE=1(the grid addsTF_GLM_PROMPT_TAIL=1), the GPU clock capped at 2,200 MHz. This head raced twice from an empty price cache, the second time after the first's records were moved aside, and its later launches read the second's records; then the grid ran glm cuda: TF_GLM_EXPERT_FORM names the expert form, so launches compare at one form #3151's head, this head, this head and glm cuda: TF_GLM_EXPERT_FORM names the expert form, so launches compare at one form #3151's head, the drafted launches the same, the two loads without draftsfactoredand unset, and last the second grid: glm cuda: TF_GLM_EXPERT_FORM names the expert form, so launches compare at one form #3151's head namingfactored(timing its windows at it), this head, this head and glm cuda: TF_GLM_EXPERT_FORM names the expert form, so launches compare at one form #3151's head namingfactored(reading that record).priceraces the forms by width, and its decode windows, which take each window's form by its rows. Ran on TP=4 GB10s: racing loads and loads that read their record with"draft": falserequests, loads that read the record with drafted requests, and loads without drafts,factorednamed and unset. Without drafts the server runs one-row windows in turn (each load's 4- and 8-stream rounds are 4.03 and 8.08 to 8.09 times its 1-stream round), so those two loads check the named form at one row, where the named load's rounds are 4.8 to 4.9% shorter than the unnamed one's; that a load timing nothing sends it for every row count is the host test's. Not run: this head naming a form on a load that times (drafts on), whose ten sweeps and timing at the named form only the host tests run (the second grid's named loads are glm cuda: TF_GLM_EXPERT_FORM names the expert form, so launches compare at one form #3151's head's); the first racing launch's forms under drafts (every later launch of this head read the second race's record); DFlash2 drafters (the race times every width there too and keeps no prices), TP=2 and TP=3.tools/bench_concurrent.py --alone --serialfinds every concurrent reply equal to the same request alone (78 checks a launch) and to the serial"draft": falsereplies (48 a launch), none failed, and everybench_openaiandbench_concurrentreply hash equals glm cuda: TF_GLM_EXPERT_FORM names the expert form, so launches compare at one form #3151's head's first launch's (12 and 78).tools/bench_openai.py(the median of three 256-token runs) andtools/bench_concurrent.py(a cell's aggregate, the median of three reps; request i sendstools/bench_prompts.json's item i, 256 tokens):bench_openaifibonacci-rawbench_openaigpu-chat-no-thinkbench_concurrent1 streamAt T=0 the four launches draft the same rounds, accepted and drafted tokens. By the same pair rule, this head's
bench_openaigpu-chat-no-think median is 0.87% higher; fibonacci-raw (+0.64%) and the threebench_concurrentcells can't be separated. At eight streams one launch of this head sat at 117.0, every rep of it under every rep of #3151's head's two, and the other at 118.9, over them. At T=1 the drafting differs from launch to launch, so those figures are for the record.cuda_moe.zigsets it only when the pass is not a prompt's), so prompt passes run the same kernels on either build.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (bench_concurrent --alone --serialon the four drafted launches above; the forms reach only decode rows, which give the same bits on either.)--drafter, no slower than without it, greedy and sampled. (Without drafts this head's rounds are 4.87% shorter than glm cuda: TF_GLM_EXPERT_FORM names the expert form, so launches compare at one form #3151's head's at one stream and 2.27% shorter at eight, and the two can't be separated at four; against glm cuda: TF_GLM_EXPERT_FORM names the expert form, so launches compare at one form #3151's head namingfactored, they are 2.70% shorter at four and can't be separated at one and eight. With drafts at T=0 one figure is 0.87% higher and the other four can't be separated; at eight streams one launch of this head sat 1.3% under glm cuda: TF_GLM_EXPERT_FORM names the expert form, so launches compare at one form #3151's head's two, every rep of it under every rep of theirs, and the other above them. The form reaches only decode rows. Where factored's lead at a width sits near the race's margin, two launches can keep different forms there, as the first paragraph says.)