Latent Sparse Attention: 22x Faster Prefill for 10M-Token Contexts
Long-context models are moving from million-token to ten-million-token windows, but sparse attention has a hidden bottleneck: the indexer that decides which tokens to attend to can consume most of the prefill time as context grows. This article breaks down the cost structure of sparse attention, explains why token selection itself becomes quadratic, and introduces Latent Sparse Attention (LSA), which performs coarse selection in a compressed latent space before mapping back to original tokens. It also summarizes reported speedups at 10M-token contexts, accuracy findings, and practical implications for profiling, architecture design, validation, and infrastructure planning.
The Hidden Bottleneck in Ultra-Long Context
Over the past year, competition around long-context capability has continued to intensify. Several leading large models have made million-token (1M) context a default specification for official services, and newer models have begun to adopt hybrid architectures that combine sparse attention with linear attention. These approaches share a common choice: instead of letting every query scan all historical tokens, they select only a small number of the most relevant tokens for the query to “look at.”
This approach has been repeatedly validated at the million-token scale. But as context continues toward ten million (10M) tokens, an overhead that once seemed minor begins to spiral out of control. Measured data shows that in the global attention layer of a mainstream sparse attention model, during the prefill stage at 10M tokens, about 98% of the time is not spent on actual attention computation. Instead, it is spent on the indexer that decides which tokens should be attended to.
The nature of the problem therefore changes. Sparse attention has already demonstrated that “looking at only a small subset” is enough to preserve accuracy. What really blocks ultra-long context is that the step of “finding that small subset” still grows quadratically with context length.
Understanding the Cost Structure of Attention
In standard full attention, every query computes relevance against all preceding keys. Let the context length be T. Then:
- The compute cost in the prefill stage is O(T²).
- The cost of decoding each token is O(T).
When context grows from 1M to 10M tokens, the attention compute in prefill expands by roughly 100x. This is the fundamental reason full attention is unsustainable for ultra-long contexts.
Sparse attention uses a division of labor:
- Indexing stage: A lightweight indexer selects the k most relevant candidates from all keys for each query.
- Computation stage: Actual attention is performed only over these k keys.
This reduces the cost of attention itself to O(Tk). When k is a constant, such as 512, the theoretical complexity grows linearly with T.
This idea relies on a key premise: the model truly needs only a small number of keys. Prior research has validated this specifically at 128K tokens. When each query is allowed to see only the 512 keys that are “truly” most relevant, about 0.8% of all keys, the model still retains about 98% of full-attention accuracy on long-context benchmarks. This indicates that sparsification itself is not the accuracy bottleneck.
The Indexer’s Hidden Bill
The paradox lies precisely in the indexing stage. To know which 512 keys are most relevant, the indexer must first score every key. In other words, selection itself is O(T²).
Existing sparse solutions have used various tactics to reduce this cost:
- Lower scoring precision: Use low-bit quantization for coarse filtering to reduce the cost of scoring each key.
- Compressed scoring dimensions: Compute relevance with projections whose dimensionality is far below that of the hidden layer.
- Block sparsity: Compress several adjacent keys into a block-level representative, select blocks first, and then select keys, reducing the number of scores by a factor.
These methods optimize at the constant-factor level, but they do not change the complexity order. If context grows by 10x, indexing cost still grows by roughly 100x. The result is that attention computation is made very light by sparsification, while the indexer consumes 98% of the time. The savings from sparsification are spent entirely on “routing.”
Latent Sparse Attention: Sparsifying the Selection Itself
To address this contradiction, a research team has proposed a new method called Latent Sparse Attention (LSA). Its core idea can be summarized in one sentence: do not perform full scoring over the original token sequence; instead, first compress historical keys into a shorter latent-space representation, perform coarse filtering in that latent space, and then map back to the original sequence to obtain precise candidates.
The workflow can be broken into three steps:
- Hierarchical compression: Aggregate long history hierarchically into latent-state summaries far fewer in number than T. For example, pooling or learned compression modules can condense 10M keys into thousands of latent-space nodes.
- Latent-space coarse filtering: The query computes relevance only against these latent-space nodes. Scoring complexity drops from O(T²) to O(T·M), where M is the number of latent nodes. M grows sublinearly with T, yielding overall subquadratic complexity.
- Candidate backtracking and exact computation: For latent nodes selected by coarse filtering, backtrack to the original key ranges they cover, retrieve the top-k candidates, and perform standard attention computation.
Because coarse filtering happens in the compressed space, the step of “finding which tokens to look at” no longer expands quadratically with context length. The indexer turns from a bottleneck back into a negligible constant-level overhead.
Performance and Accuracy Validation
The paper reports substantial measured data for ten-million-token scenarios:
- On a new-generation model using hybrid sparse and linear attention, 10M-token prefill for a single attention layer is accelerated by about 22.7x.
- On an open-source model with 27 billion parameters, the same scenario is accelerated by about 72.4x.
- On a range of tasks including long-context retrieval and multi-hop reasoning, accuracy is basically on par with the original model, with no significant degradation.
It is worth noting that the effectiveness of this type of method rests on two empirically validated facts. First, attention distributions are naturally highly sparse, and top-k covers most of the attention mass. Second, semantic relevance has good aggregability across local and hierarchical structures, so “coarse filtering in a compressed space first” does not lose truly important candidates.
Implications for Engineering Practice
For teams that need to deploy ultra-long-context capabilities in production, this research offers several practical implications:
1. Performance profiling must cover the full pipeline. Looking only at the FLOPs of the attention kernel can lead to misjudging the bottleneck. Indexing, scoring, Top-K selection, and memory movement can become absolutely dominant under ultra-long contexts. Profiling must measure the cost of “routing” separately.
2. Sparsification should consider a two-level structure. First-level sparsity, direct token selection, is acceptable at the million-token scale. Above ten million tokens, systems should move toward a two-level architecture of “coarse filtering in compressed space plus exact computation in original space.” This aligns with the classic idea of “inverted index plus fine-grained re-ranking” in vector retrieval.
3. Accuracy validation should anchor to a strong baseline. When evaluating sparse methods, compare against the accuracy upper bound of “theoretical top-k,” not only against the original model’s output. This helps distinguish sparsification loss from implementation loss.
4. Infrastructure must match ahead of time. Inference at ten-million-token scale places extremely high demands on memory capacity, KV cache management, and elastic compute scheduling. Cloud capabilities such as object storage for historical caches of ultra-long sessions, container platforms for elastic scaling, and logging and monitoring systems for tracking the share of indexer time can help translate algorithmic speedups into end-to-end latency and cost benefits.
Conclusion
Competition in long context is moving from “whether it can be supported” to “at what cost it can be supported.” Sparse attention solves the problem of “computing less,” while Latent Sparse Attention further solves the problem of “selecting faster,” moving complexity from quadratic to subquadratic. When the indexer no longer spirals with length, ten-million-token context becomes genuinely feasible from both an engineering and a commercial perspective. For developers, understanding the origins and implications of this hidden bill is an essential foundation for designing the next generation of long-context systems.
