Zenaique

Tying K and V to one projection, what is gained and what is risked?

MCQ·Medium·4.0 · 0·~1 min·Asked atCerebrasSapTuring·Relevant atMeta
Attempt it
TL;DR

Tying K and V halves attention parameters and KV-cache memory, but forces lookup address and content payload to be the same vector, which measurably hurts quality.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine a library where each book's title doubles as its entire contents. To find any book you search by title, which is fine, but every time you find one, the only thing inside is its own title repeated. The library saves a lot of shelf space, but the books are useless because the lookup label and the actual material people want to read are forced to be identical. Real libraries (and real transformers) keep titles separate from book contents so each can be optimized for its own job, finding things versus delivering useful material.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Tying K and V is the most aggressive form of weight sharing inside an attention block: instead of two separate projections producing two separate tensors, you compute one projection and use the result for both the key role (matching against queries) and the value role (delivering content to the weighted sum). The mechanical savings are immediate, half the projection parameters and half the KV cache, and the structural cost is also immediate: the model loses the ability to separate 'how to find me' from 'what to deliver when found'.

The reason this question is interesting is that it sits at a fork in the design tree. One branch (tied K = V) is rarely taken; the other branches (MQA, GQA, MLA) are the production defaults in 2026. Understanding why everyone walks the second branch reveals the right way to think about weight sharing in attention.

This deep dive walks through the mechanical accounting, the gradient signals that pull K and V apart during training, the empirical quality cost of forcing them together, and the alternatives that share intelligently along axes with redundancy rather than along axes with structural distinction.

Mechanical accounting: what tied K = V actually saves

Standard multi-head attention has four projection matrices per layer: W_Q, W_K, W_V, W_O. Each has shape (d_model, d_head * n_heads). For a Llama-style model with d_model = 4096, d_head = 128, n_heads = 32, each matrix has about 16.8M parameters; across a 32-layer model that's 538M per matrix type.

Parameter savings

Tying W_K = W_V eliminates one full matrix. For the example above, that's 538M parameters saved, about 7 percent of a 7B-class model. The relative savings shrink as the model grows because attention is a smaller fraction of total parameters in larger models (FFN dominates).

KV cache savings

The inference-time savings are usually more important than the parameter savings. The KV cache stores K and V for every (layer, head, position):

bytescache=2LHkvdhTb\text{bytes}_{\text{cache}} = 2 \cdot L \cdot H_{kv} \cdot d_h \cdot T \cdot b

Tying K = V means you only store one tensor per slot, dropping the leading factor of 2 to 1. For a 70B-class model with GQA at 8 KV heads, d_head = 128, 80 layers, FP16, the per-token footprint drops from about 327 KB to about 164 KB.

What's NOT saved

The QK^T matmul and the AV matmul both still happen at full size: the cost is in matrix multiplications over tensors of full shape, not in the projections. So tied K = V saves the projection FLOPs but doesn't change attention's O(seq_len^2 * d_head) core cost.

Why K and V want to be different vectors
Empirical quality cost
The right way to share: MQA, GQA, MLA
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
TechniqueWhat's sharedKV-cache savingsQuality cost
Standard MHANothingBaselineBaseline
Tied K = VK and V are the same tensor per head2x1 to 3% perplexity loss
MQAOne KV head for all query headsn_heads-xMeasurable but small
GQAKV heads grouped across query heads (typically 8 groups)4x to 8xNegligible at scale
MLAK and V compressed into shared latent space10x or moreNegligible after kernel tuning

Real products, models, and research that use this idea.

  • Most production transformers (GPT-style decoders, BERT-style encoders, T5 encoder-decoder) keep K and V as distinct projections; tied K = V is rare in published work.
  • Some early on-device transformer designs (MobileBERT variants, some tiny LLMs in 2022-2023) used tied K = V to fit aggressive memory budgets, accepting quality loss.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QWhy does GQA work well but tied K = V doesn't, given both are forms of weight sharing in attention?
A

The two share at different axes. GQA shares across heads, where the model has demonstrable redundancy (many heads learn similar patterns). Tied K = V shares within a head between the address role and the payload role, where the model genuinely needs distinct specialization. Sharing along an axis with redundancy is cheap; sharing along an axis with structural distinction is expensive.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Confusing tied K = V with GQA or MQA. MQA and GQA share K and V across heads while keeping K and V as distinct tensors; tying K = V makes them literally the same vector, a much more aggressive cut.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • What K does in the attention computation versus what V does

  • Exact parameter and memory savings of tying W_K = W_V

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Explain scaled dot product attention.
Short answer·Medium