Scaling Sparse Attention to 10M Tokens: The Indexer Bottleneck and Latent-Space Solutions
Sparse attention has made million-token contexts practical, but scaling to 10 million tokens exposes a new dominant cost: the indexer that decides which tokens each query should attend to. This article breaks down the cost structure, explains why indexer overhead grows quadratically, introduces latent sparse attention (LSA), and discusses engineering implications for long-context inference systems.
1. The Evolution of Ultra-Long Context
Over the past year, ultra-long context has moved from a laboratory capability to a default specification. Several leading model teams have made million-token context the default configuration for all services, and some models have introduced hybrid architectures that combine sparse attention with linear attention to support this scale. Behind these approaches is a common technical choice: each query no longer traverses all historical tokens. Instead, it selects only a small number of the most relevant tokens to attend to.
This route has been repeatedly validated at the million-token level. At the same time, industry practice has exposed a new problem: as context continues to scale toward 10 million tokens, a previously inconspicuous cost begins to spiral out of control.
Consider a global attention layer in a common block-sparse attention architecture. During prefill at 10 million tokens, the vast majority of time—up to 98% in some research estimates—is not spent on attention computation itself, but on the indexer that decides which tokens to look at.
The nature of the problem therefore changes. Sparse attention has long demonstrated that “looking at only a small subset” is enough to preserve accuracy. What actually blocks ultra-long context is that the process of “finding that small subset” still grows quadratically with context length.
2. The Cost Structure of Sparse Attention
It is useful to review the cost ledger of attention. In standard full attention, every query computes a relevance score against all previous keys. Let the context length be T. Then:
- The computation in the prefill phase is O(T²).
- The cost of decoding each token is O(T).
This means that when context grows from 1 million tokens to 10 million tokens, prefill attention computation increases by 100×. This is not a problem that linear scaling can solve; it requires an algorithmic structural breakthrough.
The idea behind sparse attention is a division of labor:
- Indexer: a lightweight module that selects the k most relevant keys for each query.
- Main attention: the actual attention computation is performed only on these k keys.
In this way, the cost of attention itself is compressed to O(Tk). When k is much smaller than T, the benefit is substantial.
This idea rests on a key premise: the model truly needs only a very small number of keys. An appendix in a related paper provided rigorous validation. With a 128k-token context, when each query attends only to the 512 keys that are truly most relevant (about 0.8% of all keys), the model still retains 98% of full-attention accuracy on long-context benchmarks. This shows that sparsification is valid in an information-theoretic sense: the vast majority of attention weights are inherently wasteful.
3. The Overlooked “Hidden Bill”: Quadratic Indexer Cost
But there is a paradox here: for the indexer to know which 512 keys are most relevant, it must first score every key. In other words, the indexer itself becomes another form of attention.
Mainstream sparse approaches in the industry, including various block-sparse designs, generally reduce the indexer’s burden by lowering scoring precision, reducing scoring dimensions, and compressing multiple keys into a block. These methods are effective enough at the 100k to 1M token scale, but they only reduce constant factors. They do not change the fundamental nature: the indexer’s scoring complexity grows linearly with T per query, and total overhead grows quadratically with T.
A straightforward estimate: if the indexer needs to scan all T keys for each query, then overall indexing overhead is O(T²)—the same order as full attention. The only difference is that each indexer score is several times cheaper than real attention. When T reaches the 10 million scale, this constant advantage of being “several times cheaper” is completely swallowed by the quadratic curve. This produces the inversion described earlier, where 98% of time is spent on indexing.
4. Latent Sparse Attention: Selecting Keys in Another Space
Recently, a research team from a startup and a well-known university published a paper proposing a new method called Latent Sparse Attention (LSA), which directly addresses the quadratic bottleneck of the indexer.
Its core idea can be summarized as follows: do not perform exhaustive scoring in the original token space. First project keys and queries into a low-dimensional latent space, complete coarse filtering there using an approximate, subquadratic method, and then return to the original space for precise fine filtering.
Mechanically, LSA includes several key designs:
- Latent-space compression: maintain a low-dimensional latent representation for each key, with a dimension far smaller than the native dimension of the attention head. The indexer computes query-key relevance only on latent representations, greatly reducing the cost of each score.
- Hierarchical candidate generation: first perform coarse-grained scoring in latent space at the block level to quickly narrow the candidate range, then perform fine-grained scoring on keys within candidate blocks. This converts the burden of “traversing all keys for each query” into “traversing a small number of candidate blocks for each query.”
- End-to-end training: latent representations and the indexer participate in model training together, ensuring that the key set selected by the indexer highly overlaps with the high-weight regions of real attention. This avoids mismatches such as “the indexer is accurate but the model does not use it” or “the model needs something but the indexer misses it.”
The experimental results reported in the paper are considerable: at the 10 million token scale, the method speeds up prefill for a single attention layer by more than 20× on a typical open-source-scale model, and by more than 70× on another mainstream-scale model, while maintaining accuracy close to the original model on a series of long-context tasks.
5. Engineering Perspective: Why This Direction Is Worth Following
From an engineering deployment perspective, work such as LSA offers several insights:
First, bottlenecks migrate, and optimization must follow. Sparse attention solves the O(T²) cost of attention computation itself, but pushes the bottleneck to the indexer. When building ultra-long-context inference systems, performance profiling must cover the complete pipeline—embedding, indexing, attention, KV cache management, and communication. Optimizing only the attention kernel may mean optimizing the 2%.
Second, subquadratic methods are the entry ticket for 10 million tokens. In the million-token era, constant-factor optimizations such as quantization, block sparsity, and kernel fusion can still hold up. In the 10 million-token era, any remaining O(T²) component becomes a critical weakness. Subquadratic techniques such as latent-space approximation and hierarchical retrieval will become standard.
Third, the methodology for validating accuracy and efficiency is mature. When evaluating such approaches, focus on accuracy retention at extremely low key sampling rates, the overlap between the indexer and the true attention distribution, and the separate gains in the prefill and decode phases.
For enterprise developers using cloud-based large-model services, these advances will ultimately translate into longer context, lower latency, and more controllable inference costs. Combined with general cloud capabilities such as GPU compute scheduling, object storage, and logging and monitoring, building 10-million-token applications for long-document analysis, codebase understanding, and multi-source knowledge integration is moving from a “technical adventure” to an “engineering routine.”
Conclusion: The next battlefield for sparse attention is not “computing less,” but “finding faster.” Latent sparse attention provides a strong opening, and also signals that the ultra-long-context technology stack is about to undergo a round of structural reconstruction.
