The model keeps every token in the residual stream. What shrinks is the historical KV-cache sequence dimension: one compressed entry is emitted every four tokens, using overlapping, learned, per-feature gated pooling.
Click a step to focus it. Shapes use the released Flash configuration: hidden size 4096 and compressed KV width 512.
All original token states remain available to the Transformer.
Each token produces branch A, branch B, and matching feature-wise gate logits.
Four tokens form each current block; branch B from the previous block is brought forward.
For every output feature, eight logits normalize into eight weights, then weighted vectors are summed.
The result is normalized, rotary position is applied, then it is stored as one compressed KV entry.
This distinction prevents the most common misunderstanding.
The four input tokens do not become one vocabulary token. Their residual hidden states, query vectors, and token-level outputs remain separate.
The historical key/value representation stored for attention is reduced from N positions to approximately N/4.
Choose a compressed entry. Pink tokens feed its previous-block branch; cyan tokens feed its current-block branch.
The gate is not one scalar per token. Each of the 512 output features gets its own eight-way softmax. Move the feature slider to see an illustrative weight pattern.
The sequence length shrinks only at the final pooling stage.
Use a multiple of four to see the prefill shape exactly.
Prefill reshapes a full sequence. Decode buffers tokens and emits a new compressed entry every fourth token.
CSA combines exact recent context with sparsely selected compressed history.
Sliding-window cache keeps 128 recent token-level KV entries.
A separate 128-D indexer compressor scores historical compressed positions.
For CSA layers, the released Flash configuration selects up to 512 compressed positions per query.
64 query heads attend to a shared 512-D KV entry for each selected position.
Values below come from the model configuration and released inference implementation.
| Parameter | Value | Why it matters here |
|---|---|---|
| Hidden size | 4096 | Width of each input token hidden state. |
| Attention / compressed KV width | 512 | One compressed KV entry has 512 features. |
| RoPE sub-dimension | 64 | RoPE is applied after pooling to the rotary slice. |
| CSA compression ratio | 4 | One output position is emitted per four input positions. |
| HCA compression ratio | 128 | Other interleaved layers compress more aggressively and use dense attention. |
| Sliding window | 128 | Preserves recent token-level detail. |
| Indexer heads × width | 64 × 128 | Used only to score compressed positions. |
| Indexer top-k | 512 | Maximum selected compressed historical positions per query. |
| KV heads | 1 shared KV | Queries are multi-head; compressed K/V is shared. |
Primary paper and released DeepSeek-V4-Flash implementation.