Breaking the Indexing Bottleneck: Latent Sparse Attention for 10-Million-Token Contexts

    As LLM context windows scale toward 10 million tokens, sparse attention has become the standard approach for reducing computation cost. However, at this scale the indexer's quadratic scoring overhead—not the attention computation itself—becomes the real bottleneck. This article examines the cost structure of sparse attention, explains why index scoring dominates prefill time at ultra-long contexts, and introduces Latent Sparse Attention (LSA), a method that compresses indexing into a low-dimensional latent space, achieving over 20x prefill speedup per attention layer at 10 million tokens while preserving accuracy. It also offers practical engineering guidance for teams deploying ultra-long-context services.

    1. The Era of Ultra-Long Contexts

    LLM context lengths are growing rapidly. From tens of thousands of tokens in early models, to one million tokens as a default service tier from multiple providers, to some models now pushing toward the ten-million-token range, long context has become a foundational capability for intelligent coding, document analysis, and multimodal understanding. A consensus has emerged across the industry on the mainstream technical route: instead of having every query attend to all historical tokens, select only a small set of the most relevant keys for computation—in other words, sparse attention.

    This approach has been repeatedly validated at the one-million-token scale. However, as context extends to ten million tokens, a previously negligible cost begins to spiral out of control and becomes the true bottleneck.

    2. The Cost Structure of Sparse Attention

    First, a review of standard full attention. For a context of length T, every query computes relevance against all preceding keys, yielding O(T²) computation during prefill and O(T) per decoded token. Scaling context from 1 million to 10 million tokens increases prefill computation by a factor of 100.

    Sparse attention solves this through a division of labor:

    1. A lightweight indexer selects the k most relevant keys for each query;
    2. The actual attention computation runs only over these k keys, reducing cost to O(Tk).

    This approach rests on one premise: the model genuinely needs only a small number of keys. Research has confirmed that at 128k tokens, letting each query attend only to the roughly 0.8% of keys that are truly most relevant still retains about 98% of full-attention accuracy on long-context benchmarks. In other words, “looking at only a small portion” is sufficient to preserve accuracy.

    3. The Hidden Bill: The Indexer’s Quadratic Curse

    The paradox is this: for the indexer to know which k keys are most relevant, it must first score every key. Scoring T keys is itself an O(T²) similarity computation—though its constant factor can be reduced through lower precision, reduced dimensionality, and key compression. No matter how small the constant, the quadratic growth trend cannot be changed.

    Measured data reveals the severity of the problem: at 10 million tokens during prefill, roughly 98% of the time in a single global attention layer is spent not on attention computation, but on the indexer that decides which tokens to look at. The nature of the problem has therefore shifted: sparse attention has already proven that “once you find that small portion, computation is fast”—what truly blocks ultra-long context is the act of “finding that small portion” itself.

    4. Latent Sparse Attention: Compressing the Index into a Low-Dimensional Latent Space

    A recent joint research effort proposed a new method called Latent Sparse Attention (LSA). Its core idea: since the index only needs to make a rough relevance judgment, there is no need for precise scoring in the original high-dimensional space. Instead, keys and queries are projected into an extremely low-dimensional latent space, where approximate top-k retrieval is performed.

    Its key design elements include:

    • Low-dimensional projection indexing: The indexer does not use the full head dimension. Instead, keys and queries are compressed into a very small latent dimension (for example, a few dozen dimensions or even lower), so scoring cost drops from proportional to the model dimension to proportional to the latent dimension;
    • Block-based hierarchical filtering: Tokens are first organized into blocks. Coarse filtering is performed at the block level in latent space, followed by fine-grained selection within candidate blocks, avoiding token-by-token scanning;
    • End-to-end training: The latent-space projection is trained jointly with the main attention, ensuring that low-dimensional relevance scores closely align with the true attention distribution and preventing accuracy loss from “the index selecting the wrong keys.”

    Because the dominant term of index scoring changes from O(T²·d) to O(T²·d’) (where d’ is much smaller than d)—and with hierarchical structures can approach O(T·d’)—indexing overhead no longer grows uncontrollably with context. Experimental results show that at 10 million tokens, this method accelerates prefill of a single attention layer by more than 20x, and under certain model configurations by more than 70x, while maintaining accuracy comparable to the original model across a range of long-context tasks.

    5. Practical Implications for Engineering Deployment

    For teams deploying ultra-long-context services in production, this line of work offers several reusable insights:

    1. Profile before optimizing: The time distribution within attention layers often defies intuition. At ultra-long contexts, “auxiliary overhead” such as indexing and memory movement can far exceed the main computation. Identify the real bottleneck first;
    2. Trade approximation for scale: Indexing is fundamentally a retrieval problem. Using low-dimensional approximation and hierarchical filtering in exchange for scalability is a general pattern for handling data at massive scale;
    3. Accuracy validation is non-negotiable: Any sparsification scheme must undergo systematic regression on benchmarks such as needle-in-a-haystack retrieval, multi-hop reasoning, and long-document QA to confirm that the “missed” keys do not affect business accuracy;
    4. Training-inference alignment: If the indexer is bolted on at inference time, distributional mismatch creates accuracy risk. End-to-end trained latent-space indexing offers stronger consistency guarantees.

    6. Conclusion

    Sparse attention solved the problem of “computing too much,” and latent sparse attention goes further by solving the problem of “searching too slowly.” Once indexing overhead drops from quadratic to near-linear, prefill at ten million tokens—and beyond—becomes genuinely feasible in engineering terms. It is foreseeable that in the standard architecture of future ultra-long-context models, low-dimensional latent-space indexing will likely become a foundational component alongside sparse computation, supporting the large-scale cloud deployment of scenarios such as intelligent coding assistants, whole-repository code understanding, and ultra-long document analysis.