Compressed sparse attention 2 (CSA2): keep detail, narrow the search
A query needs a detail that compression may have mixed away. Could we keep finer history without making every layer search it all again?
We want a new token to retrieve a detail from much earlier in the text. Full attention keeps every earlier token available, but its cache and the work of reading it grow with the sequence.
Sliding-window attention bounds that cost by keeping only the most recent tokens. Those tokens remain individually accessible, but this layer can no longer directly read entries that have left the window.
CSA keeps that recent window and adds compressed summaries of older history. An indexer selects which summaries each query reads, keeping the read small. But a query may find the right summary and still miss the detail it needs, because compression mixed that distinction away.
Finding the right summary only helps if it still contains what we need. Before making the search more elaborate, we could give the history more room: combine fewer positions into each entry, or keep positions individually.
Less compression gives each entry less information to squeeze together, but leaves more entries to store and search. Keeping positions individually avoids this pooling loss altogether.
The read stays small, but the search grows
Our familiar lightning indexer still chooses a small attention read. But its own search now covers more index keys: a fixed read budget does not bound the number of index keys it examines.
Now follow one token through the decoder layers. The global entries here represent individual encoder-output positions, as in the prefill split. The indexer searches their corresponding index keys; its selected positions identify which K/V columns to fetch. The recent sliding window is read separately.
Reuse saves searches, but fixes the choice
Searching the whole history in every decoder layer repeats the larger search. We already know another option: reuse an earlier layer’s selected positions. Later layers read those positions with their own attention weights, without another indexer search.
But the token’s representation changes between layers. An entry that looked unhelpful to the earlier layer’s indexer query may matter to a later one. Reusing only the winners gives that later layer no way to choose a different position instead.
Refresh the choice within a smaller search area
Could we pass a broader candidate set to a later indexer, while keeping the attention read small? It could reconsider the choice without searching the whole history again.
A strong match might have useful neighbours. Divide the stored positions into fixed, consecutive groups, and keep whole groups containing strong matches. Their entries remain separate; grouping only marks where a later indexer may search.
The first indexer already scored the visible history. Each group’s highest entry score tells us how promising that group is. Those scores give us two outputs: the best individual positions for this layer’s attention, and a wider set of groups for later indexers.
In every layer, the selected global entries join that layer’s recent sliding window in one attention read. The window is included directly; only the global entries go through indexer selection.
The cache keeps CL / R entries, where R is the compression ratio we chose: stronger compression leaves fewer entries to search. In the worked model, the decoder uses R = 1 and the encoder uses R = 2. The Full layer searches that stored history and establishes the candidates. A Reindex layer reads only the candidate positions from that same cache, using its own query to refresh the selection. A Reuse layer passes that latest selection directly to attention.
The first full search remains. We save work in later layers, but a useful position outside the retained groups cannot enter their restricted search. A larger candidate pool gives them more freedom at the cost of more indexing work.
These decisions belong to the same current token across layers. The next token gets a fresh search and candidate pool; entries excluded from one pool remain stored in the cache.
This combination is Compressed Sparse Attention 2 (CSA2). The DeepSeek-V4.1 architecture places these layer roles alongside its compressed encoder history and uncompressed decoder history.
Sources and diagram scope
- DeepSeek-V4.1 technical report.
- Public copy of the report, §2.3.2 and Figure 5 and reference code copy,
select_candidate_blocksandIndexer. - Reference inference implementation and model configuration.
- Worked architecture and source records.
The opening describes a possible information-loss failure, not a measured retrieval failure. Entry-rate animations compare one entry per four, two or one arrivals, not pooling-window shapes: V4 CSA pools overlapping eight-position windows every four arrivals. Input vectors are prepared representations, not raw residual-stream tokens. Each drawn K/V entry uses the worked 512-coordinate width.
The refresh diagram uses the selected model’s authored budgets from the size profile. For DeepSeek-V4.1 Flash, the candidate budget is 2,048 groups of eight positions (16,384 positions), with a final Top-512 attention read. Actual counts are capped by causally visible history. CL labels the source history length and R the compression ratio, so the cache and its index-key table have CL / R entries. The diagram follows the decoder, with R = 1; the encoder uses R = 2. Drawn columns and highlights are schematic, not a one-column-per-entry count.
Group scores are maxima of the Full layer’s individual indexer scores. Candidate groups are selected independently of that layer’s Top-K attention read; no separate region vector or region query–key scan is introduced. The reference implementation also retains the group containing the newest visible position. Later Reindex layers use their own queries and shared index keys; Reuse layers do no new indexing. The candidate pool is specific to one current token across layers.
The three rows show layer roles, not three consecutive layers. In the worked checkpoint, encoder Full layers are 3, 9 and 15; decoder Full is 21, with Reindex at 25, 29, 33 and 37. Repeated tables represent the same shared index-key and global K/V caches. Recent-window buffers and attention weights remain layer-specific. Attention outputs are shown after head combination and output projection, then added to the residual; dotted stream segments omit the feed-forward work and intervening layers.