Expand description
Typed weight binding for the GLM-5.3-Flash KDA attention family.
Every KDA self_attn block in the checkpoint binds through bind_kda_weights, which is
exhaustive and strict: the tensor set must be exactly the 15 names below, every dtype and
shape is asserted, and any unrecognised self_attn.* tensor is a hard error. There is no
“skip what we don’t know” path, silent or otherwise.
§Why this can be strict
The family is structurally uniform. Audited across the checkpoint’s 34 KDA layers:
one distinct (name, dtype, shape) signature, 0 quantisation artefacts, 0 missing
or unexpected tensors — while all 510 tensor hashes are distinct, so the blocks share
structure and nothing else. Layer 45 (MTP) is DSA-shaped, not KDA, and is not bindable
here; classify_attn_block separates the two from the tensor names alone.
§Traps this module exists to make impossible
- The checkpoint stores three conv tensors of rank 3 (
[qkv, 1, kernel]); HF holds one fused depthwise conv. Binding isconcat([q, k, v])in that order, squeezed exactly once. Both the order and the squeeze are silent if wrong — the order because all three have identical shape, the squeeze because[dim, 1, ks]and[dim, ks]share their bytes. A_logis per head and F32;dt_biasis per channel and F32. Everything else is BF16. A loader that “helpfully” casts either to BF16 changes the gate.
Structs§
- KdaBind
Report - Per-layer accounting, so “zero unknown, zero silent skips” is a reported number and not a
claim.
non_attnis counted but deliberately NOT bound — FFN, norms and mHC are other slices. - RawTensor
- One tensor as it sits in the checkpoint: dtype, shape and raw little-endian bytes.
- Tensor
Spec - The 15
self_attntensors a KDA block has — and the complete list of what it may have.
Enums§
- Attn
Block Kind - What kind of attention block a layer’s tensor names describe.
- KdaDtype
- The only two dtypes a KDA block contains.
Constants§
- DSA_
MARKERS - Names that identify a DSA (
deepseek_sparse_attention) block, including the MTP layer. Present so a caller can classify without guessing from the layer index. - KDA_
TENSORS
Traits§
- KdaTensor
Source - A checkpoint slice scoped to ONE decoder layer. Names are layer-relative
(
self_attn.q_proj.weight), so the same binder works for any layer index and any container.
Functions§
- bind_
kda_ weights - Bind one KDA block. Strict: exact tensor set, exact dtypes, exact shapes.
- classify_
attn_ block - Classify from tensor names alone — never from the layer index, and never from
layer_types, which Slice 1 has to strip and rebuild.