The Critical Path to Faster Attention at 10 Million Tokens
Long-context models are hitting a new bottleneck: at 10 million tokens, most prefill time is spent choosing which tokens to attend to, not on attention math. This article breaks down why the indexer becomes the critical path, explains how Latent Sparse Attention moves selection into a compressed latent space to bring indexing from quadratic to near-linear, and reviews reported speedups, accuracy trade-offs, and the engineering details teams need to get right before adopting the approach.
The Critical Path to Faster Attention at 10 Million Tokens
1. Ultra-Long Context Is Rewriting the Cost Structure
Over the past two years, mainstream large models have turned “native support for million-token context” from a selling point into a default specification. Whether through official hosted services or private deployment options, a 1M-token window is becoming standard, and architectures that mix sparse attention with linear attention are widely adopted. These designs share the same premise: instead of making every query scan the entire token history, they select a few of the most relevant segments to participate in the computation.
That premise has been validated repeatedly at the 1M scale. But as the window keeps expanding toward 10 million tokens, an overhead that once looked negligible starts to spiral.
Take a model with global attention layers as an example. Running prefill at 10M tokens, roughly 98% of the time is not spent on the matrix math of attention itself, but on the indexing step that “decides which tokens to look at.” In other words, sparsification successfully compressed the compute, but moved the cost into the selection stage — and the complexity of that stage still grows quadratically with context length.
The nature of the problem has therefore shifted. Sparse attention has long proven that “looking at only a small fraction” is enough to preserve accuracy. What actually blocks ultra-long context is that “finding that small fraction” has become too expensive.
2. Why the Bottleneck Lands on the Indexer
To understand this, it helps to split the prefill stage into two subtasks.
The first subtask is scoring: for each query, estimate its relevance to all historical keys. A naive implementation builds a similarity matrix between the query and every key, whose size is the square of the sequence length. Even with chunking, quantization, or low-rank approximation to shrink the constant factors, the order of magnitude is unavoidable.
The second subtask is fetching: based on the scores, move the selected keys and values from GPU memory or remote storage to the compute units. The longer the context, the more scattered the indices, the higher the share of random access, and the worse the bandwidth utilization.
Stacked together, the two produce the classic pattern of “idle compute, saturated indexing.” On monitoring dashboards this shows up as low GPU utilization paired with very high latency, while flame graphs show nearly all the time landing in operators like sorting, Top-K selection, and gather/scatter. This also explains why simply adding more compute does not improve long-context performance linearly.
3. The Core Idea of Latent Sparse Attention
A recent paper from a startup research team in collaboration with a university introduces Latent Sparse Attention, a method that moves the “selection” step out of the raw token space and into a compressed latent space.
The core idea comes down to three points:
- Compress first, then select. Project the key/value of a long sequence into a low-dimensional latent representation, forming “latent slots” far fewer than the original token count. The query only needs to score against these slots, shrinking the candidate pool from the tens of millions to the thousands or lower.
- Selections can be mapped back. The selected slots are reconstructed through decoding or weighted restoration to approximate the information contribution of the original tokens, making the result effectively equivalent to sparse sampling over the original sequence.
- Complexity drops from quadratic to near-linear. The cost of the indexing stage changes from the square of the sequence length to “compression cost + number of slots × sequence length,” a clear advantage at ultra-long windows.
The structure can be expressed with illustrative pseudocode:
# Conceptual illustration, not any specific implementationlatent = compress(kv, slots=m) # long sequence -> m latent slots, m << nscores = q @ latent.transpose(-1, -2) # score only in latent space, O(n*m)idx = topk(scores, k) # select a few slotsctx = decode(latent[idx], q) # map back to attention contextout = softmax(q @ ctx.T) @ v_selected
The key is the decoupling of m from n: as n grows, m can stay relatively stable, so indexing overhead no longer explodes.
4. Reported Gains and Accuracy
The numbers reported in the paper are compelling: at 10M tokens, for the prefill stage of a single attention layer, one model with a hybrid attention architecture was sped up by about 22.7x, and another open-weight model of comparable scale was sped up by about 72.4x, while accuracy on multiple long-context tasks stayed close to the original models.
These figures reveal two engineering facts:
- The speedup multiple is strongly tied to the model’s existing indexing strategy. The closer the original indexer is to a naive implementation, the larger the room for improvement; already heavily optimized designs see comparatively limited gains.
- Accuracy retention depends on compression quality. The latent dimensionality, the number of slots, and the alignment approach used during training all affect the final result, so tuning inference-side parameters alone is not enough.
5. Engineering Details to Watch When Adopting This
If you want to borrow this route in your own system, keep an eye on the following:
- Train/inference consistency. The latent compression layer usually needs to be trained together with attention or aligned through post-training; bolting it on at inference time only tends to lose accuracy.
- Memory and bandwidth budget. Compression itself consumes extra GPU memory and compute, so evaluate the net gain at your target sequence length rather than looking only at the indexing stage.
- Chunking and parallelism strategy. Ultra-long sequences are often split across multiple GPUs, and the latent slots need to be globally visible or synchronized across devices, so communication overhead has to be counted in the total.
- Observability. Bring indexing time, slot hit rate, and mapping-back error into your logging service and monitoring alerts, so it is easier to tell whether the issue is compression distortion or a scheduling bottleneck.
- Accuracy regression baseline. Prepare an evaluation set covering retrieval, multi-hop reasoning, and long-document summarization, and run a full regression after any parameter change.
6. Conclusion
The central tension of 10M-token context has shifted from “can’t finish computing” to “can’t finish selecting.” The answer Latent Sparse Attention offers is: don’t do selection in the raw token space — first compress the sequence into a small set of searchable latent representations, then sparsify within that latent space. This path pulls indexing complexity back from quadratic to near-linear and provides a new option for making ultra-long context usable in real workloads. For developers, the real work lies in balancing the triangle of compression quality, training alignment, and engineering budget.
