Expand description
GLM-5.3-Flash KDA integrated layer (Slice 6 – one layer, no scheduler/cache wiring). GLM-5.3-Flash DSA (DeepSeek Sparse Attention) production surface.
Scoped to LibertAIDAI/GLM-5.3-Flash-NVFP4@9e0d74e3.
The CUDA kernels already exist and are numerically proven against HF 5.16.1 on
real weights — kernels/gb10/common/dsa_indexer.cu, gated by
examples/dsa_indexer_microtest.rs (GATE 4 kpool indexer, GATE 5 NoPE MLA over
the selected tokens). What was missing, and is what this module adds, is the
production surface: kernel resolution and geometry that a real layer can
bind, rather than an example wiring pointers by hand.
The CPU reference in crate::layers::glm5next_dsa_ref stays the source of
truth for the equations. Nothing here re-derives them.
§Shape of the pipeline
k,gate,valid,ape -> kpool_compress -> pool keys/indices/valid
-> index_scores -> [Q, P] scores + candidate validity
-> topk_pools -> [Q, select_k] pool ids
-> expand_selection -> [Q, out_width] token ids (-1 = invalid)
-> NoPE MLA restricted to those tokens§🪤 Traps carried from Slice 8 (do not re-derive)
indexer.k_normis ann.LayerNorm— mean-subtracting, with a bias — not an RMSNorm.indexer.k_norm.biasexisting in the checkpoint is the only tell; every other norm in GLM-5.3 is a bias-free RMSNorm.- The pool softmax runs over the pool-slot axis, per channel, not over
head_dimand not over pools. - Pooling starts at the first valid token, so left padding is skipped rather than pooled.
- A pool counts only if every
kpoolslot is valid — a trailing partial pool is not a pool. - NoPE:
qk_rope_head_dim == 0, so thek_rotslice is zero-width. See therope > 0guards inqwen3_attention— a NoPE checkpoint carries nowkv_a_ropeand leavesrope_thetaunset. - The
-1sentinel destination must be fully written. vLLM’s day-0 GLM bug was atorch.emptytop-k buffer whose tail was never written, so uninitialised memory became “token indices”.
Modules§
- attend
- GLM-5.3 DSA attention — the launcher for the selected-index NoPE MLA paged decode.
- binding
- GLM-5.3 DSA checkpoint binding: the 14
self_attntensors of a DSA block, their expected dtype and shape, and a verifier that fails loudly. - build
- Loading one DSA block: TP sharding plus the three load-time transforms the runtime cannot do per token.
- layer
Glm5NextDsaLayer— the DSA block: NoPE MLA attention over indexer-selected tokens.- select
- GLM-5.3 DSA token selection — the production launcher for the indexer pipeline.
- state
- Per-sequence DSA indexer state — the cache the selector reads every decode step.
- tp
- GLM-5.3 DSA tensor-parallel shard plan — MLA heads sharded, indexer replicated.
Structs§
- Glm5
Next DsaConfig - DSA geometry for one layer, read from the checkpoint config — never defaulted.
- Glm5
Next DsaKernels - Every kernel the DSA path launches.
Constants§
- DSA_
MODULE - Module name the DSA kernels resolve from. Unlisted
.cufiles take their file stem as the module name, sokernels/gb10/common/dsa_indexer.cuisdsa_indexer. - KERNEL_
KV_ LORA_ DIM #define KV_LORA_DIMinkernels/gb10/common/mla_paged_decode{,_fp8}.cu.- KERNEL_
MAX_ KPOOL float lg[8]indsa_kpool_compress— the most pool slots the compression kernel can hold. The kernel loopss < KP && s < 8, so a largerindex_kpoolis silently truncated rather than rejected. Mirrored here so config validation refuses it instead.- LAYERNORM_
MODULE - Module carrying the bias-bearing BF16 LayerNorm the indexer’s
k_normneeds. Lives incommon/, so every target merges it; the name is the.cufile stem. - MASKED_
ATTN_ MAX_ KEYS - 🔴
dsa_mla_masked_attnis an oracle, not a serve path. Resolved from source 2026-08-27; do not re-derive.