First Passage Attention
Organizations: Department of Mathematics, University of Bergen, Bergen, Norway
Abstract
Augmenting softmax attention with forget gates typically relies on summing decay contributions along the key--query path. Because such accumulation is monotonic, these mechanisms cannot selectively erase intermediate context while preserving older, structurally relevant tokens. We propose First Passage Attention (FPA), which shifts from path summation to path extrema by lowering a key's logit proportionally to the deepest dip of a learned scalar field below that key's level over the intervening span. FPA encompasses the Forgetting Transformer (FoX) as a special case, and when the field and levels follow a shared learned walk, the alive keys with unpenalised logits naturally form a stack. We show that a constant-dimension FPA head realises any subset of keys left alive by subsequent dips, whereas softmax heads with positional biases or token-level forget gates require a head dimension linear in the number of keys. In synthetic experiments, one-layer FPA heads converge to these target sets while comparable softmax and FoX baselines fail on every seed. Scaling to a 110M-parameter language model, FPA matches FoX in perplexity and uniquely achieves perfect passkey retrieval at the training length, even with its key--value cache compressed to about .
Figures & tables
| Alive sets, | Varied | Two | ||||
|---|---|---|---|---|---|---|
| Method | durations | walks | Stack | |||
| FPA | 11/15 | 12/15 | 13/15 | 13/15 | 11/15 | 14/15 |
| FPA, sum of dips | — | — | — | 0/15 | — | 11/15 |
| Softmax + RoPE | 0/15 | 0/15 | 0/15 | — | — | 0/15 |
| Softmax + NoPE | 0/15 | 0/15 | 0/15 | — | — | — |
| Softmax + ALiBi | 0/15 | 0/15 | 0/15 | — | — | — |
| Loss (nats per token) | Accuracy | |||||
| SlimPajama | WikiText | PG-19 | Passkey | Passkey | RULER | |
| Method | test | 103 | 2k–4k | 3k–4k | 8k–16k | 8k |
| FPA | 2.8640 | 3.1001 | 3.282 | 1.00 | 1.00 | 0.202 |
| FoX | 2.8832 | 3.1425 | 3.316 | 0.73 | 0.20 | 0.117 |
| Selective Attention | 2.8686 | 3.1197 | 3.805 | 0.11 | 0.04 | 0.008 |
| Softmax + RoPE | 2.8908 | 3.1374 | 5.064 | 0.00 | 0.00 | 0.002 |
| One layer, ms | Model | Decoding at 8k | |||
| Method | forward | fwd + bwd | tokens/s | ms/token | bytes/pos. |
| FPA | 0.78 | 4.31 | 29,694 | 22.0 | 74,880 |
| FoX | 0.74 | 2.87 | 32,481 | 20.2 | 74,304 |
| Softmax (SDPA) | 0.87 | 4.42 | 26,913 | 23.9 | 73,728 |
| Selective Attention | 2.00 | 10.45 | 20,150 | 36.7 | 73,776 |
| The same kernel with parts of FPA switched off | |||||
Appendix figures & tables38 assets
Supplementary material from the paper’s appendix.
Appendix
| Family | Method | Runs | GPU min |
| Alive sets | FPA † | 48 | 46.3 |
| FoX † | 40 | 28.9 | |
| Selective Attention † | 40 | 30.2 | |
| Softmax + ALiBi | 28 | 16.6 | |
| Softmax + NoPE | 28 | 16.3 | |
| Softmax + RoPE | 24 | 15.8 |
| Method ( , one layer) | ||||
|---|---|---|---|---|
| FPA | 15/15 | 11/15 | 12/15 | 13/15 |
| Softmax + RoPE | 15/15 | 0/15 | 0/15 | 0/15 |
| Softmax + NoPE | 14/15 | 0/15 | 0/15 | 0/15 |
| Softmax + ALiBi | 14/15 | 0/15 | 0/15 | 0/15 |
| FoX | 15/15 | 0/15 | 0/15 | 0/15 |
| Selective Attention, scale 10 | 15/15 | 15/15 | 13/15 | 15/15 |
| Model | Fixed durations | Varied durations |
|---|---|---|
| FPA | 9/15 | 13/15 |
| FPA, sum of dips | 15/15 | 0/15 |
| Selective Attention | 15/15 | 0/15 |
| Model | Complementary walks | Identical walks |
|---|---|---|
| FPA | 11/15 | — |
| Selective Attention, shared mask | 0/15 | 15/15 |
| Selective Attention, one mask per head | 13/15 | — |
| DCP | 0/15 | 13/15 |
| Model | Seeds that succeed |
|---|---|
| FPA | 15/15 |
| FPA without the level of the key ( ) | 0/15 |
| FPA with the threshold of the query | 0/15 |
| FPA without content retrieval | 0/15 |
| FoX | 0/15 |
| Stick-breaking attention | 0/15 |
| Task | FPA | Softmax + RoPE | FoX | Sel. Att. | Stick-br. | LSTM |
|---|---|---|---|---|---|---|
| Variable assignment | 9/15 | 0/15 | 15/15 | 2/15 | 12/15 | 15/15 |
| MQRAR | 0/15 | 0/15 | 0/15 | 4/15 | 0/15 | 0/15 |
| Flip-flop | 15/15 | 0/15 | 15/15 | 15/15 | 0/15 | 15/15 |
| Copying | 15/15 | 15/15 | 15/15 | 15/15 | 14/15 | 15/15 |
| Counting | 15/15 | 15/15 | 15/15 | 15/15 | 15/15 | 15/15 |
| MQAR | 0/15 | 15/15 | 14/15 | 12/15 | 15/15 | 0/15 |
| FPA minus | FoX | Selective Attention | Softmax + RoPE |
|---|---|---|---|
| PG-19 loss, 0–2k | 0.029 [ 0.033, 0.026] | 0.014 [ 0.024, 0.007] | 0.038 [ 0.050, 0.028] |
| PG-19 loss, 2k–4k | 0.031 [ 0.037, 0.026] | 0.516 [ 0.540, 0.495] | 1.847 [ 1.939, 1.769] |
| PG-19 loss, 4k–8k | 0.020 [ 0.027, 0.015] | 0.300 [ 0.317, 0.285] | 3.666 [ 3.806, 3.545] |
| PG-19 loss, 8k–16k | 0.026 [ 0.019, 0.032] | 0.528 [ 0.557, 0.501] | 4.258 [ 4.428, 4.114] |
| Passkey 8k | 0.80 [ 0.68, 0.90] | 1.00 [ 1.00, 1.00] | 1.00 [ 1.00, 1.00] |
| Passkey 16k | 0.80 [ 0.68, 0.90] | 0.92 [ 0.84, 0.98] | 1.00 [ 1.00, 1.00] |
| RULER, 13 tasks | BABILong, qa1–qa5 | ||||
|---|---|---|---|---|---|
| Method | 4k | 8k | 16k | 0k | 4k |
| FPA | 0.208 | 0.202 | 0.051 | 0.082 | 0.006 |
| FoX | 0.218 | 0.117 | 0.072 | 0.078 | 0.000 |
| Selective Attention | 0.005 | 0.008 | 0.043 | 0.080 | 0.000 |
| Softmax + RoPE | 0.002 | 0.002 | 0.000 | 0.088 | 0.000 |
| FPA | FoX | Sel. Att. | Softmax | |||||
|---|---|---|---|---|---|---|---|---|
| World | recent | older | recent | older | recent | older | recent | older |
| Scopes in Python code | 0.24 | 0.66 | 0.01 | 0.86 | 0.39 | 0.77 | 0.45 | 0.52 |
| Who saw a hidden object | 0.52 | 0.62 | 0.47 | 0.69 | 0.41 | 0.67 | 0.69 | 0.49 |
| Branches in a version history | 0.41 | 0.60 | 0.40 | 0.60 | 0.27 | 0.73 | 0.45 | 0.56 |
| Stop-loss orders | 0.51 | 0.59 | 0.79 | 0.33 | 0.36 | 0.41 | 0.41 | 0.53 |
| A parenthetical remark | 0.55 | 0.56 | 0.69 | 0.30 | 0.77 | 0.38 | 0.77 | 0.33 |
| Step 1500 | Step 3250 | Step 5150 | |
| Mean loss over the 12 windows | 3.162 | 2.917 | 2.821 |
| Mean loss with the bias of every layer removed | 6.591 | 7.335 | 7.828 |
| Loss increase with alive sets forced into suffixes | 0.032 | 0.031 | 0.032 |
| windows with a positive increase | 12 of 12 | 12 of 12 | 12 of 12 |
| Local, middle and global heads | 90, 22, 32 | 90, 20, 34 | 90, 20, 34 |
| Heads whose alive sets are often not suffixes | 21 | 15 | 14 |
| Method | Bias added to the logit | Parameters per layer | Positions |
|---|---|---|---|
| FPA | with , | none | |
| FoX | with | none | |
| Sel. Att. | 0 | RoPE | |
| Softmax | 0 | 0 | RoPE |
| FPA | FoX | Sel. Att. | Softmax | |
|---|---|---|---|---|
| Parameters | 109,862,208 | 109,640,592 | 109,529,856 | 109,529,856 |
| of the attention mechanism | 332,352 | 110,736 | 0 | 0 |
| Layers and width | 12 and 768 | |||
| Heads head dimension | 12 64 | |||
| MLP | SwiGLU with hidden width 2048 | |||
| Normalisation | RMSNorm before each sublayer and before the output layer | |||
| Setting | Value |
|---|---|
| Data | SlimPajama, windows of 2049 tokens in one fixed order, each used at most once |
| Tokenizer | that of Mistral 7B, 32,000 tokens |
| Context | 2048 tokens |
| Batch | 256 windows, 524,288 tokens |
| Steps | 5150, 2.70B tokens |
| Optimiser | AdamW with |
| One-layer probes | Tasks from earlier work | |
|---|---|---|
| Optimiser | AdamW with , weight decay 0.01 on every parameter | |
| Batch | 64 sequences, drawn afresh at every step | |
| Steps | 4000, 16,000 on the graded depths | 4000, 8000 for MQAR |
| Warm-up | 200 steps | 10% of the steps |
| Schedule | cosine decay to 0, gradient clipping at 1.0 | |
| Precision | single | |
| Family | Heads | Positions | Final query | Steps | Test set |
|---|---|---|---|---|---|
| One-layer probes, width 64 | |||||
| Alive sets | 1 4 | key offsets, RoPE or ALiBi | MLP of the sequence | 4000 | all |
| two and four layers | 1 4 | RoPE | last token | 4000 | all |
| Graded depths | 1 8 | none | token ? | 16,000 | 2,000 per set |
| Two walks | 2 2 | query and key offsets | MLP of the sequence | 4000 | 8,192 |
| Stack | 1 8 | RoPE | last token | 4000 | 1,000 |
| Task | Layers width | Heads | MLP | Positions | Steps | Test sequences | FPA | Softmax | LSTM |
|---|---|---|---|---|---|---|---|---|---|
| Variable assignment | 2 128 | 2 64 | 512 | learned | 4000 | 2,000 | 534,672 | 533,120 | 393,088 |
| MQRAR | 2 128 | 2 64 | 512 | RoPE | 4000 | 2,000 | 462,992 | 461,440 | 329,856 |
| Flip-flop | 1 64 | 2 32 | 256 | RoPE | 4000 | 2,000 | 50,632 | 50,240 | 33,664 |
| Copying | 2 128 | 2 64 | 512 | RoPE | 4000 | 2,000 | 399,888 | 398,336 | 266,752 |
| Counting | 2 128 | 2 64 | 512 | RoPE | 4000 | 2,000 | 407,696 | 406,144 | 274,560 |
| MQAR | 2 128 | 2 64 | 512 | RoPE | 8000 | 2,000 | 1,445,904 | 1,444,352 | 1,312,768 |
| Method | Second setting | Values | Learning rates | Runs |
| Alive sets, graded depths and two walks, per method and family | ||||
| FPA | definition of the minimum | hard, soft with , annealed, soft then hard | 24 | |
| FoX | initial bias of the gates | 0, 2, 4, 6 | 24 | |
| Sel. Att. | selection scale | 1, 1/3, 3, 10 | 24 | |
| DCP | initial interaction bias | 2, 0, 4, 8 | 24 | |
| Softmax, stick-breaking | none | 12 from to | 24 | |
| Alive sets | Graded depths | Two walks | Stack | Retrieval | ||
| FPA | 0.03 | 0.003 | 0.001 | 0.1 | 0.01 | |
| FPA, sum of dips | 0.003 | 0.1 | ||||
| FoX | 0.03 (6) | 0.003 | 0.03 (6) | |||
| Sel. Att. | 0.03 (10) | 0.03 (1) | 0.03 (1/3) | 0.001 (1) | 0.03 (1/3) | |
| DCP | 0.01 (0) | |||||
| Softmax with RoPE | 0.0534 | 0.001 |
| Forward, ms | Forward and backward, ms | |||||||
|---|---|---|---|---|---|---|---|---|
| Shape | FPA | FoX | SDPA | Sel. Att. | FPA | FoX | SDPA | Sel. Att. |
| 16 512 | 0.37 | 0.34 | 0.27 | 0.67 | 1.76 | 1.13 | 1.64 | 3.54 |
| 8 1024 | 0.51 | 0.47 | 0.46 | 1.12 | 2.61 | 1.68 | 2.50 | 5.79 |
| 4 2048 | 0.78 | 0.74 | 0.87 | 2.00 | 4.31 | 2.87 | 4.42 | 10.45 |
| 2 4096 | 1.33 | 1.27 | 1.68 | 3.75 | 7.76 | 5.47 | 8.14 | 19.50 |
| 1 8192 | 2.39 | 2.33 | 3.30 | 7.29 | 15.19 | 10.45 | 15.79 | 37.37 |
| Length 2048 | Length 8192 | ||||
|---|---|---|---|---|---|
| Method | Rule | loss change | kept | loss change | kept |
| FPA | bias | 0.0063 | 29% | 0.0054 | 23% |
| bias | 0.0004 | 34% | 0.0005 | 26% | |
| bias | 0.0001 | 41% | 0.0000 | 30% | |
| FoX | bias | 0.1836 | 13% | 0.2675 | 6% |
| bias | 0.0195 | 15% | 0.0227 | 7% | |
Long-Context Language Modeling
Long-context language modeling studies how language models can use, retain, and efficiently process information across very long sequences.
See all 189 papers