Mix and project

Merge heads

×

Concatenate the heads at each position.

[B, 64, T, 256][B,\,64,\,T,\,256]
→  [B, T, 64, 256]\to\;[B,\,T,\,64,\,256]
→  [B, T, 16384]\to\;[B,\,T,\,16384]
in
OO [B batch, 64 heads, T positions, 256 value]
out
oo [B batch, T positions, 16384 heads × value]
Explanation

Heads are concatenated in order: head ii fills features 256i,…,256i+255{256i},\dots,{256i+255}.

Sources

In codeattn_output.reshape(batch_size, seq_length, -1)

Open pinned code ↗

Direct evidence

Head outputs are flattened and projected back to the model width.

modeling_glm_moe_dsa.py 460–462 ↗ · huggingface/transformers @ 5e4d6304de55

Excerpt
        attn_output = attn_output.reshape(batch_size, seq_length, -1).contiguous()
        attn_output = self.o_proj(attn_output)
        return attn_output, attn_weights, topk_indices