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

    As context windows grow into the millions, sparse attention solves the cost of computing attention but not the cost of finding what to compute. This article breaks down why indexing, not attention math, becomes the dominant bottleneck at 10 million tokens, and explains Latent Sparse Attention: a two-stage approach that moves retrieval into a low-dimensional latent space. It covers the complexity model behind the reported 22.7x and 72.4x prefill speedups, the three design choices that preserve accuracy, and a practical checklist for evaluating the idea in your own inference stack.

    1. The First-Principles Bottleneck of Ultra-Long Contexts: From Computing Attention to Finding Attention

    Over the past two years, the long-context race has mostly been about window size. Million-token contexts have gradually become a default spec for many model services, and hybrid architectures mixing sparse and linear attention are used to balance memory against throughput. These approaches share the same premise: a query vector does not need to scan all history, only to select a few of the most relevant positions to participate in the computation.

    That premise has been validated repeatedly at the million-token scale. But pushing the context one order of magnitude higher, to 10 million tokens, changes the cost structure qualitatively. Take a model with global attention layers: at 10 million tokens, roughly 98% of the prefill time is not spent on the matrix multiplications of attention itself, but on the indexing chain of “score, filter, locate.”

    The reason is not hard to see. The complexity of attention grows quadratically with sequence length, but after sparsification only a small, fixed-budget portion actually takes part in the computation. Meanwhile, the process of “picking out that small portion,” if it relies on scoring similarity between every query and all history, still carries a quadratic term. So sparse attention solved “computing too much” but did not solve “searching too expensively.”

    The nature of the problem is therefore redefined: the real obstacle to ultra-long contexts is not decaying representational capacity, but the complexity of the retrieval path.

    2. Latent Sparse Attention: Moving Retrieval into a Low-Dimensional Space

    A recent paper from a startup research team and a university lab proposes Latent Sparse Attention (LSA). Its core idea is not a smarter scoring function, but a change of coordinate system for scoring.

    In the conventional approach, queries and keys stay in the high-dimensional attention space, where similarity computation is high-dimensional, unfriendly to memory access, and hard to reuse. The latent approach introduces a set of low-dimensional latent representations: historical tokens are compressed and projected into a latent space of significantly smaller dimension, queries are projected there as well, retrieval happens in the low-dimensional space, and once candidate indices are obtained, computation returns to the original attention space for exact calculation.

    You can think of it as database index optimization: instead of comparing every row of a full table, first locate candidate primary keys in a lightweight index structure, then fetch the complete records. The diagram below illustrates this:

    1. Original high-dim space: Q(high-dim) · K(high-dim) -> full scoring, cost grows quadratically with length
    2. Latent retrieval: q_low = Pq(Q) # dimensionality-reducing projection
    3. k_low = Pk(K) # key side can be precomputed offline/incrementally
    4. idx = TopK(q_low · k_low) # low-dim scoring, fixed-budget candidate set
    5. Exact computation: O = Softmax(Q · K[idx]) V[idx]

    Illustrative pseudocode:

    1. # Prefill stage: key-side latent representations can be cached incrementally to avoid repeated projection
    2. k_latent = project_key(K) # [L, d_latent], d_latent << d_head
    3. for q_block in split(Q, block_size):
    4. scores = q_block @ k_latent.T # low-dim scoring, memory-access friendly
    5. idx = topk(scores, budget) # fixed candidate budget per query
    6. out[q_block] = attention(Q[q_block], K[idx], V[idx])

    Three engineering details here are easy to overlook. First, the projection matrices must be lightweight, or the dimensionality reduction itself becomes the new bottleneck. Second, key-side latent representations are well suited to incremental maintenance, which fits naturally with chunked prefill and cache reuse. Third, the candidate budget should be tied to task sensitivity rather than set globally with a one-size-fits-all value.

    3. The Complexity Ledger: Where 22x and 72x Come From

    The paper reports that at 10 million tokens, in the prefill stage of a single attention layer, one class of models with global attention layers is sped up by about 22.7x and another comparable model by about 72.4x, while maintaining accuracy close to the original model across multiple tasks.

    The gap between the two numbers is itself informative about where the gains come from. The speedup does not depend only on the retrieval algorithm; it depends on the denominator, the “retrieval share.” The higher the share of time a model originally spent on indexing, the more significant the end-to-end gain once indexing cost drops from quadratic to near-linear. Put differently, the more aggressive the sparsification strategy and the smaller the candidate budget, the more dramatic the relative speedup at the 10-million-token scale.

    A simplified cost model gives a rough estimate:

    1. T_total ≈ T_index + T_attn + T_proj
    2. Original: T_index ∝ L² · d_head
    3. LSA: T_index ∝ L · d_latent + L · budget · d_head

    When L reaches the order of 10 million, the quadratic term dominates completely, and the gains from dimensionality reduction plus a fixed budget scale up roughly linearly. This also explains why such optimizations often “look like only a few tens of percent” at the million-token scale, yet suddenly become an order-of-magnitude difference at 10 million.

    It is worth stressing that these numbers are measurements taken under specific models, specific layer configurations, and specific hardware conditions, and cannot be extrapolated directly into general conclusions. In engineering practice, what you actually need to do is measure the indexing share in your own workload, then judge the upper bound of the optimization.

    4. Why Accuracy Holds: Three Key Design Choices

    The most common criticism of sparsification is accuracy loss. The latent approach preserves accuracy mainly through three points.

    The first is the two-stage structure. Low-dimensional retrieval is only responsible for “nominating,” not for “finalizing”; the final output is still computed exactly by the original high-dimensional attention over the candidate set, which prevents the compressed representation from directly determining semantic results.

    The second is the fault tolerance of key-side compression. Historical tokens are enormous in number but highly redundant in information; the low-dimensional projection mainly retains the coarse-grained directional information needed for retrieval, while fine-grained discrimination is handed back to the exact stage.

    The third is budget and layer heterogeneity. Different layers and different attention heads differ markedly in their dependence on context: shallow and local attention layers can use smaller budgets, while global layers keep higher budgets, so overall accuracy stays more stable.

    5. A Practical Checklist

    If you want to evaluate a similar idea in your own inference stack, proceed in this order:

    1. Profile first: quantify the actual share of the indexing stage in prefill, and confirm the bottleneck exists before optimizing.
    2. Start with key-side caching and chunked prefill; these changes are low-risk with predictable gains.
    3. When introducing low-dimensional retrieval, validate candidate recall on an offline evaluation set first; recall is the upper bound on accuracy.
    4. Make the candidate budget configurable and tune it per layer, avoiding the accuracy collapse caused by a global fixed value.
    5. Build a dedicated long-context evaluation covering multi-hop retrieval, long-document summarization, and repository-level code understanding; perplexity alone is not enough to tell the story.
    6. Use monitoring, alerting, and logging services to continuously track time-to-first-token, prefill throughput, and memory usage, turning optimization results into observable metrics.

    6. Conclusion

    In the era of 10-million-token contexts, the competitive focus has shifted from “can we even compute a sequence this long” to “can we cheaply find the part that needs computing.” The value of Latent Sparse Attention is that it swaps the coordinate system of retrieval, compressing quadratically growing indexing overhead down to near-linear, so that sparse attention can finally deliver its promised gains under ultra-long contexts. For developers, more important than chasing a specific speedup number is mastering this cost model and evaluation method: quantify the bottleneck first, then combine dimensionality reduction, caching, and budget allocation, and finally confirm the win-win on accuracy and throughput in real business evaluations.