Sparse Attention at 10M Tokens: Breaking the Indexing Bottleneck
Million-token context windows are becoming standard, and sparse attention preserves accuracy by letting each query attend to only a small set of relevant keys. At 10M tokens, however, the indexer that selects those keys becomes the dominant cost because it still scores every key and remains O(T²). This article reviews the cost structure of attention and sparsification, explains the indexing paradox, and introduces Latent Sparse Attention (LSA), which uses compressed latent summaries, two-level filtering, and end-to-end training to reduce indexing overhead. It also summarizes reported speedups, trade-offs, and practical guidance for profiling, hierarchical retrieval, elastic cloud scheduling, and accuracy baselines.
Sparse Attention at 10M Tokens: Breaking the Indexing Bottleneck
1. Long Context Becomes Standard—and a New Bottleneck Emerges
Million-token context windows have moved from a flagship-only selling point to a baseline capability. Mainstream services commonly treat 1M contexts as a default specification. The shared technical choice behind this shift is to stop having every query scan all historical tokens and instead use sparse mechanisms so that each query focuses on only a small set of the most relevant keys.
This approach has been repeatedly validated at the 1M scale. But as context sizes move toward 10M, an originally minor cost begins to spiral out of control. Measurements on a global attention layer in a hybrid-architecture model during 10M-token prefill showed that about 98% of the time was not spent on attention computation itself, but on the indexer that decides which tokens to attend to.
The nature of the problem therefore changes. Sparse attention has already shown that “looking at only a small subset” is enough to preserve accuracy. What blocks ultra-long context is that the cost of “finding that subset” still grows quadratically with context length.
2. Review: Attention Cost Structure and the Division of Labor in Sparsification
Start with the cost model of standard full attention. When the context length is T, every query must compute relevance against all previous keys. Prefill computation is O(T²), and each decoded token costs O(T). As context grows from 1M to 10M, prefill attention computation alone increases by 100x.
The core idea of sparse attention is a division of labor:
- Indexing stage: a lightweight indexer selects the k most relevant keys for each query.
- Computation stage: the actual attention runs only over those k keys, reducing cost to O(Tk).
This idea relies on a key premise: the model really only needs a small number of keys. Ablation studies have shown that at 128k tokens, if each query attends to only its roughly 512 truly most relevant keys—about 0.8% of all keys—the model can still retain about 98% of full-attention accuracy on long-context benchmarks.
3. The Paradox: The Indexer Itself Is O(T²)
There is a hidden paradox here. For the indexer to know which 512 keys are most relevant, it must first score every key. In other words, the indexer still implicitly contains a “query × all keys” interaction, and its complexity remains O(T²). The attention body is reduced to linear cost, but the hidden indexing bill is not eliminated—it is only moved to another place.
Specifically, an indexer typically projects queries and keys into a low-dimensional space and then performs full scoring. Even if dimensionality reduction compresses the constant factor, it does not change the quadratic order. At 10M tokens, the accumulation of that constant factor is enough to make indexing dominate prefill time. This is why many sparse schemes perform well in the 128k–1M range but quickly break down at 10M.
4. LSA: Compressing Scoring into Latent Space
Recent work from a research team proposed Latent Sparse Attention (LSA), which directly targets the quadratic root of indexing cost. Its core idea can be understood at several levels.
4.1 Compressed Index Representation
Instead of having queries interact with all original keys one by one, LSA first compresses the long context into segments and then into a small number of “latent summary representations.” Each summary carries the key information of a context segment. The indexer’s first step scores the query only against these summaries, reducing the scale from O(T) to a number of summaries far smaller than T.
4.2 Two-Level Filtering Instead of Full Scoring
After coarse screening locates candidate intervals, fine-grained key-level scoring is performed inside those intervals to select the final top-k. The process is similar to the classic database pattern of “block index + in-page scan”: first locate the data block, then perform an exact lookup within the block, avoiding a full table scan for every row.
4.3 Trainable and End-to-End
The indexer is not a post-hoc heuristic rule. It is a module trained together with the model, and its scoring distribution is aligned with the true attention distribution through an auxiliary objective. This helps ensure that the selected keys overlap heavily with the high-weight keys under full attention, preserving accuracy while accelerating the engineering path.
5. Results and Costs
Public evaluation results show that at the 10M-token scale, this method achieved more than 20x speedup for prefill of a single global attention layer in a hybrid-architecture model, and more than 70x speedup for larger-parameter models, while maintaining accuracy comparable to the original model on a range of long-context benchmarks.
Its costs and applicable boundaries are also worth noting:
- Structural changes: an indexing module must be introduced into the model and participate in training. It cannot be directly applied to already trained models for lossless acceleration.
- Granularity trade-off: the higher the summary compression ratio, the greater the recall risk in coarse screening. Hyperparameters must be balanced between compression ratio and accuracy loss.
- Different decode-stage gains: LSA mainly optimizes the quadratic bottleneck of prefill. Gains in the decode stage depend on implementation details.
6. Implications for Engineering Practice
For teams building long-context applications, this progress offers several actionable judgments:
- Profile first to locate the bottleneck: do not assume by default that “the slowdown is in attention.” In ultra-long contexts, use a profiler to confirm whether time is spent on scoring, the attention kernel, or KV cache movement. The optimization direction is completely different in each case.
- Segmented and hierarchical retrieval is a general paradigm: whether in an in-model indexer or application-layer RAG retrieval, the two-level structure of “coarse screening first, fine ranking second” is a general way to reduce quadratic overhead.
- Elastic cloud resources can match the workload: 10M-level prefill is a typical short-duration, high-compute task. It is suitable for task-level elastic scheduling through cloud container orchestration and GPU resource pooling, with object storage for long document corpora and message queues to smooth task requests, avoiding long-running resources provisioned for peak demand.
- Watch accuracy baselines: any sparsification scheme should be compared with full attention on long-context retrieval, multi-hop reasoning, and other benchmarks. Confirm that accuracy loss is acceptable before launch.
7. Conclusion
Sparse attention solves the question of “how much to compute,” while latent-space indexing schemes such as LSA attempt to solve the question of “which ones to find.” As context lengths continue to move toward tens of millions and even hundreds of millions of tokens, structural optimization of indexing cost will be the next main battlefield in long-context architecture. For developers, understanding the paradox that “the indexer is also O(T²)” has more long-term value than memorizing any specific speedup number.
