# DeepSeek-V4.1-Flash: A New Era in Efficient Large-Scale LLM Serving
## Introduction
The demand for long-horizon AI agents has fundamentally reshaped how large language models are served. With repeated prefill operations and context windows stretching into the millions of tokens, the Key-Value (KV) cache has become the dominant bottleneck in deployment infrastructure. Storing and moving these caches across high-bandwidth memory and solid-state storage consumes enormous resources, driving a relentless search for architectural innovations that can shrink the cache without sacrificing capability.
DeepSeek’s latest release, DeepSeek-V4.1-Flash, tackles this problem head-on. It is a multimodal Mixture-of-Experts model built from the ground up to minimize KV cache pressure while maintaining strong performance across a wide range of benchmarks. The result is a model that promises dramatically lower infrastructure costs and higher throughput for production deployments.
## Model Architecture at a Glance
DeepSeek-V4.1-Flash features a 552-billion-parameter backbone with an additional 196 billion Engram parameters dedicated to conditional memory. The model supports a context window of up to one million tokens, making it suitable for long-document analysis, extended agent workflows, and multi-turn conversation systems.
During prefill operations, the model activates only 8 billion parameters per token. During the decode phase, that number rises to 16 billion parameters per token. This activation pattern is central to the model’s efficiency story, and it is achieved through a combination of novel architectural choices that will be explored below.
## The KV Cache Revolution
The headline metric for V4.1-Flash is its global KV cache footprint: **890 bytes per token**. This represents roughly one-quarter of the previous generation DeepSeek-V4-Flash model and is approximately 437 times smaller than the original DeepSeek-V1 model released in late 2023. This dramatic reduction is what makes the model deployable at scale without requiring heroic amounts of HBM or SSD capacity.
The model ships with open weights under an MIT license and is available through standard serving frameworks including vLLM, SGLang, and Transformers on Hugging Face. A public API is also available, offering three reasoning tiers — low, high, and max — that allow users to trade off quality for cost.
## Causal Encoder-Decoder: Cutting Prefill Compute in Half
At the heart of the efficiency gains is a novel backbone design. The 40-layer transformer is split into two distinct sections: a 20-layer causal encoder and a 20-layer decoder. This architecture draws inspiration from earlier work on encoder-decoder transformer designs.
During the prefill phase, the decoder does not compute its own global KV cache. Instead, per-layer projection weights derive the decoder’s KV entries from the final encoder hidden state. This means that prompt tokens flow through only the 20 encoder layers during prefill, effectively halving the compute required for cached-context tokens. When new tokens begin to be generated, the decoder takes over and all 40 layers participate in the generation process.
Sliding-window attention (SWA) with a 128-token window is applied in every layer of the network. When the decoder needs to rebuild its SWA states after a cache eviction, it uses a technique called **Decoder SWA Bounded Replay**, which replays only the last 128 prompt tokens rather than recomputing attention over a larger window.
## Compressed Sparse Attention 2 (CSA2)
The previous generation of DeepSeek models used a hybrid approach combining Compressed Sparse Attention with Heavily Compressed Attention. V4.1-Flash goes further by adopting pure CSA2 across the entire model, attacking cache size from the layer axis.
Every CSA2 layer is statically assigned one of three operational modes:
– **Full Mode:** The layer computes its own main KV cache and indexer K from scratch. It then selects fresh Top-512 indices from the candidate pool. This mode is used sparingly to establish the reference points that other layers will reuse.
– **Reindex Mode:** The layer reuses the main KV and indexer K from the most recent Full layer but rescores them using its own indexer queries. This allows each layer to perform its own sparse selection while sharing the bulk of the cached data.
– **Reuse Mode:** The layer reuses both the main KV and the latest Top-K indices from an earlier Full or Reindex layer, completely skipping indexer computation. This is the most efficient mode and covers the vast majority of layers in both the encoder and decoder.
Every CSA2 layer independently maintains its own main query vectors and sliding-window KV. The 18 CSA2 encoder layers use a compression ratio of 2 across three groups of six layers, with one Full layer followed by five Reuse layers. The 20 decoder layers employ a ratio of 1 in five groups of four, with the first group containing one Full layer and three Reuse layers, followed by Reindex layers with three Reuse layers each.
A **Hierarchical Sparse Indexer** residing in the decoder allows the Full layer to build a candidate pool of up to 16,384 positions, organized as 2,048 blocks of 8 tokens each. Subsequent Reindex layers then score from this bounded set rather than searching the entire context, dramatically reducing the attention computation in later layers.
## Quantization and Memory Management
The main KV cache is quantized to E2M1 format with one E4M3 scale factor per 16 channels. This quantization scheme follows the NVFP4 standard but omits the global scale component, and is introduced through quantization-aware training during the post-training phase. The result is an effective halving of KV storage compared to the FP8 cache used in the previous generation.
At the deployment level, sliding-window KV is no longer persisted to SSD. Instead, it resides in a distributed memory pool carved from 10% of host DRAM, with a time-to-live of just a few minutes. The global KV cache, by contrast, is guaranteed a 72-hour lifetime. On a cache miss, Encoder SWA Bounded Replay recomputes only the 128 most recent tokens rather than replaying all layers times the attention window, keeping recovery latency low.
## Additional Technical Innovations
Several other innovations contribute to the model’s efficiency:
– **Single-Pass mHC:** Input-mixing coefficients are shifted by one block, enabling a fused Mega-mHC kernel that halves activation memory traffic.
– **Engram Module:** A conditional memory module is placed at layers 1 and 14 of the backbone, providing targeted memory augmentation at strategic points in the network.
– **DSpark Speculative Decoding:** This is trained after the pre-training phase with the backbone held frozen, allowing faster decoding with minimal quality loss.
– **Head-wise Muon:** An optimizer-level refinement applied across attention heads that improves training stability and convergence.
– **Single-Token Decode Scaling:** FLOPs for single-token decode increase by only about 25% when the context grows from 4,000 tokens to 1 million tokens, making long-context inference far more practical.
## Training Pipeline
Pre-training spans 45 trillion multimodal tokens with a 7:1 ratio of text to multimodal data. Sparse attention mechanisms are trained from scratch at 64K sequence length, and context is progressively extended to 1 million tokens at the 34 trillion token mark. The base model delivers performance on world knowledge and coding benchmarks that matches the previous-generation DeepSeek-V4-Pro-Base, while using only one-third of the total parameters and one-quarter of the activated parameters.
Post-training introduces no new algorithmic components. Performance improvements are driven by large-scale synthesis of verifiable agent tasks, reinforcement learning across heterogeneous scaffolding environments (including tools like Claude Code, Codex, OpenCode, Pi, mini-SWE, and the DeepSeek Harness), and on-policy distillation from over 40 diverse teacher models.
## Benchmark Performance
The following table compares selected max-effort results across leading models:
| Benchmark | DeepSeek-V4.1-Flash | DeepSeek-V4-Flash | Opus-5 | GPT-5.6 Sol |
|—|—|—|—|—|
| Terminal-Bench 2.1 | 90.6 | 82.7 | 89.1 | 88.8 |
| DeepSWE v1.1 | 74.2 | 54.4 | 74.0 | 73.0 |
| Terminal-Bench 4.0 | 31.2 | 7.0 | 51.8 | 39.9 |
| Automation-Bench | 54.8 | 37.7 | 50.3 | 45.8 |
| GPQA Diamond | 90.9 | 89.9 | 93.4 | 94.1 |
| Codeforces (rating) | 3471 | 3289 | N/A | N/A |
DeepSeek-V4.1-Flash leads or closely matches the competition across agent-oriented benchmarks. The improvements over V4-Flash are particularly striking on Terminal-Bench 4.0 (31.2 versus 7.0), a task that is highly sensitive to the model’s ability to manage long-horizon tool use and context.
## Key Takeaways
– The global KV cache footprint has been reduced to 890 bytes per token, making million-token contexts practical on modest infrastructure.
– The Causal Encoder-Decoder design halves prefill compute by running only 20 encoder layers during the prompt processing phase, activating 8 billion parameters.
– CSA2 sparse attention shares KV caches and sparse indices across layers through Full, Reindex, and Reuse modes, cutting redundant computation.
– FP4 quantization and SWA Bounded Replay together reduce persistent cache to roughly one-eighth of the previous generation.
– The model achieves top-tier performance on agent benchmarks and is available under an MIT license with open weights.
## Frequently Asked Questions
**What makes DeepSeek-V4.1-Flash different from its predecessor?**
The primary advancement is the reduction in KV cache size from approximately 3,500 bytes per token to 890 bytes per token. This is achieved through a combination of the Causal Encoder-Decoder architecture, CSA2 sparse attention, FP4 quantization, and SWA Bounded Replay. The backbone also uses fewer activated parameters while matching or exceeding predecessor performance.
**How does the Causal Encoder-Decoder architecture save compute?**
By splitting the 40-layer backbone into a 20-layer encoder and a 20-layer decoder, prompt tokens only need to pass through the encoder during prefill. The decoder’s global KV cache is projected from the encoder’s final hidden state rather than being computed from scratch, nearly halving prefill compute and activation.
**What are the three CSA2 modes and when is each used?**
Full mode computes all attention components fresh and is used to establish reference caches. Reindex mode reuses existing KV data but rescoring with a new indexer query. Reuse mode is the most efficient, skipping indexer computation entirely by reusing previously computed Top-K indices. In practice, most layers operate in Reuse mode.
**Is the model open source?**
Yes. The weights are released under an MIT license and can be accessed on Hugging Face with support for vLLM, SGLang, and Transformers serving stacks. A public API is also available with low, high, and max reasoning tiers.
**What are the public API tiers?**
The API offers three reasoning tiers: low (effort value 50), high (effort value 75), and max (effort value 100). Users can select a tier based on their accuracy requirements and cost constraints.
**How long can the KV cache persist?**
The global KV cache is guaranteed a 72-hour lifetime in the distributed pool. Sliding-window KV entries have a much shorter TTL of minutes and are rebuilt on demand using Bounded Replay rather than being persisted to disk.
**What hardware is needed to deploy this model?**
The dramatically reduced KV cache footprint means the model can be deployed on hardware configurations that would be impractical for models of similar size. The team has designed the architecture specifically for deployment on commodity HBM and DRAM configurations without requiring exotic storage or bandwidth setups.
## Conclusion
DeepSeek-V4.1-Flash represents a significant step forward in making large-scale language model deployment economically and practically feasible. By attacking the KV cache problem from multiple angles — architectural redesign, sparse attention, quantization, and intelligent cache management — the model achieves a 437-fold improvement in cache efficiency compared to early generation systems.
The combination of open-source licensing, MIT terms, and integration with standard serving frameworks means that this efficiency is not locked behind proprietary infrastructure. Agent developers and deployment teams can now work with million-token contexts at a fraction of the previous cost, opening new possibilities for long-horizon AI applications.
The benchmark results speak for themselves: strong performance on coding, reasoning, and agent tasks that consistently matches or exceeds competing models, all while using significantly fewer activated parameters and a dramatically smaller memory footprint.
Thank you for reading



