Module attend

Module attend 

Source
Expand description

2026-09-25: GLM-5.3 DSA attention: the launcher for the selected-index NoPE MLA paged decode.

Owner: model-arch (GLM-5.3 DSA). Invariants:

  • decode_attention launches only after DsaDecodePaging::validate passes, the selection has one query row per decoded sequence, and kv_lora_rank equals KERNEL_KV_LORA_DIM.

It consumes what super::select produced: a [q_rows, out_width] i32 row of token ids with -1 holes, and gathers exactly those tokens from the paged FP8 latent cache. dsa_mla_masked_attn is an oracle, not this path (see super::MASKED_ATTN_MAX_KEYS). When the selection row has no duplicates, the gather attends to the same tokens as the reference’s masked attention, whose mask (glm5next_dsa_ref::topk_to_mask) is 0/1 set membership.

§NoPE, and why neither DeepSeek-V4 MLA decode kernel would do

GLM-5.3 is NoPE: the glm5_next config parser refuses qk_rope_head_dim != 0, so the latent is the whole cache token. deepseek-v4-flash/nvfp4/mla_paged_decode.cu declares kv_cache_dim and never reads it (it hardcodes ROPE_DIM 64); mla_paged_decode_fp8.cu in the same directory uses the runtime stride but then overwrites dims 448–511 with rope bytes read past the latent, which under NoPE belong to the next token. Hence a GLM-target kernel with no rope arm.

Structs§

DsaDecodeInputs
2026-09-25: Everything the decode reads, all caller-owned.
DsaDecodePaging
2026-09-25: Paging geometry the decode needs and the selection does not.
Glm5NextDsaDecodeKernel
2026-09-25: The selected-index MLA decode entry point.

Constants§

DSA_DECODE_MODULE
2026-09-25: Module name the DSA decode kernel resolves from. An unlisted .cu takes its file stem, and this one lives in the glm-5.3-flash target.

Functions§

decode_attention
2026-09-25: Launch the selected-index decode. Enqueued on stream, not synchronised.