Sparse Attention at 10M Context: Why Finding Tokens, Not Computing, Is the Real Bottleneck
As context windows scale from 128K to 1M and beyond, sparse attention has become the default way to keep costs manageable. This article explains why the bottleneck shifts from computation to retrieval at the 10-million-token scale, where an indexer can consume 98% of prefill time. It breaks down the scoring, filtering, and aggregation pipeline, introduces Latent Sparse Attention as a way to move retrieval into a low-dimensional latent space, and covers reported speedups of 22.7x and 72.4x along with practical limits around prefill, context length, and recall-sensitive tasks. Teams will find a three-step adoption path and deployment considerations for long-context inference.
1. The Real Bottleneck in Long Contexts Is Shifting From Compute to Search
Over the past two years, competition in long-context capability has mostly centered on window size: from 32K to 128K, and then to 1M. Mainstream model services have gradually made million-token context a default configuration. The key technical choice behind this shift has been highly consistent: instead of having every query traverse all historical tokens, only a few of the most relevant segments are selected to participate in computation. This approach has been repeatedly validated in practice: at the million-token scale, sparsification barely hurts accuracy while reducing the computational cost of attention by an order of magnitude.
But as contexts push into the tens of millions of tokens, an overhead that was once negligible starts to spiral out of control. Take a model with global attention layers as an example: at the 10-million-token scale, during the prefill stage, 98% of the time is not spent computing the attention matrix, but on the indexer that “decides which tokens to look at.”
This means the nature of the problem has changed. Sparse attention has already proven that “looking at only a small part” is enough to preserve accuracy. What actually blocks ultra-long contexts is that the cost of “finding that small part” still grows quadratically with context length. In other words, sparsification solved the computation problem but did not solve the retrieval problem.
2. Why the Indexer Becomes a Quadratic Bottleneck
To understand this, we need to break down the full pipeline of a single sparse attention call:
- Scoring: compute a relevance score for each query against every historical token;
- Filtering: select the Top-K tokens from the scoring results;
- Aggregation: perform attention-weighted summation over only the selected K tokens.
The cost of step 3 is proportional to K, which is typically a small constant independent of context length, so it stays manageable. The problem is step 1: scoring is essentially still a pairwise interaction between the query and all historical tokens, so its complexity remains quadratic in length. Increase the context tenfold, and scoring cost grows roughly a hundredfold, while the genuinely useful computation stays almost unchanged.
This explains a counterintuitive phenomenon: under ultra-long contexts, a large amount of GPU compute is consumed on “moving and comparing” data rather than on “multiply-add” operations. The indexer therefore becomes a structural bottleneck in the whole pipeline, which means the optimization focus must shift from “compute less” to “find cheaply.”
3. Latent Sparse Attention: Moving Retrieval Into a Low-Dimensional Space
A recent piece of work jointly released by a startup research team and a university proposes the idea of Latent Sparse Attention. The core idea is not complicated: instead of doing full scoring in the original token space, first project both the query and the historical tokens into a low-dimensional latent space, perform relevance evaluation and Top-K filtering in that compressed space, and then map the selected indices back to the original space for the actual attention computation.
You can think of it as database index optimization: the original approach is a full table scan followed by sorting, while the new approach is approximate retrieval on a pre-built low-dimensional index. Three design points are key:
- The low-dimensional projection significantly reduces the cost of a single scoring pass, bringing scoring down from quadratic to near-linear;
- Filtering and computation are decoupled: Top-K quality is determined by the latent-space representation, while computation accuracy is still guaranteed by the original high-precision representation;
- The projection matrices are learnable and can be trained jointly with the main model or aligned via lightweight post-training, avoiding the accuracy loss that comes from manual design.
A schematic flow can be written as:
# Pseudocode: single-layer forward pass of latent sparse attentionq_lat = q @ Wq_lat # project query into low-dimensional latent spacek_lat = k_cache @ Wk_lat # cache historical keys in low-dimensional formscores = q_lat @ k_lat.T # low-dimensional scoring, significantly lower costidx = topk(scores, k=K) # keep only the K most relevant positionsk_sel = k_cache[idx] # go back to original space for high-precision key/valuev_sel = v_cache[idx]out = softmax(q @ k_sel.T / sqrt(d)) @ v_sel
There are also two engineering details that are easy to overlook: first, the latent-space cache can be organized by page or by block, which naturally fits with paged attention mechanisms; second, low-dimensional scoring can be combined with quantization and batch scheduling to further reduce memory-access pressure.
4. Measured Gains and Applicability Limits
Public results show that at the 10-million-token scale, this approach delivers 22.7x and 72.4x speedups for the prefill of a single global attention layer, while maintaining accuracy close to the original model on tasks such as long-document understanding, multi-hop question answering, and code-base-level retrieval. The large difference in speedup between the two models is usually related to their original indexer implementations, the proportion of attention layers, and latent-space dimension configurations, rather than instability in the method itself.
There are limits that need to be recognized clearly:
- The gains are concentrated in the prefill stage; the decode stage processes only a single query per step, so indexing overhead is naturally small;
- The speedup depends heavily on context length, and is often not noticeable below 32K, or even brings a slight loss due to the extra projection;
- If a task requires “seeing every detail” (such as verbatim verification or exact counting), the Top-K assumption itself becomes an accuracy risk, and needs to be paired with hierarchical recall or verification-based fallback.
5. Implementation Recommendations
For teams that need to run inference under ultra-long contexts, a three-step approach is recommended: first, quantify the indexer’s share in your own workload to confirm the bottleneck is real; then, use “low-dimensional scoring + high-precision computation” as the minimal modification unit for offline evaluation, focusing on recall for long-tail tasks; finally, combine paged caching, KV quantization, and scheduling optimizations for a combined effect. For cloud-based implementations, container platforms can host inference services, object storage can hold models and caches, and monitoring and alerting systems can track time-to-first-token and throughput changes, forming a sustainable tuning loop.
The conclusion is clear: the next round of speedup for million-scale contexts will not come from more aggressive sparsity ratios, but from cheaper “finding.” Pushing retrieval cost from quadratic down to near-linear is the key step toward making ultra-long contexts usable.
