Sparse Attention at 10M Token Context: The Key to a 22x Speedup Is Fixing the Indexer

    As context windows scale toward 10 million tokens, sparse attention shifts the bottleneck from compute to retrieval: the indexer that decides which tokens to attend to can consume roughly 98% of a single global attention layer's prefill time. This article breaks down why selection cost grows superlinearly, how Latent Sparse Attention (LSA) moves scoring into a compressed latent space for reported single-layer prefill speedups of about 22.7x and 72.4x at 10M tokens, and the four engineering details—latent dimension versus recall, layer mixing ratio, index caching, and observability—that determine whether the approach works in a production inference stack.

    1. Long Context Is Turning a Compute Bottleneck into a Retrieval Bottleneck

    Over the past two years, the race for longer context has been largely a race over parameter count and data scale. At the 1M token range, mainstream approaches have converged on one idea: instead of having each query scan every historical token, select only the few most relevant tokens to participate in the computation. This has been validated repeatedly at million-token scale, with controllable accuracy loss and significant throughput gains.

    But once context pushes to 10 million tokens, an overhead that once looked negligible starts to spiral. Take one global attention layer in a certain hybrid-architecture model: during prefill at 10M tokens, roughly 98% of the time is not spent on the attention matrix multiplications at all, but on the indexer that decides which tokens to look at.

    The nature of the problem has changed. Sparse attention has already shown that “looking at only a small subset” is enough to preserve accuracy; what actually blocks ultra-long context is that the cost of “finding that small subset” still grows quadratically with context length. In other words, we successfully reduced the compute, but not the cost of the search.

    2. Why the Indexer Becomes the New Quadratic Bottleneck

    To understand this, split attention into two stages:

    1. Selection: score, rank, and pick the top-k keys/values for each query.
    2. Compute: apply attention weighting only over the selected k positions.

    At million-token context, k is usually far smaller than the sequence length n, so the compute stage is compressed to a small cost and the selection stage’s overhead is masked by the scale of n. But selection itself typically requires scoring all n candidates, and that scoring often depends on some projected interaction between query and key, so the overall complexity still carries an n² characteristic. As n grows from 1M to 10M, the absolute time of the selection stage grows far faster than that of the compute stage, and eventually dominates completely.

    Schematically, the time for a single layer can be written as:

    1. T_layer ≈ T_select(n, d) + T_compute(n, k, d)
    2. where k << n, and T_select grows superlinearly with n
    3. at n = 10M, T_select / T_layer → 0.98

    This also explains why simply increasing k or optimizing the kernel yields limited returns: the bottleneck is not in the multiply-accumulate operations, but in the size of the candidate space and the dimensionality of the scoring.

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

    A recent paper from a startup research lab and university collaborators proposes Latent Sparse Attention (LSA). Its core claim boils down to one sentence: do not retrieve in the original token space, retrieve in a compressed latent space instead.

    It involves three key designs:

    • Latent-space projection: map keys and queries into a low-dimensional latent space and compute similarity with a significantly smaller dimension, sharply reducing the complexity of the selection stage.
    • Sparse selection stays effective: the top-k positions chosen in the low-dimensional space are mapped back to the original space for the attention computation, so the compute stage retains full expressive power.
    • Hybrid with linear attention: some layers use linear attention to compress global information, while others keep global sparse attention for precise retrieval, forming a layered “coarse filter + fine compute” structure.

    The paper reports that at 10M tokens, a single attention layer’s prefill is sped up by about 22.7x and 72.4x (for two model configurations of different scale), while accuracy stays close to the original model across a range of tasks. It is worth stressing that these numbers are single-layer results under specific experimental conditions, not equivalent to end-to-end speedup; engineering deployment still has to account for communication, memory, and scheduling overhead.

    4. Engineering Deployment: Four Details That Decide Success

    If you want to borrow this idea in your own inference stack, these four points determine success or failure:

    1. The tradeoff between latent dimension and recall. Too low a dimension drops genuinely relevant tokens and hurts accuracy; use recall rather than perplexity as the first tuning metric.
    2. The layer mixing ratio. The ratio of global layers to linear layers directly affects the ability to retain long-range dependencies, and usually requires A/B testing between “retrieval accuracy” and “throughput.”
    3. Index caching and batching. Selection results can be reused during decoding, and pairing them with paged KV management significantly reduces repeated scoring.
    4. Observability. Only by instrumenting T_select and T_compute separately can you tell whether the bottleneck has really shifted.
    1. # Pseudocode: latent-space retrieval + original-space compute
    2. q_lat = proj_q(q) # low-dimensional query
    3. k_lat = proj_k(k) # low-dimensional key
    4. scores = q_lat @ k_lat.T # low-dimensional scoring, much lower complexity
    5. idx = topk(scores, k) # select a few positions
    6. out = softmax(q @ k[idx].T) @ v[idx] # fine compute back in the original space

    5. Conclusion

    The competition over ten-million-token context is shifting from “compute fast” to “retrieve accurately and cheaply.” The value of latent sparse attention lies not in any specific multiplier, but in moving the optimization target from compute volume to retrieval volume. For teams deploying in scenarios such as long-document understanding, repository-level code analysis, and multi-turn long conversations, understanding this shift matters more than memorizing any benchmark number. If you build inference services on a cloud container platform with a monitoring and alerting system, it is best to first add per-layer timing instrumentation, then gradually introduce low-dimensional retrieval and hybrid attention structures.