Latent Sparse Attention: A General Path to 22x Faster Sparse Attention at 10M-Token Contexts
This article analyzes Latent Sparse Attention (LSA), a method for reducing the indexer bottleneck that emerges when sparse attention is scaled to 10M-token contexts. It explains the cost structure of sparse attention, describes LSA’s latent-space projection and hierarchical aggregation, summarizes reported prefill speedups and accuracy findings, and outlines practical lessons for engineering ultra-long-context inference systems.
Latent Sparse Attention: A General Path to 22x Faster Sparse Attention at 10M-Token Contexts
1. The Evolution of Ultra-Long Context: From 1M to 10M Tokens
Over the past two years, the context windows of large models have expanded rapidly. From early 4K and 32K windows to later models that set 1M tokens as a default specification, long-context capability has shifted from a differentiator to infrastructure. The core technical route behind this evolution has been highly consistent: instead of letting every query traverse all historical tokens, select only a small number of the most relevant keys for attention computation. This is sparse attention.
This route has been repeatedly validated at the 1M-token scale. However, as context continues toward 10M tokens, a previously minor cost begins to spiral out of control: the indexer that decides “which tokens to look at” becomes the new performance bottleneck.
A recent study released by a group of research institutions proposes a new method called Latent Sparse Attention (LSA). In a 10M-token prefill test, the method accelerated a single global attention layer in a mainstream sparse attention model by about 22.7x, and accelerated another larger open-source model by more than 72x. At the same time, it maintained accuracy close to the original model on multiple long-context tasks. This article breaks down the technical logic behind it.
2. The Cost Structure of Sparse Attention: An Overlooked “Hidden Bill”
2.1 The Quadratic Dilemma of Full Attention
In standard full attention, every query computes relevance against all previous keys. When the context length is T:
- The compute cost in the prefill stage is O(T²).
- The cost of decoding each token is O(T).
This means that when context grows from 1M to 10M tokens, the attention compute cost in prefill theoretically grows by about 100x. That is clearly unacceptable.
2.2 The Division of Labor in Sparse Attention
The idea behind sparse attention is a division of labor:
- A lightweight indexer quickly selects the k most relevant keys for each query.
- The actual attention computation is performed only on those k keys.
In this way, the cost of the main attention body is compressed to O(Tk). When k is much smaller than T, the benefit is significant.
This strategy relies on a key premise: the model really only needs a small number of keys. The paper’s appendix provides validation: at 128K tokens, when each query in a certain model attends only to its “truly” most relevant 512 keys—about 0.8% of all keys—the model still retains about 98% of full-attention accuracy on mainstream long-context benchmarks. This shows that “looking at only a small portion” does not significantly harm quality.
2.3 The Paradox: Finding “That Small Portion” Is Expensive
The problem lies precisely in the first step. For the indexer to know which 512 keys are most relevant, it must first score every key—and the cost of scoring grows linearly with context length T. Across all queries, the total cost remains at the O(T²) level.
Existing sparse attention schemes use various methods to reduce indexing cost: lowering scoring precision, compressing scoring dimensions, aggregating adjacent keys into blocks before block-level filtering, and so on. These methods remain tolerable at the 1M-token scale, but at 10M tokens the share of indexing overhead rises sharply. Take a model with a hybrid sparse architecture as an example: when performing prefill at 10M tokens, 98% of the time is not spent on attention computation, but on the indexer.
The nature of the problem changes accordingly: sparse attention has long proven that “looking at only a small portion” is enough to preserve accuracy. What truly blocks ultra-long context is that “finding that small portion” still grows quadratically with context length.
3. The Core Idea of LSA: Move the “Finding” Process into Latent Space
3.1 Key Observation
LSA starts from a simple but profound observation: the indexer does not need exact attention scores; it only needs a sufficiently good relevance ranking. Given that, why not project keys into a lower-dimensional, more compact latent space and perform scoring there?
This resembles a classic idea in information retrieval: first use low-dimensional vectors for coarse recall, then use high-fidelity representations for precise reranking. LSA systematically introduces this idea into the attention indexer.
3.2 Two-Level Compression Mechanism
The core design of LSA can be summarized as two levels of compression:
- Latent-space projection: High-dimensional key representations are mapped through a lightweight projection into a low-dimensional latent space. Queries undergo a corresponding projection. Scoring is performed in the low-dimensional space, greatly reducing the cost of each scoring operation.
- Hierarchical aggregation: On top of the latent space, token-level representations are further aggregated into block-level units, so that the number of scoring targets is also controlled sublinearly as context grows.
With both combined, the overall complexity of the indexer drops from O(T²) to a subquadratic level—this is exactly the meaning of “Towards Subquadratic Ultra-Long Context Attention” in the paper title.
An illustrative pseudocode snippet helps explain the flow:
def lsa_indexer(queries, keys, top_k):# 1. Project to low-dimensional latent spaceq_latent = W_q_down @ queries # [T, d] -> [T, d_small]k_latent = W_k_down @ keys # [T, d] -> [T, d_small]# 2. Score in latent space (much cheaper than original dimension)scores = q_latent @ k_latent.T# 3. Select top-k, return to original space for exact attentiontopk_idx = scores.topk(top_k, dim=-1).indicesreturn attention(queries, keys[topk_idx], values[topk_idx])
Actual implementations also involve details such as grouped projection, block-level aggregation, and kernel-level optimization, but the core logic remains unchanged: replace expensive scoring in the original space with cheap scoring in latent space.
3.3 Why Accuracy Does Not Collapse
Low-dimensional projection naturally introduces information loss. How does LSA ensure filtering quality? Two points are key:
- The task does not require exact scores: The indexer only needs “approximately correct ranking.” Small deviations in the top-k set are tolerated by the subsequent real attention computation—attention itself is robust to redundant keys.
- The projection matrix is trainable: The projection weights are not randomly initialized and frozen; they can be jointly optimized with the model during training, so that the latent representation specifically serves the goal of “relevance discrimination” rather than preserving all semantic information.
This is consistent with the philosophy of techniques such as quantization and distillation: define what the module “only needs to do,” and then retain only the information necessary to complete that task.
4. Interpreting the Experimental Results
The paper reports the following key data for a 10M-token prefill scenario:
| Test target | Speedup (single attention layer) |
|---|---|
| A hybrid sparse attention model | About 22.7x |
| A 27B-class open-source model | About 72.4x |
Two points deserve attention:
- Speedup varies by model because the indexer accounts for different shares of total latency in different models—the bulkier the indexer, the greater the benefit from LSA.
- Accuracy preservation is another important conclusion: on multiple long-context retrieval, reasoning, and summarization tasks, the gap between LSA and the original model remains within an acceptable range, indicating that latent-space scoring does not damage the quality of sparse selection.
It is important to emphasize that such results depend heavily on hardware kernel implementation, batch size, and sequence length distribution. Readers should pay attention to the complete test conditions given in the paper rather than evaluating a single number in isolation.
5. Implications for Engineering Practice
The ideas behind LSA offer several transferable lessons for building ultra-long-context inference systems:
- Quantify the bottleneck before optimizing. In long-chain systems, the “commonly assumed hotspot” may not be the real hotspot. In this case, 98% of latency came from the indexer rather than attention computation. Such conclusions can only come from profiling, not intuition.
- Hierarchical approximation is a general-purpose tool. The pattern of using cheap representations for coarse filtering and high-fidelity representations for precise computation appears repeatedly in vector retrieval, recommender systems, and MoE routing. When facing quadratic complexity, first consider “whether the decision can be made in a lower-dimensional space.”
- Distinguish “correct ranking” from “numerical exactness”. Many intermediate stages only need ordering information, not exact values. This is often the safe boundary for compression and approximation.
- Focus on system design for subquadratic complexity. As context moves toward 10M tokens, any O(T²) component becomes a systemic risk. Complexity should be treated as a hard requirement in architecture reviews.
In enterprise deployments, ultra-long-context inference also involves engineering challenges such as memory management, KV cache scheduling, and distributed prefill. General cloud capabilities such as object storage, container platforms, elastic compute scheduling, and monitoring and alerting can be combined to build a complete inference service chain, but the core algorithmic efficiency problem still needs to be solved at the model architecture level.
6. Conclusion
Sparse attention solved the “compute” problem, but exposed the “find” problem. LSA moves the indexing process into a low-dimensional latent space, compressing the indexing overhead of ultra-long context to a subquadratic level. It achieves order-of-magnitude speedups at 10M tokens while maintaining acceptable accuracy. It once again confirms a rule: when system scale increases by an order of magnitude, those “negligible costs” in the old approach become the new main battlefield. The race for ultra-long context is far from over, and the co-optimization of algorithms and systems will be the necessary path toward 10M and even 100M-token contexts.
