Subquadratic Sparse Attention: Breaking the Indexer Bottleneck in 10M-Token Contexts

    Long-context models are shifting the performance bottleneck from attention computation to the indexer that selects which tokens to attend to. This article breaks down the cost structure of ultra-long context, explains why sparse-attention indexers still scale quadratically with context length T, and reviews Latent Sparse Attention (LSA), which moves relevance estimation into a low-dimensional latent space before exact attention is computed on a small selected subset. It also summarizes reported speedups at ten-million-token prefill, accuracy preservation, and practical engineering considerations for deployment.

    1. The Cost Structure of Ultra-Long Context: The Hidden Bill

    As large-model context windows grow from tens of thousands of tokens to millions and then to tens of millions, the pressure point for inference cost keeps shifting. To understand the bottleneck of ultra-long context, it helps to break down the cost structure of attention first.

    Under standard full attention, every query computes a relevance score against all previous keys. If the context length is T, the prefill-stage computation is O(T²), and the incremental cost of decoding each token is O(T). This means that when context grows from 1 million to 10 million tokens, attention computation in the prefill stage alone expands by 100×. That is only the theoretical figure; in practice, there are also engineering overheads such as memory access and KV cache management.

    The core idea of sparse attention is a division of labor: introduce a lightweight indexer that selects the k most relevant keys from the large history of tokens for each query, and perform the actual attention computation only on those k keys. This reduces the cost of attention itself to O(Tk). When k is much smaller than T, the savings are order-of-magnitude.

    This approach has been widely validated at the million-token scale: letting each query look at only a small number of the most relevant tokens can keep accuracy loss very small. Experiments have shown that at a 128k context, when each query attends to only about 0.8% of keys, long-context benchmarks still retain roughly 98% of full-attention accuracy.

    2. The Paradox: The Indexer Itself Grows Quadratically with T

    The problem lies in the indexer. To know which k keys are most relevant, the indexer must first score every key—and the act of scoring every key is itself a full scan over all keys. Whether the system lowers scoring precision, compresses key dimensions, or merges multiple keys into blocks for approximation, the indexer’s computation still grows quadratically with context length T.

    Common block-sparse designs in the industry generally follow this pattern. Measured data shows that when performing prefill at the ten-million-token scale, in a single global attention layer, most of the time—up to 98%—is not spent on attention computation but on the indexing stage that decides which tokens to look at. In other words, sparsification pushes attention computation down to a nearly negligible level, but moves the bottleneck to the indexer.

    The nature of the problem therefore changes: sparse attention has already demonstrated that looking at only a small subset is enough to preserve accuracy. What truly blocks ultra-long context is that the cost of finding that subset still grows quadratically with T.

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

    A recent study proposes a method called Latent Sparse Attention (LSA) that directly targets the indexer’s quadratic bottleneck. Its core idea can be summarized as follows: instead of scoring every key in high-dimensional token space, first project keys into a low-dimensional latent space, perform cheap relevance estimation there, and then run high-precision computation only on the small number of selected keys.

    The process can be broken down into three steps:

    1. Latent-space compression: A learnable projection maps each key to a latent vector whose dimension is much lower than the original head dimension. The dot-product cost of latent vectors is proportional to dimension; reducing the dimension from 128 to 16 makes each scoring operation about 8× cheaper.
    2. Batched block-level screening: Instead of scoring token by token, keys are organized into blocks, and coarse block-level screening is performed first in latent space to quickly eliminate the vast majority of irrelevant blocks. The complexity of this step is close to linear rather than quadratic.
    3. Exact attention computation: Standard high-precision attention is computed only on keys within the selected blocks, preserving final output quality.

    The key is that the latent-space projection is jointly trained with the model, rather than added afterward as a heuristic. The training objective constrains both paths at once: latent-space scores should be as consistent as possible with exact attention scores to ensure screening does not miss truly relevant keys, and the selected set should be as small as possible to ensure speedup. This avoids the recall failures that traditional top-k heuristic methods can suffer under distribution shift.

    4. Results: Order-of-Magnitude Gains at Ten-Million-Token Scale

    The paper’s core results focus on two points:

    • Elimination of indexing overhead: At the ten-million-token scale, the previous situation in which the indexer accounted for more than 90% of prefill time in sparse schemes is fundamentally reversed. A single attention layer can achieve more than 20× end-to-end prefill speedup. For larger models, because indexing overhead accounts for a higher share, speedup can exceed 70×.
    • Accuracy preservation: On standard benchmarks such as long-context retrieval and multi-hop reasoning, models using LSA achieve accuracy comparable to the original sparse scheme, with only a small gap to full attention.

    From a complexity perspective, LSA converts indexing cost that originally grew quadratically with T into one linear latent-space projection plus one approximately linear coarse screening step, bringing overall prefill complexity close to subquadratic. This is the meaning of “Subquadratic” in the paper’s title.

    5. Engineering Deployment Considerations

    For teams planning to deploy ultra-long-context capabilities in their own services, this work offers several transferable lessons:

    • Measure first, then optimize: Before deciding to optimize attention computation, use profiling tools to confirm the real bottleneck. The intuition many teams have at million-token context—that attention computation is the bottleneck—no longer holds at the ten-million-token scale.
    • Co-train the indexer with the model: Freezing the backbone and training the indexer separately afterward can easily lead to insufficient recall on long-text distributions, causing a sharp drop in accuracy.
    • Block granularity is the knob between accuracy and speed: Larger blocks make screening coarser and faster but more likely to miss relevant keys; smaller blocks are more accurate but more expensive. Tune block size according to the maximum context length of the workload.
    • Coordinate with tiered KV cache storage: Latent vectors are small and suitable for residency in high-speed storage; full KV can be placed in object storage or low-cost cache and loaded on demand, further reducing the cost of long-context serving.

    6. Conclusion

    Competition in ultra-long-context capability is shifting from “how many tokens can be packed in” to “can it be computed affordably and fast after packing them in.” Latent Sparse Attention shows that the next stage of sparsification is not about more aggressively cutting attention computation, but about rearchitecting the long-overlooked step of “finding what to look at.” When indexing cost is also pushed down to subquadratic, ten-million-token and even longer contexts can truly become economically feasible for industrial deployment.