Sparse Attention at 10M Token Context: Why the Indexer Becomes the Bottleneck and How Latent Retrieval Delivers a 22x Speedup

    As context windows scale from millions to tens of millions of tokens, the main cost of sparse attention shifts from attention computation to the indexer that decides which tokens to attend to. This article explains why naive top-k selection grows quadratically with sequence length, how Latent Sparse Attention (LSA) moves the selection stage into a low-dimensional latent space to break that quadratic term, and why the approach preserves accuracy while delivering over an order of magnitude speedup in single-layer prefill at the 10M token scale. It also covers practical engineering considerations for memory, block-wise strategies, prefill versus decode evaluation, accuracy regression, and observability.

    1. The Background: When Contexts Get Longer, the Bottleneck Moves

    Over the past two years, long-context capability has shifted from an experimental feature to a default specification. Million-token context is already a standard configuration across several model services, and 10M-token context is becoming the next target for both research and engineering. One of the core technical routes supporting this trend is sparse attention: instead of having every query scan all historical tokens, the model selects only a few of the most relevant segments to participate in the computation.

    This route has been validated repeatedly at the million-token scale: as long as the selection strategy is accurate enough, model accuracy is largely unaffected. But when the sequence length grows by another order of magnitude, an overhead that once seemed negligible starts to spiral out of control.

    Take a model with global attention layers as an example. During the prefill stage at 10M tokens, roughly 98% of the time is not spent on attention computation at all, but on the indexer that decides which tokens to look at. In other words, the real computational cost is not the primary issue; the retrieval cost is.

    The nature of the problem has therefore changed. Sparse attention has already shown that attending to only a small subset is enough to preserve accuracy. What actually blocks ultra-long context is the act of finding that small subset, whose cost still grows quadratically with context length.

    2. Why the Indexer Becomes a Quadratic Bottleneck

    An attention layer can be split into two logical stages:

    1. Selection stage: score every key/value pair for each query and find the top-k most relevant ones.
    2. Aggregation stage: compute a weighted sum over only the selected k positions.

    The aggregation stage has a complexity of O(n·k). Since k is a constant, it grows linearly with n and remains manageable. A naive selection stage, however, requires each query to compute relevance against all n keys, giving a complexity of O(n²) that becomes astronomical at the 10M scale.

    Illustrative pseudocode:

    1. # Naive sparse attention: the selection stage is quadratic
    2. scores = q @ K.T # [n, n], memory and compute both explode
    3. idx = topk(scores, k) # pick k keys per query
    4. out = softmax(scores[idx]) @ V[idx]

    Common engineering mitigations include block-wise scoring, a local window plus a few global anchors, and coarse-grained filtering by page or segment. These reduce the constant factor but do not change the trend of selection cost growing superlinearly with length. As n grows from 1M to 10M, the indexer goes from “negligible” to “absolutely dominant.”

    3. The Core Idea: Move Selection into the Latent Space

    A recent paper from a joint effort by a startup research team and a university lab introduces Latent Sparse Attention (LSA). Its core contribution is not a smarter scoring function, but a change of stage for scoring: instead of retrieving over the raw long-sequence tokens, it first compresses the long sequence into a low-dimensional latent space, makes the “what to look at” decision in that latent space, and then maps back to the original sequence to fetch data.

    The approach can be summarized in three steps:

    1. Dimensionality-reduction projection: compress the key/value sequence into shorter, lower-dimensional latent representations (latent codes), at an approximately O(n·d) linear scan cost.
    2. Latent-space retrieval: the query performs similarity matching and top-k selection only over the latent representations, reducing the retrieval length from n to m (m ≪ n), at an approximately O(n·m) or lower complexity.
    3. Backfill aggregation: based on the selected clusters/blocks in the latent space, return to the original sequence and apply exact attention only to the relevant tokens.

    The key benefit is that the quadratic term is decomposed into “linear compression + short-sequence retrieval,” so the selection stage no longer inflates quadratically with n.

    1. # Latent sparse attention: the selection stage is approximately linear
    2. Z = compress(K, m) # long sequence -> m latent codes, O(n)
    3. idx_cluster = topk(Z @ q, k) # retrieve over the short latent sequence, O(m)
    4. out = attend(q, K[idx_cluster], V[idx_cluster])

    4. Why Speed and Accuracy Hold at the Same Time

    Public results show that at 10M tokens, the method delivers roughly a 22.7x speedup for single-attention-layer prefill on a model with a hybrid attention architecture, and roughly a 72.4x speedup on a larger model that uses only standard attention, while maintaining accuracy close to the original model across multiple tasks.

    There are three reasons accuracy does not collapse:

    • Controllable recall: latent-space compression preserves the main semantic clusters; top-k recalls at the cluster level, and exact attention fills in the details within each cluster.
    • Compensable error: the information loss from compression happens in the selection stage, while aggregation is still performed at the original precision.
    • Architecture adaptivity: for models that already mix sparse and linear attention, the gains are moderate; for pure attention structures, the gains are more pronounced, because there was no amortizable retrieval cost to begin with.

    5. Engineering Implementation Notes

    • Memory and bandwidth: latent codes require extra storage, but since m ≪ n, the overall result is still a net gain; managing latent codes with paged KV storage is recommended for reuse.
    • Coordination with block-wise strategies: LSA is orthogonal to block-level sparsity and local windows and can be stacked with them.
    • Evaluate prefill and decode separately: the gains are concentrated in prefill; the decode stage processes a single query per step, where the bottleneck is KV read bandwidth.
    • Accuracy regression: always run regression on long-range tasks such as long-document retrieval, multi-hop question answering, and code-base-level understanding, rather than looking only at short-sample perplexity.
    • Observability: add a “selection-stage time share” metric to the monitoring and alerting system so a shifted bottleneck does not go unnoticed.

    6. Conclusion

    In the 10M-token era, the core conflict has shifted from “can we compute it” to “can we find it.” By moving the selection process into a low-dimensional space, Latent Sparse Attention decomposes quadratic retrieval into linear compression plus short-sequence matching, achieving more than an order-of-magnitude speedup on a single operator at the 10M scale while holding the accuracy line. For teams planning ultra-long-context capabilities, this points to a clear engineering principle: to optimize long context, optimize the indexer first.