Expand description
2026-09-25: GLM-5.3-Flash DSA (DeepSeek Sparse Attention): the kernel handles, the per-layer geometry and its validation.
Owner: model-arch (GLM-5.3 DSA). Invariants:
- A config returned by
Glm5NextDsaConfig::from_confighas passedvalidate:index_topkis a nonzero multiple ofindex_kpool,index_kpoolis at mostKERNEL_MAX_KPOOL,kv_lora_rankequalsKERNEL_KV_LORA_DIM, andlocal_headsis nonzero.
The checkpoint is the one kernels/gb10/glm-5.3-flash/MODEL.toml names
(LibertAIDAI/GLM-5.3-Flash-NVFP4, revision 9e0d74e3). The selection kernels are in
kernels/gb10/common/dsa_indexer.cu, and examples/dsa_indexer_microtest.rs runs them
on a GPU. crate::glm5next_dsa_ref is the CPU reference for the equations.
§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§Checkpoint and kernel facts the code depends on
indexer.k_normis a LayerNorm with a bias.indexer.k_norm.biasis the only norm bias among the checkpoint’s text tensors (crates/model-engine/tests/fixtures/glm53-nvfp4-9e0d74e3-structural.txt).- The pool softmax runs over the pool-slot axis, per channel (
dsa_kpool_compress). - Pooling starts at
first_key. A pool counts only if every one of itsindex_kpoolslots is valid, so a trailing partial pool is not a pool. - NoPE:
qk_rope_head_dimis 0, so there is no rope section and nowkv_a_ropetensor. dsa_expand_selectionwrites -1 over the whole index row before it stores any index, so every slot is written.
Modules§
- attend
- 2026-09-25: GLM-5.3 DSA attention: the launcher for the selected-index NoPE MLA paged decode.
- aux_
state - 2026-09-25: Snapshot and restore of the DSA indexer cache, the part of a GLM-5.3 sequence that a KV-only prefix-cache hit cannot rebuild.
- binding
- 2026-09-25: The tensor contract of one GLM-5.3 DSA block: the 14
self_attntensorsdsa_tensor_specslists, their dtype and unsharded shape, and a verifier. - build
- 2026-09-25: Loading one DSA block for this rank: tensor-parallel sharding plus four load-time weight transforms.
- layer
- 2026-09-25:
Glm5NextDsaLayer, one GLM-5.3 DSA block: the projections, the indexer cache write, token selection and the NoPE MLA gather-attend over the selected tokens. - select
- 2026-09-25: GLM-5.3 DSA token selection: launch geometry, scratch, and the launcher for the selection kernels.
- state
- 2026-09-25: Per-sequence DSA indexer cache: the
k_normed,gateandvalidrows the selector reads. - tp
- 2026-09-25: GLM-5.3-Flash DSA tensor-parallel shard plan: MLA heads sharded, the indexer replicated.
Structs§
- Glm5
Next DsaConfig - 2026-09-25: DSA geometry for one layer, from
ModelConfig. - Glm5
Next DsaKernels - 2026-09-25: The DSA selection kernels, the indexer LayerNorm and the two oracle kernels.
Constants§
- DSA_
MODULE - 2026-09-25: Module name the DSA selection kernels resolve from.
dsa_indexer.cuhas no entry inkernels/gb10/common/KERNEL.toml[modules], so its module is its file stem. - KERNEL_
KV_ LORA_ DIM - 2026-09-25:
#define GLM_KV_LORA_DIMinkernels/gb10/glm-5.3-flash/nvfp4/glm5next_dsa_mla_decode.cu, the latent width the decode kernel is compiled for.Glm5NextDsaConfig::validateandattend::decode_attentionrefuse akv_lora_rankthat differs. - KERNEL_
MAX_ KPOOL - 2026-09-25:
float lg[8]indsa_kpool_compress, the most pool slots the compression kernel holds. The kernel loopss < KP && s < 8, so it would drop slots past 8 without an error; config validation refuses a largerindex_kpoolinstead. - LAYERNORM_
MODULE - 2026-09-25: Module of
nllb_layernorm_bf16, the BF16 LayerNorm with a bias that the indexer’sk_normneeds:kernels/gb10/common/nllb_encoder.cu, named by its file stem. - MASKED_
ATTN_ MAX_ KEYS - 2026-09-25: The most keys
dsa_mla_masked_attntakes: it stages the[S]f32 score row in dynamic shared memory, and4 · S <= 49,152B gives 12,288.