Stuck in a Loop.

Runaway credit ratcheting in attention matrices.

Authors

Mason Eyler, AJ, Nahom Seyoum, Max Misterka, Deven Pietrzak, Adit Srivastava.

TL;DR

  • Current attention weights act as a strong filter during backpropagation, creating a positive feedback loop in which certain keys can gain exponentially more attention.
  • This feedback can lock in early differences in attention.
  • This leaves some semantically relevant keys weakly attended to; we construct an oracle to identify them.
  • Different heads within a layer have mostly compatible attention patterns, suggesting less specialized coordination between routing and value representations than we might naively expect.
  • We formulate a method to democratize the backward pass using a natural-gradient approach.
  • We find that the new gradient broadens attention patterns and gives previously weakly attended keys more weight, but worsens validation loss, suggesting that the dynamics concentrating attention on a few winners may also support learning.

One Attention Head's Forward Pass

Fix an attention head within a transformer, and let be token 's attention score during token 's forward pass.

(1)
(2)

We can express the output of the attention mechanism as

(3)

Let be the loss and let be the gradient at the head output:

(4)

Backpropagation through the head gives the following formulas for the gradients:

(5)
(6)

Notice that all of these gradients contain factors of . This implies that if we ever end up in a situation where the attention scores get very small, then the resulting gradients also become small, killing the gradient flow during backpropagation.

Denote the input to the attention layer as , and let be the set of all indices . Also, denote the , , and weight matrices by , , and , respectively. Now, we can just compute the attention scores :

(7)

Using , the chain rule gives us

(8)
(9)
(10)

For ,

(11)

This is the first way attention allocates credit. For source activations of similar norm, ten times more attention means roughly ten times more gradient to .

To obtain the query gradient, apply the chain rule through the attention weights.

(12)

We call the advantage. Shifting a fraction of the current attention distribution toward key changes the head output to , giving

(13)

We compare the spreads of attention and advantage within each query using

(14)

We measured them in every head of Qwen2.5-1.5B base over 65,536 tokens for 5.33 million layer–head–query comparisons.

Attention is far more uneven than advantage

AttentionAdvantage
10,471.285×attention5.012×advantage
Maximum / median1×10×10²×10⁴×10⁶×10⁸×10¹⁰×10¹²×p1p10p50p90p99
Figure 1. Attention is the main decider for the gradient scale.

Two regimes of attention–advantage imbalance

If we look at the attention factor in Equation (12), we notice that it can play two very different roles.

  1. It can be an instrument of calibration on a known axis.
  2. It can prevent a useful but weakly attended key from exerting enough influence to be attended to significantly more.
(15)

So let us call the first regime calibrated prioritization. Suppose key 1 receives much more attention than key 2, while key 2 has the larger advantage:

(16)

Here, the query update prioritizes key 1 because attention outweighs the difference in advantage. This pressure pushes us toward the optimal position on a known axis.

Such axes correspond to an aleatoric noise floor where hard CE and soft teacher CE are at odds. This means the current attention distribution is already optimal, but a single token would prefer to shift it. Oftentimes, these axes appear when attention is split between the first token and retrieved content.

See Appendix A for the experimental design and full results.

The second case is a softmax deadlock. To see what we mean, consider a 2D query–key space with

(17)

and attention weights

(18)

Let the hidden third key have a large negative advantage:

(19)
(20)

If we require the other two advantages to be equal, we obtain

(21)

Since , we know that

(22)

Softmax deadlock

Output space

v147.5%v247.5%v35%OutputTargetUnit corrections

Query space

5%relative gainMapped corrections
5%
Figure 2. In this three-key example, low attention flattens the Jacobian, so a vertical output correction produces a tiny query update. The ellipse is normalized by the largest singular value.

The query does shift in the direction of the useful key, but at a snail's pace due to the softmax lock.

The probe in Appendix A finds that gradients averaged over possible next tokens are often much smaller than the observed token's gradient, suggesting substantial cancellation. Arbitrarily changing gradient magnitudes based on the sampled token's advantages could upset that cancellation and push case 1 away from calibration. An invertible linear reweighting based only on the current attention geometry applies the same transformation across possible next tokens. This preserves case 1's zero expected gradient at a calibrated optimum without forcing case 2's nonzero signal to vanish.

The attention Jacobian and its empirical spectrum

In Equation (12), we derived the query gradient as a weighted sum of the keys. If we look at it more closely, we can see that it can be written as a nice Jacobian transpose vector product

(23)

where

(24)

This weighted sum is highly anisotropic and effectively low rank (only a small set of directions are transmitted strongly) because are spiked so sharply. The Jacobian is therefore an information bottleneck during backpropagation. Any component of in the nullspace of is ignored and contributes nothing to .

To see this effect, we measured this Jacobian directly in the pretrained Qwen2.5-1.5B base model. See Table 1 for details of the probe.

Table 1. Qwen attention-Jacobian probe.
ModelQwen2.5-1.5B base
Head sitesHead 0 at layers 2 (early), 14 (middle), and 26 (late)
Data and sample56 FineWeb validation sequences of 1,024 tokens, positions 32–1,023, 55,552 Jacobians per head and 166,656 total
Jacobian post-rotary matrix in fp64, spectrum from the eigenvalues of
ValidationRelative error of against an autograd Jacobian

The main effective rank statistic actually uses squared singular weights,

(25)

whose distribution we can see in Figure 3.

Table 2. Per-head summaries of the Jacobian spectrum.

(early)

(middle)

(late)
Effective rank using normalized Median, effective modes10.943.2313.28
Participation ratioMedian, effective modes2.741.191.78
Modes with Count at median token20726
Modes with Count at median token451470

The main result is very simple. In every head, at least 99% of tokens have squared-spectrum effective rank below 10, and no token went above 19. The middle-layer head is the most concentrated, which is consistent with its median top-1 attention weight of 0.75.

Per-token effective-rank distribution

  • L2 h0
  • L14 h0
  • L26 h0
Probability per 0.1-rank bin00.050.10.150.20.25124816Effective rankL2 h0L14 h0L26 h0

Mean relative singular spectrum

  • L2 h0
  • L14 h0
  • L26 h0
Relative singular value0.010.1112345678Singular-value rank1% thresholdL2 h0L26 h0L14 h0
Figure 3. Per-token query matrix Jacobians on Qwen2.5-1.5B base.

Training Attention Routing Follows a Positive Feedback Loop

Each key's contribution to the gradients of the value matrix () and query matrix () is proportional to its attention weight . Since softmax makes attention ratios exponential in score differences, these weights can span orders of magnitude, making it plausible for early attention patterns to become self-reinforcing during training.

Consider gradient descent on the value matrix and attention scores, with positive learning rates and . Define the signed advantage of source as .

In this example, we apply the gradient update to the value matrix while holding the input and attention scores constant and measure the change in advantage. The loop below showcases how positive feedback can arise in this setup.

The attention credit loop

(26)
(27)
(28)
(29)
(30)
(31)

Equation (27) measures the size of the gradient matrix; Equation (28) applies the matrix itself. The Frobenius norm has not been canceled. With the input fixed, the intervening step is

(32)

The next step must account for the changing mixture. Summing the value updates for this query gives , using from Equation (10). Consequently,

(33)

Subtracting these changes and taking their inner product with yields Equation (29). Its sign is not necessarily positive: a source must improve relative to the mixture to gain advantage. For orthogonal unit inputs, it reduces to , which can favor an already strongly attended source. Recomputing , changing the inputs or attention, or adding other queries' gradients introduces further effects.

Finally, positive advantage increases a logit in this local model, but the attention odds in Equation (31) grow only when . The exponential describes the dependence on the score gap; it does not by itself establish exponential growth over training time.

Empirically, attention patterns differ far more cross-run than within a run. By as early as step 1000, a run is more similar to its final state (step 10000) than the endpoints of different runs are to each other.

Within-run stability, cross-run drift

Fewer pairsMore pairs

Within runSteps 1,000 → 10,000

ln a (A, 10k)
−12−12−8−8−4−400ln a (A, 1k)ln a (A, 10k)
−12−12−8−8−4−400ln a (A, 1k)ln a (A, 10k)
−12−12−8−8−4−400ln a (A, 1k)ln a (A, 10k)

ln a (A, 1k)

Across runsHeads matched at step 10,000

ln a (B, 10k)
−12−12−8−8−4−400ln a (A, 10k)ln a (B, 10k)
−12−12−8−8−4−400ln a (A, 10k)ln a (B, 10k)
−12−12−8−8−4−400ln a (A, 10k)ln a (B, 10k)

ln a (A, 10k)

Figure 4. Attention patterns stabilize very early within runs, but are also distinct across runs.

Buried Keys Are Measurable

We rank each key by advantage in Qwen2.5-1.5B for a fixed query.

For a fixed query, each head picks its top keys by absolute advantage, . We select a key if at least heads pick it and agree on whether to increase or decrease attention to it. To rank qualifying keys, we divide each head's advantages by their root mean square across keys for that query, then sum the normalized magnitudes over agreeing heads.

Cross-head agreement at layer 25

Input: is now completed and posted on Vimeo. Watch parts 1 - 3

Increase attention
IncreaseDecrease
H0H1H2H3H4H5H6H7H8H9H10H11

Source context: …. From popcan earrings to oil paintings of beach scenes, you may not need to head anywhere…

For the Vimeo query, the top keys by absolute advantage for heads 3, 6, 7, 8, and 9 were “out,” “bean,” “6,” “Health,” and “beach,” respectively. The consensus metric selected “3,” with six heads agreeing on a negative advantage: they favor less attention to this source. The selected “food” source and the leading “3” source in the food-code example also have negative coalitions. The Dembski example's “…” sources have positive coalitions. In the “suction” and “is” rows, no tokens pass the cross-head gate.

The consensus metric finds coordinated advantages even for keys with attention ranks as high as 600. This gives us a way to inspect potentially relevant sources that current attention largely excludes.

Heads are not simply separate probability budgets

At a high level, each head is a selection rule (, ) and a representation of what we write into the residual stream when selected (). Naively, we'd expect that the rules and representations are matched pairs which may not be permuted. This is largely not the case.

Fix a layer, and replace all pre-softmax attention scores with their average across heads.

(34)
(35)
(36)

We perform this operation for each of Qwen2.5-1.5B's 28 layers separately.

With shared attention, the value paths combine into a single map. Let be head 's block of the output projection and . Then

(37)
Loss increase
Median90th percentile99th percentile
Median
0.000195 nats
90th percentile
0.411 nats
99th percentile
1.35 nats
Figure 5. Sharing attention weights in the first layer (layer 0) raises the median token loss by nats. In every later layer, the median increase is at most nat.

These upper-tail losses include continuations of names, places, and multi-token identifiers. Table 4 shows examples from the later layers, where sharing attention barely affects the median token.

Qwen2.5-1.5B · 28 LAYERS

Transformer surgery

… Amy Andrews Gossip Girl by Amy Andrews

2724201614LAYER 1412080400
Layer 14

Loading recorded Qwen tensors…

Loss change
0 nats
Probability / original
1
Table 4. Loss increase on the bold token when all heads at the listed layer use the same attention weights, compared with the unmodified model.
Layer changedText being scored (target token in bold)Extra loss (nats)
1… submit their pictures as massive synths. MWAHAHAHAHAHAA!+9.3
6… Find More Posts by laurlynn. Tallahassee,+5.9
14… Amy Andrews Gossip Girl by Amy Andrews.+7.9
15… garbage can jailhouse ambiance, wouldn't you agree? ORLANDO, Fla+13.9
22… Former Nickelodeon star Amanda Bynes arrested for drug+6.6
26… the players and coaches have insisted Rainey's big+5.2
27… that was all the opening Denmark needed to strike+6.6

Ramapuram et al. (2024) show that, with appropriate normalization and initialization, elementwise sigmoid attention can replace softmax across language, vision, and speech tasks. Combining this with head averaging yields the following approximation:

(38)

where is a fixed scalar bias. Here is the effective value map and represents the combined scoring function.

At this level of approximation, multiheaded attention, with all its justifications about distinct probability distributions and selection rules, collapses into this inelegant filtration mechanism. Its ability to nearly block out values deemed unimportant makes the rule powerful, but also leads to the ratchet effect.

NATQ: Changing the Query Gradient

We know that carries a factor of , so a small query movement changes attention only weakly for keys that already receive little attention. In regular gradient descent, we constrain parameter movement to an ball around the current point in parameter space and hence are constrained to an ball around the query vector . Writing , this gives

(39)

Natural gradient instead bounds movement in attention-distribution space: the new attention row must lie within a KL ball around the current row. Let denote the full attention distribution for query , with the keys held fixed. For small query movements, the KL divergence and its constraint are locally approximated by

(40)
(41)

The resulting local geometry is given by the attention row's Fisher information matrix . For one head and query , define

(42)

For invertible , minimizing the linearized loss under the local KL constraint gives the inverse-Fisher descent direction:

(43)

Under the KL constraint, equal-length query movements along larger-eigenvalue directions of are more costly because they change the attention distribution more strongly. Movements along smaller-eigenvalue directions cost less. The inverse-Fisher direction therefore gives those weaker directions relatively more weight.

In our experiments, we use NATQ: a damped version of this direction with the incoming gradient's norm restored. Damping limits amplification along directions with small eigenvalues, while norm restoration keeps the query-gradient magnitude unchanged. For , the NATQ gradient is

(44)

where is the identity matrix and damps the inverse. The scaling ensures . For , we explicitly set , avoiding division by zero.

Because norm restoration depends on the gradient, NATQ is nonlinear in and does not inherit the cancellation guarantee of a fixed linear reweighting.

A Weaker Ratchet, a Worse Model

Validation loss at the best tested settings

  • Control
  • Control · second seed
  • NATQ
Validation loss (nats)33.544.552501k2k3k4k5kTraining step
Figure 6. Validation loss measured every 250 steps. Training setup: size — 124M; depth — 12 layers, 6 heads per layer; dataset — FineWeb; steps — 5,000; cosine LR schedule; 512 seq/step. Each variant is tuned for LR and WD.

Wider attention does not find more useful content

StatisticControlNATQ
Mean attention entropy (nats)3.754.69
Mean top-key attention0.2380.149
Mean attention within eight tokens0.3830.209
Heads with local attention mass above 0.781
Heads with entropy above 4.5 nats748
Table 5. Attention statistics across all 72 heads. Local attention refers to the eight-token window.

Higher attention entropy means attention is spread more evenly across keys. NATQ roughly halves the weight given to self-attention and the local token window. In layers 4–7, tokens with attention weights below 0.1% in the control receive 67% of the increase.

Attention under NATQ

Fewer pairsMore pairs

Control vs NATQ

ln a (NATQ, 5k)
−12−12−8−8−4−400ln a (Control, 5k)ln a (NATQ, 5k)
−12−12−8−8−4−400ln a (Control, 5k)ln a (NATQ, 5k)
−12−12−8−8−4−400ln a (Control, 5k)ln a (NATQ, 5k)

ln a (Control, 5k)

Control vs second seed

ln a (Second seed, 5k)
−12−12−8−8−4−400ln a (Control, 5k)ln a (Second seed, 5k)
−12−12−8−8−4−400ln a (Control, 5k)ln a (Second seed, 5k)