At ten million tokens the bottleneck is not attention: 98 percent of the time goes into finding

One global attention layer of GLM-5.3-Flash. One H200. Ten million tokens of prefill. Ninety-eight percent of the wall clock is not spent computing attention, it is spent deciding which tokens to look at.

That number comes from Latent Sparse Attention: Towards Subquadratic Ultra-Long Context Attention (arXiv:2610.42147, submitted 2026-10-30, revised 2026-11-03), a joint paper from Prefrontal AI and ETH Zurich, with Torsten Hoefler among the authors. Code is Apache-2.0. QbitAI covered it on 2026-11-17 and that is how most Chinese readers met the paper.

I am not going to restate the abstract. One claim matters: the past two years of long-context work have been about making attention look at less, and that part is basically done. What is left is finding the right subset faster, and that term is still quadratic.

The quadratic term did not disappear, it moved

Full attention is easy to account for. During prefill every query scores every previous key, so cost is O(T squared). Going from one million to ten million tokens makes the attention part 100 times more expensive.

Sparse attention splits the work: a lightweight indexer picks the k most relevant keys per query, and the real attention only runs on those, so the attention body drops to O(Tk). The first half of that story holds up. The paper includes a clean check: at 128k tokens, letting every query of Qwen3.8-27B see only its truly top-512 keys, about 0.8 percent of all keys, still retains 98 percent of full-attention accuracy on RULER.

The second half is the problem. To know which 512 keys are relevant, the indexer has to score every key first. DeepSeek's DSA, MiniMax's sparse attention, and the block-sparse schemes in GLM and Qwen all reduce the indexer's load by cutting precision, cutting dimensions, or packing four keys into one. Those tricks divide the constant by a few. They do not change the fact that the indexer's work grows linearly with context, so prefill stays quadratic.

Put it as a library: you want 4,096 books out of ten million. Fetching them is fast. The slow part is reading every spine in the building to decide which 4,096.

The paper measures the bill directly. At ten million tokens, if indexer cost went to zero, sparse attention prefill would get another 58 times faster. Most of the compute in this architecture goes into finding books, not reading them.

Getting the indexer from quadratic to O(T log T)

LSA stops checking individual keys and starts checking groups of keys. Whether you group is not the interesting question. How you group is.

Existing block-sparse methods usually group by position, packing adjacent keys into a block. That is a library that boxes books by acquisition date and writes one summary per box. A single important book gets buried under a summary written for its irrelevant neighbours. LSA groups by content instead: keys are projected into a learned low-dimensional latent space (64 dimensions in D-LSA), Ward hierarchical clustering groups semantically similar keys into buckets, and each bucket keeps one centroid plus an index table of member positions. At query time the query only scores centroids, picks the best buckets, expands them into concrete keys, and fills the k slots that go to attention.

The flat variant buys a constant factor. The tree variant changes the complexity: buckets are clustered again into higher-level nodes, layer after layer, until the structure is a tree. A query descends from the root keeping only the best-scoring branches at each level, which is beam search over a hierarchy. Each query examines O(log T) centroids, so indexer prefill drops from quadratic to O(T log T). That is where the word subquadratic in the title comes from.

None of this is a new idea. Reformer's LSH buckets and Routing Transformer's clustering both organized keys by content. The difference is that few earlier attempts validated accuracy and speed together above one million tokens. Bucket quality falls apart at that scale, and a bad bucket is worse than no bucket.

Bolt it onto an existing model, or grow it from scratch

Two paths. One for models you already have, one for models you are about to train.

D-LSA freezes every parameter of the base model and adds two small projection matrices per layer, mapping keys and queries into a 64-dimensional index space, then distils the indexer so its scores approximate the original attention distribution. The whole distillation run uses 352 million tokens. For scale: DeepSeek's DSA burned 2.1 billion tokens on the dense warm-up of its indexer alone. Six times less. That is the practical part of D-LSA, because retrofitting a 27B model no longer means retraining the base.

There is also a training-free variant that uses the principal components of the keys as the projection, and on Qwen3.8-27B it lands close to the distilled version. If you want to poke at this before committing hardware, start there.

N-LSA uses LSA natively during pretraining, trained on the standard next-token loss with no extra projection, no teacher, no auxiliary objective, and no added parameters. It clusters the attention layer's own keys. The team trained a 0.5B hybrid (24 layers, one global attention layer every four, the rest Gated DeltaNet) with a 128k anneal. Validation loss came out at 1.085, exactly matching full attention. At the same sparse budget, NSA scored 1.117, PISA 1.100, sliding-window attention 1.154. On 128k RULER, N-LSA scored 32.2 against 34.7 for full attention, while NSA fell to 19.2 and PISA to 14.6. Forward plus backward on a single layer runs 1.6x faster than the FlashAttention-3 implementation.

That last set is worth pausing on. Sparse attention losing points on RULER has been the quiet cost of the entire compute-saving line of work. Matching full attention on validation loss means N-LSA is not spending its sparse budget on the wrong keys.

22.7x on one layer, 2.2x end to end

At ten million tokens, D-LSA makes one layer's prefill 22.7 times faster than GLM-5.3-Flash's native sparse attention and 72.4 times faster than full attention on Qwen3.8-27B. Decode improves 4.6x and 42.5x. The speedup grows with context: 3.5x against GLM at one million tokens, 2.1x at 512k.

But a layer is not a model. Served through SGLang at ten million tokens, time to first token for GLM went from roughly 7.5 minutes to 3.4 minutes, a 2.2x gain with context parallelism on. Qwen3.8-27B went from about 76 minutes to about 8 minutes, 9.2x. GLM only gets 2.2x because it is already a sparse hybrid, and its non-attention layers own most of the clock. LSA cannot touch those. Do the ROI math per model. Multiplying your bill by 22.7 will be wrong.

Accuracy: MMLU-Pro, GPQA-Diamond, AIME25, MATH500 and LongBench v2 all land inside the baseline's 95 percent confidence interval, with no meaningful change in reasoning length. On RULER at 10M, Qwen plus D-LSA scores 63.9 against 59.9 for full attention; GLM plus D-LSA stays within 4 points of its native sparse baseline. Note that GLM's baseline was trained jointly with its sparse attention while D-LSA is distilled onto a frozen model, so the comparison favours the baseline.

What actually made me stop scrolling was a new benchmark called PaperTrail. It plants fictional research threads inside a large body of real 2026 arXiv papers: one fictional paper reports a result, several real papers get paragraphs inserted that cite it, a few weeks later another fictional paper corrects a number and renames the method, and some later papers keep citing the stale value. The model has to find and connect those facts the way a literature review would. At the 10M scale each sample holds 400 to 465 papers. Qwen plus D-LSA scores 29.1 against 19.8 for full attention.

This is not needle-in-a-haystack. It is which-of-two-contradicting-documents-do-you-believe, which is closer to what an agent doing multi-day research actually faces. Full attention scoring 19.8 is the real headline: a long window is not long comprehension. Fitting context into the window and building correct factual dependencies inside it are separate problems, and only the first one is solved by buying more memory.

Index overhead per attention layer at 10M tokens (GLM-5.3-Flash, single H200)
MethodIndex memory per layerSingle-layer prefill
D-LSA (tree)246 MiB22.7x
GLM-5.3-Flash native sparse331 MiB1x baseline
Qwen-style block sparse642 MiBslower

Run the numbers before you swap a serving stack

22.7x is somebody else's model on somebody else's GPU. The question you have is where your workload sits. The paper's figure gives three share points (indexer is 67 percent of prefill at 512k, 79 percent at one million, 98 percent at ten million). Those three points pin down the ratio between the indexer and attention coefficients, which extrapolates to any length:

def share(tokens, a_over_q):
    # indexer is roughly q*T*T, attention is roughly a*T, so share = 1 / (1 + a/(q*T))
    return 1.0 / (1.0 + a_over_q / tokens)

POINTS = [(512_000, 0.67), (1_000_000, 0.79), (10_000_000, 0.98)]
ratios = [t * (1 - s) / s for t, s in POINTS]
a_over_q = sum(ratios) / len(ratios)

print("a/q estimate (context length where indexer cost equals attention cost):")
for (t, s), r in zip(POINTS, ratios):
    print(f"  {t:>10,} tokens  share={s:.2f}  ->  a/q={r:,.0f}")
print(f"  mean a/q = {a_over_q:,.0f} tokens")
print()
print("extrapolated indexer share:")
for t in (131_072, 262_144, 524_288, 1_048_576, 4_194_304, 10_485_760):
    s = share(t, a_over_q)
    print(f"  {t:>10,} tokens  indexer={s*100:5.1f}%  prefill if indexer were free: {1/(1-s):4.1f}x")
print()
print(f"crossover: {a_over_q:,.0f} tokens")
$ python indexer_share.py
a/q estimate (context length where indexer cost equals attention cost):
     512,000 tokens  share=0.67  ->  a/q=252,179
   1,000,000 tokens  share=0.79  ->  a/q=265,823
  10,000,000 tokens  share=0.98  ->  a/q=204,082
  mean a/q = 240,695 tokens

extrapolated indexer share:
     131,072 tokens  indexer= 35.3%  prefill if indexer were free:  1.5x
     262,144 tokens  indexer= 52.1%  prefill if indexer were free:  2.1x
     524,288 tokens  indexer= 68.5%  prefill if indexer were free:  3.2x
   1,048,576 tokens  indexer= 81.3%  prefill if indexer were free:  5.4x
   4,194,304 tokens  indexer= 94.6%  prefill if indexer were free: 18.4x
  10,485,760 tokens  indexer= 97.8%  prefill if indexer were free: 44.6x

crossover: 240,695 tokens

The crossover sits near 240,000 tokens. Translated: if your prompts usually stay under 128k, the indexer eats a third of prefill and swapping your serving stack buys you little. Once you routinely pass one million tokens, it eats four fifths, and optimising the indexer is the only optimisation left with room in it. Kernel fusion, batching, attention-body tuning all spend their time on the remaining fifth.

One cross-check. The paper reports 58x more headroom at 10M if indexer cost vanished; the 98 percent share implies 50x. The gap is the fixed cost outside the indexer itself, meaning clustering, bucket expansion and position-table lookups, none of which scale with T. Keep the two terms separate in your own cost model and the error stays bounded.

Actually starting it in SGLang

LSA ships as an SGLang plugin behind a forked serving image. Shortest path, one H200, Qwen3.8-27B:

docker pull ghcr.io/prefrontal-ai/sglang:lsa-v0.1.0

gh release download d-lsa-weights-v1 -R Prefrontal-AI/latent-sparse-attention --dir ./maps --pattern 'qwen38_27b__long-16k-1M-heavy-key-and-query-d2048.pt'
mv ./maps/qwen38_27b__long-16k-1M-heavy-key-and-query-d2048.pt ./maps/qwen38.pt

docker run -it --rm --gpus all --shm-size 32g --network host -e HF_HOME=/hf -v $PWD:/ws:ro -v ./maps:/maps:ro -v $HF_HOME:/hf ghcr.io/prefrontal-ai/sglang:lsa-v0.1.0 bash

pip install --no-deps /ws

export LSA='{"lsa": {"projections": "/maps/qwen38.pt", "query_heads": "all"}}'
python -m sglang.launch_server --model-path Qwen/Qwen3.8-27b --attention-backend fa3 --page-size 1 --disable-prefill-cuda-graph --json-model-override-args "$LSA"

Three traps, all of which you hit at launch:

  • --disable-prefill-cuda-graph is mandatory. LSA picks keys on the host during prefill, and CUDA graph capture cannot see that code. Without the flag the server crashes on startup. Decode graphs still work, so disabling prefill capture does not cost you decode throughput.
  • causal-conv1d needs a CUDA 12.x nvcc. CUDA 13 will not compile it. GLM-5.3-Flash's delta-attention layers depend on it and silently fall back to a slower PyTorch kernel without it. B300 is sm_100 and needs 12.8 or newer. If you only want evaluation, skip the build with --no-install-package causal-conv1d.
  • No enabled line in the log means it is not on. The plugin registers through an sglang.srt.plugins entry point and activates itself from the lsa config block; the server prints enabled at startup. If you do not see that line, requests are still using the model's original attention and every number you measure is fiction. The line appears before startup finishes, so wait for /health before sending traffic.

The image ships paper-flat defaults tuned for H200. B300 uses the lsa-v0.1.0-b300 tag. GLM-5.3-Flash needs eight GPUs, with templates under configs/evaluation/accuracy/glm53_flash/.

For two years the competition was about remembering more. The next round may be about finding faster. Indexer complexity is going to be the steepest segment of the cost curve for agents that run for days, and someone just showed that segment can be moved.

Further reading

Commentaires

Ce site est uniquement frontal : pas de backend ni de compte. Les commentaires vont sur GitHub Issues, Discussions ou par e-mail.

Collez ceci dans l'issue ou l'e-mail pour m'aider à localiser le problème ; cela n'inclut rien de ce que vous avez saisi

Aussi :Voir les commentaires existants · Commentaires par e-mail (sans compte GitHub) :278975598@qq.com