Sparse Attention at 10M Context: An Engineering Breakthrough Delivering 22x Speedup
This article breaks down why indexing—not attention computation—becomes the dominant cost as context windows scale from 1M to 10M tokens. It explains the core idea behind Latent Sparse Attention, which moves key selection into a low-dimensional latent space, and reviews reported prefill speedups of 22.7x and 72.4x with near-full-attention accuracy. Engineers will also find practical notes on joint training, incremental index maintenance, and combining this approach with linear or block-sparse attention.
1. The Hidden Cost of Ultra-Long Context
Over the past two years, long-context capability has moved from 128K to 1M and has become a default specification for mainstream LLM services. As context expands further from 1M toward the 10M range, a previously overlooked cost item begins to dominate overall latency.
Take a model with global attention layers as an example. At 10M tokens, running prefill spends roughly 98% of the time not on the matrix operations of attention itself, but on the indexing step that decides which tokens to look at. This means that even after attention computation has been sparsified, the overall complexity is still dragged back into the quadratic range by the indexer.
The nature of the problem has therefore shifted. Sparse attention has long shown that attending to only a small subset of keys is enough to preserve accuracy. The real bottleneck is that the process of finding that subset still grows quadratically with context length.
2. Breaking Down the Cost Structure of Sparse Attention
In standard full attention, every query must compute relevance against all historical keys. Prefill complexity is O(T²), and per-token decoding complexity is O(T). Increasing context from 1M to 10M amplifies the attention workload by 100x.
Sparse attention divides the work as follows: a lightweight indexer first selects the k most relevant keys for each query, and attention is then computed only over those k keys, reducing attention overhead to O(Tk).
This strategy holds only if the model genuinely needs very few keys. Existing validation shows that at 128K tokens, letting each query attend to only about 512 of the most relevant keys (less than 1% of the total) still preserves roughly 98% of full-attention accuracy on long-context benchmarks.
A paradox then appears: to decide which 512 keys are most relevant, the indexer must first score every key. Common industry approaches include lowering scoring precision, compressing dimensions, or aggregating multiple keys into a single block, but these only mitigate constant factors and cannot change the O(T²) order of magnitude.
3. The Core Idea of Latent Sparse Attention
A recent academic paper proposes Latent Sparse Attention, which moves the indexing process from the original token space into a latent space.
The key insight is that original keys are high-dimensional and highly redundant, making direct scoring expensive. Projecting keys into a low-dimensional latent space before similarity retrieval can substantially reduce scoring cost. Crucially, the latent projection matrix is jointly optimized with model training, so that low-dimensional retrieval results align closely with the true top-k in the original space.
The process can be summarized in three steps:
1. Map all keys into a d_latent-dimensional latent space via a learnable projection matrix2. Use approximate nearest neighbor search in the latent space to find candidate top-k for each query3. Map the candidates back to the original space and perform exact sparse attention
Because the latent dimension is far lower than the original dimension (for example, reduced from 128 to 16 or 32), and approximate nearest neighbor search is itself sub-quadratic, the overall indexing overhead drops from O(T²) to roughly O(T log T) or O(T·√T).
4. Experimental Results and Accuracy Retention
The paper reports that at 10M tokens, the method speeds up prefill for a global attention layer by 22.7x, and by 72.4x on another model. The magnitude of speedup varies with the proportion of global layers in the model architecture and the latent dimension configuration.
On accuracy, across multiple long-context understanding, retrieval, and reasoning tasks, Latent Sparse Attention produces outputs close to those of the original model’s full attention. The paper’s appendix further ablates hyperparameters such as latent dimension and candidate count, confirming that the method is fairly robust to configuration choices.
5. Key Considerations for Engineering Deployment
First, the latent projection matrix must be jointly trained with the model or adapted through post-training; it cannot be inserted into a frozen model without calibration.
Second, building the approximate nearest neighbor index is a one-time cost during prefill. For multi-turn conversation scenarios, a strategy for maintaining the incremental index needs to be designed separately.
Third, this method is orthogonal to approaches such as linear attention and block sparsity and can be combined with them. In hybrid architectures, a natural layered strategy is to use linear attention in local layers to control complexity and Latent Sparse Attention in global layers to resolve the indexing bottleneck.
Fourth, when deployed in the cloud, such methods place high demands on memory bandwidth and the parallelism of retrieval operators, making them well suited to elastic scaling on container platforms and high-performance compute instances.
6. Summary
Sparse attention solves the question of “how much to look at,” while Latent Sparse Attention solves the question of “how to find it.” As context moves from the million-token range toward the ten-million-token range, indexing overhead replaces attention computation as the primary bottleneck, and moving retrieval into a low-dimensional latent space is currently one of the most feasible sub-quadratic paths. For teams that need long-context capability in scenarios such as ultra-long document understanding and repository-level code analysis, this direction is worth continued attention and experimental validation.
