Repository navigation
glm sp: quantized MoE and MLA gathers on the pair (cold prefill +3.1%, exact) - #347
Conversation
In multi-rank worlds the GLM vision tower sizes its scratch for the processor's whole budget (GlmCapacity::budgets: 120,000 patches, one video temporal group). That is 1.25 GiB held for the life of the process on the encoding rank, and since the KV pool is the minimum across ranks it costs every rank the same number of blocks. The tower only runs between prefill passes, so the scratch now comes from the BufferArena instead. The arena's 15 per-pass members (FP8 activations, router and gate logits, QKV/attention/norm/MoE outputs, SSM and expert intermediates) are carved from one allocation (buffers/lend.rs), and the encoding rank lends that span to the tower: - lend(): device-wide sync, then hand out the span's base. - return_lent(): zero only the borrowed bytes that overlap members decode expects zeroed, then wait on the encode stream. The four members the arena never zeroes sit first in the span, so the borrow's first bytes need no memset. Every encode call site (prefill and the vision cache head) goes through vision_forward_items(). When the span is smaller than the tower's scratch, the factory falls back to a private allocation, which is the old behaviour. total_bytes() accounts for the aligned span. GLM-5.3-Flash FP4-Local, TP=2 on two GB10s, 4x1M profile, util 0.91: the KV pool goes from 116,958-122,639 to 142,988-144,780 blocks (+19%). Vision output is identical to the owned-scratch build (images and a 19K-token video, alone and mixed with text decodes, every token logprob), greedy text and prompt logprobs are identical, and text decode is level. Image TTFT is about 20 ms (0.7%) higher from the sync and memset around each encode. Co-Authored-By: Claude Opus 5.5 <[email protected]>
norm_output is now carved from the arena's per-pass span, which is freed once through its base, so the teardown-order check looks for the span. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The confidence width rule never verified one draft on the pair, because a lone owner's 2-row verify was priced 10.3 ms over its 3-row one. That was the 2026-09-28 sweep of the fused two-row path, which expert TP retired. On SparkGLM 0.3.2 (TP2, prose, ATLAS_DFLASH_FIXED_WIDTH=1, 2026-11-11) a 2-row verify takes 42.0 ms against 47.4 for 3 rows, and 46% of prose steps accept no draft. The pair now prices 2 rows on the same 5.68 ms line, so an unsure block verifies one draft. The chain has not been re-measured and keeps the charge. Verification stays exact at any width. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…line Review: the non-chain branch also serves a single GPU and a pair without expert TP, which still run the fused two-row path the 10.3 ms charge was measured on. The row-line price now needs the pair under expert TP (set at startup with the topology); everything else keeps the charge, and the width tests keep their expectations. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…_PAIR
The four-rank chain gathers a sequence-parallel layer's MoE input as NVFP4
rows + routes (2368 B a row), its KDA input cast and side-projected (4864)
and its MLA input as FP8 block rows + scales (4224) instead of 8192 B of
BF16. The pair was held to BF16 by `sp.ranks > 2` in each of the three, by
the MLA's chain-only `supports_gather_async` check, by b_proj_full being
loaded at TP4 only, and by its 8196-row chunks (4098 rows a part, off the
KDA cast's 128-row scale tile grid). The gathers themselves are
`SpRows::all_gather{,_block}`, which already swap the two parts over the
pair's exchange.
ATLAS_GLM_SP_QUANT_GATHER_PAIR (default 0, in the startup parity table):
1 MoE and MLA gather quantized on the pair; KDA too where a part is
whole 128-row tiles (not on the pair's own 8196-row chunks).
2 also cuts the pair's chunks to 128 rows a rank (8192), as the chain's
are, so KDA layers gather quantized.
Unset, every topology takes the paths it took: the chain's conditions are
the same expressions, and the pair's stay false.
Tests: the switch and gating, the row multiple, the parity table, and both
mock ranks through a seam that gathers staged tensors of other widths in
place of the normed rows (whole, and per block group).
Co-Authored-By: Claude Fable 5.2 <[email protected]>
The row-local steps of the three quantized gathers were checked on the chain's quarters and sixteenths. Add the pair's parts: halves, a half's four seam blocks (1025/1023 rows of a 4098-row half for the MoE), eighths for the KDA cast on the tile grid, and the MLA indexer GEMM with one of two parts set. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Review: under mode 1 a KDA layer gathered quantized whenever a chunk's parts fell on the 128-row tile grid (a 4096- or 8192-row tail), a path the pair's own 8196-row chunks never run. Mode 1 is now MoE and MLA only, and b_proj_full is loaded for the pair only in mode 2. Co-Authored-By: Claude Fable 5.2 <[email protected]>
951e5c9 to
b55c317
Compare
|
Restacked: the four GLM PRs are now one linear stack on main
Pre-push checks on the stack top: fmt, Pair gate on 2× GB10 is running now: GLM-5.3-Flash FP4-Local, the SparkGLM 0.3.2 4x1m spark launch with KV shard at 0.91, each PR's binary against its parent's. Results will follow here. Generated with Devin |
|
@data-angel pair gate for #347: passed. Merging after this comment. Setup: 2× GB10. Fresh builds at exact commits: parent = #346
Mode 1 matches your +3.1% cold prefill and bit-identical output. With the switch unset, 28K TTFT read 8.49 against 8.44 (ranges just disjoint at n=4); 2K/8K/16K and decode are level, and the default path's code is unchanged. We read that as boot noise, recorded here in case it shows up again. Mode 2 wasn't run. On the env-budget ratchet: this adds one switch, so the count goes 1134 → 1135 (budget 1091; main already fails). If mode 1 should become the pair's default, folding it into the profile or a MODEL.toml field would retire the knob. That would be a follow-up PR. Qwen: the 11-11 pair receipt on this patch covers it (KL 0 / 34,245 positions, bench level), so we didn't re-run it. Generated with Devin |
…_GLM_SP_QUANT_GATHER_PAIR PR #347's mode 1 measured bit-exact against mode 0 on the two-rank pair and ~3% faster on cold prefill, so the pair now always takes it; mode 2 was never output-validated and gained nothing, so it is deleted. One fewer env var on the budget. Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
During sequence-parallel prefill the four-rank chain gathers each layer's MoE and MLA inputs in the packed form the receiving rank would compute anyway (NVFP4 rows + routes, FP8 block rows + scales) instead of BF16 rows. The pair was held to BF16 by
sp.ranks > 2checks.Change
ATLAS_GLM_SP_QUANT_GATHER_PAIR(default 0, in the startup parity table):1: the pair gathers MoE and MLA inputs quantized on its own chunks. KDA layers keep the BF16 gather.2: the pair's chunks are also cut to 128 rows a rank, as the chain's are, and KDA layers gather quantized too.Unset, every topology takes the paths it took: the chain's conditions are the same expressions and the pair's stay false.
Result (2x DGX Spark, GLM-5.3-Flash, mode 1)
Tests
Host tests cover the switch, gating, row multiple, parity table and both mock ranks through a seam. GPU tests cover the pair's halves and seam blocks.
cargo test -p spark-model --lib glm_spandstartup_paritypass.Note: this adds one environment switch, so the env budget check may need a maintainer's call.
🤖 Generated with Claude Code