Skip to content

Coarse Semantic Blocks: Training-Free Sparse Attention at 1M Tokens

THE ARGUMENT

Without training a selector or changing weights, prompt-specific 2,048-token semantic blocks can cut whole-model prefill latency by 2.3–2.4x at 512K, but the 4B model pays for it on multi-key retrieval.

On this page

You have 512K tokens of technical manuals and one H200 budget, but should you buy the vendor’s 2.3–2.4x prefill claim? At first glance, the usual advice is that sparse attention needs a trained indexer, or that training-free selection is too irregular to speed up prefill. This paper argues otherwise: it builds a prompt-specific key index by clustering keys into 2,048-token semantic blocks, lets each query select its own blocks, and uses the same index for prefill and decoding. The headline is a whole-model wall-clock gain of 2.3–2.4x for prefill and 1.7–2.0x for decoding at 512K on Qwen3.5-4B and 35B-A3B, with index construction included [1].

The default view: sparse attention needs training, or saves only decoding

Long-context attention is expensive because every new token scores against all previous tokens. Sparse attention, which lets each query read only a subset of tokens, saves time only when selection and KV preparation cost less than the attention it removes. The paper sorts prior work into two camps. DSA, MSA, and QSA train an indexer with the model and operate with a 2,048-token budget; Quest, MoBA, MInference, and FlexPrefill avoid training but select contiguous blocks or share one selection across neighboring queries. ClusterKV and Tactic cluster keys, yet their index mainly serves decoding, while prefill stays dense [1].

The target is precise: can training-free, per-query block selection also speed up prefill? The answer is to make blocks large enough that scoring and grouped execution amortize.

Method: cluster keys into semantic blocks, then let each query choose

The method runs spherical k-means on normalized keys for each prompt, layer, and KV head. Each key joins its nearest centroid, and the resulting block can span noncontiguous positions. The average block size u sets the cluster count at roughly C=L/u, with u=2,048 in the main setting. Each query scores only C centroids instead of L keys, sums those scores across the GQA group, applies a size penalty with temperature 0.1 and exponent 0.25, and attends to the original keys and values of the selected blocks. If the selected set is all visible positions, the computation reduces to dense attention.

Prefill processes contiguous chunks; tokens inside the current chunk are visible without selection, and only earlier history is block-selected. Decoding uses the same prompt index, keeps recent generated tokens unselected, and can add older generated tokens to the index. Execution is KV-outer: queries that chose the same block are processed together, which preserves per-query choice while reusing KV tiles. On Qwen3.5-4B at 512K, this is 2.6x faster than processing neighboring queries over the union of their blocks, and storing each block contiguously in original order avoids about 9% gather overhead.

Measured numbers: 2.3–2.4x prefill at 512K, 2.9–3.0x at 1M

All numbers are whole-model wall-clock on one NVIDIA H200; index construction and use are included, and dense attention runs on the same vLLM stack. At 512K, prefill is 2.3–2.4x and decoding 1.7–2.0x faster; at 1M, prefill is 2.9–3.0x faster. The method replaces only full-attention layers: 8 of 32 in Qwen3.5-4B and 10 of 40 in 35B-A3B. Prefill remains quadratic in prompt length, with a smaller constant, because both C and K grow with L. A chunked-prefill variant clusters only the first 64K keys and assigns later keys to the nearest centroid, with similar accuracy.

ItemNumber in the paperScope
Prefill, 512K2.3–2.4xWhole-model wall-clock, index included, one H200
Decoding, 512K1.7–2.0xSame
Prefill, 1M2.9–3.0xSame
Full-attention layers replaced8/32 and 10/40Qwen3.5-4B and 35B-A3B

Quality: 35B stays close, 4B loses on multi-key retrieval

The 35B-A3B model stays close to dense attention on five RULER tasks through 1M, on LongBench-v2 overall, and on MRCR through 256K. The 4B model loses accuracy mainly on multi-key retrieval, yet it beats dense Qwen3.5-2B, whose latency is similar at 512K, on all three benchmarks. That comparison is narrower than it sounds: it is a smaller dense model at similar latency, not the same-size dense model. The paper does not claim the 4B sparse model matches dense Qwen3.5-4B on every task.

Bigger blocks can be more accurate: block size and token budget move together

Block size is a trade, not a free knob. Smaller blocks give finer selection but require scoring more centroids and processing more blocks; larger blocks make centroid scoring and KV-outer cheaper but coarser. The paper’s claim is that a larger block with a larger token budget can be both faster and more accurate than a smaller block with a smaller budget. The main setting uses 2,048-token blocks and a budget of L/16, whereas Squeezed Attention, ClusterKV, and Tactic use blocks on the order of tens of tokens. This is why per-query selection becomes affordable: at 2,048 tokens, the centroid and grouping costs amortize; at tens of tokens, they do not.

Boundaries: when this method fails

The method fails when the model has no hybrid full-attention layers to replace, and the paper warns that sparse results on all-attention Transformers do not transfer to hybrids, where a quarter or fewer layers carry exact distant access. It also assumes the whole prompt is available for indexing; the main experiments run one layer at a time over the prompt, and ordinary chunked prefill needs the 64K-key approximation. Prefill is still quadratic, so cost returns as budgets scale. Accuracy fails mainly on multi-key retrieval for the 4B model; 35B is close, not identical, across tasks.

Use it to answer a narrow procurement question: on a hybrid model, can a training-free semantic-block index deliver more than 2x whole-model prefill speed while losing accuracy only on specific tasks? Do not use it to claim lossless acceleration for every model and every retrieval workload.

References

  1. Coarse Semantic Blocks for Efficient Training-Free Sparse Attention

Sign in to Padda

A code in your inbox. No password to remember.

Connecting to sign-in…