Expand description
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.
Owner: model-arch (GLM-5.3 DSA). Invariants:
decode_kfails before its first launch when the indexer cache is behind the sequence (len < seq_len) orkis 0 or above the workspace’smax_rows. An indexer cache ahead of the sequence is rewound toseq_lenfirst.indexer_forwardchecks that the indexer cache has room (ensure_room) before it writes.
Decode, end to end:
hidden ─┬─ q_a_proj ─ RMSNorm ─┬─ q_absorb ────────────── Q (latent space)
│ └─ indexer.wq_b ────────── q_idx ─┐
├─ indexer.wk ─ LayerNorm(w,b) ─ state.k_normed ──────────┤
├─ compress_gate ─────────────── state.gate ──────────────┼─ select_tokens
├─ weights_proj ──────────────── head weights ────────────┘ │
└─ kv_a_proj ─ RMSNorm ─ FP8 ─── paged latent cache │
▼
glm5next_dsa_mla_decode_fp8 (gather)§Kernel choices the shapes do not check
- The norms use
rms_norm_vanilla,x * rms * w. Therms_normkernel (modulenorm) computesx * rms * (1 + w)with the same signature. indexer.k_normis a LayerNorm with a bias:nllb_layernorm_bf16(x, w, b, …).weights_projcarriesindex_heads^-0.5from load (Glm5NextDsaWeights), becausedsa_index_scoresdoes not apply it.- Q reaches the decode kernel as
q_absorb:q_b_projmultiplied throughkv_b_proj’s K half, so it is in thekv_lora_rank-wide latent space the kernel dots against. The rawq_b_projisqk_head_dim(256) per head.
Structs§
- Glm5
Next DsaLayer - Glm5
Next DsaLayer Kernels - 2026-09-25: The projection, norm and latent-write kernels of a DSA block. The selection
kernels are in
Glm5NextDsaKernels, the decode kernel inattend. - Glm5
Next DsaWeights - 2026-09-25: One DSA block’s weights on the device, already sharded for this rank.
- Glm5
Next DsaWorkspace - 2026-09-25: Scratch reused across
decode_kcalls; each layer owns one.