Papers · arXiv 2412.19437
DeepSeek-V3 Technical Report
Summary in three lines
- 🎯 Frontier-scale MoE models require immense computational budgets, suffer performance degradation from auxiliary balancing losses, and face massive cross-node all-to-all communication bottlenecks.
- 🔧 Employs Multi-head Latent Attention (MLA), DeepSeekMoE with auxiliary-loss-free balancing, FP8 mixed-precision training with fine-grained quantization, DualPipe overlap scheduling, and Multi-Token Prediction (MTP).
- 📈 Trained 671B parameters (37B activated) on 14.8T tokens using just 2.788M H800 GPU hours (~$5.576M), achieving state-of-the-art open-source scores and competitive performance with GPT-4o and Claude-3.5-Sonnet.
Abstract
We present DeepSeek-V3, a strong Mixture-of-Experts (MoE) language model with 671B total parameters with 37B activated for each token. To achieve efficient inference and cost-effective training, DeepSeek-V3 adopts Multi-head Latent Attention (MLA) and DeepSeekMoE architectures, which were thoroughly validated in DeepSeek-V2. Furthermore, DeepSeek-V3 pioneers an auxiliary-loss-free strategy for load balancing and sets a multi-token prediction training objective for stronger performance. We pre-train DeepSeek-V3 on 14.8 trillion diverse and high-quality tokens, followed by Supervised Fine-Tuning and Reinforcement Learning stages to fully harness its capabilities. Comprehensive evaluations reveal that DeepSeek-V3 outperforms other open-source models and achieves performance comparable to leading closed-source models. Despite its excellent performance, DeepSeek-V3 requires only 2.788M H800 GPU hours for its full training. In addition, its training process is remarkably stable. Throughout the entire training process, we did not experience any irrecoverable loss spikes or perform any rollbacks. The model checkpoints are available at https://github.com/deepseek-ai/DeepSeek-V3.
Reading guide
Problem and motivation
Frontier large language models (LLMs) continue to close the gap toward AGI, but scaling open-source models typically demands prohibitive compute budgets and infrastructure. Furthermore, scaling Mixture-of-Experts (MoE) architectures introduces specific engineering challenges:
- Auxiliary Loss Degradation: Traditional auxiliary load-balancing losses heavily restrict routing flexibility and harm language modeling capacity.
- Communication Bottlenecks: Fine-grained cross-node routing causes severe all-to-all communication overheads, often reaching a computation-to-communication ratio of 1:1.
- Numerical Precision & Memory: Standard 16-bit training is memory-intensive, while naive FP8 training suffers numerical instability and underflow due to activation outliers and limited Tensor Core accumulation precision.
DeepSeek-V3 addresses these challenges through co-designed algorithmic strategies and hardware-level infrastructure optimizations to achieve frontier performance at minimal training cost.
Key ideas
- Architecture Efficiency: Combines low-rank Key-Value compression via Multi-head Latent Attention (MLA) with fine-grained routed experts via DeepSeekMoE (1 shared + 256 routed experts, 8 activated).
- Auxiliary-Loss-Free Load Balancing: Replaces performance-degrading auxiliary losses with dynamically updated expert bias terms, enabling distinct domain specialization without routing collapse.
- Multi-Token Prediction (MTP): Predicts multiple future tokens sequentially at each position along a preserved causal chain to enrich training signals and support speculative decoding (1.8× TPS).
- DualPipe Parallelism: A bidirectional pipeline schedule that fully overlaps forward and backward computation with cross-node MoE all-to-all and PP communications.
- FP8 Mixed-Precision Training: Uses E4M3 across all tensors, applying tile-wise () activation and block-wise () weight scaling, accompanied by accumulation offloaded to CUDA Core registers in FP32 every steps.
- Reasoning Distillation: Distills verification and reflection long-CoT reasoning patterns from the DeepSeek-R1 series directly into SFT and RL post-training stages.
Method
1. Multi-head Latent Attention (MLA)
For token hidden state , MLA compresses KV cache into a shared latent vector and query states into :
During inference, caching is restricted to only and , dramatically lowering memory footprints.
2. DeepSeekMoE with Auxiliary-Loss-Free Balancing
Feed-forward network outputs combine shared experts and routed experts:
Expert affinities are calculated as . Gating values are computed by normalizing , where routing decisions incorporate a dynamic bias term :
If expert is overloaded at step end, ; if underloaded, (with ). A tiny sequence-wise balance loss () is used as a complement.
3. Multi-Token Prediction (MTP)
For prediction depth (with ), representation is combined with the shifted token embedding:
The total training loss adds .
Results
- Pre-Training Budget: Pre-trained on 14.8T tokens for only 2.664M H800 GPU hours (3.7 days per 1T tokens on 2048 GPUs). Full training consumed 2.788M GPU hours (~$5.576M at $2/hour).
- Stability: Zero rollbacks and zero irrecoverable loss spikes across all 14.8T tokens.
- Base Model Benchmarks:
- Outperforms LLaMA-3.1 405B Base on MMLU (87.1 vs. 84.4), BBH (87.5 vs. 82.9), HumanEval (65.2 vs. 54.9), and MATH (61.6 vs. 49.0).
- Outperforms Qwen2.5 72B Base on C-Eval (90.1 vs. 89.2) and GSM8K (89.3 vs. 88.3).
- Chat Model Benchmarks:
- Math & Code: Sets state-of-the-art non-o1 scores: MATH-500 (90.2), AIME 2024 (39.2), LiveCodeBench CoT (40.5).
- Broad Knowledge: MMLU (88.5), MMLU-Pro (75.9), GPQA-Diamond (59.1).
- Open-Ended: Exceeds 85% win rate on Arena-Hard (85.5%) and achieves 70.0% on length-controlled AlpacaEval 2.0.
Limitations and open questions
- Hardware Inference Minimums: Efficient serving requires large deployment units (32 GPUs for prefilling unit, 320 GPUs for decoding unit), presenting infrastructure barriers for small organizations.
- Cross-Node SM Allocation: 20 SMs per GPU were dedicated strictly to managing cross-node all-to-all communication routines rather than matrix math.
- Factual Discrepancies: Lags closed-source frontier models (e.g., GPT-4o, Claude-3.5-Sonnet) on English factual tasks like SimpleQA (24.9% vs. 38.2%), despite leading on Chinese SimpleQA (64.8%).
Key terms
- Multi-head Latent Attention (MLA)
- An attention mechanism that low-rank compresses Keys and Values into a shared latent vector to drastically minimize KV cache consumption during inference.
- DeepSeekMoE
- A Mixture-of-Experts architecture utilizing fine-grained experts with dedicated shared experts to enhance specialization and routing expressiveness.
- Auxiliary-Loss-Free Load Balancing
- A routing approach that dynamically modifies per-expert affinity bias terms based on batch load instead of adding large regularizing auxiliary losses to the objective.
- Multi-Token Prediction (MTP)
- A training framework that sequentially predicts multiple future tokens per position using causal modules while reusing the main model vocabulary embeddings and heads.
- DualPipe
- A bidirectional pipeline parallelism algorithm that overlaps forward, backward-for-inputs, and backward-for-weights computation with all-to-all and pipeline communication.
- Warp Specialization
- An execution model partitioning GPU Streaming Multiprocessors into dedicated task warps for concurrent IB and NVLink data dispatching and combining.
- Group Relative Policy Optimization (GRPO)
- A reinforcement learning algorithm that removes the need for a separate critic model by computing advantages relative to a group of sampled responses.
Questions
How many total and activated parameters does DeepSeek-V3 have?
DeepSeek-V3 has 671B total parameters, with 37B activated per token (1 shared expert plus 8 routed experts chosen out of 256).
How much did it cost to train DeepSeek-V3?
Full training required 2.788M H800 GPU hours (2.664M for pre-training, 119K for context extension, and 5K for post-training), costing approximately $5.576M USD at an estimated $2 per GPU hour.
Why is the auxiliary-loss-free balancing method superior to standard auxiliary loss?
Standard sequence-level auxiliary losses force uniform expert usage on individual sequences, harming domain specialization. DeepSeek's dynamic bias updating ensures batch-level balancing without contaminating the primary language modeling gradient objective.
How was FP8 mixed-precision successfully trained without loss divergence?
By using tile-wise (1x128) activation quantization, block-wise (128x128) weight quantization, pure E4M3 representation, and copying intermediate Tensor Core sums to FP32 registers on CUDA Cores every 128 elements to avoid low-precision accumulation underflow.
The overview on this page was written by AI from the paper and may contain mistakes. Read the paper for the details.