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, T positions, 16384 heads × content]
out
QCQ^{C} [B batch, 128 heads, T positions, 128 content]

vLLM keeps queries, keys and values token-first, [tokens, heads, …], with the batch’s requests packed along the token axis (mla.py 225); the atlas writes them head-first.

Sources

In codeq.view(-1, heads, self.qk_head_dim)

Open pinned code ↗

Direct evidence

The fused down-projection’s output is split into the query latent and the key–value part; the query latent is normalized, projected up by q_b_proj and viewed as heads of qk_head_dim features, and RoPE rotates each head’s last qk_rope_head_dim features.

mla.py 183–230 ↗ · vllm-project/vllm @ 5df63a7203cd

Excerpt
            qkv_lora = self.fused_qkv_a_proj(hidden_states)[0]
            q_c, kv_lora = qkv_lora.split(
                [self.q_lora_rank, self.kv_lora_rank + self.qk_rope_head_dim],
                dim=-1,
            )
            q_proj_layer = self.q_b_proj
            if not self.fuse_qkv_rmsnorm:
                q_c = self.q_a_layernorm(q_c)
            q_proj_input = q_c

… lines 192–220 omitted …

        q = q_proj_layer(q_proj_input)[0]
        heads = self.num_heads
        if self.dcp_q_replicate:
            heads *= q_proj_layer.group_size
        q = q.view(-1, heads, self.qk_head_dim)

        if self.rotary_emb is not None:
            q[..., self.qk_nope_head_dim :], k_pe = self.rotary_emb(
                positions, q[..., self.qk_nope_head_dim :], k_pe
            )