Sparse Attention at 10M Token Context: Why Finding Tokens, Not Computing Them, Is the Real Bottleneck

    As context windows grow from 1M to 10M tokens, sparse attention shifts the bottleneck from computing attention to locating the right tokens. This article explains why the quadratic cost moves into the indexer, how Latent Sparse Attention performs selection in a compressed latent space, where the reported speedups come from, and what engineering practices are needed to realize them in production.

    1. The Bottleneck Shift: From Computing Attention to Finding Attention

    Over the past two years, the dominant approach to long-context models can be summarized in one sentence: instead of having every query scan all historical tokens, select only a few of the most relevant positions to participate in the computation. This approach has been repeatedly validated at the million-token scale, 1M context is gradually becoming a default specification for many online services, and combining sparse attention with linear attention has become a common architectural choice in the industry.

    But as the context pushes toward 10 million tokens, an originally negligible overhead starts to spiral out of control. Take one global attention layer in a billion-parameter-class model with global attention capability as an example: at the 10M token scale during prefill, roughly 98% of the time is not spent on the matrix operations of attention itself, but on the indexing step that “decides which tokens to look at.”

    The nature of the problem has therefore changed. Sparse attention has long proven that “looking at only a small fraction” is enough to preserve accuracy. What truly blocks ultra-long context is that the cost of “finding that small fraction” still grows quadratically with context length. In other words, we successfully compressed the computation but did not compress the retrieval.

    2. A Complexity View: The Quadratic Term Has Not Disappeared, It Just Moved

    The cost of standard attention is the product of query length and key length. Sparsification reduces the number of keys participating in the computation from N to k (k is usually far smaller than N), so the computation term becomes approximately linear. But the process of choosing those k positions often requires scoring all N candidates, and the scoring itself must interact with the query, so the quadratic term is moved into the indexer.

    This structure can be represented with minimal pseudocode:

    1. # Naive sparse attention: computation is cheaper, selection is more expensive
    2. scores = query @ keys.T # [N] scales linearly with context length, but runs once per query
    3. topk_idx = top_k(scores, k) # selection
    4. out = softmax(query @ keys[topk_idx].T) @ values[topk_idx]

    Overall, the cost of the first and third layers grows with k, while the second layer together with the first introduces a linear scan over N; when the number of queries is also of the same order as N, the total remains quadratic. This is the fundamental reason prefill time is swallowed by the indexer at 10M tokens, and it is also a problem that simply increasing sparsity or reducing k cannot solve.

    3. The Core Idea: Moving “Selection” into Latent Space

    A recent piece of work jointly completed by a startup research institution and universities proposes the idea of Latent Sparse Attention: instead of scoring and filtering candidates in the original token space, first compress the long sequence into a low-dimensional latent representation, perform relevance localization in the latent space, and then map the localization result back to original positions to fetch keys and values.

    The key design can be broken down into three layers:

    1. Latent-space compression. Aggregate the continuous key-value sequence into latent units far fewer than the number of tokens, with each latent unit carrying a summary of a local segment of semantics. Compression is causal and chunked, ensuring consistency between prefill and incremental decoding.
    2. Latent-space retrieval. The query only needs to compute similarity against a very small number of latent units, reducing complexity from linear in N to dependent on the compression ratio, so the quadratic term is genuinely eliminated.
    3. Position back-filling and fine fetching. Perform fine-grained fetching within the original intervals corresponding to the selected latent units, trading a window far smaller than N for accuracy and avoiding the semantic smoothing caused by compression.

    At the pseudocode level, it can be abstracted as:

    1. # Latent sparse attention: compress first, then select in latent space
    2. latent = compress(kv_blocks, ratio=r) # N -> N/r latent units
    3. hit = top_k(query @ latent.T, m) # score only in latent space
    4. idx = expand_to_positions(hit, window=w) # back-fill to original positions
    5. out = attend(query, keys[idx], values[idx])

    4. Where the Gains Come From: Three Accounts to Settle Together

    The first is the retrieval account. The number of latent units drops by a factor of r, the scoring cost drops by the same factor, and the quadratic term is compressed to near-linear.

    The second is the memory-access account. Under ultra-long context, the read bandwidth of the key-value cache often saturates earlier than compute. The latent-space index makes the selected intervals more concentrated, improving cache hit rate and prefetch efficiency, so the actual speedup is often higher than the theoretical speedup.

    The third is the accuracy account. Compression inevitably brings information loss, so the design usually retains a small number of global or sliding-window paths in parallel with the latent-space selection result, trading controllable redundancy for stable accuracy. The publicly reported magnitudes are: at 10M tokens, a single global attention layer achieves speedups of about 22.7x and 72.4x in prefill, with accuracy close to the original model across multiple task types. It should be emphasized that these numbers are layer-level results under specific models, specific layer types, and specific hardware conditions; end-to-end gains will shrink noticeably depending on model architecture, sparsity ratio, and implementation quality, so evaluation should be based on your own workload.

    5. Engineering Implementation Checklist

    • Layered design: enable the latent-space index only for global attention layers, and keep sliding windows for local layers, avoiding diminishing returns from a full-model overhaul.
    • Tuning compression ratio and window: r determines retrieval cost and w determines the accuracy floor; a two-dimensional grid search on a validation set is recommended rather than fixed empirical values.
    • Causal consistency: compression must be chunked and must not see the future; otherwise incremental decoding and prefill results will be inconsistent, causing hard-to-locate quality fluctuations.
    • Kernel fusion: fuse compression, scoring, and back-filling into the same operator to reduce memory round trips of intermediate tensors; this is usually the dividing line for whether the theoretical speedup can be realized.
    • Observability: instrument index time, attention time, and cache hit rate separately in logging services and monitoring alerts, so you can tell whether the bottleneck has truly shifted.
    • Elastic resources: for ultra-long context tasks, work with container platforms and message queues to queue and smooth peaks, moving prefill pressure off the online path onto a scalable batch layer, while object storage is used to accumulate long-document corpora.

    6. Conclusion

    In the era of 10M tokens, the competitive focus of sparse attention has shifted from “compute less” to “find faster.” Moving the selection process into latent space, trading compression for retrieval and a small amount of redundancy for accuracy, is currently one of the more convincing paths; whether order-of-magnitude gains can be obtained in a business depends on whether the three engineering tasks of layered strategy, parameter tuning, and operator implementation are done solidly.