· ML systems
The Race to O(n)
Updated 11 November 2026
Dense self-attention compares token pairs, giving quadratic arithmetic cost in sequence length at fixed head dimension. Materialising its score matrix also takes quadratic memory; IO-aware implementations can avoid that allocation. Longformer, BigBird and linear attention were already tackling this in 2020, well before hundred-thousand-token contexts became common. Longer windows made the trade-offs more expensive, rather than starting the research programme. [1, 3, 4, 7, 9]
Family 1: keep the comparisons, prune them
Fixed sparse patterns compute only selected entries of the attention matrix. Longformer combines local windows with global tokens; BigBird adds random connections. BigBird proves universal approximation and Turing completeness under its assumptions, but those results do not promise equal efficiency at fixed depth. Appendix C constructs a task solvable by dense attention in a constant number of layers that requires nearly linear depth for sparse attention under standard complexity assumptions. Missing direct connections can therefore be costly even when eventual expressivity is preserved. [3, 4]
FlashAttention tiles exact attention into on-chip SRAM and uses an online softmax, avoiding a full score matrix in GPU memory. At fixed head dimension this brings auxiliary memory down to linear in sequence length while retaining quadratic arithmetic. Its speedup comes from reduced memory traffic. [7] The cost plot below is an illustrative operation-count model, not a hardware benchmark. Its selector crossover is a chosen configuration parameter.
Family 2: learn what to prune, and pay for the learning
DeepSeek's Native Sparse Attention (NSA, February 2025) combines compressed blocks, selected blocks and a sliding window in a natively trainable design. DeepSeek Sparse Attention (DSA), introduced with V3.2-Exp in September 2025, is a separate mechanism. DSA uses the Lightning Indexer to score candidate keys and select a fine-grained sparse read. The indexer belongs to DSA, not NSA. [31, 53]
DSA's indexer scores query-key pairs with a cheaper scoring function than the main attention operation. Scoring all earlier keys still gives quadratic prefill work at fixed indexer dimensions, even when the selected read has a fixed budget. This matters for asymptotic scaling, but it does not cancel practical speedups at deployed lengths. The 52K crossover and 16×/190× overhead ratios quoted in SubQ's report are the vendor's estimates for particular configurations, not independent measurements or properties of NSA. [6, 53]
A separate routing-absorption study asks whether a trained gate improves over a frozen random gate at matched sparsity. In its controlled 31M-parameter experiment, soft joint gating gives perplexities of 48.73 and 49.83; hard top-k gating gives 71.22 and 71.24. Those measurements identify a failure mode in that setup. They do not show that every production selector, or NSA and DSA specifically, has failed to learn useful routing. Hard top-k indices have zero derivative almost everywhere, but auxiliary losses, soft routes and staged training can still train the surrounding selector. [26]
Different architectures handle routing differently. Reformer uses locality-sensitive hashing; Routing Transformer updates clustering statistics; H-Transformer-1D uses a continuous hierarchical approximation. DSA uses indexer distillation and sparse-model training, and NSA supplies its own multi-branch training design. These are alternatives to test against the routing-absorption failure mode, not evidence that successful systems universally avoid hard selection or joint training. [31, 33, 35, 36, 53]
Family 3: replace comparison with a running memory
A third family doesn't prune the O(T²) computation. The pairwise comparison structure is eliminated entirely. The kernel trick is to factor the similarity between a query and key as an inner product of feature maps, φ(q)ᵀφ(k), then reorder the double sum in attention so a query only ever touches one fixed-size matrix, never the T individual keys that produced it [9]. That matrix, W, is a running memory where each token adds an outer product of its value and feature-mapped key, and each output is one read against the current W. Training cost drops to linear in T, and inference per token becomes constant time [9]. This is also a description of a linear RNN. Some popular architectures are RetNet's retention mechanism with an explicit recurrent/parallel/chunkwise duality [10,11]; RWKV's receptance-weighted recurrence, built to combine transformer-style parallel training with RNN-style constant-memory inference [12,13]; Griffin's RG-LRU gated linear recurrence, no attention at all in the "Hawk" variant [14]; S4's structured state-space parameterization, made input-selective by Mamba [15,16,37].
Mamba-2's State Space Duality result is the cleanest unification: a structured class of SSMs is exactly a form of linear attention with a semiseparable causal mask, so the same computation can be read either as a cheap recurrence or as a quadratic matrix multiply, and systems tricks transfer between the two readings [17,18,19]. That unification matters because it means this family's fixed-size state absorbing an unbounded sequence is a compression, and compression is lossy [6].
Family 4: don't just accumulate, correct
Naive linear attention just writes forever: W ← W + v⊗κ, with nothing to un-write, so old associations linger and interfere with new writes to overlapping key directions [20]. DeltaNet asks (before writing) what the memory already predicts for the current key, and writes only the residual (one step of online gradient descent on a reconstruction loss) [20,21]. The error-correction needs its own hardware-efficient parallelization: a chunked, WY-representation form of the delta rule (before it scales past toy sizes) [21,22].
DeltaNet still can't clear memory in bulk; every correction is local to one key. The lineage adds bulk forgetting one control dimension at a time. Gated DeltaNet applies a scalar decay to the whole memory before the delta-rule correction [23]; Kimi Delta Attention makes that decay channel-wise, so some feature subspaces are retained while others are aggressively cleared [24]; Gated DeltaNet-2 decouples the erase gate (which key-feature channels get removed) from the write gate (which value channels get committed), previously controlled by the same scalar [25]; CARVE argues Gated DeltaNet-2's gating is still over-parameterized relative to what a single hardware-friendly triangular solve supports, and restricts gating to the key axis to preserve that solve while conditioning erasure on the previous chunk's own content [38]. Each step is legible as one more knob on the same fast-weight object, motivated by a specific failure the previous step couldn't fix.
Family 5: prove the ceiling instead of chasing it
A fifth line of work stops optimizing architecture and asks how bad the fixed-size-state constraint fundamentally is. Jelassi et al. show theoretically that a two-layer transformer can copy strings of exponential length while any fixed-state generalized state-space model is bounded regardless of depth or training, and confirm empirically that pretrained transformers dramatically outperform pretrained SSMs at copying and retrieving context [39]. Zoology frames the same gap as a recall–throughput trade-off: a bounded state cannot do content-addressed recall beyond roughly its own dimension, however cleverly it's gated [27,28]. Mimetic initialization shows that the right initialization lets Mamba copy and recall over sequences several times longer than standard init achieves, but the gap to attention narrows rather than closes [29]. BASED responds pragmatically, combining cheap-but-imprecise linear attention with exact softmax attention in a small sliding window, tuning the window to trace the recall–memory Pareto frontier rather than picking one point [40]. Log-linear attention takes the more theoretical middle path: let the number of hidden states grow logarithmically with sequence length instead of staying fixed, admitting a matmul-rich parallel form at log-linear compute cost [41].
Alman and Yu establish a conditional lower bound for document-similarity tasks that transformers can implement. Under the Strong Exponential Time Hypothesis (SETH), those tasks admit no truly subquadratic algorithm in the specified regime. This is a worst-case forward-computation result, not a backward-pass theorem or an unconditional impossibility proof. [42] Alman and Song separately study attention gradients: almost-linear approximation is possible in a bounded-entry regime, while a SETH-based lower bound applies beyond it. The dimensions, entry bounds and approximation tolerance are part of the theorem. [54] Efficient architectures can still be useful by changing the task, accuracy target or resource trade-off.
The claim that all four properties can be had at once
Subquadratic AI's May 2026 report claims that its SSA selector is content-dependent and subquadratic including selection. The vendor reports 99.12% on 13-task RULER at 128K, 100% single-needle retrieval through 2M, and 98% retrieval at 12M after training at 1M, at a 0.13% attention budget. Its claimed 17× and 191× selector savings against DSA's Lightning Indexer are comparisons from the same report. These figures need independent replication and matched evaluation before they establish an advantage over competitors. [6]
The public report omits the selector mechanism and records a trade-off between retrieval-optimised checkpoints and multi-document synthesis or contract analysis. It also describes switching the primary development signal to RULER. [6] Publishing the selector, its full training cost, matched baselines and held-out task results would make the claim substantially easier to assess.
A useful diagnostic would compare SSA's trained selector with frozen and random selectors at matched sparsity. The routing-absorption study motivates that comparison; it cannot establish how an undisclosed SSA mechanism behaves. [26]
An orthogonal axis: sharing across depth, not just across sequence
Every mechanism above is about sequence mixing within a layer. A separate failure mode is dilution across layers: information written at layer 3 can be hard to recover by layer 20, because each layer only sees what survived the residual stream above it. For softmax stacks, value-residual learning feeds an early layer's attention values forward into later layers to counteract this over-smoothing [46,47]; Mixture-of-Depths lets tokens skip layers entirely via a learned router instead [48,49]. Applying a full depth-attention operator to a linear-memory stack partially defeats the point, though (reintroduces quadratic-ish cost across depth).
Tommaso Cerruti from ETH Zürich, along with Tim Rieder, George Rowlands and Lingfeng Jin, test the DeltaNet-flavored answer. They forward a lower layer's write error into the next layer's value target (Cross-Layer Error Residuals). This doesn't beat a matched baseline, because the routed error lands in the receiver's independently-learned value space, misaligned with that layer's own geometry, competing with rather than complementing its write target [50]. They (i) route into the shared residual stream instead, through a zero-initialized projection so the routed contribution starts at exactly zero and the model learns how strongly to use it; and separately, (ii) route the write value rather than the write error. That Cross-Layer Value Routing (CLVR) lowers final validation loss for both DeltaNet and Gated DeltaNet hosts. It cleanly establishes sharing across depth helps specifically where the naive version of it fails and that the fix is a change of injection space. The same paper's broader sweep found that a hybrid stack (one softmax layer per two linear-memory layers) beat every pure recurrent configuration tested [50], echoing the MiniMax M1-to-M2 story at a much smaller scale.
The throughline
The recurring engineering questions concern different boundaries. Does content-aware routing beat a random selector? What does selection itself cost? Does cross-layer information arrive in a representation the next layer can use? The routing study, DSA and CLVR address different parts of that problem. Matched ablations and complete cost accounting are needed to connect their results; the SubQ comparison remains a vendor claim. [26, 50, 53]
The shape of this problem looked familiar to me. The race to O(n) and continual learning asks a structurally identical question (across tasks instead of depth or token position) whether an update from a new process regime genuinely generalizes or gets absorbed and overwritten by what an earlier regime already encoded, depending on whether it's expressed in a shared geometry the receiver can actually use [51,52].
Sources
- Vaswani, A., et al. "Attention Is All You Need." NeurIPS 2017.
- NVIDIA. "Attention Is All You Need!, Transformer Engine Documentation." https://docs.nvidia.com/deeplearning/transformer-engine/user-guide/examples/attention/attention.html
- Zaheer, M., et al. "Big Bird: Transformers for Longer Sequences." NeurIPS 2020. https://papers.neurips.cc/paper_files/paper/2020/file/c8512d142a2d849725f31a9a7a361ab9-Paper.pdf
show all 54 referencesshow fewer references
- Beltagy, I., Peters, M. & Cohan, A. Longformer: The Long-Document Transformer, 2020. Primary paper.
- "Exploring Sparse Attention in Transformers: BigBird and LongFormer." https://medium.com/@ashutoshadhikari141/exploring-sparse-attention-in-transformers-bigbird-longformer-and-their-applications-3e69920c2085
- Subquadratic AI. SubQ-1.1-Small Technical Report, 2026. Vendor results and competitor-cost estimates; not independently replicated here. Technical report.
- Dao, T., Fu, D. Y., Ermon, S., Rudra, A., Ré, C. "FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness." arXiv:2205.14135. https://arxiv.org/abs/2205.14135
- "FlashAttention: Making Attention I/O-Aware." Hugging Face blog. https://huggingface.co/blog/garg-aayush/flash-attention
- Katharopoulos, A., Vyas, A., Pappas, N., Fleuret, F. "Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention." ICML 2020. arXiv:2006.16236. https://arxiv.org/abs/2006.16236
- Sun, Y., Dong, L., Huang, S., et al. "Retentive Network: A Successor to Transformer for Large Language Models." arXiv:2307.08621. https://arxiv.org/abs/2307.08621
- "A Survey of Retentive Network." arXiv:2506.06708. https://arxiv.org/abs/2506.06708
- Peng, B., et al. "RWKV: Reinventing RNNs for the Transformer Era." arXiv:2305.13048. https://arxiv.org/abs/2305.13048
- "The Evolution of RWKV: Advancements in Efficient Language Modeling." arXiv:2411.02795. https://arxiv.org/html/2411.02795v1
- De, S., et al. (Google DeepMind). "Griffin: Mixing Gated Linear Recurrences with Local Attention for Efficient Language Models." arXiv:2402.19427. https://arxiv.org/pdf/2402.19427.pdf
- Gu, A., Goel, K., Ré, C. "Efficiently Modeling Long Sequences with Structured State Spaces" (S4). arXiv:2111.00396. https://arxiv.org/abs/2111.00396
- Gu, A., Dao, T. "Mamba: Linear-Time Sequence Modeling with Selective State Spaces." arXiv:2312.00752. https://arxiv.org/abs/2312.00752
- Dao, T., Gu, A. "Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality" (Mamba-2). arXiv:2405.21060. https://arxiv.org/abs/2405.21060
- "A Survey of Mamba." arXiv:2408.01129. https://arxiv.org/html/2408.01129v8
- "Mamba-3: Improved Sequence Modeling using State Space Principles." arXiv:2603.15569. https://arxiv.org/html/2603.15569v1
- Yang, S., Wang, B., Zhang, Y., Shen, Y., Kim, Y. "Parallelizing Linear Transformers with the Delta Rule over Sequence Length." NeurIPS 2024. arXiv:2406.06484. https://arxiv.org/abs/2406.06484
- Songlin Yang's DeltaNet talk/poster materials, NeurIPS 2024. https://sustcsonglin.github.io/assets/pdf/neurips24_poster_deltanet.pdf
- "Linear Transformers for Efficient Sequence Modeling." Talk slides, Songlin Yang. https://sustcsonglin.github.io/assets/pdf/talk_linear_transformer.pdf
- Yang, S., Kautz, J., Hatamizadeh, A. "Gated Delta Networks: Improving Mamba2 with Delta Rule." ICLR 2025. arXiv:2412.06464. https://arxiv.org/abs/2412.06464
- "Kimi Linear: An Expressive, Efficient Attention Architecture." arXiv:2510.26692. https://arxiv.org/pdf/2510.26692.pdf
- "Gated DeltaNet-2: Decoupling Erase and Write in Linear Attention." arXiv:2605.22791. https://arxiv.org/pdf/2605.22791.pdf
- Aquino-Michaels, K. "Routing Absorption in Sparse Attention: Why Random Gates Are Hard to Beat." arXiv:2603.02227. https://arxiv.org/html/2603.02227
- Arora, S., et al. "Zoology: Measuring and Improving Recall in Efficient Language Models." ICLR 2024.
- "Revisiting associative recall in modern recurrent models." arXiv:2508.19029. https://arxiv.org/html/2508.19029v2
- "Mimetic Initialization Helps State Space Models Learn to Recall." arXiv:2410.11135. http://arxiv.org/pdf/2410.11135.pdf
- "SubQ: a sub-quadratic LLM with 12M-token context." Hacker News discussion. https://news.ycombinator.com/item?id=48023079
- DeepSeek-AI. "Native Sparse Attention: Hardware-Aligned and Natively Trainable Sparse Attention." arXiv:2502.11089. https://arxiv.org/pdf/2502.11089v1.pdf
- "Native Sparse Attention (DeepSeek NSA) Paper Note." ACL 2025 Best Paper. https://en.papernotes.org/ACL2025/llm_efficiency/native_sparse_attention/
- Kitaev, N., Kaiser, Ł., Levskaya, A. "Reformer: The Efficient Transformer." arXiv:2001.04451. https://arxiv.org/pdf/2001.04451.pdf
- "Do We Need Reformer for Vision? An Experimental Comparison." arXiv:2512.11260. https://arxiv.org/html/2512.11260v1
- Roy, A., Saffar, M., Vaswani, A., Grangier, D. "Efficient Content-Based Sparse Attention with Routing Transformers." TACL 2021. arXiv:2003.05997. https://arxiv.org/abs/2003.05997
- Zhu, Z., Soricut, R. "H-Transformer-1D: Fast One-Dimensional Hierarchical Attention for Sequences." arXiv:2107.11906. https://arxiv.org/abs/2107.11906
- Yang, S., Wang, B., Shen, Y., Panda, R., Kim, Y. "Gated Linear Attention Transformers with Hardware-Efficient Training." arXiv:2312.06635. https://arxiv.org/pdf/2312.06635.pdf
- "CARVE: Content-Aware Recurrent with Value Efficiency for Chunk-Parallel Linear Attention." arXiv:2606.27229. https://ar5iv.labs.arxiv.org/html/2606.27229
- Jelassi, S., Brandfonbrener, D., Kakade, S. M., Malach, E. "Repeat After Me: Transformers are Better than State Space Models at Copying." ICML 2024. arXiv:2402.01032. https://arxiv.org/abs/2402.01032
- Arora, S., Eyuboglu, S., et al. "Simple linear attention language models balance the recall-throughput tradeoff" (BASED). arXiv:2402.18668. https://arxiv.org/abs/2402.18668
- Guo, H., Yang, S., Goel, T., Xing, E. P., Dao, T., Kim, Y. "Log-Linear Attention." arXiv:2506.04761. https://arxiv.org/abs/2506.04761
- Alman, J., Yu, H. "Fundamental Limitations on Subquadratic Alternatives to Transformers." arXiv:2410.04271. https://arxiv.org/html/2410.04271v2
- "Overcoming Long-Context Limitations of State-Space Models" (joint recall hardness for SSM+sparse-attention hybrids). arXiv:2507.00449. https://arxiv.org/html/2507.00449v3
- "SubQ and the Attention Scaling Problem: What the Numbers Actually Say." Primere Substack. https://primere.substack.com/p/subq-and-the-attention-scaling-problem
- Morey, A. "Subquadratic attention is an old dream. SubQ is finally worth auditing." https://www.adityamorey.com/writing/subquadratic-attention-worth-auditing
- "Value Residual Learning For Alleviating Attention Concentration In Transformers" (ResFormer). arXiv:2410.17897. https://arxiv.org/html/2410.17897v1
- Hugging Face Papers. "Value Residual Learning." https://huggingface.co/papers/2410.17897
- Raposo, D., Ritter, S., Richards, B., Lillicrap, T., Humphreys, P. C., Santoro, A. "Mixture-of-Depths: Dynamically Allocating Compute in Transformer-Based Language Models." arXiv:2404.02258. https://arxiv.org/abs/2404.02258
- "Attention Is All You Need For Mixture-of-Depths Routing." arXiv:2412.20875. https://arxiv.org/abs/2412.20875
- Cerruti, T., Rieder, T., Rowlands, G., Jin, L., Schlag, I. "Mechanisms, Trade-offs, and Cross-Layer Routing." ETH Zürich, arXiv:2607.07953, July 2026. https://arxiv.org/pdf/2607.07953
- Störk, J. "Interference and Retention in Continual Learning." arXiv:2607.09202. https://arxiv.org/html/2607.09202v1
- Störk, J. "The Geometry of Forgetting in Continual Learning." Personal blog, 5 July 2026. https://j-stoerk.github.io/post-geometry-of-forgetting.html
- DeepSeek-AI. DeepSeek-V3.2-Exp, September 2025. DSA and the Lightning Indexer. Model card and technical report.
- Alman, J. & Song, Z. The Fine-Grained Complexity of Gradient Computation for Training Large Language Models, NeurIPS 2024. arXiv:2402.04497.
Use your identity on another device
Save an encrypted identity file and restore it in another browser. Keep the file and its passphrase private.