Query heads

Split rotary heads

×

Partition the rotary features into 128 heads.

[B, T, 8192]  →  [B, 128, T, 64][B,\,T,\,8192]\;\to\;[B,\,128,\,T,\,64]
in
qpeq^{\mathrm{pe}} [B batch, 1 position, 8192 heads × rotary]
out
QpeQ^{\mathrm{pe}} [B batch, 128 heads, 1 position, 64 rotary]
Sources

In codeq.view(bsz, seqlen, self.n_local_heads, self.qk_head_dim)

Open pinned code ↗

Direct evidence

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

model.py 560–564 ↗ · deepseek-ai/DeepSeek-V3.2-Exp @ 87e509a2e5a1

Excerpt
        qr = self.q_norm(self.wq_a(x))
        q = self.wq_b(qr)
        q = q.view(bsz, seqlen, self.n_local_heads, self.qk_head_dim)
        q_nope, q_pe = torch.split(q, [self.qk_nope_head_dim, self.qk_rope_head_dim], dim=-1)
        q_pe = apply_rotary_emb(q_pe, freqs_cis)