Latent Sparse Attention (LSA): 22x Faster Than Mainstream Sparse Attention at 10M Tokens
Ultra-long context has become a key battleground for large language models, but as context windows push toward 10 million tokens, the indexing overhead of mainstream sparse attention becomes the dominant cost. This article breaks down Latent Sparse Attention (LSA), a recently proposed method that performs key selection in a low-dimensional latent space instead of the original token space. It explains the cost structure of sparse attention, why the indexer itself becomes the bottleneck, how LSA works, its reported 22.7x–72.4x prefill speedups on a single attention layer at 10M tokens, and practical engineering takeaways for building ultra-long-context inference systems.
Ultra-long context capability has become the main battleground for large language models. One leading vendor made 1M-token context the default across its official services, and flagship models from multiple organizations followed with 1M-token support, often adopting hybrid architectures that combine sparse attention and linear attention. Behind all of these approaches is a shared design choice: instead of letting every query attend to all historical tokens, select only a small set of the most relevant ones.
This approach has been validated repeatedly at the million-token scale. But as context windows push toward 10 million tokens, a cost that once seemed negligible starts to spiral out of control. A recent paper published jointly by an overseas startup team and a university proposes Latent Sparse Attention (LSA), which accelerates prefill of a single attention layer by 22.7x to 72.4x at 10M tokens while maintaining accuracy close to the original model. This article systematically breaks down its core ideas and engineering implications.
1. Background: The Cost Structure of Sparse Attention
Let’s start with the basic math of attention. In standard full attention, every query computes relevance against all previous keys. With a context length of T, prefill compute is O(T²), and each decoded token costs O(T). Scaling context from 1M to 10M tokens means 100x more attention compute during prefill.
Sparse attention divides the work: a lightweight “indexer” first selects the k most relevant keys for each query, and the actual attention computation runs only on those k keys. This brings the attention cost down to O(Tk).
This approach rests on one premise: the model really does need only a small number of keys. The paper’s appendix validates this explicitly: at 128k tokens, letting each query of a mainstream open-source model attend only to its “truly” most relevant 512 keys (about 0.8% of all keys) still preserves 98% of full-attention accuracy on long-context benchmarks. This confirms that “attending to only a small fraction” is sound from an accuracy standpoint.
2. The Paradox: Finding That Small Fraction Is Also Expensive
The problem lies in the indexer itself. To know which 512 keys are most relevant, the indexer must first score every key—which is essentially still one full query-to-all-keys interaction.
Existing solutions reduce the indexer’s burden in various ways: lowering scoring precision, reducing scoring dimensionality, or compressing multiple keys into a single block. But none of them change the fundamental property: indexing overhead still grows quadratically with context length. At the 1M scale, indexer cost is tolerable; at 10M, it flips and becomes the dominant cost.
The paper’s data makes this vivid: for a global attention layer of a mainstream model supporting 1M context, when prefilling at 10M tokens, 98% of the time is not spent on the attention computation itself, but on the indexer deciding “which tokens to look at.” In other words, sparse attention long ago proved that attending to a small fraction is enough to preserve accuracy—what truly bottlenecks ultra-long context is the cost of finding that fraction.
3. The Core Idea of LSA: Selection in Latent Space
LSA’s approach can be summarized in one sentence: instead of selecting keys in the original token space, first compress into a low-dimensional latent space and perform selection there.
It involves three key steps:
1. Compressed representation. All historical keys are mapped through a lightweight projection into a latent space much smaller than the original dimension. In this space, the sequence itself can be further aggregated (for example, merging consecutive keys into a small number of latent states), reducing the number of “candidates” participating in scoring from T to T/r (where r is the compression ratio).
2. Latent-space scoring and selection. The query is likewise projected into the latent space, scored against the compressed latent states, and the highest-scoring ones are selected and mapped back to their original key positions. Because the number of latent states is far smaller than T, scoring cost drops from O(T²·d) to O(T²·d’/r) or even lower—achieving sub-quadratic growth.
3. Exact attention recomputation. The small set of selected keys returns to the original high-dimensional space and undergoes standard attention computation with the query, ensuring output quality is not compromised. This matches the classic “coarse selection + fine computation” two-stage structure of sparse attention—the difference is that the coarse selection step is moved into a low-dimensional space.
This design closely mirrors the intuition of “retrieve first, then read”: when humans browse long documents, we scan the table of contents and summaries (low-dimensional compressed representations) to locate the relevant sections, then read the original text carefully—rather than comparing word by word across every page.
4. Measured Results: 22.7x to 72.4x Speedups
The paper validates LSA on two representative open-source models. In a 10M-token prefill scenario, a single global attention layer of a model using a hybrid sparse-and-linear attention architecture achieved a 22.7x speedup; for a larger dense model, the speedup reached 72.4x.
More important is accuracy preservation: across multiple long-context benchmark tasks, the LSA-augmented models performed essentially on par with the originals. This validates the key hypothesis from earlier—as long as selection is accurate enough, attention needs only a tiny fraction of keys, and the selection process can be completed entirely in a low-dimensional latent space without losing localization precision.
It should be noted that these speedups are layer-level measurements on specific hardware. End-to-end gains also depend on the proportion of global attention layers in the overall network, memory access patterns during decoding, and other factors. But the overall conclusion is clear: at the 10M-token scale, indexing cost is the number-one bottleneck, and latent-space selection is one of the most direct solutions available today.
5. Engineering Takeaways
LSA highlights several directions worth attention for ultra-long-context engineering:
1. Optimize indexing and attention separately. When designing sparse attention schemes, don’t focus only on “how much to attend to”—also evaluate “the cost of finding.” Profile prefill at the layer level to clarify the time share of the indexer versus the attention computation, then set optimization priorities accordingly.
2. Low-dimensional coarse filtering is a general paradigm. Whether it’s key selection inside attention or external retrieval-augmented generation (RAG), “coarse filtering over compressed representations, fine computation over original representations” is a proven two-stage structure. When deploying ultra-long-context inference services in the cloud, you can combine container platforms for elastic scaling and use monitoring and alerting to track changes in indexing-phase latency, so you can spot bottleneck shifts early.
3. Accuracy validation should mirror real workloads. The paper’s “top-k oracle” validation method is worth adopting: first let the model attend with the truly most relevant key set to measure the accuracy ceiling, then evaluate how close approximate selection gets to that ceiling. This exposes the quality of the selection mechanism far better than directly comparing final task scores.
4. Pay attention to the decoding phase. The gains discussed in this article focus on prefill. During decoding at 10M-token context, KV cache memory access pressure is equally significant. How sparse selection can work in concert with KV compression and paged caching techniques is the next engineering priority.
6. Conclusion
Competition in ultra-long context is shifting from “can we support it” to “at what cost can we support it.” LSA’s answer is to move the selection process into a latent space, so that “finding what to look at” no longer inflates quadratically with length. As 10M-scale context gradually enters production scenarios, sub-quadratic attention mechanisms of this kind are likely to become standard components of next-generation inference architectures—and are worth continued attention from every engineer focused on inference performance optimization.
