Millisecond-Token Context: Breaking the Sparse Attention Indexing Bottleneck
As models move from million-token to ten-million-token contexts, the cost center of long-context inference shifts from computing attention to finding the right keys. This article breaks down why a lightweight indexer becomes the dominant prefill cost at extreme context lengths, and explains how Latent Sparse Attention projects keys into a low-dimensional latent space for approximate nearest-neighbor retrieval. It covers the three factors behind the speedup, the engineering boundaries required to preserve accuracy, and a practical evaluation checklist for deciding whether to ship.
1. Ten-Million-Token Context Shifts the Cost from Compute to Search
Over the past two years, long context has become a standard feature of large model serving. Million-token windows moved from a differentiator offered by a few models to a default specification in many official services; by 2026, mainstream model families treat a million tokens as a baseline capability, and architecturally they commonly adopt a hybrid design of global attention plus sparse or linear attention.
All of these designs share one premise: a query does not need to scan every historical token, only to select a few of the most relevant keys for computation. At the million-token scale, this route has been validated repeatedly. But as context pushes toward ten million tokens, an overhead that once looked negligible starts to spiral.
Take a representative global attention layer. At ten million tokens, running prefill spends roughly 98% of the time not on attention computation itself, but on the indexing step that decides which tokens to look at. The nature of the problem therefore changes: sparse attention has long shown that attending to a small subset is enough to preserve accuracy, so what actually blocks extreme-length context is that the cost of finding that small subset still grows quadratically with context length.
2. Cost Breakdown: Attention Gets Cheaper, the Indexer Gets Expensive
The cost structure of standard full attention is straightforward: with context length T, prefill compute is roughly O(T²), and decoding each token is O(T). Going from one million to ten million tokens implies roughly a 100x increase in prefill attention compute in theory.
Sparse attention divides the work like this: a lightweight indexer first selects the k most relevant keys for each query, then real attention computes over only those k keys, pushing attention cost down to O(Tk). This works because of one critical premise: the model genuinely needs very few keys. Related validation shows that at a scale of a few hundred thousand tokens, letting each query attend only to the small number of keys truly most relevant to it (about 0.8% of all keys) still preserves roughly 98% of full-attention accuracy on long-context benchmarks.
Here lies a paradox: for the indexer to know which few hundred keys are most relevant, it must first score every key. Common mitigations in the industry include lowering scoring precision, compressing dimensions, and aggregating multiple keys into a block before scoring. These slow the slope of quadratic growth but do not change the order of magnitude. The indexer thus moves from a supporting role to the primary cost center at extreme context lengths.
3. Latent Sparse Attention: Moving Scoring into a Low-Dimensional Space
A recent paper from a startup research team in collaboration with universities proposes Latent Sparse Attention. The core idea: instead of scoring exhaustively in the original token space, first project keys into a low-dimensional latent space, perform similarity retrieval there, then return to the original space for attention.
The gains come from three compounding factors:
- Lower dimensionality: scoring runs only on highly compressed latent vectors, sharply reducing the cost of a single dot product;
- Candidate pruning: latent-space retrieval naturally supports approximate nearest-neighbor structures, avoiding exact scoring of every key;
- Compatibility with block sparsity: latent-space scoring composes orthogonally with block-level aggregation to further reduce the candidate set.
The paper reports that at ten million tokens, a single attention layer’s prefill is about 22.7x faster (one model class) and about 72.4x faster (another model class) than existing sparse attention approaches, while maintaining accuracy close to the original model across multiple tasks. It is worth stressing that these are single-layer results under specific models, specific layer types, and specific hardware conditions, not an end-to-end overall speedup ratio.
4. Why the Latent Space Balances Accuracy and Speed
The underlying assumption behind latent-space methods is that relevance between tokens is highly redundant in the original high-dimensional space, and that the main semantic structure survives compression into a lower dimension. This is closely related to ideas long used in retrieval, such as two-tower recall and product quantization: trading a controlled loss of accuracy for an order-of-magnitude gain in retrieval efficiency.
Three boundaries must be held in engineering:
- Training/adaptation consistency: the latent projection must be trained jointly with the main model or thoroughly distilled, otherwise the retrieval distribution drifts;
- Recall safeguards: apply a similarity threshold and a minimum candidate count to retrieval results so long-tail queries still gather enough keys;
- Layered strategy: local window, global sparse, and latent retrieval divide the work, with local information not depending on retrieval.
Illustrative pseudocode:
# Conceptual illustration: latent retrieval + sparse attentionz = project_to_latent(keys) # reduce to latent spaceidx = ann_search(z, query_latent, k) # approximate nearest neighbor candidatesk_sel, v_sel = gather(keys, values, idx) # fetch subset in original spaceout = sparse_attention(q, k_sel, v_sel) # compute only over candidates
5. Deployment Evaluation Checklist
- Break down latency by layer: measure the share of indexing, attention, projection, and communication separately to confirm whether the bottleneck is really indexing;
- Watch the decode phase: faster prefill does not mean faster decode, so measure per-token latency and throughput separately;
- Accuracy regression: beyond long-context benchmarks, add retrieval, multi-hop reasoning, and code tasks;
- Memory and bandwidth: latent vector caches and candidate index structures add extra memory and bandwidth overhead;
- Cloud deployment: pair with a container platform for elastic scaling, use monitoring, alerting, and logging services to locate long-tail requests, and use object storage to accumulate evaluation samples.
6. Conclusion
At ten million tokens, the real bottleneck has migrated from computing attention to finding keys. By using dimensionality-reduced retrieval, Latent Sparse Attention turns indexing from quadratic exact scoring into near-linear candidate recall, making it one of the most engineering-valuable directions today. The practical advice for developers: first profile latency by layer to locate the bottleneck, then evaluate the combined gains of latent retrieval and block sparsity, and finally validate with a full accuracy regression and end-to-end latency metrics before deciding whether to ship.
