61 transformer blocks › 60 MoE blocks › Latent attention › Causal attention › Mix and project
Merge heads
×no parametersattn_output.reshape(bsz, q_len, self.num_heads * self.v_head_dim)
Concatenate the heads at each position.
- in
- [B batch, 64 heads, T positions, 128 value]
- out
- [B batch, T positions, 8192 heads × value]
Explanation
Heads are concatenated in order: head fills features .
Codemodeling_deepseek.py 848–852
attn_output = attn_output.transpose(1, 2).contiguous()
attn_output = attn_output.reshape(bsz, q_len, self.num_heads * self.v_head_dim)
attn_output = self.o_proj(attn_output)Sources1
Direct evidence
Head outputs are flattened and projected back to the model width.
mla-output · moonshotai/Kimi-K2-Instruct / modeling_deepseek.py
Pinned revision fd1984e2b7a3 ↗ · lines 848–852
Read code excerpt
attn_output = attn_output.transpose(1, 2).contiguous()
attn_output = attn_output.reshape(bsz, q_len, self.num_heads * self.v_head_dim)
attn_output = self.o_proj(attn_output)