Glossary · Attention

Sparse attention (DSA indexer)

Also: DeepSeek Sparse AttentionDSAlightning indexerindex_topk

Read it at the depth you need: one sentence · a paragraph · the math · in the models here

1In one sentence

Attention where a small, cheap scorer (the indexer) picks the top k earlier tokens for each query, and full attention runs only over those.

2In a paragraph

Full attention scores every earlier token, which gets expensive at long contexts. DeepSeek Sparse Attention adds a lightweight indexer: a few small heads that quickly score every earlier token, after which the real attention looks only at the 2,048 best. The indexer still touches everything, but it is far cheaper than full attention, so long contexts cost much less. DeepSeek-V3.2 added it to V3.1 without changing the rest; GLM-5 uses it too, with one indexer shared by several layers.

3The math, shapes and parameters

For a query at position t, with HI indexer heads of size hI:

It,s = Σj wt,j · ReLU(qIt,j · kIs)  → attend only to the top k values of s

The indexer's queries come from the compressed query (wq_b [HI·hI, rq]); its key is one vector per token (wk [hI, d], with a LayerNorm), cached like the KV latent; weights_proj [HI, d] weighs the heads. It adds hI numbers per token per layer to the cache.

4In the 96 models on this site

ModelIndexer heads × sizeTop kLayers with their ownKV per token
DeepSeek-V3.264 × 1282,04861 of 6185.9 KB
GLM-5.232 × 1282,04821 of 78109.8 KB

Introduced in DeepSeek-AI, “DeepSeek-V3.2: Pushing the Frontier of Open Large Language Models” (2025).

Related

Multi-head latent attention (MLA) · Self-attention · KV cache · every term