Sparse Attention at 10 Million Token Context: Why Indexing Becomes the Bottleneck and How Latent Search Delivers Up to 72x Speedup

    As context windows expand from 128K toward 10 million tokens, the bottleneck in long-context inference shifts from compute to retrieval. This article explains why sparse attention indexing grows quadratically, how Latent Sparse Attention moves the search into a low-dimensional latent space to cut per-position scoring cost, and what engineering practices—training consistency, layered hybrid attention, caching, observability, and cost control—matter when deploying it. Readers will learn how to evaluate any long-context solution by measuring its indexing time share.

    Over the past two years, long-context capability has moved rapidly from 128K to 1M, and is now being pushed toward the 10 million token range. One cloud provider made million-token context the default specification for its official service this spring, and another platform soon followed by supporting the same length in a lightweight model, introducing a hybrid structure of sparse attention and linear attention for the first time. These approaches share the same premise: instead of having every query scan all historical tokens, only a few of the most relevant segments are selected to participate in the computation.

    This premise has been repeatedly validated at the million-token scale. But when the length grows another tenfold, an originally negligible overhead starts to spiral out of control. Take a global attention layer in a lightweight model as an example: during prefill at 10 million tokens, roughly 98% of the time is not spent on the attention operator 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 “finding that small fraction” still grows quadratically with length.

    2. Why Indexing Becomes a Quadratic Bottleneck

    Standard attention costs O(n²·d). Sparsification reduces this to O(n·k·d), where k is the budget per query. In theory, this is an order-of-magnitude win—but only if selecting k is itself a cheap operation.

    Common approaches fall into three categories:

    • Block-based coarse filtering: Split the sequence into blocks, score them with block-level summaries, then run fine-grained computation on candidate blocks. Building summaries and scoring still requires scanning the full sequence.
    • Cache-based retrieval selection: Build a vector index over historical tokens and use approximate nearest neighbor queries to fetch top-k. The query is sublinear, but index construction, updates, and memory residency costs accumulate with length and cannot be amortized during prefill.
    • Scorer-based end-to-end selection: A lightweight network directly outputs relevance scores. This offers the best expressiveness, but the scorer must evaluate every historical position, pushing complexity back to O(n²).

    The shared blind spot is that all three search in the original token space. That space is high-dimensional and highly redundant, making index structures hard to compress—so the attention compute saved is eaten back by indexing.

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

    A recent paper from a startup research team in London and a university in Zurich proposes Latent Sparse Attention. Its core idea is not a smarter scoring function, but changing the space in which the search happens.

    The approach has three steps:

    1. Compression: Project the key vectors of historical tokens into a low-dimensional latent space, forming compact latent representations that significantly reduce redundancy along the sequence-length dimension.
    2. Retrieval: Perform similarity evaluation and top-k selection in the latent space. The candidate set size depends on the latent dimension and k, rather than scaling linearly with the original sequence length.
    3. Restoration and computation: Map the selected candidates back to the original space and run full attention only on those positions, keeping the output distribution close to the original model.

    Illustrative pseudocode (not a specific implementation, only expressing the data flow):

    1. # z: compact latent representation of historical keys, shape [n, r], r << d
    2. # q_lat: query projected into the latent space
    3. scores = q_lat @ z.T # low-dimensional scoring, cost O(n·r) with very small r
    4. idx = topk(scores, k) # select candidate positions
    5. k_sel, v_sel = gather(K, V, idx) # return to original space to fetch real keys and values
    6. out = softmax(q @ k_sel.T / sqrt(d)) @ v_sel

    The key point: low-dimensional scoring still scans n positions, but the cost per position drops from d to r. Candidate filtering can also be fused with the compression process and done in a streaming, block-wise manner, reducing memory access and bandwidth pressure at the same time. In practice, this approach achieves prefill speedups of 22.7x and 72.4x for a single attention layer at 10 million tokens (depending on model structure), while maintaining accuracy close to the original model across multiple tasks.

    4. Engineering Implementation Notes

    • Training and inference consistency: The latent projection must be trained alongside the model or lightly fine-tuned; otherwise, distribution drift will collapse top-k hit rates. Before launch, validate recall with long-text retrieval evaluations.
    • Layered hybrid design: Use sparse selection for global layers, keep sliding windows for local layers, and use linear attention for channel layers. Dividing labor by layer is more stable than a uniform strategy across all layers.
    • Caching strategy: Latent representations can reside alongside the KV cache. Watch memory and bandwidth budgets, and offload to object storage or a high-speed cache service in tiers when necessary.
    • Observability: Bring candidate hit rate, average candidate span, and indexing time share into monitoring and alerting. Indexing time share is the most direct early-warning metric.
    • Cost control: Long-context inference should combine elastic scaling on container platforms with log services for end-to-end latency attribution, avoiding wasted compute on ineffective indexing.

    5. Conclusion

    At the 10 million token scale, the deciding factor is no longer the attention operator but the design of the retrieval path. Moving the search from the original token space into a low-dimensional latent space is the key step to bring quadratic indexing overhead back under control. For developers, when evaluating any long-context solution, the first question to ask is: what is its indexing time share?