Sparse Attention at 10 Million Tokens: Why Indexing, Not Compute, Is the Real Bottleneck

    As context windows scale toward 10 million tokens, the cost of selecting which tokens to attend to grows quadratically and can dominate prefill time. This article explains why explicit scoring becomes the bottleneck, how Latent Sparse Attention moves candidate selection into a low-dimensional latent space, and what engineering practices help teams deploy it safely.

    Over the past two years, long context has moved from an experimental feature to a default specification. Million-token context is becoming standard in mainstream model serving, and hybrid architectures that combine sparse and linear attention are being used to balance memory usage against throughput. The premise behind this approach is simple: each query does not need to scan the entire history, only a few of the most relevant segments.

    But as context grows into the tens of millions of tokens, an overhead that once seemed negligible starts to spiral. Take a global attention layer as an example. At a scale of 10 million tokens, roughly 98% of the prefill time is not spent in the attention operator itself, but in the indexing step that decides which tokens to look at. In other words, sparsification saves compute, but it does not save retrieval.

    This changes the nature of the problem. Sparse attention has repeatedly shown that attending to only a small subset is enough to preserve accuracy. What actually blocks ultra-long context is that the cost of finding that subset still grows quadratically with context length. The indexer has gone from a supporting role to the main character, and has even become a new complexity bottleneck.

    2. A Complexity View: Why Indexing Balloons Quadratically

    Let the context length be n. Each query needs to score its relevance against every historical position and then keep the top k. Scoring itself is O(n), and the number of queries is also O(n), so the two multiply into O(n²). A smaller k can only reduce the constant factor; it cannot change the order of magnitude.

    The logic can be sketched as:

    1. # Pseudocode: explicit scoring-based sparse selection
    2. scores = query @ keys.T # [n, n], grows quadratically with n
    3. idx = topk(scores, k) # only reduces downstream compute
    4. out = softmax(scores[idx]) @ values[idx]

    What really consumes time in practice is producing and moving that [n, n] score matrix. It is constrained by memory bandwidth, block scheduling, and memory access locality, and it easily degrades into a memory-bound workload on ultra-long sequences. The conclusion is that further optimizing within the explicit-scoring framework will have its gains eaten by the n² term.

    3. Latent Sparse Attention: Moving the Search Into a Low-Dimensional Space

    A recent paper from a startup research team in collaboration with universities proposes Latent Sparse Attention. Instead of pairwise scoring in the original token dimension, it first projects queries and keys into a low-dimensional latent space, performs similarity evaluation and candidate filtering there, and then returns to the original space to fetch the corresponding keys and values for attention.

    The key benefits come from three points:

    1. The scoring dimension drops significantly, making each similarity evaluation cheaper and reducing memory access.
    2. Candidate filtering can run stably under blocking and low-precision representations, which better matches hardware parallelism and bandwidth characteristics.
    3. The selection logic is decoupled from attention computation, so the indexing stage no longer grows quadratically with n.

    According to the paper, at a scale of 10 million tokens, the prefill stage of a single attention layer can achieve speedups on the order of tens of times (varying widely by model size, from roughly 20x to over 70x), while maintaining accuracy close to the original model on multiple long-context tasks. It is worth emphasizing that these numbers come from a specific experimental setup, and real-world results in your own workloads still need to be measured.

    4. Engineering Implementation Notes

    • Profile the bottleneck first: use per-layer timing analysis to confirm the share of the indexing stage, and avoid spending your optimization budget on operators that are no longer the bottleneck.
    • Chunking and streaming prefill: split long sequences into reusable blocks, and combine them with prefix caching to reduce repeated scoring.
    • Precision tiering: use low precision in the latent space for filtering, and higher precision in the original space for weighted aggregation, balancing speed and numerical stability.
    • Coordinate with hybrid architectures: use sparse selection in global layers to control scope, and let local or linear layers handle short-range modeling, reducing the number of global layers.
    • Capacity and elasticity: ultra-long context inference is sensitive to memory and bandwidth. Container platforms can provide elastic scaling, object storage can hold long documents and cache snapshots, and monitoring, alerting, and logging services can track time-to-first-token and throughput jitter.
    • Accuracy regression: build a long-context evaluation set covering retrieval, multi-hop reasoning, and long-document summarization to prevent “faster but less accurate” regressions.

    5. Conclusion

    In the era of 10 million tokens, the core tension has shifted from “attention cannot finish computing” to “candidates cannot be found fast enough.” Moving the selection process into a low-dimensional latent space and replacing quadratic scoring with a decoupled index is currently one of the most cost-effective directions. For developers, the implementation order should be: first quantify the share of indexing, then rework the selection path, and finally run both accuracy and performance regression tests on real business corpora.