How Sparse Attention Gets Another 20x Speedup at 10-Million-Token Context Lengths
Long-context models with million-token windows are becoming the default, but at ten million tokens, the indexer that picks which tokens to attend to can take longer than the attention computation itself. This article explains why the bottleneck has shifted from attention math to token retrieval, and how Latent Sparse Attention (LSA) moves token selection into a compressed latent space. It also covers the reported speedups, how to read them, and practical points for production deployment.
How Sparse Attention Gets Another 20x Speedup at 10-Million-Token Context Lengths
1. Background: Ultra-Long Context Is Becoming the Default
Over the past year, leading large language models have made million-token context windows their default specification. This has made scenarios such as repository-level code understanding, question answering over entire technical manuals, and joint reasoning across multiple documents practical.
These models share a common engineering choice. Instead of having each query position attend to all historical tokens, they select a small set of the most relevant Key-Value pairs for each attention computation. This approach is known as Sparse Attention.
The approach has been validated repeatedly at the million-token scale. Attending to a small portion of the context causes minimal accuracy loss, while computation and memory usage drop substantially. As context length grows toward ten million tokens, however, an overhead that used to be minor starts to get out of control. The indexer, which decides which tokens to look at, now takes more time than the attention computation itself.
2. The Problem: The Bottleneck Shifts from Computing Attention to Finding Attention Targets
Consider a typical global attention layer. During prefill over ten million tokens, up to 98% of the time goes to scoring and filtering candidate tokens, not to the attention matrix multiplication.
The nature of the problem has changed:
- The core constraint in the past: The compute cost of full attention grows quadratically with sequence length. Sparsification solved this by attending to only a small subset.
- The core constraint now: The retrieval process used to find that small subset still grows roughly quadratically with context length. In other words, sparse attention turned a compute bottleneck into a retrieval bottleneck.
This resembles searching a document library of ten million documents. Even if you only read ten documents closely, scoring the entire library for every new query makes the scoring step the ceiling on system throughput.
3. A New Approach: Selecting in Latent Space Instead of the Original Space
Recently, a research team released a method called Latent Sparse Attention (LSA). Its core idea fits in one sentence: move the choice of which tokens to attend to from the original high-dimensional token space into a compressed, low-dimensional latent space.
The method rests on three key design choices.
1. Low-dimensional proxies replace full-dimensional scoring
Traditional indexers compute relevance scores from full Key vectors. LSA keeps a low-dimensional “latent proxy” vector for each historical token. Query vectors are projected into the same latent space, and relevance scoring happens between these low-dimensional vectors. Because the dimensionality is greatly reduced, the floating-point operations and memory accesses per score also drop. This brings the total cost of scoring across ten million tokens down to a manageable level.
2. Retrieval structure is decoupled from attention
Latent-space scoring pairs naturally with approximate retrieval structures, such as chunk summaries, hierarchical indexes, and approximate nearest neighbor search, which are common techniques across the industry. The retrieval stage only needs to run Top-K selection on the compressed representations. After a match, the system returns to the original space to fetch the corresponding Key-Value pairs for exact attention. Because retrieval and computation are decoupled, each can be optimized separately and organized into a pipeline.
3. Compatibility with existing model architectures
The method does not require retraining the entire model. It can replace or sit alongside the attention layer in existing sparse or linear-hybrid attention architectures. This makes it a convenient upgrade path for models already in production.
4. Results: Over 20x Speedup for a Single Layer
According to the public paper, in the prefill stage at ten-million-token scale, the method speeds up a single global attention layer of a mainstream hybrid-attention model by about 22x. It speeds up the corresponding layer of another open-source large model by more than 70x. Across several long-context tasks, accuracy remains essentially on par with the original models.
These numbers need careful reading. They measure the prefill time of a single attention layer, not end-to-end inference latency. The overall gain depends on the share of global attention layers in the full network, the proportion of time spent in decoding, and the quality of the engineering implementation. Even so, cutting the step that takes 98% of the time by an order of magnitude would still be a decisive factor in overall throughput.
5. Practical Considerations for Deployment
For teams that want to apply this approach in production inference services, these recommendations apply:
- Profile before optimizing: Use performance analysis tools to confirm that the indexer’s share of runtime is actually a bottleneck. At around 100,000 tokens of context, it may not be the main constraint.
- Storage and updates for latent proxies: Latent representations need an extra memory budget and must stay in sync with the appending and eviction of the KV cache. Design them together with the existing KV paging mechanism.
- Keep accuracy safeguards: Long-context tasks such as needle-in-a-haystack retrieval and cross-document reasoning are highly sensitive to missing key tokens. Before launch, evaluate both recall and end-to-end accuracy on representative benchmarks.
- Software-hardware co-optimization: Low-dimensional scoring lends itself well to vectorization and operator fusion. Custom operators in the inference framework can further reduce constant-factor overhead.
6. Conclusion
Sparse attention showed that attending to a small part of the context is enough to preserve accuracy. Latent Sparse Attention goes further by showing that finding that small part does not have to cost something that grows with context length. As context windows expand from millions to ten million tokens, competition is shifting from who can attend to the most tokens to who can find the right ones fastest. For developers, understanding the causes of the retrieval bottleneck and the latent-space selection approach will be key groundwork for building the next generation of long-context inference services.
