The Key to 22x Faster Sparse Attention at 10-Million-Token Context
As context windows grow from 128K toward 1M and beyond, sparse attention has proven that attending to only a few relevant tokens preserves accuracy. But at 10-million-token scale, the bottleneck shifts from the attention math itself to the cost of deciding which tokens to attend to. This article breaks down that cost structure, explains why naive indexing degrades back to O(T^2), and introduces Latent Sparse Attention, a method that moves retrieval into a low-dimensional latent space to cut index overhead. It also covers why reduced-dimension retrieval does not hurt accuracy and offers a practical checklist for evaluating similar designs in your own inference stack.
1. Long Context Is Spending the Compute It Saved
Over the past two years, long-context capability has moved quickly from 128K to 1M, and is now probing the 10-million-token range. The industry has largely converged on one idea: instead of having every query scan all historical tokens, select only the few most relevant ones for computation. This approach has been validated repeatedly at the million-token scale, with manageable accuracy loss.
But when the context grows another tenfold, an initially negligible overhead starts to spiral. Take a model with global attention layers as an example: at 10-million-token scale, most of the prefill time is not spent on the attention matrix multiplications at all, but on the indexing step that decides which tokens to look at.
The nature of the problem has therefore changed. Sparse attention has already shown that “looking at only a small fraction” is enough to preserve accuracy. What actually blocks ultra-long context is that the cost of “finding that small fraction” still grows quadratically with length.
2. Cost Breakdown: Attention Is Cheap, Finding Attention Is Expensive
The cost of standard full attention is clear: with context length T, prefill computation is roughly O(T^2), and decoding each token costs about O(T). Going from 1M to 10M tokens inflates the prefill attention computation by roughly 100x.
Sparse attention splits the work: a lightweight indexer first selects the k most relevant keys for each query, then the real attention computes only over those k keys, pushing the main computation down to O(Tk).
This works under one premise: the model really does need only a handful of keys. Validation at the 128K level showed that keeping only the few most relevant keys per query (roughly a few thousandths of all keys) still retains about 98% of full-attention accuracy on long-context benchmarks.
But here lies a paradox: for the indexer to know which keys are most relevant, it must first score every key. So indexing degenerates into a “full scan plus full scoring” pass, and the complexity returns to O(T^2). Existing engineering tricks—lowering scoring precision, compressing dimensions, aggregating multiple keys into a block—only shrink the constant factor; they do not change the order of magnitude.
# Complexity intuition for naive block-sparse indexing (illustrative)# Every query scores all blocks; doubling the length -> ~4x the scoring workscores = query @ keys_block_mean.T # [T, T/B]topk_idx = scores.topk(k_blocks, dim=-1) # indexing cost grows with T^2
3. Latent Sparse Attention: Moving Retrieval into a Low-Dimensional Space
A recent paper from a London startup and a Zurich university, completed jointly, proposes Latent Sparse Attention. Its core is not to keep optimizing the scoring function, but to change the space in which retrieval happens.
Three key design points:
- Latent-space projection. Map both keys and queries into a low-dimensional latent space and compute relevance there. With the dimension significantly reduced, both compute and memory access in the scoring stage drop, and no longer scale linearly with the original head dimension.
- Decoupling from main attention. The index only “nominates” candidates and does not participate in the final numerical computation; the original key/value of the selected tokens still go through standard attention, so the accuracy path is not compressed.
- A shift from near-quadratic to near-linear. When the index dimension is small enough and the block granularity is reasonable, the actual time of the indexing stage is pushed far below that of main attention, and overall prefill shifts back from “index-dominated” to “compute-dominated.”
The paper reports that at 10-million-token scale, a single attention layer’s prefill achieves speedups of about 22.7x and 72.4x (for two different model configurations), while maintaining accuracy close to the original model across multiple long-context tasks. The difference in speedup comes mainly from the model’s head dimension, block-sparse configuration, and indexer design, rather than any bias of the method toward particular models.
4. Why Reduced-Dimension Retrieval Does Not Hurt Accuracy
A common objection is: can similarity in a low-dimensional space still represent true relevance? The paper’s line of reasoning is complete.
- Relevance is inherently low-rank. In long text, the number of semantic directions that actually determine dependencies is far smaller than the original feature dimension, and the information loss from projection concentrates on long-tail noise.
- Recall can be amplified. The indexing stage can select more candidates (for example, 2-4x the target k), then let main attention do the fine ranking, trading a small amount of extra compute for recall.
- Error is measurable. In engineering, “top-k recall” and “end-to-end task accuracy” should be monitored separately: the former is indexer health, the latter is model health.
5. Engineering Checklist
If you want to evaluate a similar approach in your own inference stack, proceed in this order:
- Quantify the index share first. Profile prefill on the target model to confirm whether indexing is truly the bottleneck; if the context is only within 128K, the gains may be limited.
- Chunking and shared prefixes. Apply block-level caching to repeated prefixes such as system prompts and long documents to avoid repeated scoring.
- Staged recall. First do a coarse filter with a very small dimension, then fine-rank the candidates at high precision, forming a funnel.
- Coordinate with the decoding stage. After prefill is optimized, the memory and bandwidth of the KV cache become the new bottleneck, requiring paged caching, quantization, and offloading strategies.
- Establish accuracy regression. Validate on a dual track of long-context benchmarks plus your own business evaluation set to prevent “faster indexing, worse answers.”
6. Conclusion
The real bottleneck in the 10-million-token era is not the floating-point operations of attention, but the complexity of “selection.” Moving retrieval into latent space is essentially an acknowledgment: in ultra-long context, the indexer needs a cheap, coarse, but sufficiently high-recall ranker, not an expensive, precise scorer. This idea has direct reference value for any team building its own long-context inference service, and it also suggests that when building long-context capability in the cloud, attention implementation, cache management, and monitoring/alerting should be designed as a whole rather than optimized as isolated points.
