Query heads

Join query parts

×

Place each head’s content and rotated features side by side.

Q=[QC; QR]{\htmlData{light=output join}{{\htmlClass{vl-stream-q}{Q}}}}=[{\htmlData{light=content content-heads}{{\htmlClass{vl-stream-q}{Q^{C}}}}};\,{\htmlData{light=rotated rotate}{{\htmlClass{vl-stream-q}{Q^{R}}}}}]
in
QCQ^{C} [B batch, 128 heads, T positions, 128 content]QRQ^{R} [B batch, 128 heads, T positions, 64 rotary]
out
QQ [B batch, 128 heads, T positions, 192 content + rotary]

vLLM rotates the rotary part of each head in place, so the head is joined throughout (mla.py 227–230).

Sources

In codeq · mla.py 228

Open pinned code ↗

Direct evidence

On the prefill path kv_b_proj rebuilds each head’s content keys and values from the normalized latent, each head’s key joins its content part and the shared rotary key, and the prefill backend runs attention over the new tokens.

mla_attention.py 3207–3227 ↗ · vllm-project/vllm @ 5df63a7203cd

Excerpt
        kv_nope = self.kv_b_proj(kv_c_normed)[0].view(
            -1, self.num_heads, self.qk_nope_head_dim + self.v_head_dim
        )
        k_nope, v = kv_nope.split([self.qk_nope_head_dim, self.v_head_dim], dim=-1)
        k = self._concat_k_nope_k_pe(k_nope, k_pe)

        if use_fp8_prefill:
            k = k.to(prefill_metadata.q_data_type)
            v = v.to(prefill_metadata.q_data_type)

        output_prefill = prefill_metadata.prefill_backend.run_prefill_new_tokens(
            q=q,
            k=k,
            v=v,
            return_softmax_lse=has_context,
            out=(
                output.view(-1, self.num_heads, self.v_head_dim)
                if output_scale is not None
                else None
            ),
            output_scale=output_scale,