State-Resolving Attention for Length-Extrapolating Transformers

Zicheng Liu, Di Wu, Jintao Chen, Di HuangNeurIPS 2026

TL;DR

Standard Transformers often stumble on long contexts because they treat everything like a static "needle in a haystack" search, blending what is relevant with when it happened into a single mathematical soup. Sieve Attention decouples these two jobs: it first uses a sparse filter to discard irrelevant noise, and then applies a recency rule strictly among the surviving candidates. The result is a model without explicit positional encodings that tracks evolving states—like variable updates in code or revised user preferences—far beyond its training length.

What Problem Does This Paper Address?

Picture a long sequence of variable assignments: A=1, B=3, A=7, C=4, A=?. Answering this isn't just about retrieving A; it’s state tracking—finding all mentions of A and figuring out which one is current. Real-world tasks like reading code execution traces, parsing document edit histories, or following shifting dialogue preferences work the exact same way.

Standard scaled dot-product attention forces a single probability distribution to make two fundamentally different decisions at once: content selection (which tokens are about A?) and state resolution (which A came last?). As sequences stretch past the model's training length, dense softmax attention spreads tiny bits of probability mass across thousands of irrelevant tokens, diluting the signal. Meanwhile, explicit positional encodings (like RoPE or ALiBi) become brittle outside their training window, and purely sequential mechanisms (like stick-breaking attention) waste their recency bias on irrelevant intervening noise (B=3, C=4).

Methods

To untangle this knot, the authors introduce State-Resolving Attention (SRA), instantiated as Sieve Attention. True to its name, it drops positional encodings entirely and breaks causal attention into a "content-first, time-second" pipeline:

Figure 2: Sieve Attention first forms a sparse candidate set using a content-based filter, then applies sequential allocation only over the selected candidates. The recency bias is therefore applied among content-relevant tokens rather than among all previous tokens.
  1. The Content Sieve: Given standard query-key dot-product scores over all preceding tokens, the mechanism applies $\alpha$-entmax—a sparse cousin of softmax that assigns exact zero weight to tokens falling below an adaptive threshold. Importantly, these entmax weights aren't used as the final attention; they simply act as a hard bouncer, letting a compact candidate set of relevant tokens through the door.
  2. Sequential Hazard Allocation: Sorting only the surviving candidates in their original temporal order, the model runs a sequential "stick-breaking" process. Moving backward from the most recent candidate, each token takes a bite out of a metaphorical unit "stick" of attention proportional to the sigmoid of its score. If a recent candidate matches strongly, it consumes most of the stick, naturally suppressing older updates to the same state. Any leftover stick acts as a learned "abstention," letting the residual stream take over when nothing relevant is found.

Because the hard candidate mask doesn't pass gradients directly to excluded tokens, the authors widen the candidate net during training using a temperature parameter ($T=2$) and compute the stick-breaking allocation in log-space via a memory-efficient tiled kernel.

Datasets

No brand-new benchmarks are introduced, though the authors construct targeted diagnostics around established synthetic and natural-language tasks:

  • Synthetic Extrapolation: Multi-Query Repeated Associative Recall (MQRAR) (tracking keys updated repeatedly across contexts, plus diagnostics for distractor insertion, first-write-wins, and exact-position retrieval) and Copy (exact memory of repeated tokens).
  • Language Modeling & Long-Context Suites: Pretraining on ~1T tokens (evaluating on ARC, OpenBookQA, HellaSwag, PIQA, Winogrande, and WikiText perplexity), byte-level language modeling on WikiText-2 and WikiText-103, and out-of-the-box long-context evaluation up to 128k tokens on RULER (covering Needle-in-a-Haystack and Variable Tracking).

Key Insights and Ideas

  • True Distractor Invariance: Because irrelevant tokens get zeroed out before temporal ordering happens, you can stuff thousands of noisy tokens between state updates without changing the relative attention weights of the surviving candidates. Mathematically and empirically, attention allocation becomes independent of global sequence length.
  • Ending the "Seed Lottery": Purely sequential mechanisms like Stick-Breaking can extrapolate without positional encodings, but whether a training run finds that solution is a coin toss across random seeds. Filtering content first stabilizes optimization so every seed learns to extrapolate.
  • Adaptive Thresholds Beat Fixed Top-$k$: Swapping the adaptive $\alpha$-entmax sieve for a rigid Top-8 filter causes accuracy to plummet from 96.4% to 25.5% at $4\times$ training length. As contexts grow, the raw rank of a valid update can slip amidst more competitors, whereas an adaptive threshold adjusts dynamically.
  • Knowing When Not to Use Recency: On a "first-write-wins" diagnostic, Sieve Attention extrapolates with 100% accuracy while recency-hardcoded models like ALiBi fail—proving the model can recognize a first occurrence by content at encoding time without its recency allocator misfiring.

Key Results

Length extrapolation on MQRAR and Copy tasks

Figure 1: Length extrapolation after training at length 64 (mean ± std over five seeds; shaded region: in-distribution). Left: Multi-Query Repeated Associative Recall (MQRAR); right: Copy. Softmax collapses beyond the training length with or without RoPE; ALiBi’s fixed recency suits MQRAR but collapses on Copy; Stick-Breaking extrapolates only for some seeds. Sieve Attention is the only mechanism competitive on both tasks. Full numbers are in Tables 1 and 2.
  • Synthetic Extrapolation: Trained at length 64, Softmax+RoPE collapses to near-chance (5.9%) at $4\times$ length on MQRAR, while Sieve Attention hits 96.4% (and averages 46.5% across $4\times$–$1024\times$ lengths with tight seed variance). While ALiBi dominates MQRAR (99.4% average) thanks to its hardcoded recency penalty, ALiBi completely collapses on Copy at $64\times$ length (3.5%), where Sieve Attention leads all methods (35.5% at $64\times$; 53.0% OOD average).
  • Massive Distractor Insertion: When 2,048 irrelevant key-value pairs are spliced into MQRAR prompts (expanding sequence length ~65-fold), Sieve Attention retains 91.6% accuracy, compared to 67.0% for ALiBi, 43.8% for Stick-Breaking, and 4.1% for Softmax+RoPE.
  • Scale & RULER: Pretrained at 1B and 3B parameters (4k context), Sieve Attention matches standard Transformer baselines on short-context reasoning (e.g., 10.6 vs. 11.3 WikiText PPL at 3B) while degrading much more gracefully on RULER out to 128k tokens, particularly on Variable Tracking. (In a candid note on scientific provenance, the authors disclose that a server failure wiped out their original 1B/3B checkpoints after submission; all synthetic and byte-level studies were subsequently rebuilt from scratch across multiple seeds).

Limitations and Future Work

Sieve Attention is built for sparse state tracking, not everything. As expected for a position-free, content-first design, it fails on purely positional queries (like "return the $k$-th token"), and dense global reasoning or counting tasks remain out of scope. Training through a non-differentiable support mask requires careful learning-rate tuning, and using a single fixed sparsity parameter ($\alpha=1.5$) across all heads is likely suboptimal. Finally, its research kernel still trails FlashAttention in wall-clock speed due to extra passes needed for exact thresholding. Future work includes multi-seed pretraining at scale, long-context finetuning, and testing length-extension recipes on RULER.

Summary updated

Abstract

Long-context failures are often framed as retrieval failures: a model must find a relevant token among many distractors. However, many practical long-context settings are better understood as state-tracking problems: dialogue histories contain corrections to earlier preferences, code traces repeatedly assign values to variables, document histories revise previous claims, and tool-use trajectories update the current task state. In these settings, a model must not only identify relevant tokens, but also resolve which relevant occurrence is currently valid. We propose Sieve Attention, a position-encoding-free attention mechanism for length-extrapolating Transformers. SRA decomposes attention into two operations: content filtering and temporal state resolution. For each query, SRA first applies a sparse content filter over the full prefix to identify candidate state updates, and then applies a sequential hazard allocation process only over the selected candidates. This resolves repeated updates according to their relative order without relying on external positional encodings, allowing irrelevant intervening tokens to be ignored before recency is applied. We formalize the mechanism and show that its final attention support is contained in the sparse candidate set, that filtered distractors receive exactly zero mass, and that attention ratios among selected candidates are independent of global sequence length and absolute position. Experiments on repeated associative recall and copy tasks show strong extrapolation far beyond the training context length. On long-context evaluation and language-model pretraining, SRA improves long-context behavior while remaining competitive with standard Transformer baselines. These results suggest that content-first, time-second state resolution is a useful inductive bias for long-context models that must track evolving information.
BibTeX
@inproceedings{liu2026state,
  author = {Zicheng Liu and Di Wu and Jintao Chen and Di Huang},
  title = {{State-Resolving Attention for Length-Extrapolating Transformers}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=yhRk81TgYO},
}
Figure