The Key to 22x Faster Sparse Attention at 10M Token Contexts

    Long-context inference is shifting from million-token to 10M-token windows, and the bottleneck is no longer attention math but the indexer that decides which tokens to attend to. This article explains why selection cost stays O(N²) even with sparse attention, introduces Latent Sparse Attention (LSA), which scores and filters keys in a low-dimensional latent space before running exact attention on the original tokens, and reports the published prefill speedups of 22.7x and 72.4x at 10M tokens. It also outlines a practical rollout path—stage-level profiling, hierarchical retrieval, tuning k and latent dimensions, caching, splitting work between global and linear layers, and observability—along with the limits of the gains and the caveats to watch.

    The Key to 22x Faster Sparse Attention at 10M Token Contexts

    1. Million-Token Contexts Are Standard; 10M Marks a New Cost Inflection

    Over the past two years, long context has moved from an experimental feature to a baseline spec. A 1M token context window is now a default configuration in mainstream LLM services, and in the second half of this year a new generation of models went further by mixing sparse attention with linear attention. The combination—global layers for precise recall, linear layers for cheap coverage—delivers both accuracy and throughput at the 1M scale.

    The intuition behind this approach is simple: a query does not need to revisit every historical token, only the few fragments that are genuinely relevant. The industry has repeatedly confirmed that this “look at a small subset” strategy loses almost no accuracy on long-document QA, code repository understanding, and multi-turn conversation memory.

    But as the context grows to 10M tokens, an overhead that once looked negligible starts to spiral.

    2. The Real Bottleneck: Deciding What to Look At, Not Computing Attention

    Take a typical global attention layer. During prefill at 10M tokens, roughly 98% of the time is spent not on the attention matrix math but on the indexer—the step that scores and selects which tokens to attend to.

    The nature of the problem therefore changes:

    • Sparse attention addresses compute: it reduces attention from O(N²) to O(N·k), where k is the number of tokens kept per query.
    • But the selection cost remains O(N²): every query must score all N historical tokens before picking the top-k.

    The result is an awkward situation: the compute you saved gets eaten by the cost of “finding.” The longer the context, the more extreme the ratio. With 98% of the time spent in indexing at 10M, even reducing attention compute to zero would make the whole thing only 2% faster.

    The accounting, schematically:

    1. Total time ≈ indexing time + attention compute time
    2. Measured at 10M tokens: indexing ≈ 98%, compute ≈ 2%
    3. Optimization ceiling = 1 / 0.98 ≈ 1.02x ← optimizing compute alone yields almost nothing

    The conclusion is direct: to go faster, you must optimize the indexer itself, not keep tuning the attention kernel.

    3. Latent Sparse Attention: Moving the “Find” Step into a Low-Dimensional Space

    A recent paper from an overseas startup research lab and a European technical university introduces Latent Sparse Attention (LSA). The idea comes down to three points:

    1. Do not retrieve in the original token space; first compress the keys into a low-dimensional latent space.
    2. Score and filter in that low-dimensional space, where complexity drops substantially with the dimension.
    3. Run exact attention only on the selected original tokens, so accuracy does not regress.

    The key is the division of labor: cheap coarse filtering, accurate fine computation. The low-dimensional projection makes scoring inexpensive, while the final computation still uses the original high-precision representations, so compression does not cost semantic detail.

    Reported results show that at 10M tokens, prefill for a single attention layer sped up by 22.7x and 72.4x on two models of different sizes, while accuracy stayed close to the original models across long-document retrieval, multi-hop QA, code understanding, and other tasks. Gains vary considerably between models, typically depending on the original indexer implementation, the number of attention heads, and the latent space dimension settings.

    4. Engineering Practice: Reusing This Idea in Your Own Inference Stack

    If you are building or tuning a long-context inference service, proceed in this order:

    • Measure before optimizing: profile prefill by stage to establish the share of indexing, compute, and communication. If indexing is below 50%, the headroom is limited and it is not worth prioritizing.
    • Hierarchical retrieval: coarse-filter with a low-dimensional or mean-pooled “summary representation,” then score the candidate set exactly, forming a two-stage funnel.
    • Tune k and the dimension: k sets the accuracy floor, the latent dimension sets the indexing cost; grid-search both per task rather than fixing them globally.
    • Caching and reuse: in multi-turn conversations, the latent representations of historical keys can be cached to avoid repeated projection; combined with chunked prefill, this noticeably smooths peak memory usage.
    • Divide work with linear attention: global layers handle precise recall, linear layers handle cheap coverage; reducing the number of global layers scales the overall gain linearly.
    • Observability: track prefill latency, indexing share, and top-k hit rate with monitoring, alerting, and logging so performance regressions are caught before release.

    5. Where the Gains Stop, and What to Watch

    • The gains land mainly in the prefill stage. Decode processes a single query per step, so the indexing share is naturally low and the speedup is limited.
    • The low-dimensional projection adds parameters and memory overhead, which may not pay off at short context lengths; switch dynamically based on context length.
    • Accuracy evaluation must cover needle-in-a-haystack retrieval and multi-hop reasoning; looking at average scores alone hides long-tail regressions.
    • If your inference service runs on cloud container platforms with object storage, archive profiling data and evaluation results together to make version-to-version comparison easier.

    6. Summary

    In the 10M token era, the focus of long-context optimization has shifted from “compute fast” to “find accurately and cheaply.” The value of Latent Sparse Attention is precisely that it pushes the quadratically growing retrieval cost back into an acceptable range, taking 10M-scale context from demo to usable. For engineering teams, the highest-return path is to measure by stage first, then introduce hierarchical retrieval and caching.