Sparse attention
Interleaved DeepSeek Sparse Attention
DeepSeek Sparse Attention turns long-context attention into a token-level retrieval problem. The attention itself becomes sparse, but exact top-k selection introduces a global dependency that is difficult to scale across context-parallel GPUs.
Block-sparse attention selects groups of tokens. With block size B, a highly tuned selector examines roughly N/B candidates. DSA is finer-grained: it ranks individual tokens and therefore examines N candidates. As context grows, the ranking path can become a first-order contributor to time-to-first-token.
Where DSA spends its work
DSA separates selection from attention. A lightweight indexer scores the historical sequence and returns token indices. Sparse MLA then gathers only the selected rows from its latent KV cache. This saves attention work, while leaving the indexer responsible for scanning the sequence.
This distinction matters in a distributed system. When context is split across GPUs, each card sees only a local shard. It can identify its own strongest candidates, but it cannot know which of them belong to the global top-k.
The exactness barrier
The conventional solution has two ranking stages. Every GPU computes a local top-k, the candidates are gathered, and a second top-k selects the global winners. The second stage is exact, but it also forms a synchronization barrier: communication must complete before sparse attention can begin.
This barrier is especially visible at low batch size and long sequence length. Those are precisely the settings where context parallelism is useful for reducing latency and distributing KV storage.
The observation behind the relaxation
To look for a way around this barrier, I start from one observation in our experiments: k = 2048 is a training setting, but it is not necessarily the best inference setting. Model quality improves as inference-time k increases. The improvement is steep before 2048, then continues more slowly toward full attention.
My hypothesis comes from the training history of DeepSeek-V3.2. The model was not sparse from scratch; it was continuously pretrained from a full-attention base model. How strongly it adapts to sparsity should therefore depend on the relative training intensity of these two stages:
When this ratio is limited, sparse adaptation changes how the model retrieves context without completely removing the full-sequence perception inherited from the base model. This gives a plausible reason why increasing k at inference time can still help.
Can we deliberately include some additional, less important tokens outside exact top-k, while preserving high recall of the important tokens inside top-k?
If the answer is yes, we no longer need an exact global boundary. We can relax the candidate set, remove the second global top-k, and break the distributed dependency barrier.
Local top-m, then one gather
Interleaved DSA asks every GPU for a smaller local top-m set. The sets are gathered and their union is passed directly to Sparse MLA. There is no second global ranking stage. The union can be larger than k, but it avoids placing an exact top-k decision on the critical path.
Exact distributed DSA
Interleaved DSA
The useful operating point is the smallest m that retains the global top-k with a chosen confidence. Smaller m reduces both selection work and communication; larger m gives more recall margin.
Why interleaving matters
Important context is not uniformly distributed. Attention often concentrates on contiguous semantic regions. With contiguous context shards, one GPU can receive most of a relevant region and therefore most of the global winners. A fixed local m then becomes either unsafe for that GPU or wastefully large for every other GPU.
Round-robin interleaving assigns token i to GPU i mod G. Contiguous neighborhoods are spread across cards, making the number of important tokens per GPU more balanced.
Choosing the local list size
Let G be the number of GPUs, C the complete context, Cg the tokens assigned to GPU g, K the desired global top-k, and γ the target coverage confidence. We require the union of local top-m sets to cover the global top-k:
Writing m = K/G + ε, the goal is to minimize the safety margin ε while satisfying the coverage constraint. Under the probability model in our derivation, the local list size can be estimated as:
Interleaving supports this estimate by making the load-balancing assumption more plausible when attention is locally clustered. The algorithm replaces a globally exact boundary with a probabilistic coverage guarantee, while Sparse MLA still receives the token indices it needs.
The systems trade-off is simple: admit a controlled number of extra candidates so that sparse attention no longer waits for a global second top-k.