Sources: NVIDIA Technical Blog, Co-Designing Sparse Attention for Efficient Long-Context Inference, 2026-11-17, by Liu, Bhatia, Jain, Chandran, Darvish Rouhani and colleagues. Surfaced by NVIDIA AI's post.
The problem
Agent sessions, long documents and large codebases push context into the hundreds of thousands of tokens. Dense attention scores every query against every key, so at 128K tokens attention dominates prefill time. Sparse attention has each query attend only to the top k keys, typically a few thousand. Core attention then stops growing with context, but the cost does not disappear. A component called the indexer still scores all N keys to find the top k. In DeepSeek V3.2's sparse attention, the indexer plus top-k selection take 47% of the prefill layer time at 128K tokens.
Three stages
Indexer: a cheap scoring pass over all keys, producing one logit per key.
Top-k: keep the k highest-scoring keys or key blocks.
Core attention: ordinary softmax attention over those k keys and values.
Stages 2 and 3 scale with k. Stage 1 scales with N, so it becomes the bottleneck to engineer.
Design space
The post compares how recent designs fill in the indexer: DeepSeek DSA, GLM 5.2 and 5.3 Flash, LongCat LSA-Flash, CSA, Qwen QSA, MiniMax MSA, NSA, MoBA and others. They vary in query heads, key heads, head dimension, post-processing (ReLU plus weighted sum, max-pool or softmax), compression ratio and selection granularity (single tokens or blocks of 4 to 128). It then sweeps each knob with a production FP8 kernel. The scope is sparsity trained into the model, not add-on methods applied after training.
The eight guidelines
Size query-head grouping to the Tensor Core tile. Keep the grouped query rows within one tile (about 200 rows, or 256 with an FP16 epilogue) so the indexer stays compute-efficient.
Run the indexer epilogue in FP16, and accumulate in FP16 too if the QK scaling keeps values in range.
Use one key head, with a reduction across query heads, so the indexer writes one logit per key.
Use a head dimension of 128 or 256. At 64 the Tensor Cores wait on the epilogue; most designs pick 128 to keep decode bytes down.
Score fewer keys using compression, hierarchical indexing and sharing the index across layers. These reduce work but do not change arithmetic intensity, so use them alongside guidelines 1 to 4.
Budget top-k as part of the indexer. Its cost follows the number of keys scored, not k. Fuse it with the indexer, and in decode reuse the previous step's result.
Prefer block-level selection with large blocks. Blocks let core attention fetch keys in bulk and share them across queries.
Use a large core-attention group size, so many query heads share each KV head.
Why it matters beyond kernel teams
Long-context pricing and latency for agent workloads depend on these choices. Models whose sparse attention follows the hardware get cheaper long contexts.
When comparing long-context models for serving, "sparse attention" alone says little. The indexer design decides whether the savings appear.
Block-level selection and index sharing interact with KV-cache layout and prefix caching, so serving and model teams need to agree on them.
Tradeoffs and failure modes
Vendor guidance tuned to one hardware family. The thresholds (tile size, FP16 epilogue) are specific to NVIDIA GPUs and may differ elsewhere.
Accuracy is out of scope. The post optimizes speed. Larger blocks or heavier compression can drop relevant tokens, so quality on long-range retrieval must be measured separately.
FP16 overflow. Lower-precision accumulation depends on QK scaling staying in range, and an overflow shows up as silent mis-selection.
Decode reuse of top-k assumes relevance changes slowly between steps, which may fail after abrupt context shifts such as tool outputs.
Review checklist for a long-context model or serving stack
What fraction of prefill time goes to the indexer and top-k at your context lengths?
Token-level or block-level selection, and at what block size?
Is the index shared across layers, and is accuracy checked at your context lengths?
Is top-k fused, and is it reused in decode?
Was long-range recall measured after the sparsity changes, not just throughput?
Related entries
R191 WorldTrace: keeping a compressed KV cache addressable over long horizons.
R180 Serving Trace Lab: KV-cache memory and batching in LLM serving.
R025 LongCapHarness: a harness instead of long-context training.
R174 QDA: the quantization side of inference cost.