Query heads

Split content heads

×

Partition the content features into 128 heads.

[B, T, 16384]  →  [B, 128, T, 128][B,\,T,\,16384]\;\to\;[B,\,128,\,T,\,128]
in
qCq^{C} [B batch, 1 position, 16384 heads × content]
out
QCQ^{C} [B batch, 128 heads, 1 position, 128 content]
Sources

In codeq.view(bsz, q_len, self.num_heads, self.q_head_dim).transpose(1, 2)

Open pinned code ↗

Direct evidence

Queries are produced through a low-rank latent and split into a non-rotated and a rotated part.

modeling_deepseek.py 816–820 ↗ · deepseek-ai/DeepSeek-V2 @ 4461458f186c

Excerpt
        q = self.q_b_proj(self.q_a_layernorm(self.q_a_proj(hidden_states)))
        q = q.view(bsz, q_len, self.num_heads, self.q_head_dim).transpose(1, 2)
        q_nope, q_pe = torch.split(
            q, [self.qk_nope_head_dim, self.qk_rope_head_dim], dim=-1
        )