Sparse Attention at 10M Tokens: The Indexing Bottleneck

    As context windows grow from millions to 10M tokens, sparse attention becomes necessary, but its indexing stage can dominate cost. This article explains when indexing becomes a bottleneck, how latent-space retrieval works, how to evaluate speed-accuracy trade-offs, and what to check before deployment.

    Context Windows Move from Millions to 10M Tokens

    Large language models can handle rapidly growing context lengths. A few years ago, mainstream services supported only tens of thousands of tokens; today, some services treat one million tokens as a standard specification. With growing demand for long-document analysis, codebase understanding, and long-term conversations, some teams are beginning to experiment with 10M-token contexts.

    In global attention, every Query computes relevance against all historical tokens, so both computation and memory grow quadratically with length. Long-context models therefore generally use sparse attention. The idea is straightforward: each Query attends only to a small set of the most relevant tokens. This approach has seen substantial validation in million-token contexts.

    Why the Indexing Step Becomes a Bottleneck

    Sparse attention has two steps. The first is indexing: determining which historical tokens the current Query should attend to. The second is the actual attention computation. Indexing itself also requires relevance scoring. If every layer and every Query densely scores all historical tokens, this step also grows quadratically with length.

    This conclusion has a premise. If indexing uses clustering, approximate nearest neighbor search, or hierarchical structures, complexity depends on the specific structure and parameters and cannot be generalized. Therefore, before concluding that indexing is a bottleneck, measure the share of total latency taken by the indexing stage in your own model rather than applying a general conclusion directly.

    Basic Idea of Latent-Space Retrieval

    One common approach is to project high-dimensional Queries and Keys into a low-dimensional latent space, quickly find candidate tokens in that space, and then return to the original space for exact attention. Low-dimensional computation is faster, the candidate set is smaller, and the cost of exact computation decreases accordingly.

    There are industry methods for latent-space sparse attention, but publicly available material is currently limited. Specific performance data should be based on reproducible papers or open-source implementations. This article does not rely on any unverified numbers and discusses only the general principles of this approach.

    Trade-off Between Speed and Accuracy

    Reducing indexing cost usually means candidate tokens may be missed, and accuracy may decline. To determine whether a method is usable, consider three things. First, which evaluation sets and tasks are used for testing, such as long-document question answering, information extraction, and multi-turn dialogue. Second, what is the accuracy change relative to the same baseline model, and which metrics are used. Third, on which tasks does degradation occur, and is that degradation acceptable.

    Performance data is meaningful only with test conditions. Hardware type, model size, batch size, sequence length, precision configuration, and comparison baseline should all be stated. A speedup reported without this information can only serve as a reference and should not be used directly for capacity planning.

    Pre-Deployment Checklist

    1. Measure the indexing-stage share of latency. Record Prefill latency by layer and stage to confirm whether the bottleneck is really indexing.
    2. Confirm KV cache capacity. A 10M-token cache may exceed single-GPU memory, so evaluate sharding, quantization, or offloading to external storage.
    3. Troubleshoot OOM in order. First check peak memory, then batch size, then whether the cache is released promptly, and finally consider adjusting the parallel strategy.
    4. Set alert thresholds. Set thresholds for indexing latency share, per-request latency, and memory utilization, and log request characteristics when thresholds are exceeded.
    5. Evaluate cost. Long-context requests consume more GPU time. Estimate cost based on request volume and peak traffic, and set rate limits.

    Conclusion

    First, evaluate latent-space retrieval methods only when the indexing latency share is clearly high. Second, before adoption, reproduce accuracy and speed on your own tasks and hardware, and keep baseline comparisons. Third, after deployment, continuously monitor per-layer latency distribution, memory, and cost, and adjust batch size and parallel strategy accordingly.