Sparse Attention at 10M Tokens: The Key Breakthrough Behind a 22x Speedup

    This article examines why ultra-long context at 10 million tokens shifts the bottleneck from attention computation to the indexer that selects relevant keys. It explains the core ideas behind Latent Sparse Attention (LSA), including shared latent-space projection, block-level coarse filtering, and decoupling from the main attention path, along with reported single-layer speedups, practical engineering considerations, and how to interpret benchmark results.

    1. The First-Principles Problem of Ultra-Long Context: The Cost Structure Has Changed

    Over the past two years, mainstream large models have gradually made a 1M-token context window the default specification. Processing million-scale long text has moved from a “demo capability” to a “baseline configuration.” But when we push the target further to 10 million tokens, the nature of the problem changes fundamentally.

    Start with the cost structure. In standard full attention, every query must compute relevance against all previous keys. When the context length is T, the prefill stage costs roughly O(T²) in computation, and the decode stage costs roughly O(T) per generated token. Scaling the context from 1 million to 10 million tokens increases the prefill compute for attention alone by about 100x.

    Sparse attention addresses this with a division of labor: a lightweight indexer first selects the k most relevant keys for each query, and the actual attention is computed only over those k keys, reducing the attention itself to O(Tk). This approach is well supported by empirical evidence. At a 128k length, if each query attends to only the roughly 512 keys most relevant to it (less than 1% of the total), the model still retains about 98% of full-attention accuracy on long-context benchmarks. In other words, “looking at only a small fraction” is enough to preserve quality.

    2. The Overlooked Hidden Cost: The Indexer Becomes the New Bottleneck

    The paradox appears in the indexing step. To determine which 512 keys are most relevant, the indexer must first score every key. As a result, the industry commonly relies on dimensionality reduction, low-precision scoring, and compressing multiple keys into a single block representation to contain this overhead.

    But at the 10-million-token scale, this “seemingly minor” cost spirals out of control. Take one global attention layer in a model that supports million-token context as an example: during prefill at 10M tokens, roughly 98% of the time is not spent on attention computation but on the indexer that decides “which tokens to look at.”

    The conclusion is clear: sparse attention has already proven that “looking at less” does not hurt accuracy. What truly blocks ultra-long context is that “finding the small fraction worth looking at” still grows quadratically with length. To break through to the 10-million-token level, the indexing itself must be reworked into subquadratic complexity.

    3. Latent Sparse Attention: Moving Retrieval into a Lower-Dimensional Space

    A recent paper titled “Latent Sparse Attention: Towards Subquadratic Ultra-Long Context Attention” (jointly completed by a London-based startup and ETH Zurich) proposes LSA (Latent Sparse Attention). Its core idea is not to make the indexer “compute faster,” but to make it “compute in a smaller space.”

    Three key designs:

    1. Shared latent-space projection. Both keys and queries are projected into a latent space whose dimension is far lower than the head dimension, and scoring is done only in that space. Complexity drops from O(T·d) to O(T·d’), where d’ ≪ d.
    2. Block-wise accumulation and coarse filtering. Summary representations are maintained per block in the latent space. A block-level coarse filter runs first, then fine-grained scoring is applied only to a small number of candidate blocks, avoiding a precise computation over every single token.
    3. Decoupling from the main attention. The index path and the attention path have separate parameters. The index can use lower precision and a smaller dimension while the main attention keeps its original precision, so generation quality is not sacrificed.

    On the results side, the paper reports a 22.7x prefill speedup for a single attention layer at 10M tokens (mainly for global attention layers) and 72.4x (for another model configuration), with accuracy close to the original model across multiple long-context tasks. It is worth emphasizing that these numbers are single-layer results under a specific model, specific layer type, and specific hardware. End-to-end gains can scale significantly depending on layer structure, parallelism strategy, and the share of IO.

    Illustrative pseudocode:

    1. # Latent-space indexing: subquadratic coarse filtering + a little fine scoring
    2. def lsa_index(q, K, block=256, d_latent=64):
    3. q_l = proj_q(q) # project down to the latent space
    4. K_l = proj_k(K)
    5. K_sum = block_summary(K_l, block) # block-level summary, O(T)
    6. scores = q_l @ K_sum.T # block-level coarse filter, O(T * d_latent)
    7. cand = topk_blocks(scores, n=8) # keep only a few candidate blocks
    8. fine = score_in_latent(q_l, K_l[cand]) # fine scoring within candidates
    9. return topk(fine, k=512)

    4. Engineering Implementation Notes

    • Configure by layer type: use LSA for global layers and keep local/sliding-window layers as they are. This yields the largest benefit with the lowest risk.
    • Precision and recall trade-off: too low a latent-space dimension hurts recall. Start from 64 and run ablations while monitoring the candidate hit rate.
    • Coordinate with the KV cache: index summaries can be updated incrementally along with the cache, avoiding recomputation at every step.
    • Parallelism and IO: 10-million-scale prefill is often limited by memory bandwidth, so reducing index complexity should be done together with paged caching and operator fusion.
    • Evaluation methodology: distinguish “single-layer speedup” from “end-to-end speedup,” and report both accuracy and throughput on long-context benchmarks.

    5. Conclusion

    In the era of 10 million tokens, the competitive focus has shifted from “can we compute it” to “can we cheaply find the part that needs computing.” Latent sparse attention pulls indexing out of the quadratic trap and offers a reusable engineering path toward subquadratic ultra-long context. Combined with containerized inference services, object storage, and monitoring and alerting systems on a general-purpose cloud platform, this kind of optimization is easier to productize reliably.