Latent Space Sparse Attention: Fixing the Indexing Bottleneck for 10M-Token Contexts

    Long-context language models have moved from 100K to millions of tokens, but pushing toward 10M tokens exposes a new bottleneck: the indexing step in sparse attention. This article explains why the indexer—not the attention computation itself—consumes nearly all prefill time at extreme context lengths, and how Latent Sparse Attention (LSA) addresses it by projecting tokens into a low-dimensional latent space for fast candidate screening before precise attention computation. It covers the execution flow of sparse attention, LSA's key design choices, reported speedups, and the engineering implications for long-context inference.

    From Long Context to a New Bottleneck

    Context lengths in large language models have been climbing rapidly—from 100K to millions, and now toward 10M tokens. The mainstream industry approach is well established: instead of having every query attend to all historical tokens, select only a small set of the most relevant segments to “look at.” This is the core idea behind sparse attention.

    The approach has been repeatedly validated at the million-token scale. One leading model makes million-token context its default configuration, and another vendor’s lightweight model adopts a hybrid architecture combining sparse and linear attention. But when context continues pushing toward 10M tokens, an overhead that once seemed negligible starts to spiral out of control.

    Profiling of a single global attention layer performing prefill at 10M tokens shows that roughly 98% of the 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 already proven that “looking at only a small subset” preserves accuracy; what actually blocks ultra-long contexts is that “finding that small subset” still scales quadratically with context length.

    Why the Indexer Becomes the Bottleneck

    Understanding this requires breaking down how sparse attention executes. A typical sparse attention layer works in three steps:

    1. Retrieval/indexing: for each query, select the top-k most relevant keys from all historical tokens;
    2. Aggregation: gather the selected key/value pairs;
    3. Computation: run standard attention on the selected subset only.

    The computation in step 3 has been successfully compressed to scale with k rather than with N (the total token count). But the cost of step 1 is often overlooked: to determine “what is most relevant to the query,” the naive approach still computes relevance scores between the query and all N keys. This means:

    • Score computation itself is O(N×d), where d is the attention head dimension;
    • On GPUs, this step involves random reads and reductions over a massive KV cache—memory-bound and hard to parallelize;
    • When N reaches the tens of millions, even a modest d makes this step far more expensive than steps 2 and 3 combined.

    In other words, sparse attention converts a “compute bottleneck” into a “retrieval bottleneck.” If the retrieval algorithm still scores against everything, the overall asymptotic complexity has not truly improved.

    LSA’s Core Idea: Filtering in Latent Space

    A recent paper from a startup team working with university researchers proposes Latent Sparse Attention (LSA), targeting the indexing bottleneck directly. Its key insight: relevance judgment does not have to happen in the high-dimensional attention space. Tokens can first be compressed into a low-dimensional latent space, where a fast coarse screening is performed, before returning to the original space for precise computation.

    LSA consists of several key design elements:

    1. Low-dimensional latent projection. Each token maintains a low-dimensional latent representation (which can be understood as a lossy compressed summary of the key). Since the dimension is far smaller than the original head dimension, the cost of scoring the query against all tokens in latent space drops from O(N×d) to O(N×d’), where d’ ≪ d.

    2. Top-k coarse screening in latent space. Approximate relevance scores are computed in latent space to quickly select a candidate token set. Memory traffic in this step also drops dramatically with the reduced dimension, easing memory bandwidth pressure on GPUs.

    3. Exact computation in the original space. Standard attention is executed in the original high-dimensional space only for the coarse-screened candidates. Since the candidate set size k is fixed and small, this part’s cost is controllable.

    The flow can be summarized in pseudocode:

    1. # Pseudocode: single-layer LSA attention
    2. def lsa_attention(Q, K_cache, V_cache, latent_proj, k):
    3. # 1. Project into low-dimensional latent space (latent reps of K_cache can be pre-cached)
    4. Q_lat = latent_proj(Q) # [b, s, d']
    5. K_lat = K_cache.latent # [b, N, d'], d' << d
    6. # 2. Coarse top-k screening in latent space
    7. scores = Q_lat @ K_lat.transpose(-1, -2) # O(N*d')
    8. idx = topk(scores, k) # candidate indices
    9. # 3. Exact attention in the original space
    10. K_sel = gather(K_cache.full, idx)
    11. V_sel = gather(V_cache, idx)
    12. return softmax(Q @ K_sel.T / sqrt(d)) @ V_sel

    4. Accuracy safeguards. Coarse screening can miss genuinely relevant tokens, so LSA typically combines several mitigations: the latent projection is jointly optimized during training to preserve the ranking information of attention scores; boundary tokens with scores near the threshold are conservatively included; critical layers (such as local window attention) retain full computation, with the sparse path applied only to global layers.

    Reported Results and Engineering Significance

    According to the paper, at 10M-token prefill:

    • For a model with a hybrid sparse architecture, a single global attention layer speeds up by roughly 22.7x;
    • For another open-weight model, a single layer speeds up by up to 72.4x;
    • On tasks including long-document understanding and retrieval-based QA, accuracy remains close to the original models.

    The difference in speedup stems from how much of the original runtime each model’s indexer consumed—the higher the indexing overhead, the greater LSA’s gains. This aligns with the earlier observation that “98% of time is spent on indexing”: LSA precisely compresses that 98%.

    From an engineering perspective, LSA’s significance lies in:

    • Genuinely reduced asymptotic complexity: the coarse screening cost scales linearly or better with N, breaking the quadratic bottleneck;
    • Memory efficiency: the storage footprint of latent representations is far smaller than the full KV cache, helping serve longer contexts within limited GPU memory;
    • Plug-and-play potential: the approach operates on the execution path of attention layers, decoupled from specific model architectures, making it feasible to port to other sparse attention schemes.

    Summary and Outlook

    The technical evolution of ultra-long context shows a clear progression: the first step proved that “attending to less” does not hurt accuracy (sparse attention); the second step makes “finding what to attend to” no longer expensive (latent-space coarse screening). LSA represents a typical solution for the second stage—using low-dimensional summaries to handle retrieval, reserving high-dimensional computation for the few tokens actually selected.

    For developers, directions worth watching include: training strategies for the latent projection, the trade-off curve between coarse-screening recall and end-to-end accuracy, and how this integrates with existing inference optimizations such as paged KV caches and operator fusion. As 10M-token contexts move toward practical use, optimizing indexing overhead will become an unavoidable part of long-context inference systems engineering.