Why Sparse Attention Needs a Better Indexer at 10 Million Tokens

    This article explains why indexing, not attention math, becomes the dominant cost of sparse attention at 10-million-token context lengths, and how Latent Sparse Attention addresses it by scoring in a compressed latent space. It covers the reported prefill speedups, how to interpret those numbers, and practical guidance for evaluating the approach in your own inference stack.

    1. Long Contexts Are Shifting the Bottleneck from Compute to Retrieval

    Over the past two years, the long-context race has mostly been about window size. Million-token contexts have gradually become a default spec for many model services, and some models have gone further by combining million-token windows with hybrid architectures built from sparse and linear attention. These designs share the same premise: instead of having every query vector scan the entire token history, select a few of the most relevant segments to participate in the computation.

    That premise has been validated repeatedly at the million-token scale. But as contexts push toward 10 million tokens, an initially unremarkable cost starts to spiral. Take a model with global attention layers: at 10 million tokens, roughly 98% of prefill time goes not to the attention matrix multiplications but to the indexing step that decides which tokens to look at.

    The nature of the problem has changed. Sparse attention has already shown that attending to a small subset is enough to preserve accuracy; what actually blocks ultra-long contexts is that the cost of finding that subset still grows quadratically with context length. Put differently, sparsification solved computing too much, not searching too slowly.

    2. Why the Indexer Becomes the New Quadratic Bottleneck

    Attention can be split into two subproblems: scoring, which computes the relevance of each historical token to the current query, and aggregation, which takes a weighted sum over only the high-scoring tokens. Sparse schemes typically optimize only the second step; the first still requires a full scan over the entire history.

    From a single-layer, single-GPU view, that scan looks like a small constant overhead. In a real inference system, however, it gets amplified along three directions.

    • Layer amplification: a model usually keeps only a few global attention layers, but each one performs its own full scoring pass.
    • Head amplification: in multi-head settings, indexing often has to be repeated per head or per group, stacking bandwidth pressure.
    • Stage amplification: prefill processes the entire input at once, so indexing cost scales with the square of sequence length. Long documents and repository-level code inputs are hit first.

    There is also a hidden engineering cost: index results typically produce irregular memory access patterns, leading to low cache hit rates and poor GPU memory bandwidth utilization. Even when theoretical FLOPs drop, wall-clock time does not necessarily drop with them.

    3. The Core Idea of Latent Sparse Attention

    A recent paper from a startup research team in collaboration with academic researchers proposes Latent Sparse Attention. Its core idea fits in one sentence: don’t retrieve in the original token space; first compress into a lower-dimensional latent space, then do the scoring and selection there.

    It involves three key steps.

    1. Dimensionality-reduction projection: map the key vectors of historical tokens into a latent space with substantially lower dimensionality, preserving the main information needed to distinguish samples.
    2. Latent-space scoring: compute similarity between the query and historical segments in the low-dimensional space to obtain a candidate set.
    3. Selective restoration: restore the original-dimension representation only for candidate tokens, which then enter standard attention aggregation.

    The gains come from two directions: low-dimensional scoring reduces both the compute and the bandwidth of the indexing stage by an order of magnitude, while the sparse candidate set keeps aggregation cost bounded. Combined, they push the overall speedup beyond what single-point optimization can achieve.

    The illustrative pseudocode below emphasizes the order: compress first, retrieve second, restore last.

    1. # Conceptual illustration, not a specific implementation
    2. latent_keys = project_to_latent(keys) # Dimensionality reduction, computed once and reusable
    3. scores = query_latent @ latent_keys.T # Low-dimensional scoring, substantially cheaper
    4. topk_idx = select_topk(scores, budget=B) # Select candidate tokens
    5. selected = gather(keys, topk_idx) # Restore and aggregate only the candidates
    6. out = softmax(query @ selected.T) @ gather(values, topk_idx)

    4. Reported Results and How to Read Them

    The paper reports that at 10 million tokens, a model with global attention layers achieved roughly a 22.7x prefill speedup for a single attention layer, while another model of a different scale achieved roughly 72.4x, with accuracy close to the original model across multiple tasks.

    Three points matter when interpreting these numbers.

    • The unit of measurement is prefill of a single attention layer, not end-to-end throughput; end-to-end gains are diluted by other layers and communication overhead.
    • The speedup is strongly tied to model structure: the higher the proportion of global attention layers and the heavier the indexing cost, the more pronounced the benefit.
    • Accuracy is close to, not identical with, the original. The sparsity budget and latent-space dimensionality are hyperparameters that need to be calibrated per task.

    5. Recommendations for Engineering Adoption

    To evaluate this class of methods on your own inference stack, proceed in this order.

    • Measure before optimizing: use monitoring, alerting, and logging services to break down prefill time by stage and confirm whether indexing is really the top cost.
    • Configure budgets per layer: shallow and deep layers, and different attention heads, can use different candidate budgets instead of a one-size-fits-all setting.
    • Cache latent representations: dimensionality-reduction projection results can be reused across requests; pair them with object storage or a distributed cache to cut repeated computation.
    • Keep a fallback: retain a dense-path switch for long-tail tasks, and compare accuracy and latency via A/B testing.
    • Plan for capacity elasticity: ultra-long-context inference is sensitive to GPU memory and bandwidth, so elastic scaling and batching policies on container platforms need to be adjusted accordingly.

    6. Conclusion

    In the 10-million-token era, the central tension has shifted from “can’t compute it” to “can’t find it accurately or fast enough.” The value of Latent Sparse Attention is that it moves retrieval into a low-dimensional space, cutting the quadratic cost of indexing at the source. The real takeaway for developers: when optimizing long context, first locate whether the bottleneck is retrieval or aggregation, then choose a sparsification strategy. That yields more practical gains than blindly enlarging the window.