Sparse Attention at 10 Million Tokens: Indexing Bottlenecks and Latent-Space Acceleration

    At 10 million tokens, sparse attention can spend more time finding relevant tokens than computing attention over them. This article explains why candidate indexing becomes a bottleneck, how low-dimensional latent-space retrieval reduces that cost, and how to evaluate recall, accuracy, and system-level performance before deployment.

    1. Why Sparse Attention Still Hits a Bottleneck Beyond Million-Token Contexts

    Million-token context windows have increasingly moved from demonstrations to standard model specifications. To keep inference costs manageable over very long inputs, sparse attention selects a small set of relevant historical tokens for each query, then computes exact attention only over those candidates.

    This approach has been demonstrated repeatedly at the million-token scale: sufficiently accurate candidate selection can preserve quality close to full attention while substantially reducing computation.

    At 10 million tokens, however, the bottleneck changes. Sparse attention reduces the cost of attending to tokens, but it does not automatically reduce the cost of finding them.

    During prefill, a typical global attention layer must decide which historical tokens each query should attend to. An indexer usually makes this decision by scoring the relevance of historical tokens or token blocks and selecting the top-k candidates. If it scans the entire history for every query, the total indexing cost grows quadratically with context length.

    Experiments reported publicly indicate that, at 10 million tokens, indexing can account for as much as 98% of prefill time in certain global attention layers, rather than attention computation itself.

    The central scaling problem therefore shifts from expensive attention computation to expensive relevance retrieval. Sparse attention has already shown that a small candidate set can preserve accuracy. What needs redesigning is how those candidates are discovered.

    2. Why Indexing Has Quadratic Cost

    Let the context length be L, the hidden dimension be d, and the number of candidates selected per query be k. A common indexer computes similarities between each query and all historical tokens, then selects the top-k scores:

    1. for each query q_i:
    2. scores = q_i · K^T # Approximately L scores
    3. topk = select_topk(scores, k)
    4. output = attention(q_i, V[topk])

    As L grows from 1 million to 10 million, both the number of queries and the number of historical positions increase. Total indexing computation therefore grows approximately as L².

    Even inexpensive dot products become costly when repeated across tens of millions of queries and historical positions. Indexing can consequently dominate prefill latency.

    There are also practical hardware costs. Indexers may need to store large score matrices or stream through large volumes of scores, creating pressure on memory bandwidth, cache efficiency, and kernel-launch overhead.

    Optimizing attention kernels alone is therefore insufficient. The indexing stage must move from exhaustive high-dimensional scoring to low-dimensional filtering followed by a small amount of exact computation. This is the core idea behind latent-space sparse attention.

    3. Latent-Space Sparse Attention: Finding Candidates in Fewer Dimensions

    Latent-space sparse attention does not simply reduce the number of attention heads or shorten the input. Instead, it separates candidate discovery from exact attention:

    1. Coarse retrieval: Map queries and historical tokens into a lower-dimensional latent space. Use these representations to estimate token- or block-level relevance and retrieve a small number of candidate blocks.
    2. Exact computation: Apply attention in the original dimensionality only to tokens selected from those blocks, preserving the quality of the final output.

    One implementation combines block summaries with low-dimensional projections. Historical tokens are divided into fixed-size blocks, each with a summary representation. Queries receive low-dimensional routing representations, which are compared against the block summaries. The highest-scoring blocks are selected, followed by optional token-level filtering and exact attention.

    1. # Coarse retrieval: low-dimensional block scoring
    2. for each query q_i:
    3. q_low = project_q(q_i) # Low-dimensional routing representation
    4. block_scores = q_low · block_summaries # Compare only with block summaries
    5. candidate_blocks = topk(block_scores, B)
    6. # Fine filtering within blocks; low-dimensional token scoring is optional
    7. candidate_tokens = []
    8. for block in candidate_blocks:
    9. token_scores = q_low · block.token_low
    10. candidate_tokens += topk(token_scores, k_per_block)
    11. # Exact attention in the original dimensionality
    12. output_i = attention(q_i, K[candidate_tokens], V[candidate_tokens])

    Instead of computing a high-dimensional dot product against every token, each query performs low-dimensional comparisons against block summaries, followed by high-dimensional attention over a small candidate set.

    When there are far fewer blocks than tokens and the routing dimension is much smaller than the original hidden dimension, indexing costs can fall substantially.

    At 10 million tokens, publicly reported experiments have shown approximately 22.7× single-layer prefill acceleration for one category of global attention layers and approximately 72.4× for another model category, while maintaining accuracy close to the original models across multiple tasks.

    These figures apply to specific layers, hardware, and batching configurations. They should not be treated as expected end-to-end speedups; deployment decisions require measurements on the intended workload.

    4. Preserving Accuracy: Candidate Recall Matters More Than Complexity Alone

    Low-dimensional filtering introduces approximation error. If the latent representation fails to retain enough semantic distinction, candidate selection may miss genuinely relevant tokens, degrading the final attention output.

    Candidate recall should therefore be a first-class engineering metric, not an afterthought to latency.

    Three areas deserve particular attention:

    • Block size and overlap: Large blocks bring more irrelevant tokens into the exact-attention stage. Small blocks increase the number of summaries and the cost of coarse retrieval. Overlapping blocks in critical layers can reduce the risk of splitting relevant information across block boundaries.
    • Latent dimension and projection method: The routing dimension trades retrieval quality against bandwidth requirements. Projection matrices should be trained or calibrated to align with the original attention distribution. At inference time, quantization error must not disrupt candidate ranking.
    • Multiple retrieval paths and fallback: Long-document retrieval and multi-hop question answering can benefit from hierarchical block retrieval followed by token-level filtering. Queries with low retrieval confidence can fall back to larger candidate sets or full attention to protect accuracy in critical layers.

    Evaluation should extend beyond perplexity. Include long-document retrieval, multi-document question answering, summarization, and codebase understanding. Track top-k candidate recall, task accuracy, time to first token, throughput, and GPU memory usage.

    Indexing acceleration is useful only when both retrieval quality and downstream task performance remain stable.

    5. Engineering Deployment: From Layer-Level Speedups to System-Level Gains

    A faster prefill operation in one layer does not translate into an equivalent end-to-end speedup. Production systems must also account for scheduling, caching, batching, and positional encoding.

    A practical deployment checklist includes the following steps:

    1. Profile before optimizing. Measure the time spent in indexing, attention kernels, and memory transfers. If indexing is not a major contributor, prioritize other execution paths.

    2. Enable the approach selectively by layer. Not every layer is equally suitable for sparsification. Global attention layers can use latent-space retrieval, local layers can retain windowed attention, and critical layers can receive larger retrieval budgets.

    3. Cache block summaries. Maintain historical block summaries incrementally as tokens arrive, avoiding unnecessary recomputation during subsequent prefill operations. Account for cache consistency and positional changes.

    4. Manage batching and load balance. Candidate-block counts can vary across queries. Apply candidate-budget limits and load balancing so that a small number of expensive queries do not delay the entire kernel.

    5. Use quantization and fused operators carefully. Low-dimensional projection and block scoring are suitable targets for quantization and operator fusion, provided candidate rankings remain stable. Exact attention should retain the original precision or use controlled quantization.

    6. Use general-purpose cloud infrastructure where appropriate. On cloud platforms, container services, object storage, logging, monitoring, and alerting can support elastic scaling and performance observability. Actual acceleration still depends on model architecture, sequence length, and hardware configuration.

    6. Conclusion: Ultra-Long Context Depends on Better Attention Retrieval

    At 10 million tokens, the main cost of sparse attention can shift from attention computation to candidate indexing.

    Latent-space sparse attention addresses this bottleneck through low-dimensional coarse retrieval followed by exact attention over selected candidates. It replaces exhaustive high-dimensional candidate search with a more efficient retrieval process, offering a practical path toward longer context windows.

    For developers, the most useful takeaway is not a particular speedup figure but a repeatable workflow: identify the indexing bottleneck, design low-dimensional retrieval, and validate the result against both candidate recall and task-level metrics.

    That combination is what turns a 10-million-token context window from an experimental capability into a dependable system feature.