
DeepSeek-V4: Towards Highly Efficient Million-Token Context Intelligence
Key Points
- 1DeepSeek-V4 introduces a high-efficiency architecture featuring Manifold-Constrained Hyper-Connections and a hybrid attention mechanism that combines Compressed Sparse Attention with Heavily Compressed Attention to enable million-token context windows.
- 2By integrating the Muon optimizer and advanced infrastructure optimizations, the models achieve significantly lower computational costs, requiring only 27% of the single-token inference FLOPs and 10% of the KV cache compared to DeepSeek-V3.2.
- 3Extensive pre-training on 32T+ tokens and a specialized post-training pipeline—utilizing domain-specific expert cultivation and on-policy distillation—establish the DeepSeek-V4 series as a new state-of-the-art benchmark for open models in reasoning, coding, and long-context performance.
The DeepSeek-V4 series introduces a high-efficiency Mixture-of-Experts (MoE) architecture designed for long-context intelligence, supporting up to one million tokens. The series includes the DeepSeek-V4-Pro (1.6T total parameters, 49B activated) and DeepSeek-V4-Flash (284B total parameters, 13B activated). The architecture aims to mitigate the quadratic complexity of standard attention mechanisms through hardware-aware optimizations and novel structural innovations.
Core Methodological Innovations
- Hybrid Attention Architecture (CSA and HCA): To handle 1M-token sequences, the model employs a combination of Compressed Sparse Attention (CSA) and Heavily Compressed Attention (HCA).
- CSA: Compresses the KV cache by a factor of by combining adjacent entries and then uses a "Lightning Indexer" to perform sparse attention. The indexer computes scores using low-rank projections of query hidden states to select the top- most relevant compressed KV blocks.
- HCA: A more aggressive compression strategy that reduces the KV cache by (where ) while maintaining dense attention for the remaining entries. Both mechanisms are supplemented by a sliding window of local KV entries to preserve fine-grained local dependencies.
- Manifold-Constrained Hyper-Connections (mHC): DeepSeek-V4 replaces standard residual connections with mHC to improve stability during deep stacking. The residual transformation is constrained by ensuring the residual mapping matrix resides within the manifold of doubly stochastic matrices (). This ensures the spectral norm is bounded by 1, preventing signal explosion in deep networks. The matrix is computed via the Sinkhorn-Knopp algorithm: .
- Optimizer and Training: The model utilizes the Muon optimizer, which enhances training stability and convergence speed. The architecture adopts the DeepSeekMoE framework with fine-grained routed experts. A significant shift in the routing mechanism involves replacing the sigmoid-based affinity computation with to improve expert selection stability.
- Infrastructure and Efficiency:
- Inference Efficiency: In a 1M-token context, DeepSeek-V4-Pro requires only 27% of the FLOPs and 10% of the KV cache relative to DeepSeek-V3.2.
- Quantization-Aware Training: The models incorporate FP4 quantization for routed expert weights and the indexer query-key (QK) path, significantly reducing memory footprint without degrading core reasoning capabilities.
- Kernel Optimization: The implementation leverages TileLang for custom, batch-invariant, and deterministic kernels, ensuring high performance across various hardware settings and bitwise reproducibility.
Post-Training Pipeline
The models undergo a two-stage post-training process:- Specialist Training: Independent training of domain-specific experts (mathematics, coding, agentic workflows) using Supervised Fine-Tuning (SFT) and Reinforcement Learning via Group Relative Policy Optimization (GRPO).
- On-Policy Distillation: A unified student model is trained to consolidate the diverse proficiencies of the specialist experts by minimizing the reverse KL divergence between the unified model and the specialized teacher models.