Query heads

Checkpoint configuration and implementation zai-org/GLM-5 @ c183ef8, huggingface/transformers @ 5e4d630 · parameter count checked against the checkpoint’s tensor headers · How to read

78 transformer blocks › 75 MoE blocks › Sparse latent attention › Query heads

Split content heads

×

no parametersself.q_b_proj(q_resid).view(query_shape).transpose(1, 2)

Partition the content features into 64 heads.

[B, T, 12288]  →  [B, 64, T, 192][B,\,T,\,12288]\;\to\;[B,\,64,\,T,\,192]
in
qCq^{C} [B batch, T positions, 12288 heads × content]
out
QCQ^{C} [B batch, 64 heads, T positions, 192 content]
Codemodeling_glm_moe_dsa.py 394–396
modeling_glm_moe_dsa.py 394–396
        q_resid = self.q_a_layernorm(self.q_a_proj(hidden_states))
        q_states = self.q_b_proj(q_resid).view(query_shape).transpose(1, 2)
        q_pass, q_rot = torch.split(q_states, [self.qk_nope_head_dim, self.qk_rope_head_dim], dim=-1)
Sources1

Direct evidence

Queries are produced from the normalized query latent and split into a non-rotated and a rotated part.

mla-queries · huggingface/transformers / modeling_glm_moe_dsa.py
Pinned revision 5e4d6304de55 ↗ · lines 394–396

Read code excerpt
        q_resid = self.q_a_layernorm(self.q_a_proj(hidden_states))
        q_states = self.q_b_proj(q_resid).view(query_shape).transpose(1, 2)
        q_pass, q_rot = torch.split(q_states, [self.qk_nope_head_dim, self.qk_rope_head_dim], dim=-1)