Skip to main content
CookLLM logoCookLLM Docs

Attention Sink

Premium

Why the first token absorbs most attention: the mechanism and cost of this phenomenon, and why eliminating it is deferred to Gated Attention

Get code access

What Remains After GQA

In the previous chapter we saw that GQA compresses the KV cache to 1/4 of MHA, at the cost of a slight quality drop on some tasks. But GQA changes the number of KV heads; it does not touch the mathematical structure of attention itself: it is still softmax, still causal mask, still QKT/dQK^T / \sqrt{d}.

If we take a different angle, bypass the KV cache, and look only at the attention weights, we find a phenomenon that has nothing to do with the number of heads or the number of groups: during inference, the vast majority of attention flows to the first token.

This is Attention Sink. In this chapter we trace it from start to finish on Qwen3-0.6B; and mechanistically, as long as attention is still the combination of softmax + causal, it will appear.

Schematic: what an attention sink looks like
key j (attended position) →query t (attending) ↓012345678012345678sinkattention weighthighlow

Each row is a query, each column a key; under the causal mask a query only sees itself and the keys to its left (dashed cells are masked out). Notice column 0: almost every query puts most of its attention weight there, forming a vertical bright stripe across all queries. That stripe is the attention sink.

This chapter answers three questions:

  1. What does this phenomenon look like, and how extreme is it in the data?
  2. Why does it inevitably appear?
  3. What cost does it leave for the system?

Log in to continue reading

This is premium content. Please log in to access the full article.