Simple Algorithm
Deep Learning · Emergence · 26 min

Attention Sinks & Massive Activations

Why models park attention on the first token, and the outliers this creates.

Open the attention maps of almost any trained language model and many heads put most of their weight on the first token, whatever that token is. Evict it from the cache and generation falls apart. The same models carry a handful of activations thousands of times larger than the rest, and those break naive quantization. Both turn out to be one mechanism: softmax heads that need a way to do nothing.

What you’ll learn

  • Explain why a softmax head that should leave its token unchanged must still place its weight somewhere, and prove that a sink with a zero value is equivalent to an extra logit in the softmax denominator.
  • Describe the streaming failure of window attention and why keeping a few initial tokens, or training a dedicated sink, repairs it.
  • Describe massive activations and outlier features, show how a single huge coordinate makes a token's key and value nearly input-independent under normalization, and explain why such outliers break 8-bit quantization.
  • Compare the fixes (sink logits, explicit attention biases, clipped softmax, gated attention, output gating, registers) and weigh the evidence on when sinks emerge and whether they help or hurt.

Every row must sum to one

In BERT, Clark et al. (2019) found that a large share of attention lands on the separator token [SEP] and argued that heads use it as a "no-op". Kobayashi et al. (2020) then measured what attention actually writes, the weight times the norm of the transformed value, and found that the tokens receiving the most weight, such as [SEP] and periods, contribute vectors of small norm. In decoder language models the role is taken by the first token: an attention sink.

The reason is the softmax. Every row of attention weights sums to 11, so the output of a head is always a convex combination of value vectors. A head whose pattern is irrelevant for the current token cannot output "nothing" unless some token offers a value near zero and receives almost all the weight.

DerivationProof, and what it costs
  1. z=eσs 0+∑jeσjvjeσs+∑jeσj=∑jeσjvjeσs+∑jeσj\mathbf z=\frac{e^{\sigma_s}\,\mathbf 0+\sum_je^{\sigma_j}\mathbf v_j}{e^{\sigma_s}+\sum_je^{\sigma_j}}=\frac{\sum_je^{\sigma_j}\mathbf v_j}{e^{\sigma_s}+\sum_je^{\sigma_j}}

    Write out the softmax over the sink and the real tokens; the sink's term drops out of the numerator because its value is zero:

  2. σs=0:softmax⁡1(σ)j=eσj1+∑leσl\sigma_s=0:\quad\operatorname{softmax}_1(\boldsymbol\sigma)_j=\frac{e^{\sigma_j}}{1+\sum_le^{\sigma_l}}

    With σs=0\sigma_s=0 this is the "softmax plus one" proposed as a fix (below). Fixing the real scores and moving σs\sigma_s from −∞-\infty to +∞+\infty moves the real tokens' total weight continuously from 11 to 00.

  3. σs−σmax⁡ ≥ ln⁡(T−1)(1−ε)εe.g. T=1000, ε=0.01:  gap≥11.5\sigma_s-\sigma_{\max}\ \ge\ \ln\frac{(T-1)(1-\varepsilon)}{\varepsilon}\qquad\text{e.g. }T=1000,\ \varepsilon=0.01:\ \ \text{gap}\ge11.5

    The price is a large score gap. To guarantee weight 1−ε1-\varepsilon on the sink against T−1T-1 real tokens whose scores may all reach σmax⁡\sigma_{\max} (the worst case), the gap must satisfy the inequality below, which grows with the context length and with the precision demanded. A head that must be "off" reliably needs logits several units apart, and that has to come from somewhere in the activations.

Predict before you look

A head scores the first token at 88 and each of 99 other tokens at 00. What fraction of its attention, in percent, goes to the first token?

Show the answer

96.8 %

e8/(e8+99)=2981/3080≈0.968e^8/(e^8+99)=2981/3080\approx0.968. With 999 other tokens the same gap gives only e8/(e8+999)≈75%e^8/(e^8+999)\approx75\%: keeping a sink dominant as the context grows needs a gap growing like ln⁡T\ln T.

Streaming breaks without the sink

Xiao, Tian, Chen, Han and Lewis (2024) met the sink while trying to stream: generate indefinitely with a fixed-size KV cache. Keeping only the most recent WW tokens (window attention) works until the first tokens are evicted, and then perplexity jumps from normal values into the thousands. Recomputing the window from scratch for every new token works but is slow. Their fix, StreamingLLM, keeps the keys and values of the first few tokens permanently, plus a rolling window:

text
STREAMING-KV-CACHE(sinks = 4, window = W)
  on each new token t:
      append (k_t, v_t) to the cache
      if cache length > sinks + W:
          evict the oldest entry that is not one of the first 'sinks' tokens
  attention for token t reads: the first 4 tokens  +  the last W tokens

Four initial tokens sufficed for the models they tested (Llama-2, MPT, Falcon and Pythia), which then modeled up to 4 million tokens stably, up to 22.2× faster than recomputing a sliding window.

Why the first tokens? Under a causal mask they are visible to every later token, so they are the natural place for heads to learn to park their weight, whatever their content. Evicting them removes the sink: the weight it absorbed is redistributed over the remaining tokens, and every head that was "off" now writes a blend of real values into the residual stream.

The authors also pre-trained 160-million-parameter models with one extra learnable token at the start of every sequence. That single dedicated sink was enough for streaming. Adding an extra zero logit instead ("Zero Sink", the softmax-plus-one above) helped only partly: the models still recruited initial tokens as sinks.

Check your understanding

In window attention the evicted first token carried almost no meaning. Why does losing it still wreck generation?

  1. Its embedding stored the model's knowledge of the prompt's topic
  2. The positional encodings of the remaining tokens shift and become invalid
  3. Heads that parked their weight on it must now spread that weight over real tokens, so their outputs change everywhere
  4. The causal mask needs the first token to be present
Show the answer

C. Heads that parked their weight on it must now spread that weight over real tokens, so their outputs change everywhere

Rows still sum to one. With the sink gone, a head that was effectively off writes a convex combination of real values, perturbing every later layer. A dedicated sink token, kept permanently, restores the behavior.

Massive activations

Sun, Chen, Kolter and Liu (2024) found the other half of the mechanism in the residual stream. A massive activation is a coordinate of a hidden state up to about 100,000100{,}000 times larger than typical. In LLaMA2-7B the largest is about 2,6222{,}622 against a median magnitude of about 0.20.2, always in the same two feature dimensions, and only at the starting token and at the first period or newline. The values appear abruptly around layer 2 and stay nearly constant through most of the network.

Two interventions show what they are for. Setting them to zero makes perplexity explode; setting them to their mean values leaves it essentially unchanged. They act as fixed biases, not as information about the input. In the deeper layers, attention concentrates on exactly the tokens that carry them, and a GPT-2 trained with an explicit learnable key and value slot in every attention layer matched the original's performance without developing massive activations at all.

DerivationHow one huge coordinate makes a content-free sink
  1. RMSNorm⁡(h)≈d γmsign⁡(μ) em+O(d ∥h−m∥∣μ∣)\operatorname{RMSNorm}(\mathbf h)\approx\sqrt d\,\gamma_m\sign(\mu)\,\mathbf e_m+\order{\frac{\sqrt d\,\norm{\mathbf h_{-m}}}{\abs\mu}}

    Pre-norm blocks feed each sublayer RMSNorm⁡(h)i=γihi/1d∑lhl2\operatorname{RMSNorm}(\mathbf h)_i=\gamma_ih_i\big/\sqrt{\tfrac1d\sum_lh_l^2}. Suppose one coordinate hm=μh_m=\mu dwarfs the rest, μ2≫∑l≠mhl2\mu^2\gg\sum_{l\ne m}h_l^2. Then the normalizer is about ∣μ∣/d\abs\mu/\sqrt d and

  2. cos⁡∠(h,u)=25572+1507225572+15072+4094×12≈0.9998\cos\angle\big(\mathbf h,\mathbf u\big)=\frac{\sqrt{2557^2+1507^2}}{\sqrt{2557^2+1507^2+4094\times1^2}}\approx0.9998

    The normalized input is nearly the same vector whatever else the token contains, so its key ks=WK⊤RMSNorm⁡(h)\mathbf k_s=W_K^\top\operatorname{RMSNorm}(\mathbf h) and value are nearly constant across inputs. A few massive coordinates act the same way. In LLaMA2-7B the starting token carries two, about 2,5572{,}557 and −1,507-1{,}507 on average, varying across inputs by only about 141141 and 8383 (one standard deviation; Sun et al., 2024). Even if the other 4,0944{,}094 coordinates had root mean square 11, five times their median magnitude, the hidden state would stay within cosine 0.99980.9998 of the direction u\mathbf u of its two massive coordinates:

  3. fixed ks,  qt⋅ks≫qt⋅kj,  ∥WO⊤vs∥≈0⟹head≈off\text{fixed }\mathbf k_s,\ \ \mathbf q_t\cdot\mathbf k_s\gg\mathbf q_t\cdot\mathbf k_j,\ \ \norm{W_O^\top\mathbf v_s}\approx0\quad\Longrightarrow\quad\text{head}\approx\text{off}

    A fixed key that every query scores highly, with a value the head maps close to zero, is exactly the zero-value sink of the proposition: an attention bias implemented with activations. That is why replacing the massive values by their means changes nothing, and why an explicit key–value bias slot makes them unnecessary.

Outlier features and quantization. Dettmers et al. (2022) found related outlier features in decoder language models: hidden dimensions with magnitudes far beyond the rest, which at about 6.7 billion parameters abruptly appear in all layers while staying concentrated in about six dimensions across the whole network. A single scale per tensor for 8-bit activations must cover the outliers, so every ordinary value is rounded with a step many times too coarse. Their LLM.int8() keeps the outlier dimensions in 16-bit and multiplies more than 99.9% of the values in 8-bit. Quantization in Depth takes the methods further; this lesson is where the outliers come from.

Heads that learn to do nothing

Bondarenko, Nagel and Blankevoort (2023) connected the pieces. In BERT, heads that should not update a token put nearly all their probability on [SEP], periods and commas, whose values are small: a soft no-op. Pushing that probability toward exactly 11 requires ever larger softmax inputs during training, which the network produces through outliers in a few hidden dimensions, strongest at the outputs of the feed-forward layers of the last blocks. In vision transformers the same heads park on uninformative background patches. Their two fixes let a head switch off without extreme logits:

clipped_softmax⁡(x;ζ,γ)=clip⁡((ζ−γ)softmax⁡(x)+γ, 0, 1),gated_attn⁡(X)=σ(G(X))⊙softmax⁡ ⁣(QK⊤dhead)V\operatorname{clipped\_softmax}(\mathbf x;\zeta,\gamma)=\operatorname{clip}\big((\zeta-\gamma)\softmax(\mathbf x)+\gamma,\ 0,\ 1\big),\qquad\operatorname{gated\_attn}(X)=\sigma\big(G(X)\big)\odot\softmax\!\Big(\frac{QK^\top}{\sqrt{d_{\text{head}}}}\Big)V
With ζ≥1\zeta\ge1 and γ≤0\gamma\le0, clipped softmax reaches exact zeros and ones from finite inputs. The gate σ(G(X))\sigma(G(X)) is computed per head from the input and can scale a head's output to zero directly. In their BERT runs, the largest activation fell from about 735 to 21.5 (clipped softmax) or 39.2 (gating), with far smaller kurtosis, enough for full 8-bit activation quantization.
FixHow the head can do nothingEvidence
Keep initial tokens in the cachethe model's own learned sink survives evictionstable streaming to millions of tokens (Xiao et al., 2024)
Dedicated sink token, or an explicit key–value biasa learned slot with a fixed key and valueone sink token suffices (Xiao et al., 2024); no massive activations in GPT-2 (Sun et al., 2024)
Extra logit in the denominatorweight can drain out of the row; σs=0\sigma_s=0 gives softmax-plus-one (Miller, 2023, a blog post)zero sink alone only partly removed sinks in small models; a learned per-head logit is used in OpenAI's gpt-oss models (model card, 2025)
Clipped softmaxexact zeros without infinite logitslargest activation 735 → 21.5 in BERT and 359 → 74 in a ViT; on OPT-125m it lowered the maximum (340 → 63) but worsened 8-bit perplexity (Bondarenko et al., 2023)
Gated attention, output gatinga sigmoid gate scales the head's output toward zerolargest activation 340 → 8.7 in OPT-125m (Bondarenko et al., 2023); at 1.7B dense and 15B mixture-of-experts scale, better loss, more stable training and larger usable learning rates, with sinks mitigated (Qiu et al., 2025)
Registers (vision)extra learnable tokens absorb the role of background patchesremoves high-norm artifact tokens (Darcet et al., 2024)
Every fix gives the head an explicit way out, so it no longer has to manufacture one from activations.

Output gating at scale. Qiu et al. (2025) compared about thirty gated variants of softmax attention in 15-billion-parameter mixture-of-experts and 1.7-billion-parameter dense models, trained on up to 3.5 trillion tokens. The best was an elementwise, head-specific sigmoid gate on the output of scaled dot-product attention, Y′=Y⊙σ(XWθ)Y'=Y\odot\sigma(XW_\theta), where XX is the token's hidden state after pre-normalization. They credit two effects: a nonlinearity inserted into the otherwise linear path from values to the output projection, and query-dependent sparse gating, which lets a head contribute nothing for tokens where it is irrelevant. In one of their models the average attention on the first token fell from about 47% to about 5%, and the mean of the largest hidden activation from about 1,050 to about 94. The gated models also extrapolated better to long contexts.

Registers, and whether sinks are a bug

Vision transformers. Darcet, Oquab, Mairal and Bojanowski (2024) found artifacts in the attention maps of supervised (DeiT-III), text-supervised (OpenCLIP) and self-supervised (DINOv2) vision transformers, in the first two already at Base size. In DINOv2 they are tokens with roughly ten times the typical output norm, about 2% of all tokens, sitting on redundant, low-information patches such as background; they emerge around the middle layers, only after about a third of training and only in models of ViT-Large size or more, and they hold global information about the image. Appending a few learnable registers, extra tokens discarded at the output, removes the artifacts and improves dense features. Sun et al. found massive activations in CLIP and DINOv2 ViTs too, and in a register-equipped DINOv2 they sit in one register. What Vision Transformers Attend To takes up the vision side; the mechanism is the one above.

Key takeaways

  • Softmax rows sum to one, so a head can do nothing only by parking its weight on a token with a near-zero value: a sink, equivalent to an extra logit in the softmax denominator. Keeping it dominant needs score gaps that grow like ln⁡T\ln T.
  • Language models use the first tokens as sinks because every later token can see them. Evicting them breaks window attention; keeping four initial tokens, or training one dedicated sink token, restores stable streaming.
  • Massive activations, a few coordinates thousands of times larger than typical at specific tokens, act as fixed biases: under RMSNorm they make the sink's key and value nearly input-independent. Related outlier features force mixed precision in 8-bit inference.
  • Giving heads an explicit way out (sink logits, key–value biases, clipped softmax, gated attention, output gating, registers in vision) removes the need for extreme activations; whether sinks are useful or merely a workaround is debated.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

A head attends to a sink token with value vs=0\mathbf v_s=\mathbf 0 and score σs\sigma_s, and to real tokens with scores σj\sigma_j. Its output equals:

  1. Ordinary softmax attention over the real tokens; the sink changes nothing
  2. The zero vector, since the sink's value is zero
  3. Softmax attention over the real tokens with an extra term eσse^{\sigma_s} in the denominator
  4. The value of the highest-scoring real token
Show the answer

C. Softmax attention over the real tokens with an extra term eσse^{\sigma_s} in the denominator

The sink contributes eσse^{\sigma_s} to the normalizer and nothing to the numerator, so the real tokens' total weight is ∑jeσj/(eσs+∑jeσj)\sum_je^{\sigma_j}/(e^{\sigma_s}+\sum_je^{\sigma_j}), which the head controls through σs\sigma_s.

Question 2

In LLaMA2-7B, setting the massive activations to zero ruins the model, while setting them to their average values over many inputs changes almost nothing. What does this indicate?

  1. They act as fixed, input-independent biases rather than as information about the input
  2. They store the facts the model knows
  3. They are numerical noise that training failed to remove
  4. They encode the position of each token
Show the answer

A. They act as fixed, input-independent biases rather than as information about the input

A quantity that can be replaced by its mean without harm carries no input-specific information, yet the model depends on it. Saturating the normalization, it gives the sink token a near-constant key and value: an attention bias built from activations.

Question 3

Why do a few outlier dimensions break 8-bit quantization of activations with one scale per tensor?

  1. 8-bit numbers cannot represent negative values
  2. The scale must cover the outliers, so the step between levels is far too coarse for every ordinary value
  3. Outliers overflow and become infinite
  4. Quantization changes the softmax temperature
Show the answer

B. The scale must cover the outliers, so the step between levels is far too coarse for every ordinary value

With 127 levels on each side of zero, a largest value of 60 makes each step about 0.47, enough to round most entries of size around 1 to a handful of levels or to zero. Keeping the outlier dimensions in 16-bit (LLM.int8()) or giving them their own scales avoids this.

Question 4

How does output-gated attention let a head contribute nothing without an attention sink?

  1. It replaces the softmax by an argmax
  2. It masks the first token
  3. It lowers the softmax temperature
  4. A sigmoid gate computed from the token multiplies the head's output and can drive it toward zero
Show the answer

D. A sigmoid gate computed from the token multiplies the head's output and can drive it toward zero

The gate acts after the attention-weighted sum, so the weights can still sum to one while the head's write is scaled down. The head no longer needs a token with a near-zero value and a huge score gap.

Further reading

  • G. Xiao, Y. Tian, B. Chen, S. Han & M. Lewis, "Efficient streaming language models with attention sinks," ICLR (2024).
  • M. Sun, X. Chen, J. Z. Kolter & Z. Liu, "Massive activations in large language models," COLM (2024).
  • Y. Bondarenko, M. Nagel & T. Blankevoort, "Quantizable transformers: Removing outliers by helping attention heads do nothing," NeurIPS (2023).
  • Z. Qiu et al., "Gated attention for large language models: Non-linearity, sparsity, and attention-sink-free," NeurIPS (2025).
  • X. Gu, T. Pang, C. Du, Q. Liu, F. Zhang, C. Du, Y. Wang & M. Lin, "When attention sink emerges in language models: An empirical view," ICLR (2025).