Expand description
GLM-5.3-Flash KDA attention block — the reusable production component.
One Glm5NextKdaLayer is a fully bound KDA self_attn block. Any of the checkpoint’s
34 KDA layers instantiates through the same path; the family is structurally uniform
(one distinct name/shape/dtype signature across all 34 — see binding).
q|k|v_proj -> pack -> conv1d + SiLU -> L2(q,k only) -> kda_gate / sigmoid(b_proj)
-> kda_chunk (prefill) | kda_recurrent (decode)
-> sigmoid-gated RMSNorm(o_norm, g_b(g_a(h))) -> o_projScope: the attention block only. No DSA/MLA, no MoE/dense FFN, no mHC hyper-connection, no scheduler or cache integration. The model is not loadable on this alone.
§Facts this component encodes (proven, do not re-derive)
- Nothing in a KDA block is quantised. All 15
self_attntensors are BF16 exceptA_loganddt_bias, which are F32 — verified across all 34 blocks, 0 artefacts. There is no NVFP4 dequant and no NVFP4 GEMM anywhere on this path, so a real-checkpoint KDA oracle is the production numerics. - 🪤 The checkpoint SPLITS the conv; HF FUSES it. HF holds one depthwise
nn.Conv1d(conv_dim); the checkpoint storesq_conv1d/k_conv1d/v_conv1d, each[qkv, 1, kernel]. Binding isconcat([q, k, v], dim=0)in that order — the same order asmixed_qkv = cat([q_proj, k_proj, v_proj]). Reordering is silent. - 🪤
squeeze(1)is a shape-only fix.[dim, 1, ks]and[dim, ks]have identical row-major bytes, so nothing moves — but a loader trustingshape.len() == 2rejects the tensor outright.bindingasserts rank 3 and squeezes exactly once. - 🪤
o_normis ADAPT, not REUSE. Every Atlas gated RMSNorm applies SiLU to the gate (kernels/gb10/common/rms_norm.cu); GLM’sGlm5NextTextRMSNormGatedsetsactivation = "sigmoid". Shapes, dtypes and launch geometry all agree, which is why it was first mis-classified. Hencekda_o_norm_gated_*inkernels/gb10/common/kda_layer_ops.cu. - 🪤
dense_gemm_bf16writesC[row * N + col]— its output row stride isNand there is no caller-supplied output stride, so the three q/k/v projections cannot be aimed at offsets inside one[T, 3*qkv]buffer. They would overwrite each other forT > 1, while being silently correct atT = 1. Hence the separate parts buffer pluskda_pack_qkv_bf16. - Conv state widths differ. HF keeps
kernel - 1slots, Atlas keepskerneland shifts left before convolving, soHF[0..k-1] == Atlas[1..k]and Atlas slot 0 is a don’t-care. - Decode conv fuses L2; prefill does not and needs a separate
l2_norm_bf16over q|k. q/k are normalised exactly once; V never. - The recurrent state is FP32 by reference semantics, not Atlas policy — HF stores it via
.to(torch.float32)and vLLM’skda_state_dtypehardcodes fp32.
Modules§
- binding
- Typed weight binding for the GLM-5.3-Flash KDA attention family.
- tp
- GLM-5.3 KDA tensor-parallel shard plan — head-parallel, one all-reduce.
- tp_bind
- Applying the TP plan: the shard copies, as an upstream adapter so the binder is untouched.
Applying
super::tp::KdaTpPlan— the shard COPIES, at last.
Structs§
- Glm5
Next KdaConfig - Geometry and the config values that MUST be read from the checkpoint.
- Glm5
Next KdaKernels - Glm5
Next KdaLayer - One bound KDA attention block.
- Glm5
Next KdaWeights - One KDA block’s device weights. Torch
Linearlayout[out, in], BF16, except the two F32 gate parameters. There is noZtensor — the output gate is low-rankg_a/g_b. - Glm5
Next KdaWorkspace - Scratch owned by the forward path. Sized once for
max_tokensand reused across layers — the whole KDA family shares one workspace because every block has identical geometry. - KdaSeq
State - The per-sequence state a KDA layer carries. Both buffers are read-modify-write.
Constants§
- SMEM_
CEILING - Dynamic shared memory available with no
cuFuncSetAttributeopt-in inAtlasCudaBackend. GB10 reportssharedMemPerBlockOptin = 101376, real but unreachable from Atlas today.