Repository navigation
GLM-5.2/GLM-5.3 PR 2: GLM-5.2 with MLA, fp8 MoE and DSA #387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
98 commits
Select commit
Hold shift + click to select a range
a74c56a
engine: MLA, fp8 MoE, step budget, symm all-reduce
vasilevklart e443ade
glm52: GLM-5.2 with MLA and fp8 MoE
vasilevklart d5867ac
glm52: refuse a prompt without room, as a 400
vasilevklart fe290bf
serving_chat: decode text across chunk boundaries
vasilevklart 324ae35
glm52: emit each token's raw bytes
vasilevklart 74eb6a5
attn: MLA wrappers per slot, graph indices per row
vasilevklart b3b31bb
glm52: ask for the MoE op pre-build
vasilevklart 7978911
fused_moe: prefill experts as one custom op
vasilevklart 53448e7
glm52: fail loading loudly, not serve garbage
vasilevklart 2db5679
micro_scheduler: step budget takes the oldest
vasilevklart e34dfac
api_server: TextChatAdapter checks what it passes
vasilevklart 49423a4
fused_moe: decode router takes at most 64 tokens
vasilevklart c3b4b87
glm52: smaller review fixes
vasilevklart 421c683
attn: FlashMLA only for eager MLA plans
vasilevklart 4b2efd2
glm52: refuse a scaled RoPE
vasilevklart 94251af
fused_moe: an empty step skips the align op
vasilevklart f97bcda
test: CI runs the new CPU tests
vasilevklart 42bd26a
distributed: symm all-reduce on every rank or none
vasilevklart 2720d19
glm52: tokenizer registers special tokens
vasilevklart 8cf5b51
cuda_graph_runner: refuse empty/cudagraph modes
vasilevklart 0dedee4
glm52: a prefill stop token ends the reply
vasilevklart 3d0589f
fused_moe: check block scales and inputs
vasilevklart 7fe62b4
glm52: a bad sampling kwarg is a 400
vasilevklart 930abb1
kv: SHM transfer reads an MLA cache by token
vasilevklart ac446e1
glm52: refuse min_p as a 400
vasilevklart b608622
conductor: pre-build the MoE op only when asked
vasilevklart b695608
api_server: TextChatAdapter refuses what it drops
vasilevklart 4f60268
attn: refuse what only the MLA backend reads
vasilevklart 39a27f5
glm52: no max_tokens runs to the window
vasilevklart c3b3848
test: CI runs the new CPU tests
vasilevklart a758aee
cli: mstar serve glm52
vasilevklart 299c824
engine: select TP async scheduling from config
vasilevklart a898a7e
pyproject: glm extra
vasilevklart 15b10a5
api: warmup_requests can repeat their text
vasilevklart 0abdf03
glm52: an oversized top_k or seed is a 400
vasilevklart a707775
worker: tp_async_sched reads boolean words
vasilevklart aaf7ad9
glm52: an oversized max_tokens is a 400
vasilevklart 392f2e8
cuda_graph_runner: empty compile mode env is unset
vasilevklart 7b3ff81
glm52: an out-of-range sampling value is a 400
vasilevklart c12e701
distributed: load timeout ends after warmup
vasilevklart 50a1031
api_server: three more dropped fields are a 400
vasilevklart 126b097
micro_scheduler: drop the step token budget
vasilevklart 454e606
attn: refuse context_only on the backends that don't read it
vasilevklart 603ea45
attn: drop FlashMLA
vasilevklart a4a72f3
cuda_graph_runner: drop MSTAR_GRAPH_COMPILE_MODE
vasilevklart 7331b80
distributed: tp_allreduce and dist_timeout_s from the config only
vasilevklart bc5c827
distributed: all-reduce backends as classes
vasilevklart d08c0c0
distributed: one multimem kernel on every rank
vasilevklart e681819
docs: the MLA attention resource in adding_models
vasilevklart 7bb3b48
distributed: a class per symmetric-memory kernel
vasilevklart 71544d0
Merge main into glm/01-engine
vasilevklart 402f3ff
Merge main into glm/01-engine
vasilevklart 3fc40d8
Merge main into glm/01-engine
vasilevklart 07d96e3
Merge main into glm/01-engine
vasilevklart f6ee3c7
Merge glm/01-engine into glm/02-glm52
vasilevklart 1d55403
glm52: the accelerator graph names from #262, and capture takes #341'…
vasilevklart 825d4aa
test: the GLM-5.2 tests install the CPU FlashInfer per test, not at i…
vasilevklart 838d50d
test: GLM-5.2's attention spec takes #603's AUTO backend
vasilevklart 54be997
pyproject: the glm extra takes main's Mooncake floor
vasilevklart 9e84091
distributed: compiled one-shot all-reduce stays on NCCL
vasilevklart 0c51490
Merge main into glm/01-engine
vasilevklart 1ee5ac9
test: #755's looping worker has the timeout restore warmup ends on
vasilevklart 439000b
Merge glm/01-engine into glm/02-glm52
vasilevklart 752be3c
Merge main into glm/02-glm52
vasilevklart 772dcc4
Merge main into glm/02-glm52
vasilevklart 1f7787e
test: rust-transport lists TextChatAdapter's chat as not ported
vasilevklart af3b6a9
test: the GLM-5.2 serve harnesses stop as the runtime does
vasilevklart 597cce9
glm52: request kwargs through normalize_generation_kwargs
vasilevklart 7d29b6f
glm52: checkpoints resolve through hf_snapshot.resolve_snapshot_dir
vasilevklart 94d8a7a
glm52: a request's token budget and prefill stop in its request_state
vasilevklart be35b96
glm52: positions from a PositionSpec
vasilevklart 56412ed
fp8 block-scale checkpoints in mstar/utils/fp8_block.py
vasilevklart 9af6a39
moe: the noaux_tc router and fp8 expert loaders are shared
vasilevklart 9e692a5
rope: the interleaved fp32 RoPE is shared
vasilevklart caf7008
mla: the shared MLAAttention; GLM-5.2's layer adds DSA
vasilevklart dafc265
glm52: stage host tensors through main's PinnedStager
vasilevklart c3fc4de
dsa: GLM-5.2's DSA as an engine resource
vasilevklart 0bd7748
glm52: drop the unmeasured MoE fused all-reduce switch
vasilevklart 93ed39c
docs: DSASpec in adding_models.rst
vasilevklart 2def934
position: refuse rope_table_dtype widths the CUDA kernel can't rotate
vasilevklart fc97c34
glm52: positions and RoPE from the position resource, softmax_scale f…
vasilevklart 52ec678
Merge main into glm/02-glm52
vasilevklart 2fcc545
dsa: a selecting step's page tables go to the device once, in plan
vasilevklart 540df53
api_server: TextChatAdapter refuses tool calls
vasilevklart 170e8c8
glm52: chat turns in their roles, main's intake checks, batched check…
vasilevklart 4606b4b
Merge main into glm/02-glm52
vasilevklart 952b555
glm52: GLM-5.2 declares its KV layout
vasilevklart fbc9ce1
glm52: no token-budget clamp; the KV pool is the context window
vasilevklart 3488aea
Merge main into glm/02-glm52
vasilevklart 6371189
loader: pread into private buffers, an index for stacked rules (from …
vasilevklart 1c6ac1f
configs: glm52_tp8_longctx points its DSA limits at the resource
vasilevklart 202900e
Merge main into glm/02-glm52
vasilevklart 7aa9eed
Merge main into glm/02-glm52
vasilevklart 5c0b75d
test: the GLM-5.2 layout test asks main's validation checks
vasilevklart 798de5c
Merge main into glm/02-glm52
vasilevklart 5315bf0
Merge main into glm/02-glm52
vasilevklart 1557b04
Merge main into glm/02-glm52
vasilevklart 8945dcf
Merge main into glm/02-glm52
vasilevklart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| model: "glm52" | ||
| # GLM-5.2 on 8 GPUs of 141 GB. The fp8 checkpoint is ~750 GB; routed experts | ||
| # stay fp8-resident, so weights are ~96 GB/rank at TP8. Resolve the | ||
| # checkpoint through the HF cache (HF_HOME) or pass | ||
| # model_kwargs.checkpoint_path. | ||
| # | ||
| # Routed experts run the fused fp8 W8A8 kernel (moe_quant_kernel: auto), which | ||
| # is what lets decode capture. model_kwargs.moe_quant_kernel: reference serves | ||
| # the per-expert dequant loop instead, eager, as the numerics anchor. | ||
| # | ||
| # Without dsa_long_context the context is capped at index_topk (2048), where | ||
| # dense MLA equals the sparse reference exactly; the submodule refuses more. | ||
| # See glm52_tp8_longctx.yaml to serve beyond it. | ||
| max_seq_len: 2048 | ||
| # A 750 GB load outruns PyTorch's default process-group timeout. | ||
| dist_timeout_s: 7200 | ||
| # A request holds at most 16 pages (17 with MTP's verify rows): 64 of them | ||
| # fit the pool below, so a decode step never finds it empty. | ||
| max_concurrent_requests: 64 | ||
| resources: | ||
| kv: | ||
| # MLA latent pages: 576 dims x bf16 = 1.15 KB/token/layer, ~90 KB/token | ||
| # across 78 layers. 1536 x 128-token pages = 196k tokens, ~17.7 GB/rank. | ||
| max_num_pages: 1536 | ||
| page_size: 128 | ||
| node_groups: | ||
| - node_names: [LLM] | ||
| ranks: [0, 1, 2, 3, 4, 5, 6, 7] | ||
| tp_size: 8 | ||
| graph_walks: [prefill, decode] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| model: "glm52" | ||
| # GLM-5.2 TP8 with the DSA long-context path. Same box shape as | ||
| # glm52_tp8.yaml; the difference is the model_kwargs below. | ||
| # | ||
| # dsa_long_context lifts the context <= index_topk (2048) guard to | ||
| # max_seq_len. Indexer layers then keep a per-request k-store outside the | ||
| # paged pool: fp32 on CUDA (k_norm autocasts to fp32), ~10.75 KB/token/rank | ||
| # across the 21 full-attention layers, ~2.1 GB/rank at 24 x 8192 tokens. | ||
| # Decode beyond 2048 runs sparse absorbed attention over each token's | ||
| # top-2048 latents. A request that stays within 2048 runs the dense paged | ||
| # path bit-identically to glm52_tp8.yaml; batched with a longer one it takes | ||
| # the sparse gather instead (fp32, outside the engine's bf16 autocast): same | ||
| # selection, but not bitwise equal to the dense path. | ||
| # | ||
| # Limits, both follow-ups in mstar/engine/resources/dsa/manager.py: prefill prompts must | ||
| # still fit index_topk, and serving is eager only, since the indexer's | ||
| # per-request host work would not replay in a captured graph. | ||
| max_seq_len: 8192 | ||
| dist_timeout_s: 7200 | ||
| # A full-window request holds 64 pages (8191 rows): 24 of them fit the pool | ||
| # below, so a decode step never finds it empty. | ||
| max_concurrent_requests: 24 | ||
| model_kwargs: | ||
| dsa_long_context: true | ||
| # Becomes config.max_seq_len: the guard bound and the KV sizing input. | ||
| # Must stay <= max_num_pages * page_size per rank. | ||
| max_seq_len: 8192 | ||
| resources: | ||
| kv: | ||
| # 24 x 64 pages + the sink page the manager holds back. At 1.15 | ||
| # KB/token/layer, ~17.7 GB/rank. | ||
| max_num_pages: 1537 | ||
| page_size: 128 | ||
| node_groups: | ||
| - node_names: [LLM] | ||
| ranks: [0, 1, 2, 3, 4, 5, 6, 7] | ||
| tp_size: 8 | ||
| graph_walks: [prefill, decode] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| model: "glm52" | ||
| # GLM-5.2 on a single rank, for dummy mode and small-scale development. The | ||
| # real checkpoint is ~750 GB fp8, so production serving is TP8: see | ||
| # configs/glm52_tp8.yaml. | ||
| # | ||
| # max_seq_len here is presence-checked only. The serving ceiling stays | ||
| # Glm52ModelConfig.max_seq_len, and without dsa_long_context the hard limit | ||
| # is index_topk (2048) regardless. | ||
| max_seq_len: 2048 | ||
| model_kwargs: | ||
| # no checkpoint: dummy mode (no submodule is built); the registry's repo id | ||
| # would download all 750 GB and allocate the model on one GPU. Name a | ||
| # checkpoint, or config_variant: reduced with tokenizer_mode: byte, to serve. | ||
| model_path_hf: "" | ||
| node_groups: | ||
| - node_names: [LLM] | ||
| ranks: [0] | ||
| graph_walks: [prefill, decode] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| """What a model declares for DeepSeek sparse attention (DSA): its config, spec and step. | ||
|
|
||
| Kept free of the manager so a submodule can declare a step without importing it. | ||
| """ | ||
|
|
||
| from dataclasses import dataclass | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| from mstar.engine.resources.spec import NodeResourceSpec | ||
| from mstar.engine.resources.step import ResourceStep | ||
|
|
||
| if TYPE_CHECKING: | ||
| from mstar.engine.resources.base import Resource | ||
|
|
||
|
|
||
| @dataclass | ||
| class DSAConfig: | ||
| # the paged MLA cache: a step's rows come from its plan, the attended latents from its pages | ||
| kv_cache: str | ||
| # the keys a query attends once it sees more: its top ``topk`` by the indexer's score | ||
| topk: int | ||
|
|
||
|
|
||
| @dataclass | ||
| class DSASpec(NodeResourceSpec): | ||
|
vasilevklart marked this conversation as resolved.
Resolved
|
||
| config: DSAConfig | ||
|
|
||
| def depends_on(self) -> set[str]: | ||
| return {self.config.kv_cache} | ||
|
|
||
| @property | ||
| def resource_class(self) -> "type[Resource]": | ||
| from mstar.engine.resources.dsa.manager import DSAManager | ||
|
|
||
| return DSAManager | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class DSAStep(ResourceStep): | ||
| pass | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.