Sparse Attention at 10 Million Tokens: The Indexing Breakthrough Behind a 22x Speedup
As context windows grow from millions to tens of millions of tokens, sparse attention shifts the bottleneck from computing attention to finding which tokens to attend to. This article explains why the indexer dominates prefill cost at extreme context lengths, how Latent Sparse Attention moves retrieval into a compressed latent space with hierarchical coarse filtering and decoupled indexing, and why reported speedups of roughly 22x and 70x come from structural complexity changes rather than accuracy trade-offs. It also covers four practical concerns for developers: prefill versus decode bottlenecks, KV cache and latent representation storage, inference stack compatibility, and long-context accuracy regression testing.
1. Long Context Is Pushing Overhead Out of Control
Over the past two years, long-context capability has moved from an optional feature to a default specification. Context windows of a million tokens are now standard in many general-purpose LLM services. At the same time, mainstream open-source and closed-source models have widely adopted hybrid architectures that combine global attention with sparse or linear attention, so each query no longer scans the entire token history but selects only a few of the most relevant segments for computation.
This approach has been repeatedly validated at the million-token scale: accuracy stays largely under control, while memory and compute overhead drop significantly. But as the context grows to the tens-of-millions-of-tokens range, an overhead that once seemed minor starts to spiral.
Consider a model with global attention layers. During the prefill stage at a 10-million-token scale, more than 90% of the time is spent not on the attention matrix multiplications but on the indexer that decides which tokens to look at. In other words, sparse attention saves computation but shifts the cost to selection.
2. The Nature of the Problem Changes: From Too Slow to Too Hard to Find
The complexity of traditional attention is quadratic in sequence length. The original intent of sparse attention was to turn “each query attends to N tokens” into “each query attends to k tokens,” reducing computation to near-linear.
The catch is that selecting those k most relevant tokens usually requires scoring or retrieving across the entire token history. That scoring step often still carries quadratic or near-quadratic complexity. The result is an awkward situation:
- Computation: already sparsified, with near-linear overhead.
- Indexing: still quadratic, and now the dominant term.
- Total latency: determined by the indexer, which absorbs much of the benefit of sparsification.
So what really blocks extreme long context is not the idea of attending to only a small subset, but the fact that finding that subset remains expensive.
3. Latent Sparse Attention: Moving Retrieval into a Lower-Dimensional Space
A recent paper from a startup research team in collaboration with universities proposes Latent Sparse Attention. The core idea fits in one sentence: do not retrieve in the original token space; retrieve in a compressed latent space.
The key design has three layers.
3.1 A Low-Dimensional Latent Space Replaces the Original Key Space
A traditional indexer scores a query against all historical keys via dot products, with high dimensionality and many candidates. The latent approach first projects keys into a lower-dimensional latent representation and projects the query into the same space, then performs similarity computation and top-k selection there. The gain from lower dimensionality is multiplicative: scoring cost drops linearly with dimension while the candidate pool stays the same size.
3.2 Hierarchical Coarse Filtering Avoids a Global Scan
Low-dimensional retrieval is typically combined with a hierarchical structure: historical tokens are aggregated at the block level into block-level latent representations; the query is first compared against those block representations to narrow down a few candidate blocks; fine-grained scoring then happens inside those blocks. This splits a global scan into coarse filtering plus fine ranking, reducing complexity from quadratic to near-linearithmic.
3.3 Decoupling Indexing from Computation
Because indexing happens in the latent space, the indexer can be optimized independently, for example with quantization, cache reuse, and batched parallelism, without affecting the numerical accuracy of the main attention path. In engineering terms, the indexer can often be folded into existing projection matrices, saving a round trip to memory.
4. Results and Accuracy: Speed Comes from Structure, Not Sacrifice
The paper reports that at the tens-of-millions-of-tokens scale, for a single attention layer in the prefill stage, one type of hybrid architecture model achieves roughly 22x speedup and another achieves roughly 70x, while maintaining accuracy close to the original model across multiple long-context tasks.
The important point is that these speedups do not come from trading accuracy for speed; they come from a change in complexity structure. Accuracy holds for three reasons:
- Sparsity itself has been validated as sufficient: attention distributions are naturally highly concentrated, with a few tokens carrying most of the weight.
- Retrieval happens in the latent space, where ranking closely matches the original space and top-k hit rates stay stable.
- The hybrid architecture retains a small number of global layers to guarantee the transfer of critical information.
5. Engineering Adoption: Four Things Developers Should Watch
If you are building long-context applications, keep these points in mind.
Separate prefill and decode bottlenecks. In prefill, indexing overhead dominates and latent retrieval offers the largest gains. In decode, each step processes a single query, so the bottleneck shifts to memory bandwidth and KV cache management, which require different optimization strategies.
Storage layout for the KV cache and latent representations. The latent approach usually requires caching additional low-dimensional representations, so evaluate memory usage and bandwidth overhead, and use quantization or tiered eviction where necessary.
Compatibility with the existing inference stack. Changing the indexer touches attention operators, so confirm whether the inference framework supports custom operators and whether it remains compatible with existing paged caching and continuous batching.
Accuracy regression testing is not optional. Evaluation sets for long-context tasks often differ substantially from short-text benchmarks. Cover retrieval, aggregation, and multi-hop reasoning tasks to avoid a situation where average accuracy holds but a specific task collapses.
6. Outlook: The Next Stop for Long Context
From a million to tens of millions and then to billions of tokens, the main line of attention evolution is clear: computational sparsification is only the first step; sparsifying retrieval and indexing is what determines the ceiling. Latent retrieval, hierarchical coarse filtering, and decoupling indexing from computation are becoming a standard toolbox for extreme long-context inference.
For platform providers, these capabilities will ultimately settle into general inference optimization capabilities, offered through common cloud product categories such as container platforms, model serving, and logging, monitoring, and alerting. For developers, understanding the source of complexity and the boundaries of applicability matters more than memorizing a specific number, because context length will keep growing while the optimization methodology will keep being reused.
