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

    This article explains why the cost of finding relevant tokens, rather than computing attention, dominates at 10 million token context lengths. It breaks down the quadratic indexing cost of top-k selection during prefill, introduces Latent Sparse Attention (LSA), which moves retrieval into a low-dimensional latent space while keeping aggregation in the original space, and reports the published single-layer prefill speedups of 22.7x and 72.4x. It also covers why hybrid attention architectures are a prerequisite, and lists the engineering checklist for block summaries, positional encoding alignment, caching, and accuracy guardrails.

    Over the past two years, mainstream large models have turned million-token context from an experimental feature into a default specification. First, a flagship model from a cloud vendor made 1M context the default for its official service; then a lightweight model released on a platform also supported 1M, and introduced a hybrid architecture of sparse attention and linear attention in that series for the first time. These designs share the same bet: instead of having every query scan the entire token history, only a few of the most relevant tokens are selected to be “looked at.”

    This approach has been repeatedly validated at the 1M scale. But as context keeps growing toward 10 million tokens, an overhead that once looked negligible starts to spiral. Take one global attention layer in a lightweight model: at 10M tokens, roughly 98% of prefill time is not spent on the attention computation itself, but on the indexer that decides which tokens to look at.

    The nature of the problem has therefore changed. Sparse attention has long proven that looking at only a small fraction is enough to preserve accuracy; what actually blocks ultra-long context is that the cost of finding that small fraction still grows quadratically with context length.

    2. Where the Quadratic Indexing Cost Comes From

    Splitting the prefill computation into two parts makes the bottleneck clear:

    • Scoring and selection: the query must be compared for similarity against all historical tokens (or their compressed representations) to obtain the top-k candidates. This step costs roughly O(L²·d), where L is the context length and d is the head dimension.
    • Sparse aggregation: attention is weighted over only the k candidates, costing roughly O(L·k·d). Since k is usually far smaller than L, this part is close to linear.

    When L grows from 1M to 10M, the second part grows 10x while the first grows 100x. The indexer goes from a rounding error to the main term. Worse, the indexer often also maintains block summaries, cross-layer caches, and positional encodings, so memory-access overhead stacks on top of compute overhead and the real share is worse than the theoretical estimate.

    Schematically, the time of one global attention layer can be written as:

    1. T_layer ≈ T_index(L²) + T_attend(L·k) + T_overhead
    2. At L = 10M, T_index dominates and T_attend is nearly negligible

    The conclusion is direct: continuing to optimize top-k retrieval in the raw token space means gains get eaten by the quadratic term. Speeding things up by more than an order of magnitude requires changing the space in which retrieval happens.

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

    A recent paper from an overseas startup research team, jointly published with a European technical university, proposes Latent Sparse Attention (LSA). Its core idea is not to make the query look at less, but to make finding cheaper: each token’s key/value is first compressed into a low-dimensional latent vector, similarity scoring and top-k selection are then performed in the latent space, and sparse aggregation finally happens back in the original space.

    It can be understood as a three-stage pipeline:

    1. Compression: a learnable projection maps each token’s key/value into dimension r (r far smaller than d), forming a compact latent representation, with summaries maintained per block.
    2. Retrieval: the query is projected into the latent space as well, and similarity is computed against block summaries and intra-block latent vectors to select the top-k blocks and intra-block positions. Because the dimension drops from d to r, scoring cost falls by roughly d/r.
    3. Aggregation: attention is computed only over the selected tokens using the original key/value, so output accuracy is not polluted by compression error.

    The key is the division of labor between low-dimensional retrieval and high-dimensional aggregation: compression only affects the selection path, not the final weighting path, so the accuracy loss is limited to occasionally selecting a few wrong tokens rather than a distorted representation itself.

    The paper reports that at 10M tokens, a single attention layer’s prefill is 22.7x faster than a sparse attention baseline and 72.4x faster than an open-source model using a different sparse strategy, while maintaining accuracy close to the original model across a range of long-context tasks. Note that these are single-layer prefill speedups; end-to-end gains also depend on the distribution of layer types and the system implementation.

    4. Why a Hybrid Architecture Is a Prerequisite

    LSA’s gains build on hybrid attention rather than replacing it. A typical division of labor is:

    • Linear attention layers handle the “coarse read” for the vast majority of tokens, maintaining global information with constant-size state at low cost, though memory decays;
    • Global attention layers are few in number and responsible for precise look-back, which is where LSA applies;
    • Local window layers handle nearby dependencies and need almost no indexing.

    This division means LSA only has to act on a small number of global layers, keeping the modification surface small and the risk controllable. If a model were all global attention, the indexer’s share would be higher and LSA’s absolute gains larger, but the engineering effort and memory pressure would rise in tandem.

    5. Engineering Implementation Checklist

    • Blocking and summaries: block size must be tuned jointly with the latent dimension r; blocks that are too large make candidate granularity too coarse, while blocks that are too small raise summary maintenance overhead.
    • Positional encoding consistency: latent-space retrieval must align with the original-space positional encoding, otherwise long-range extrapolation becomes inaccurate.
    • Caching strategy: during prefill, the latent index can be built offline and reused with prefix caching; during decode, update incrementally to avoid repeated scoring.
    • Accuracy guardrails: use a small long-context evaluation set to monitor the “wrong selection rate,” and dynamically enlarge top-k when necessary.
    • Resource setup: ultra-long-context inference is typically paired with a container platform for elastic scaling, object storage for long samples, and logging and monitoring services to track first-token latency and throughput.

    6. Limits and Outlook

    LSA is not a master key. It optimizes the indexing path, so gains shrink if the bottleneck is memory bandwidth or KV cache capacity; for tasks that require precise token-by-token look-back, the recall of compressed retrieval remains a risk. But the trend is clear: as context length keeps growing, retrieval cost will become the first constraint in architecture design. Moving the selection process into the latent space, and upgrading sparsity from “looking at less” to “finding more cheaply,” is a key step toward ten-million-token context. The practical takeaway for developers: when evaluating long-context solutions, do not look only at attention complexity, but also at the indexer’s complexity and memory-access behavior.