Sub-Quadratic Attention at 10M Tokens: Why the Indexer Is the Real Bottleneck
As million-token context windows become standard, scaling toward 10M tokens exposes a hidden cost in sparse attention: the indexer that selects relevant keys. This article breaks down the cost structure of full versus sparse attention, explains why sub-quadratic retrieval is the missing piece, and introduces Latent Sparse Attention, which moves scoring into a compressed latent space. It also offers practical engineering guidance on layered indexing, candidate-size tuning, KV cache reuse, monitoring, and elastic resources.
1. The Context Race Enters the 10M Token Era
Million-token context is quickly shifting from a selling point to a standard feature. Several model services recently made 1M context the default specification, making long-document understanding, cross-repository code analysis, and long-session memory practical to deploy. But engineering practice soon revealed a new ceiling: as context scales from 1M toward 10M, the cost curve does not shift upward linearly. Instead, it shows structural loss of control.
The industry has converged on one technical approach: instead of having each query traverse all historical tokens, select only a few of the most relevant keys to participate in computation. This approach has been repeatedly validated at the 1M scale. However, once it enters the 10M range, an originally unremarkable overhead begins to dominate.
2. The Overlooked “Hidden Bill”: The Indexer Becomes the Bottleneck
Take a global attention layer in a hybrid attention architecture as an example. When performing prefill at 10M tokens, roughly 98% of the time is not spent on attention computation itself, but on the indexing step that “decides which tokens to look at.” This data reveals a key fact: the real problem with sparse attention has shifted from “computing too much” to “searching too expensively.”
2.1 Cost Structure Breakdown
- Full attention: prefill computation grows as O(T²) with context length T, and each decoding step is O(T). When T increases from 1M to 10M, attention computation increases by roughly 100x.
- Sparse attention: a lightweight indexer first selects the k most relevant keys for each query, then computes only over those k keys, reducing the attention body to O(Tk).
- Hidden cost: if the indexer must determine “which k are most relevant,” it must first score all keys, and this step is often still on the order of O(T²). As a result, the overall complexity does not truly decrease.
2.2 Why “Looking at Only a Small Part” Works
Existing validation shows that at 128k tokens, letting each query attend to only about 0.8% of the most relevant keys still preserves roughly 98% of full-attention accuracy on long-context benchmarks. This indicates that sparsity itself is not the accuracy bottleneck; the bottleneck is how to find that small subset at sub-quadratic cost.
Illustrative complexity comparison (pseudocode):
# Naive sparse attention: indexing is still quadraticscores = q @ K.T # O(T^2)topk_idx = topk(scores, k) # O(T log k)out = softmax(q @ K[topk_idx].T) @ V[topk_idx] # O(Tk)
3. Latent Sparse Attention: Moving the “Search” into a Low-Dimensional Space
A recent paper jointly completed by a startup research team and universities proposed the idea of Latent Sparse Attention. The core is to migrate indexing and scoring into a compressed latent space, thereby reducing the cost of “finding relevant keys” to sub-quadratic. Its key design can be abstracted into three steps:
- Compression: project the key/value of long sequences into low-dimensional latent representations, reducing the scoring dimension and candidate scale.
- Coarse filtering: use approximate nearest neighbor-style retrieval within the latent space to quickly lock onto a candidate set, avoiding precise computation for each original key one by one.
- Fine computation: restore high-precision attention only for the candidate set to ensure output quality.
Public materials show that at 10M tokens, this approach can achieve order-of-magnitude-level speedups in the tens for single-attention-layer prefill, while maintaining accuracy close to the original model on multiple long-context tasks. It should be emphasized that the specific multiplier is strongly related to model structure and hardware, and engineering deployment should be based on self-testing.
4. Engineering Deployment Recommendations
- Layered indexing: use latent-space coarse filtering for global layers and retain window attention for local layers, balancing accuracy and speed.
- Candidate-size tuning: k and latent dimension are the core knobs; it is recommended to perform a small-scale grid search per task.
- Cache coordination: index results can be reused with the KV cache, reducing repeated scoring.
- Monitoring first: incorporate “index time ratio” into monitoring and alerting to avoid the bottleneck quietly migrating.
- Elastic resources: ultra-long-context tasks can leverage container platforms and message queues for asynchronous splitting to smooth peaks.
5. Conclusion
The essence of the 10M token competition is to decompose quadratic cost into “searchable coarse filtering + affordable fine computation.” Latent Sparse Attention provides a reusable engineering paradigm: first find candidates in a low-dimensional space, then compute accuracy in a high-dimensional space. For developers, understanding that the indexer is the real bottleneck matters more than chasing single-point speedup numbers.
