Selective-Attention-Study v0.1.0 · results
Selective Attention, trained with no position encoding at 16K
Selective Attention (Leviathan, Kalman and Matias, ICLR 2025) lets each query subtract from its attention logits how strongly earlier queries already selected each key. The paper trained it with learned position embeddings and measured it inside its training context. We trained it the way our DilutionAttention models were trained, at 209 million parameters and a 16K context with no position encoding, and found that it retrieves planted keywords out to 128K tokens — eight times its training context — on all three seeds, with in-context loss level with dilution attention. Training it at that scale needed a fused kernel, which this release provides.
8×
training context, retrieval held
0.99–1.00 to 128K, all three seeds
3.059
validation loss, mean of 3 seeds
dilution 3.056 · softmax + RoPE 3.083
0
parameters added to attention
the operator is parameter-free
½
softmax's training throughput
36K vs 72K tokens/s at 16K
Every model is a 24-layer, 209-million-parameter decoder trained at a 16K context on 4.19 billion FineWeb-Edu tokens (Chinchilla-matched) with the DilutionAttention harness, data and schedule unchanged. The softmax and dilution results are the published DilutionAttention runs; the Selective Attention models are new, three seeds. Only the attention operator, its position encoding and the seed differ.
Why this study
While reviewing related work for DilutionAttention we found that Selective Attention has the same shape: both subtract from each attention logit a term built from what earlier queries did with the same key. In small experiments at a 2K context it behaved much like dilution with no position signal at all, which made it worth testing at the scale where the dilution results were measured.
The paper's listing builds the full attention matrix, which does not fit a 24-layer model at 16K tokens. We wrote fused Triton kernels — forward and full backward, tested against the paper's listing — that compute the same operator without it. With those it trains at about dilution's speed on the unchanged DilutionAttention harness, so its results sit directly beside the published runs.
The operator
Head 0 decides how strongly each query "selects" each earlier key; the running total of those selections is subtracted from every head's logits for later queries. No parameters are added.
L_h[i, j] = q_h[i] . k_h[j] / sqrt(d) # every head h, keys j <= i S[i, j] = relu(L_0[i, j]) for 1 <= j < i # head 0 selects; not <BOS>, not self F[i, j] = sum over r < i of S[r, j] # selection by strictly earlier queries A_h = causal_softmax(L_h - F); out_h = A_h @ v_h
Dilution attention has the same form, softmax(L − F), with a different history F: the log of the softmax demand each key has accumulated, per head. The two differ in what is accumulated, how it is subtracted and whose history is used, and those differences show up in the long-document results below.
Retrieval past the trained context
A keyword is planted at varying depths in haystacks from 3.8K to 512K tokens. Everything to the right of the vertical rule is longer than any sequence the models saw in training. Each row is one trained model.
Harder retrieval: natural text and distractors
The standard test repeats one paragraph, so a model can pass by spotting the only sentence that breaks the pattern. Two harder conditions: the haystack is real book text, and three similar facts about other keys are planted beside the target.
Past the training length natural text costs Selective Attention retrieval, with a wide spread between seeds, and it loses facts in the middle of the input first. With three distractors, every operator scores 0.24–0.46 inside 16K and most misses are a distractor's keyword: the models find the planted facts but often attach the wrong one to the key. The position-free operators hold that level to 128K; softmax with RoPE falls toward chance.
A practical lesson: train with a BOS token
Selective Attention exempts position 0 from selection because the paper assumes it holds a beginning-of-sequence token. Windows cut from a token stream start mid-document, and without a BOS token two of our three models could not retrieve a fact placed in the very first sentence of their input (2/7 and 1/7 placements), at every length, while every other depth was retrieved. Putting a BOS token at the start of every training window brought those two seeds to 7/7 and 6/7 at no measurable cost in loss. The failure did not appear in our 2K-context experiments, so a short screen may not catch it.
Long documents: tolerated, not used
The same models read 29 PG-19 books to 128K tokens, out of domain for a model trained on educational web pages. Loss is averaged over each range of positions.
A flat curve shows that a model tolerates long input, not that it uses it. Scoring the same tokens with the whole book and with only a 16K rolling window, Selective Attention gains a little from text one to two windows back and is hurt by text more than four windows back, by up to 0.29 nats at 16–32×; dilution is about neutral to 131K and hurt about a third as much. Its lower loss on these books is in-window quality. Trained on to twice the tokens, its long-book loss climbs well above dilution's, which stays flat.
Selective vs dilution
The two operators share a form, softmax(L − F), and differ only in the history F: Selective Attention subtracts a linear running sum of head 0's selections, shared by every head; dilution subtracts the log of each head's own accumulated softmax demand. Trained identically, they split the axes.
Where Selective Attention is ahead: it retrieves further on the standard test (all three seeds at 0.99–1.00 to 128K), models book text better inside its window by about 0.1 nats, and its kernel is slightly faster with half the memory. Validation loss on the training distribution is a tie.
Where dilution is ahead: stability. It needs no BOS token; its long-book loss stays flat to 32× its training length, at 1× and after twice the training, where Selective Attention's rises; and distant text harms it about a third as much. Its natural-text retrieval declines more gently on the one seed we evaluated, but the selective seeds spread so widely that this is not settled.
A plausible reading, not yet tested causally: Selective Attention's history grows linearly with the number of earlier queries and is shared by every head, so its suppression keeps strengthening with length and with training; dilution's log of demand grows slowly and is kept per head.
What it costs
One attention layer, forward and backward at 16K, takes 27.7 ms with the selective kernel against 30.5 ms for the dilution kernel and 9.4 ms for flash softmax attention: 2.9× softmax's time, 0.91× dilution's, with half dilution's memory. For the whole model a 16K training step runs at about 36K tokens/s against 72K for softmax with RoPE, so at equal wall clock softmax sees about twice the tokens; every comparison here is at equal tokens. Cached decoding is written in PyTorch, not as a kernel.
What this does not establish
One model size, one corpus and one context length, with three seeds of Selective Attention and two of each reference. The retrieval tests are synthetic — one planted keyword, in repeated text or in natural text with distractors — and how far retrieval reaches past 16K varies by seed.
Retrieval scores overstate long-context ability: neither position-free operator uses distant natural text to predict better, and Selective Attention's long-document loss degrades further with more training. Why its extrapolation varies between seeds and erodes with training is not resolved; damping the history term at evaluation time made things worse. The Forgetting Transformer and stick-breaking attention also train without position encoding and were not run at this scale. This is an independent implementation, not affiliated with or endorsed by the paper's authors.
Everything behind these results
The release ships the fused Triton kernels with exact gradients and the plain reference they are tested against, the training and evaluation code, the configurations, metrics and data provenance of every run, every result file behind these charts, and the investigation scripts. It is research code published as-is, released under the Apache-2.0 license.
Code & study on GitHub → Release v0.1.0 → Archived software (DOI) → DilutionAttention results → Back to news →