Sparse Attention at 10 Million Tokens: Why Retrieval Is the Real Bottleneck and How Latent-Space Indexing Delivers a 22x Speedup
As language models scale from million-token to 10-million-token contexts, the cost of sparse attention shifts away from the attention math itself and toward the indexer that decides which tokens to attend to. This article explains why scoring and top-k selection grow quadratically with context length, and how Latent Sparse Attention (LSA) moves retrieval into a compressed latent space to flatten that curve. It covers the three-step sparse attention pipeline, the reported speedups (72.4x for a 27B-class model layer and 22.7x for a million-context model layer at 10M tokens) with near-baseline accuracy, and a practical deployment checklist spanning hybrid layouts, training strategy, memory management, serving, and evaluation.
1. Long Contexts Shift the Bottleneck to Retrieval
Over the past two years, mainstream large models have gradually made million-token context a default specification, and hybrid architectures combining sparse attention with linear attention have been widely adopted. They share the same assumption: a query vector does not need to scan the entire history, only to pick out a small set of the most relevant segments to participate in the computation.
At the million-token scale, this assumption holds and the cost stays manageable. But as the context pushes toward 10 million tokens, the cost structure changes qualitatively. Take a global attention layer as an example: during prefill at the 10-million-token scale, roughly 98% of the time is not spent on the attention matrix multiplications, but on the indexer that “decides which tokens to look at.”
This changes the nature of the problem. Sparse attention has long proven that “looking at only a small fraction” is enough to preserve accuracy; what actually slows down ultra-long context is the overhead of “finding that small fraction,” which still grows quadratically with context length.
2. Why Indexing Grows Quadratically
Broken down, one sparse attention pass has three steps:
- Scoring: estimate similarity between the query and all historical keys to produce a candidate ranking;
- Selection: take the top-k as the visible set;
- Computation: run attention only over the visible set.
The complexity of step 3 is determined by k and is essentially decoupled from context length. Steps 1 and 2, however, must scan and rank the full history. Double the context and the candidate space doubles, so the total work for scoring and filtering accumulates quadratically. Multiply that by the number of layers, the number of heads, and the prefill length, and the indexer becomes the absolute hotspot.
Common engineering mitigations each carry a cost: block-based approximation sacrifices recall; caching indexes strains memory on long sequences; quantized scoring introduces accuracy loss. To stay stable at the 10-million-token scale, you have to attack the scoring space itself.
3. Latent Sparse Attention: Moving Retrieval into a Low-Dimensional Space
A recent paper from a startup research team in collaboration with universities proposes Latent Sparse Attention (LSA). Its core idea is a single sentence: do retrieval not in the original token space, but in a compressed latent space.
It has three components:
- Latent keys: learn a low-dimensional latent vector for each historical position, with a dimension far smaller than the original head dimension;
- Low-dimensional scoring: project the query into the same latent space first, then take a dot product with the latent vectors to obtain candidate scores;
- Retrieval in the original space: only for the small number of selected positions, go back to the original key/value to complete attention.
Because scoring and filtering happen in the low-dimensional space, the cost per candidate drops substantially and the quadratic term of the indexer is significantly flattened; meanwhile the number of positions actually involved in computation, k, stays unchanged, so the “quality of the visible set” that accuracy depends on is preserved.
Illustrative pseudocode:
# z: [N, d_latent] latent keys for historical positions# q_lat: [d_latent] projection of the query into the latent spacescores = q_lat @ z.T # low-dimensional scoring, cost ≈ N*d_latentidx = topk(scores, k) # select top-kout = attention(q, K[idx], V[idx]) # compute back in the original space
4. Why the Gains and Accuracy Go Together
The paper reports that at the 10-million-token scale, the method speeds up prefill for a single attention layer of a 27B-class model by 72.4x, speeds up a single layer of a model supporting million-token context by 22.7x, and stays close to the original model’s accuracy across multiple tasks.
The gains come from three sources:
- Dimensionality-reduced retrieval: the scoring dimension drops from hundreds to tens, making index cost approximately linear;
- Unchanged computation: k matches the original attention, so the ability to cover long-range dependencies is not weakened;
- Trainable alignment: the latent keys and projection matrices are trained jointly with the main task, keeping the retrieval objective aligned with the language modeling objective and reducing the chance of “selecting the wrong segments.”
5. Engineering Deployment Checklist
- Hybrid layout: enable latent-space retrieval only for global attention layers, and leave local window layers as they are;
- Training strategy: warm up the retriever on short contexts, then gradually extend to the 10-million-token scale to avoid cold-start mismatch;
- Memory management: keep latent vectors resident, swap original KV in by block, and use paged caching to control peak memory;
- Serving: deploy prefill and decoding separately, batch the retriever, and use queues and monitoring to locate long-tail latency;
- Evaluation: report recall, end-to-end latency, and task accuracy together to prevent “fast but wrong.”
6. Conclusion
At the 10-million-token scale, the key is no longer “computing fast” but “finding accurately and cheaply.” Moving retrieval into a low-dimensional latent space is currently one of the most cost-effective directions. For teams that want to build ultra-long context capabilities, validate the hybrid architecture at the million-token scale first, then introduce latent-space retrieval for stress testing; if you run training and inference on a cloud container platform with object storage, adding logging and monitoring alerts helps you locate indexer hotspots faster and steadily approach the goal of being both fast and accurate.
