Repository navigation
glm cuda: full GLM-5.3 (glm_moe_dsa) at TP=3 with a bf16 cache, drafts, slots and prompt steps - #4900
bjornmonnens wants to merge 17 commits into
Conversation
8b5d393 to
da78731
Compare
da78731 to
58052d1
Compare
…' Config, and its TP shares config_dsa.zig reads a glm_moe_dsa config.json (glm_dsa's parser, reused through a build import) into the CUDA pieces' glm.Config: dsa set, a plain residual (hc 1), pools of one key, the shared indexer layers as a bitset, 576-wide roped latent rows and a 64-dim index rope, and the MTP layer. It refuses shapes the kernels do not take: tied embeddings, rope pairs that are not interleaved, a vocabulary off 128s, a malformed n_shared_experts or a non-boolean flag. Share.of cuts heads one by one, widths in 64s, and EXL3 experts and the vocabulary in 128s; a full GLM-5.3 rank holds no KDA heads. Config.max_layers rises to 96 for its 78 layers and MTP layer; GLM-5.3-Flash's configs and the Metal family's weights keep their 46.
…ual, shared indexer layers, 6144 and 2048 norms cuda_native_dsa registers glm_moe_dsa as an entry of the GLM CUDA engine, and cuda_dsa_load.zig loads its layers under the checkpoint's "model." prefix. Every layer runs on GLM-5.3-Flash's DSA block; the residual is plain: residualAdd after attention and the MLP and rmsnormBy for the site norms, so the hyper-connection kernels are not launched. A shared indexer layer runs no indexer of its own and attends the token lists its indexed layer left in scratch. The GLM norm template gains two widths, tf_glm_rmsnorm_6144 (hidden) and tf_glm_rmsnorm_2048 (q_lora), and SwiGLU runs unclamped. GLM-5.3-Flash's loads, kernels and launches are unchanged.
…ns them as in-process ranks Config.shares is 3 for full GLM-5.3 (0 for GLM-5.3-Flash: one share a rank). Every row-parallel sum adds the three shares' fp32 partials in share order, as Nemotron's do, so a TP=1 server computes TP=3's bytes. At TP=1, cuda_engine_shares.zig loads the other two shares' weights, states and buffers and runs them as in-process ranks over Exchange.local; other rank counts are refused (SharesNotOnRanks). TP=1 refuses KV pages, drafters, vision, packed linears, prompt logprobs, structured output, several prompts in one pass, shared windows and --mtp-confidence (SharesOneRankEach), and kept states (SharesKeepNoStates); a stream's planned bytes count the held shares' states.
…er each; rank 0 holds 9.6 GiB less An EXL3 expert's 2,048 intermediate rows cut at 128-row tiles into parts of 768, 640 and 640 rows. With one cut for every layer, rank 0 held the 768-row part of every MoE layer. Share.moeAt rotates it: layer i's larger part goes to rank (rank + i) mod world, and moeMost sizes the buffers for it. On the 2.75bpw checkpoint rank 0's weights fall from 105.6 to 96.0 GiB. GLM-5.3-Flash keeps one cut for every layer.
…: no index rings or pooled keys, 13% less a token A shared indexer layer reads the token lists its indexed layer chose, so its cache keeps latent rows alone: no index key or gate rings and no pooled keys. The caches' shape moves into cuda_cache_shape.zig (a cache a DSA layer and the MTP layer, the shared ones flagged), which the state arena, the pages and the snapshot layout read. Full GLM-5.3 takes 94.4 KiB a token instead of 108.6. GLM-5.3-Flash has no shared layers, so its layouts are unchanged, as the snapshot layout test pins.
… kernels a launch a width; full GLM-5.3's layers use them The glm-exl3-layer GPU check reads full GLM-5.3 (its config, prefix and rotated cut) and sizes the prompt plan for every slot, the shared expert's included.
…oken lists A paired prompt step's second chunk shared the first's DSA scratch, token lists included, so a shared indexer layer could attend the other chunk's picks: rows its own chunk had not written. Cold prompts past about 6.6K tokens then varied from run to run (TF_KV_POISON=1 turned the reply to NaN from the second shared layer on). A paired chunk now keeps its own token lists and counts, and a shared window's streams pick into their own rows. Both hold only for full GLM-5.3 (Index.apart): GLM-5.3-Flash has no shared layers and keeps one set of lists, as before. On three GB10s, with the prompt cache off: three cold 25K-token prompts gave one reply, drafted and with "draft": false; a copied 1,741-token reply equalled its plain one; two concurrent 8K-token prompts equalled their solo replies.
…e under split prefill Since ashhart#4510 split prefill sends only the peers' partials: rank me's slot of the gathered buffer is unused and its partial stays in place. tf_glm_residual_add_own sums as tf_glm_residual_add does, rank 0 first, with rank me's partial read from own (glm_glue::ranks8own, as tf_glm_hc_post_own).
tf_glm_rmsnorm_6144 (hidden, 8 warps over an 8,192-wide block) and tf_glm_rmsnorm_2048 (q_lora, 4 warps) are new widths of the GLM norm template with no old entrypoint, so each is checked against float64 alone: rows and 64-sums at 1, 70 and 2,048 rows, with the weight read as bf16. Two planted controls launch each width with stride 0, every row reading row 0, and must fail gate 3. nvcc 13.0.88 records on sm_80/86/89/120/121: 58/58/58/48/48 registers at 6144 (32 bytes static), 40/40/40/39/39 at 2048 (16 bytes), measured from the glm_glue image with the build's flags; the same measurement gives rmsnorm_4096's existing record. The runner's GLM norm registrations move into contract_glm_norms.zig's Set, which keeps contract_tests.zig under 600 lines.
The struct Engine.init built to pad KDA inputs and tile the linears after a rank's weights load moves beside the two functions it calls, as cuda_tile.Tiler; the engine and the held shares' loader pass it to cuda_load_owner.finish as before. No behaviour changes; it keeps cuda_engine.zig under 600 lines.
…side the cold chunks The lane host hands a prompt step a row cap (--decode-share's rows beside live decoders) only to a family that declares chunk_invariant. GLM declared none, so a long prompt ran whole 2,048-row cold chunks while the other streams waited. Full GLM-5.3 has no KDA layers, whose chunked scan is why GLM-5.3-Flash's tokens depend on its cuts, so it now takes the cap the way Qwen 3.5 CUDA does (lanes.step_cap): - cuda_prompt_cuts.cappedEnd cuts a step inside its cold chunk on a 128-row grid from the chunk's start, never past the cold cut, so every cold cut still lands and an uncapped step is the cold pass's; cappedRows is every rank's check of such a step. - Leader.chunkCapped sizes a capped step, or the rest of a chunk a capped step began, and sends its rows in the chunk header's flags from bit 2: a capped step's part alone cannot tell 128 rows and the next id from 129 rows at a prompt's end. Engine.cap_rows carries them into prefillChunk for this step alone, as index_split does. - Kept states and resumes stay on cold cuts: an interrupted step past a capped one keeps no state there, since no resume would read it. - The lanes backend declares chunk_invariant for full GLM-5.3 alone; GLM-5.3-Flash steps and validates exactly as before. glm-cap-check (tf-cuda-test) is the device qualification: five prompts, with and without request starts, stepped under changing caps against their cold passes, comparing the first token, the next window's tokens and logits, and every state byte but the index rings: at a pool of one key they hold a step's keys only until pool_keys copies them, and a capped pass rebases them at other rows. On three GB10s at TP=3 it passes with 16 steps inside a cold chunk. Host tests cover the cuts, the declaration and the lane path's cap argument.
…glm-ref-dsa) Full GLM-5.3's bf16 projections take glm_mm at shapes GLM-5.3-Flash never sends, and a decode window's K slices follow (n, k), so each class gets its own float64 reference: q_a and kv_a, q_b, o, the indexer's keys and weights and its q_b, the dense and shared expert gate/up and down, MTP's eh and the head, each at rank 0's and rank 2's TP=3 shares (22 and 21 heads, 704 and 640 shared rows, 51,712 and 51,584 vocabulary rows). A prompt call and decode windows of 1, 4, 17 and 64 rows (1 and 4 for the head) run on the same input rows and are reported apart, each by its worst column. The router check takes the hidden size, so glm-ref keeps 4096 and glm-ref-dsa adds 6144.
The served exactness profile for glm_moe_dsa: drafted against "draft": false, repeat, concurrent at one and two streams against solo, resumed against a cache-off server, the shared refusals, cancel and evict. Its ranks span three nodes, so it runs with --url and --fresh-url against servers started a rank a node.
… TP=1 check reads e.local)
58f2d3d to
5a14547
Compare
|
sm_120 kernel-contract measurement (RTX 5060 Ti, All real gates pass — mla chunks/split/merge, glm_vision vis_qk, vit attention, glm_topk (flat-pick semantics, non-finite logits, deterministic five-run byte-identical), combine_tail. The 4 limit problems are all |
|
Thanks @bjornmonnens. The full-model shape, three-share handling, shared index lists and mixed-width prompt launches are present. The existing Flash branches remain separate, and this head merges cleanly with main. This is ready for an exact comparison, with the BF16 cache. Before landing, please include the checkpoint revision and file digests, the tested head and launch settings, and the full-model token results for drafts, capped prompts, slots and cache restore. The description stops before those results. The posted contract subset is useful, but its four limit failures still need their per-symbol explanation. Please also include a byte comparison for the new own-partial residual path; a float64 bound alone does not establish unchanged FP32 order.
|
…sidual_add byte for byte (NaN in the own slot)
|
The clean trial merge of zig build test-glm-tp3-host test-glm-exl3-host test-glm-exl3-prompt-host test-glm-prompt-settings-host test-glm-formats-host check-native-cuda-host -Dfixed-cpu -j2 --summary allFor the own-partial residual comparison, I compiled the two residual bodies and their rank-sum helpers from Igor Lessio - AIFLOW LABS |
…launch settings, conformance token rows, capped steps, the own-partial residual byte for byte, the contract's four limit records
…nch.md) in place of this machine's wrapper scripts
|
@ashhart, thanks. The head is now Checkpoint, head and launch. Full-model token results (
Capped prompts: in The four limit failures. These are Compiled offline (nvcc 13.0, sm_121, including the 1024 reserved bytes):
The receipt's README has the table per symbol. I've left those records unchanged here. Re-measuring them fits a small Own-partial residual, byte for byte. Performance is outside this pull request. It comes next, each part in a pull request of its own with its quality gate @AIFlowML, thanks for the trial merge and the CPU fixture. The two points you left open are now in the receipt: the |
What this changes
Full GLM-5.3 (
glm_moe_dsa) serves on CUDA as its own family on GLM-5.3-Flash's CUDA pieces, slice (b) of #3063: TP=3 (TP=1 runs the three shares as in-process ranks), a bf16 latent cache, MTP drafts, slots,prefill_stepwith the lane host's row cap, and resumes on the cold cuts. No new copies of Flash's kernels: two new norm widths, a split-prefill form of the residual add, and per-width launches of the existing EXL3 prompt kernels. GLM-5.3-Flash's code paths, kernels and launch arguments are unchanged.mainac79d6db6. 17 commits:77b3fcb61config.json (glm_moe_dsa) as the CUDA pieces'Config, and its TP sharesec904ea4cthe family on the GLM engine: a plain residual, shared indexer layers, 6144 and 2048 norms28f65f44bsums in three shares at TP=1 and TP=3; TP=1 runs them as in-process ranks2ab07c9f5ranks take the larger EXL3 expert part a layer each (rank 0 holds 9.6 GiB less)9ae3a7512shared indexer layers keep latent rows alone: no index rings or pooled keys (13% less a token)f63fd4a19mixed-width experts (2, 3 and 4 bits) take the prompt kernels a launch a widthbcd15a0beshared indexer layers read their own rows' token listsc840ea981the plain residual reads its own partial in place under split prefill2eecca637the 6144 and 2048 norms under the contract8b9782745the engine's load tiler moves tocuda_tile.Tiler(keepscuda_engine.zigunder 600 lines)b56246dd6prompt steps take the lane host's row cap inside the cold chunks (lanes.step_cap)aa9bb4ac7FP64 references per projection class at TP=3 shares (glm-ref-dsa)a4ef4340dconformance profileglm53-cuda5a145476ehost test: the prompt-rows fake engine holds no shares (itse.localwas unset; CI'stest-host-a)f3bed06efglm-ref-dsacompares the own-partial residual with the gathered one byte for byte641f48647the receipt,docs/receipts/glm53-cuda-f3bed06e/(adds that folder alone)428b326a6the receipt's launch as commands, container flags and environment (launch.md)main'schangelog: #NNNN under Unreleasedcommits doatc overlap --json: not run (ATC not installed here). The same check by hand on git 2.56: every open pull request's head (376) test-merged against this branch and againstmainwithgit merge-tree. Conflicts this branch adds against main's: GLM on CUDA: the latent split's per-rank page book and owner (TF_GLM_KV_SPLIT, #1431 part 1; stacked on #1411) #2415 (profile.zig,cuda_dsa_block.zig,cuda_follow.zig,cuda_native.zig,cuda_state.zig), glm cuda: a dense MLP stored bf16 is read as bf16 in any checkpoint, not only an EXL3 one #3680 (cuda_state.zig) and MiMo-V2.6-Flash on CUDA (2x GB10) with DFlash as the drafter #728 (the EXL3 prompt files,profile.zig,cuda_families.zig); 162 others that touch these files already conflict with main. Whichever lands second rebases.Notes for review, against the 2026-11-12 comment:
config_dsa.zigreadsglm_moe_dsainto the existingglm.Config(dsa, hc 1, pool 1, the shared-layer bitset); every layer runs on Flash's MLA, DSA indexer, router, EXL3 expert and page pieces. Flash's KDA and hyper-connection paths are skipped fordsa; a plain residual usesresidualAdd/rmsnormBy.Leader/follow; no scheduler or broadcast of its own. The three shares are summed in share order on every rank count (as Nemotron does), so TP=1 computes TP=3's bytes; TP=1 refuses pages, drafters, vision, packs, prompt logprobs, structured output, batched prompts, shared windows,--mtp-confidenceand kept states. Other rank counts are refused.cuda_prompt_cuts). Full GLM-5.3 has no KDA layers, so it declareschunk_invariant: the lane host's cap (--decode-share) cuts a step inside a cold chunk on a 128-row grid throughlanes.step_cap.end, every cold cut still lands, and kept states stay on cold cuts. The capped step's rows travel in the chunk header (flags from bit 2): a capped part alone cannot tell 128 rows plus the next id from 129 rows at a prompt's end. GLM-5.3-Flash keeps whole cold chunks and declares nochunk_invariant, as before.glm-ref-dsa: every bf16 projection class (q_a + kv_a, q_b, o, the indexer's keys and weights and its q_b, dense and shared gate/up and down, MTP's eh, the head) at rank 0's and rank 2's TP=3 shares onglm_mm, a prompt call and decode windows of 1 to 64 rows on the same input rows, reported apart by worst column; plus the router at 6144.tf_glm_rmsnorm_6144andtf_glm_rmsnorm_2048(registered, FP64 cases, nvcc 13.0 records, a planted control each);tf_exl3_prompt_{gu,down}_m{4,6,8}(the existing prompt kernels at one width a launch, registered as pending like the existingtf_exl3_prompt_gu/_down);tf_glm_residual_add_own(split prefill'stf_glm_residual_addreading rank me's partial in place, astf_glm_hc_post_owndoes; like those two it is not in the contract on main; I can add a case if you want one).What comes next, in the order you set: (c) the conversation states on the core's disk tier (#1411), then (d), one PR each with its quality gate written before any numbers: the FP8 latent cache on the Flash family's E4M3 rows and writers, 4-bit dense projections, and context parallelism once it is compared with the latent split (#2415); the FP4 cache only after FP8 has its data. After those, the speed work, each piece with contract records and FP64 references. For scale only: our own engine on these three Sparks serves 3 streams of 464K tokens with an FP4 cache and 4-bit dense projections, decoding 22 to 35 tok/s; that is the room the follow-ups aim at, not a claim for them.
Checks on this head
428b326a6, onmainac79d6db6; tested implementationf3bed06ef(the receipt below, 2026-11-25). Earlier GPU rows ran on these commits overmain42bbc8e35(f7536bb79); the rebases since met one-line conflicts (profile.zig,cuda_families.zig,CHANGELOG.md, since dropped) and changed no engine code.python3 tools/zig/lean_check.py:main165, this head 165, 0 new.tools/pr_check.py: 0 errors.zig build test-cuda-host compile-cuda-tests: 9,003 tests, 8,961 passed, 42 skipped, 0 failed; one step does not compile on that x86 machine (a clang warning about its GCC install inwindow_fallback_shim.c, untouched here). The GPU binaries were built on GB10 with nvcc 13.0.88 (Zig 0.17.0).zig build -Dgpu=spark -Dnvcc=/usr/local/cuda/bin/nvcc -Doptimize=fast: builds.glm-cap-check(new, TP=3, full model, onf3bed06ef): 5 prompts with and without request starts, stepped under changing caps (16 steps ending inside a cold chunk) against their cold passes: first token, the next window's logits and tokens, and every state byte but the index rings' equal.glm-ref-dsa(new, one GB10, onf3bed06ef): 11 classes at both shares and the router at 6144, worst column at 0.714 of its float64 tolerance; andtf_glm_residual_add_ownagainsttf_glm_residual_addbyte for byte, NaN in the rank's own gathered slot: 40 cases (worlds 2 and 3, every rank, 1 to 1,024 rows, widths 6144 and 2048), the same bytes, so split prefill's FP32 sum keeps its order.tools/conformance.py tools/conformance_profiles/glm53-cuda.jsononf3bed06ef, BF16 cache (cache-off and cached servers one after the other on the same three Sparks): 7 passed, 0 failed, 0 skipped. drafted == plain 10/10 (401 of 683 drafts accepted), repeat 10/10, concurrent == solo 28/28 (levels 1 and 2, drafted and plain, 16 with a long prompt among decoders), resumed == fresh 6/6 (4,096 cached each), refusals 4/4, cancel 4/4, evict 3/3. Every request's token sha256 is in the receipt'srecords/conformance.json(103 rows).--drafter(DFlash2) not run, MTP drafts only.Receipt
Receipt folder:
docs/receipts/glm53-cuda-f3bed06e/(testedf3bed06ef, 2026-11-25): the checkpoint's revision and every one of its 146 files' sha256 (the same on all three hosts), both binaries' sha256, every launch command, container flag and environment variable, the conformance receipt with each request's token sha256, and theglm-cap-check,glm-ref-dsaand contract logs. Machine names and addresses are placeholders; values and hashes are as written.Main against branch: GLM-5.3-Flash EXL3 4bpw at TP=2 on two DGX Spark (GB10), greedy,
main42bbc8e35against these commits on it: the same 8 greedy replies (4 solo, 2 long prompts of about 9k and 22k tokens, 2 paired);bench_cache.py --require-cold, 16,384-token prompt: sametoken_sha(b59261eacf82), coldttft_s11.31 s on main, 11.28 s on the branch;bench_openai.py --tokens 256 --reps 5 --temperatures 0, median decode tok/s:Within run-to-run spread (the branch's runs 51.5 to 64.7 and 26.3 to 29.9; main's 63.7 to 65.2 and 23.7 to 28.6).
Boxes it reaches: CUDA GLM-5.3-Flash (unchanged paths); CUDA full GLM-5.3 (new).
New switch? None. Full GLM-5.3 takes the existing
--decode-sharecap throughchunk_invariant.Environment: Zig 0.17.0; CUDA 13.0 (nvcc 13.0.88); 3× DGX Spark, NVIDIA GB10 (sm_121), Linux aarch64, 200G RoCE between them;
Mia-AiLab/GLM-5.3-EXL3-2.75bpw-TensorFoldrevision2d747d0e30eca6e3fe37ba63c471cdf9172faa83(bf16 dense, mixed 2/3/4-bit experts, MTP layer).Paths and platforms the change reaches: CUDA only. Ran on sm_121.
Exactness: the conformance gates above; TP=1 against TP=3; capped against cold passes.
Full GLM-5.3, bf16 cache, TP=3,
--parallel 2,--context 102400, MTP drafts on:bench_openai.py --tokens 256 --reps 5 --temperatures 0median decode: fibonacci-raw 20.1 tok/s, gpu-chat-no-think 18.0 tok/s;bench_cache.py --require-cold, 16,384-token prompt: coldttft_s32.7 s (about 500 tok/s); a 99,968-token needle prompt read in 209.8 s (477 tok/s) and answered; two streams decode 28.9 tok/s together.Licence of any new weights or drafter: n/a.
Kernel contract
tf_glm_rmsnorm_6144andtf_glm_rmsnorm_2048(new widths of the GLM norm template, no old entrypoint) against float64, rows and 64-sums at 1, 70 and 2,048 rows. nvcc 13.0 records: 6144 58/58/58/48/48 registers (32 bytes static), 2048 40/40/40/39/39 (16 bytes), sm_80/86/89/120/121.SUMMARYon GB10 (sm_121),kernel-contract glm mla, onf3bed06ef: 62 kernels pass gates 1-4, 0 fail, 5 known findings; 15 controls red as planted, 0 missed; 4 limit problems, the same four asmainon the same machine and as the sm_120 run posted below:tf_ctl_glm_old_rmsnorm_512,_1536,_4096andtf_ctl_glm_old_hc_finish, live static shared 128 bytes against recorded 16, 16, 32 and 48 (registers equal). The records match the source; since542deb953thecontract_controlsimage also holdsflashnext_hcn.cuh, whoseextern __shared__ __align__(128)makes nvcc pad every kernel's static block of that image to 128 bytes (shown offline: 1040/1040/1056/1072 bytes alone, 1152 with that header, 1152 with one__align__(128)declaration, 1088 for_4096with__align__(64)). The receipt's README has the table. Those records aremain's; this pull request leaves them as they are.kernel-contract-limitsover sm_80/86/89/120/121 images: againstmain's the only new stale records are the sixtf_exl3_prompt_*_m*launches, pending like main'stf_exl3_prompt_gu/_down.Checklist
The title and description match the head commit, including the receipt and the stack.
New tests fail before the change, pass after it, and skip cleanly without their dependency.
Comments and docstrings are one line. No measurements or history in the source.
No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
Drafted output equals
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.No precision traded for speed. If the bits change, the description says which sums change and why.
Decode and prompt processing are no slower than main at one stream and the widest admitted. (GLM-5.3-Flash at
--parallel 2, no drafter.)