DeepSeek V4.1-Flash
Separate the model's causal encoder–decoder memory sharing from FlashAttention and linear attention.
Jump to a section
Why this matters
DeepSeek V4.1-Flash is a concrete example of compressed sparse attention, not a synonym for FlashAttention or linear attention. Its model card describes a causal encoder–decoder arrangement: decoder global K/V are projected from final encoder hidden states rather than independently derived from each decoder layer's hidden states.
This differs from the 2017 translation Transformer's bidirectional source encoder. Similar architectural names do not imply identical masks or execution schedules.
Build the mental model
Compressed Sparse Attention 2 assigns layers Full, Reindex or Reuse modes to share memory and reuse sparse selections. A hierarchical indexer narrows later candidate searches. FP4 main-cache storage and local-window replay address other parts of the memory problem. The diagram separates these mechanisms instead of treating all of them as “linear attention.”
The model card reports 552B backbone parameters, with 8B active per token during prefill and 16B during decode; Engram parameters are reported separately. Active parameters describe work selected per token, not the full checkpoint size.
Select which memory entries a query reads.
Compression reduces the stored representation; sparse indexing selects entries to attend to. These are different decisions. DeepSeek V4.1-Flash combines compression, indexing, cross-layer reuse and a local-window branch.
- Dense score entries / head
- 16,777,216
- Uncompressed K + V entries / head
- 524,288
Element counts with fixed head width 64. Excludes model weights, other intermediates, batching and layers; not peak GPU memory or a speed benchmark.
A model name containing “Flash” does not mean FlashAttention or linear attention. Sparse selection has its own costs and can omit useful context. DeepSeek V4.1-Flash model card
Full · Reindex · Reuse
Sliding-window attention
Work through the math
A useful decomposition is:
Compressing cache entries changes their byte size. Selecting fewer entries changes what a query reads. Reusing entries across layers changes duplication. None of those alone proves linear total runtime: indexing, projections, feed-forward work and scheduling still matter.
Read the implementation
Use explicit units when comparing reported cache figures. This arithmetic example deliberately uses an invented 1,024-byte-per-token budget, not a model measurement.
bytes_per_token = 1024 # Hypothetical budget, not DeepSeek telemetry.
tokens = 1_000_000
cache_gib = bytes_per_token * tokens / 2**30
print(round(cache_gib, 3))
# Add weights, local state and runtime allocations separately.A deployment estimate needs the actual checkpoint and serving engine. Quantization metadata, replication and temporary allocations can invalidate an estimate based only on a headline cache rate.
Questions and trade-offs
Is sparse selection the same as compressing K/V? No. Selection chooses entries; compression changes their representation. A system can do either or both.
Why distinguish prefill and decode? Prefill processes an input prefix; decode produces additional tokens. Architectural work and cache reuse can differ between the two phases. One throughput number cannot characterize both.
Does “Flash” identify the kernel? No. Read the attention description and implementation. Compare FlashAttention with linear attention.
Check your understanding
A system reduces stored K/V bytes but leaves every query reading all past entries. Has it necessarily reduced the number of pairwise score computations? No. Memory compression and interaction sparsity are separate claims.
Source: DeepSeek's official V4.1-Flash model card. Architecture claims reviewed October 2026; diagrams show data dependencies, not measured timing or independently reproduced performance.
Oliver Perrin
Machine Learning Engineer · Founder, LiminalML
LiminalML brings together concept explanations, mathematical examples, and working visuals. Find more writing by Oliver on the LiminalML Substack.
Keep exploring the idea.
Ask a follow-up in a guided session, work through the self-check, or open the visual in Studio to build on it.
Related concepts
Deep Learning
Transformer Architecture
Follow attention, feed-forward layers, normalization, and residual connections through a Transformer block.
LLMs
KV Cache
See which token projections caching saves, what attention must still read, and how memory use grows with context.
Deep Learning
Positional Encoding
Compare positional signals at different frequencies, then connect absolute encodings and RoPE to attention.