Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path →
DeepSeek-V3,
explained.
In late 2024, the going assumption was that a frontier model cost somewhere between $50M and $500M to train. Then a lab working on export-restricted GPUs published one for about $5.6M — open weights, full recipe — and matched the giants on the benchmarks that mattered. V3 isn't one clever idea; it's a stack of them, compounding: compress the attention cache, balance the experts without a tax, predict two tokens at once, and train the whole thing in 8-bit.
Contents 16 sections
The delta The shape: huge brain, small bite MLA: shrink the cache, keep the quality Load balancing without the auxiliary-loss tax Multi-token prediction: denser signal, free speed FP8: training a frontier model in 8 bits The receipt: 2.79M GPU-hours Why it still matters How it works The math The evidence Since then Solve it yourself Questions Check yourself Where this sitsWhat changes against Switch: the balancing loss goes, and the KV cache shrinks
Rungs 1 and 2 keep experts balanced with an auxiliary loss, and both admit it is a term pulling against the language objective. This rung's first change is to remove it: balance is maintained by adjusting a per-expert bias on the routing scores, nudged up for underused experts and down for overused ones, so the pressure is applied to the decision rather than added to the loss. The gradient the model learns from is then only about language. That is a small idea with a clean argument behind it, and it is the rung's most portable contribution.
The second change targets the cost that actually dominates serving rather than training. A transformer's key-value cache grows with every token in every sequence, and at long context and high concurrency it, not the weights, is what fills the accelerator's memory. The change is to project keys and values down into a much smaller latent representation and cache that instead, reconstructing what attention needs on the fly — trading a little arithmetic for a large reduction in the thing that limits how many users you can serve at once.
Stated in the ladder's units, and these are the numbers the page carries: 671B total parameters with about 37B active per token — a roughly 18× decoupling, which is rung 1's identity taken much further than rung 2 did — trained in FP8 rather than a 16-bit format, with an auxiliary multi-token prediction objective, for a reported training compute cost around $5.6M.
The shape: huge brain, small bite
V3 is a mixture-of-experts pushed toward its logical extreme: 671B total parameters, organized as many small experts, with a router activating only ~37B per token — about 5%. You store the knowledge of a giant; you pay the compute of a mid-size model. Each token consults 8 routed experts plus one shared expert that every token sees.
Fine-grained experts (many small ones rather than few big ones) give the router more precise choices — specialization without redundancy. The blueprint came from DeepSeek's own MoE work; V3's contribution was making this shape trainable and servable at 671B without the usual MoE taxes. Those taxes are what the next two sections remove.
MLA: shrink the cache, keep the quality
Serving throughput dies on the KV cache — the per-token attention state that grows with context and batch. Standard fixes (GQA, MQA) share keys and values across heads: less memory, some quality loss. V3's multi-head latent attention goes further: compress keys and values into one small latent vector, cache only that, and reconstruct full per-head K/V from it at use time.
small latent c
far smaller (57× in the config below)
full heads restored
The result: KV memory an order of magnitude smaller than vanilla attention — longer contexts, bigger serving batches, cheaper tokens — with benchmark quality that matches or beats standard attention. It's the rare compression that costs nothing you can measure.
The size difference is countable. Standard attention caches K and V for every head; GQA shares them across a few groups; MLA caches only the latent (plus a tiny decoupled RoPE key):
That's 57× smaller than MHA — a 128k-token cache drops from ~477 GB to ~8 GB. The runnable version below computes it for any config.
Load balancing without the auxiliary-loss tax
MoE's classic pathology: the router collapses onto a few favorite experts — they overload, the rest atrophy. The standard cure is an auxiliary loss punishing imbalance. But that loss competes with the language-modeling objective: you're paying quality to buy balance.
V3's fix is almost cheeky: auxiliary-loss-free balancing. Each expert carries a bias term used only for routing — not in the gradient, not in the output weights. Overloaded expert? Bias nudged down, fewer tokens routed there. Underused? Nudged up. Balance emerges from a feedback controller outside the training objective, so the model never trades quality for it.
Separate the concerns: let gradients optimize prediction, let a bias controller manage traffic. The ablations show it beats auxiliary-loss balancing on both balance AND quality — a free lunch made of good engineering hygiene.
Multi-token prediction: denser signal, free speed
Standard training predicts one next token per position. V3 adds a lightweight module predicting the token after next as well — multi-token prediction (MTP). During training this densifies the learning signal (every position teaches two lessons) and pushes representations to plan a little further ahead.
At inference the MTP head gets a second life: it drafts the next-next token for speculative decoding, with ~85% acceptance — meaningfully faster generation, using machinery training already paid for. One module, two dividends.
FP8: training a frontier model in 8 bits
Most labs trained in BF16. V3 ran the bulk of its matrix math in FP8 — half the memory traffic, nearly double the arithmetic throughput on H800s — something widely considered too unstable at frontier scale. The stabilizers: fine-grained scaling (per-tile/per-block scale factors so outliers don't wreck a whole tensor) and high-precision accumulation (sums collect in FP32 before rounding back down).
Sensitive pieces — embeddings, norms, router, optimizer states — stay in higher precision. The headline stat that convinced everyone: zero irrecoverable loss spikes across the entire 14.8T-token run. Add DualPipe (overlapping the MoE's heavy cross-GPU communication behind compute) and the hardware efficiency story is complete.
The receipt: 2.79M GPU-hours
| Item | Number |
|---|---|
| Training data | 14.8T tokens |
| Total compute | 2.788M H800 GPU-hours |
| Rental-price cost | ≈ $5.576M |
| Benchmarks | top of open-weights; competitive with frontier closed models on math/code |
The number needs its caveats — it excludes research, ablations, failed runs, salaries and the cluster itself — but the like-for-like comparison still landed like a thunderclap: contemporary frontier runs were estimated at 10–50× more compute spend. The efficiency stack above, compounding multiplicatively, is where the order of magnitude came from.
Why it still matters
V3 is the paper that made training efficiency a first-class research axis — after it, "what does your compute buy?" became as important a question as "how much compute do you have?" It's also the foundation everything DeepSeek-famous stands on: R1's reasoning RL runs on the V3 base, and the GRPO lineage got its frontier-scale proving ground here.
Architecturally, its ideas went mainstream fast: MLA-style cache compression, aux-loss-free balancing and MTP heads now appear across open models — including the next entry in this library, Kimi K2, which scales the same skeleton to a trillion parameters. And strategically, V3 + R1 reset the world's assumptions about who can afford to build frontier AI. The moat, it turned out, was partly an engineering culture.
The reasoning sequel: DeepSeek-R1. The MoE foundations: Mixture of Experts. The trillion-parameter descendant: Kimi K2.
How DeepSeek-V3 was built and trained, step by step
The technical report is a stack of mostly independent choices. In the order a token, and the training run, meets them:
- Prepare 14.8T tokens. A corpus richer in math and code than DeepSeek-V2's, with more languages beyond English and Chinese, tokenized with a byte-level BPE of 128K entries. About 10% of documents are rearranged for fill-in-the-middle training, prefix and suffix first and the middle to predict, which teaches code infilling without hurting ordinary next-token prediction.
- Stack 61 layers. The hidden size is 7,168. Attention is multi-head latent attention with 128 heads of size 128: keys and values are cached as a 512-dimensional latent plus a 64-dimensional decoupled key that carries rotary position information, and queries are compressed too, to 1,536 dimensions, to save activation memory in training.
- Make the feed-forward layers MoE. Every feed-forward layer except the first three has 1 shared expert and 256 routed experts, each with an intermediate size of 2,048. A token uses the shared expert plus 8 routed ones. That yields 671B parameters in total and about 37B per token.
- Route with sigmoid affinities and a bias. Each expert's affinity is a sigmoid of the token's dot product with that expert's centroid. A per-expert bias is added only when choosing the top 8; the gate weights that scale the chosen experts' outputs use the unbiased affinities, normalized over the 8. After each step an overloaded expert's bias falls by γ and an underloaded one's rises by γ, with γ = 0.001 for most of training and 0 for the last 500B tokens. A sequence-level balance loss with a tiny weight, 0.0001, guards against extreme imbalance inside a single sequence.
- Limit each token to four nodes. The routed experts are spread over 8 nodes. For each token, nodes are ranked by the sum of the highest affinities among the experts they hold, and its 8 experts are picked only from the top 4 nodes, which caps the cross-node traffic each token creates. With balance maintained this way, no tokens are dropped in training or at inference.
- Add one multi-token prediction module. Beside the main next-token loss, a sequential module predicts the token after next. It combines the main model's final hidden state at position i with the embedding of token i+1, passes them through one Transformer block, and predicts token i+2 through the shared output head. Its loss is weighted 0.3 for the first 10T tokens and 0.1 after that.
- Train in FP8 with fine-grained scaling. Most matrix multiplies take FP8 (E4M3) inputs, with one scale factor per 1×128 tile of activations and per 128×128 block of weights, and partial sums are promoted to FP32 every 128 elements. The embedding, output head, gating, normalization and attention stay in BF16 or FP32, as do master weights and optimizer states.
- Parallelize without tensor parallelism. On 2,048 H800 GPUs: 16-way pipeline parallelism with the DualPipe schedule, which overlaps the computation of paired micro-batches with their all-to-all and pipeline communication; 64-way expert parallelism across 8 nodes; and ZeRO-1 data parallelism.
- Optimize. AdamW with β1 0.9, β2 0.95 and weight decay 0.1, on 4K-token sequences. The learning rate warms to 2.2 × 10^−4 over 2K steps, holds until 10T tokens, then decays on a cosine; the batch ramps from 3,072 to 15,360 sequences over the first 469B tokens.
- Extend context, then post-train. Two YaRN stages stretch the context from 4K to 32K and then to 128K. Post-training is supervised fine-tuning on 1.5M examples, with reasoning data distilled from internal DeepSeek-R1 models and other data written by DeepSeek-V2.5 and checked by people, followed by reinforcement learning with GRPO, using rule-based rewards where an answer can be checked and a reward model elsewhere.
Bias-adjusted routing and the multi-token prediction loss
ut— token t's input to the MoE layer;ei— expert i's centroid;σ— the sigmoid, so each affinity is computed independently rather than competing in a softmax.bi— the balancing bias. It decides which experts are chosen and never how much they count, and it moves by ±γ after each step according to observed load, not by gradient.Kr = 8routed experts; their normalized weights sum to 1, and the shared expert FFN^(s) is always added at full weight.λ— the MTP weight, 0.3 and then 0.1;LMTP^k— cross-entropy for predicting the token k+1 positions ahead at depth k.
At the extremes: with γ = 0 the biases freeze and routing follows affinity alone, and a very large γ would let load chase content out of the routing decision. With λ = 0, training reduces to ordinary next-token prediction. Because the bias never touches the gate weights, the language-modeling gradient is the same whether balance is good or bad.
What the V3 report measured
The base model is compared with leading open models, including Qwen2.5 72B and Llama-3.1 405B; the chat model also with GPT-4o and Claude-3.5-Sonnet. Ablations were run on smaller MoE baselines, not on V3 itself.
| Chat-model benchmark | DeepSeek-V3 |
|---|---|
| MMLU | 88.5 |
| MMLU-Pro | 75.9 |
| GPQA-Diamond | 59.1 |
| MATH-500 | 90.2 |
| AIME 2024 | 39.2 |
| SWE-bench Verified | 42.0 |
V3 was the strongest open model on most of these at release. Against the closed models it led clearly on the math benchmarks, MATH-500 and AIME 2024, and trailed Claude-3.5-Sonnet on SWE-bench Verified and GPQA-Diamond.
| Ablation or measurement | Finding |
|---|---|
| Bias-based balancing against an auxiliary loss, at two model scales | Better on most benchmarks, with experts more clearly specialized by domain |
| Multi-token prediction on against off, at two scales | Better on most benchmarks, at no inference cost when the module is dropped |
| FP8 against BF16 training, about 1T tokens at two scales | Relative loss difference stays below 0.25% |
| MTP module reused for speculative decoding | 85–90% of second tokens accepted, about 1.8× tokens per second |
| Stability of the full 14.8T-token run | No irrecoverable loss spikes and no rollbacks |
The report also states its limits. The recommended unit for deploying V3 efficiently is large, a real burden for small teams, and generation speed still has room to improve. A comparison of batch-level and sequence-level balancing found similar loss, with batch-level balance risking imbalance within small batches and under domain shift at inference. And its cost figure covers only the final training run, not the research, ablations and failed runs that found the recipe.
What is claimed, what is contested, and what happened next
The cost figure is the contested part, and the contest is about scope rather than honesty. It refers to the final training run priced at a market rate for GPU hours. It does not include the research that found the recipe, the failed runs, the ablations, the data pipeline, the salaries, or the capital cost of owning the cluster. The report is reasonably clear about what it is measuring; a great deal of the commentary that followed was not, and treated it as the total cost of producing a frontier model. Both the number and its scope are worth carrying, because the pair is the actual lesson.
What is not seriously disputed is that the efficiency work is real and that the resulting model was competitive with far more expensively-trained ones — which is a statement about how much headroom remained in training efficiency, and therefore about how much of prior spending was buying capability versus paying for inexperience.
How it held up: the two mechanisms were adopted quickly. Loss-free load balancing is a clean improvement with no obvious downside, and latent compression of the key-value cache addressed the constraint every serving operator actually feels — the same constraint paged attention attacks from the memory-management side rather than the representation side. Its largest effect was on expectations: after this report, a frontier-class result from a mid-sized budget stopped being assumed impossible.
Weigh the KV cache: MHA vs GQA vs MLA
MLA's whole win is bytes, and bytes are countable. This computes the KV-cache size per token for standard multi-head attention, grouped-query attention, and DeepSeek-V3's latent attention — then scales it to a 128k-token context. Watch a cache that would need ~477 GB under vanilla attention shrink to ~8 GB under MLA, a 57× cut that's exactly why the model serves long contexts cheaply. Change the head count, latent size, or context length.
Write the body of total_gb. Everything else in the file is
already written; this is the function the paper is about. Press ▶ Run to check it against
the 5 assertions below — they start red.
- MHA caches K and V for every head
- GQA shrinks the cache by the head-sharing ratio
- MLA caches only a small latent, far smaller than MHA
- MLA beats even GQA
- The total cache scales linearly with context length
Questions people ask about DeepSeek-V3
How does DeepSeek-V3's multi-token prediction work?
DeepSeek-V3 adds one sequential prediction module on top of the main model. For each position i, the module takes the main model's final hidden state at i and the embedding of the true next token, i+1, normalizes each with RMSNorm, concatenates them, projects back to the model width, runs one Transformer block, and predicts token i+2 through the output head. The embedding table and output head are shared with the main model, so the module adds only its block and projection. Its cross-entropy loss is added with a weight of 0.3 for the first 10 trillion tokens and 0.1 afterward. Each prediction builds on the previous depth's representation, so the causal chain is kept, unlike designs that predict several future tokens from independent heads.
How did DeepSeek-V3 train in FP8 without diverging?
Three choices did most of the work. First, fine-grained scaling: instead of one scale factor per tensor, activations get a scale per 1×128 tile and weights per 128×128 block, so a single outlier only distorts its own small group. Second, higher-precision accumulation: the GPU's FP8 matrix units accumulate with limited precision, so partial sums are copied to FP32 registers every 128 elements. Third, selective precision: the embedding, output head, router, normalization and attention stay in BF16 or FP32, as do the master weights and optimizer states. Checked against BF16 on models trained for about a trillion tokens, the loss difference stayed below 0.25%, and the full run had no irrecoverable loss spikes.
Does DeepSeek-V3 drop tokens like the Switch Transformer?
No. Switch-style models give each expert a fixed buffer and skip any token that overflows it, while DeepSeek-V3 drops no tokens during training or inference. It can afford to because its routing stays well balanced: a per-expert bias, adjusted after every step, steers tokens away from overloaded experts, and node-limited routing bounds how much traffic any token can send across the network. For inference, the report describes deploying redundant copies of heavily loaded experts to keep the load even across GPUs. Without dropping, every token gets the full computation of its chosen experts, regardless of what else happened to be in the batch.
What is node-limited routing in DeepSeek-V3?
The 256 routed experts in each MoE layer are spread across 8 nodes, and moving tokens between nodes over InfiniBand is much slower than moving them within a node over NVLink. So each token may use experts on at most 4 nodes. For each token, the router scores each node by adding up the highest affinities among the experts that node holds, picks the 4 best nodes, and chooses its 8 experts only from those. That bounds the cross-node traffic per token, which is what lets the DualPipe schedule hide communication behind computation. DeepSeek-V2 used a similar device-limited routing scheme before it.
How was DeepSeek-V3 post-trained?
In two stages, after pre-training and context extension. Supervised fine-tuning used about 1.5 million examples. Reasoning examples in math, code and logic were generated by internal DeepSeek-R1 models and filtered to keep R1's accuracy while avoiding its tendency toward overthinking and excessive length; other examples, such as creative writing and simple question answering, were written by DeepSeek-V2.5 and verified by people. Reinforcement learning then used Group Relative Policy Optimization, which scores a group of sampled answers against each other instead of training a separate value model, with rule-based rewards where answers can be checked, such as math with a final answer or code with tests, and a learned reward model elsewhere.
4 questions to test what you just read
Work each one out before you open it — a number, a prediction or a reason, not a definition. Producing the answer is what makes it stick. Your progress is kept on this device.
What fraction of DeepSeek-V3's parameters runs for each token, and what fraction of its routed experts?
Show answer
37 / 671 ≈ 5.5% of parameters. Routed experts: 8 / 256 ≈ 3.1%, plus the always-on shared expert. Attention and the three dense layers run for every token, which is why the parameter fraction is above the expert fraction.
Pre-training cost about 180K H800 GPU-hours per trillion tokens. How many GPU-hours is 14.8T tokens, and how many days on 2,048 GPUs?
Show answer
180K × 14.8 ≈ 2.66M GPU-hours, the report's 2.664M. Divided by 2,048 GPUs and 24 hours, that is about 54 days, consistent with pre-training finishing in under two months.
Expert 17 is overloaded, so its bias drops by 0.001. Does the weight on its output change for tokens that still pick it?
Show answer
No. The bias enters only the top-8 selection; the gate weight uses the raw sigmoid affinity, normalized over the chosen experts. The correction changes which tokens reach expert 17, not how much its output counts, so the language-modeling gradient is untouched.
If the MTP module's draft token is accepted 85–90% of the time, about how many tokens does each decoding step produce?
Show answer
Each step yields the main token plus the draft when it is accepted: 1 + 0.85 to 1 + 0.90 ≈ 1.85–1.9 tokens per step. The cost of verifying drafts brings the measured gain to about 1.8× tokens per second.
One model, many experts
Sparsity: route each token to a few experts and buy parameter count without paying for it at inference. 2017 idea, 2026 frontier default.
- 1Mixture of Experts2017
- 2Switch Transformer2022
- 3DeepSeek-V32024
- 4DeepSeek-V42026
- 5Qwen4-Coder2026
Explore the topic
See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.
More Paper Breakdowns
- Attention Is All You NeedThe paper that introduced the Transformer — the architecture underneath GPT, BERT, Claude, and Gemini. Self-attention, Query/Key/Value, multi-head attention, positional encoding, and the real BLEU results, explained in depth with analogies and animated visuals, not just equations.Read →
- BERTThe paper that made "pre-train once, fine-tune anywhere" the default for NLP. Bidirectional context, masked language modeling, next-sentence prediction, the [CLS]/[SEP] tokens, and the GLUE sweep — explained with analogies, not just equations.Read →
- Chain-of-Thought PromptingShow a model a few worked examples with their reasoning and it starts solving problems it used to fail. Why reasoning emerges only at scale, the GSM8K jump, zero-shot "Let's think step by step", and how CoT seeded modern reasoning models.Read →
- LoRAThe paper that made fine-tuning affordable. Freeze the giant pretrained model and train two tiny low-rank matrices instead — up to 10,000x fewer trainable parameters, no extra inference latency, and swappable per-task adapters. The road to QLoRA and PEFT.Read →
- Direct Preference OptimizationRLHF without the RL. Align a model to human preference pairs with one simple classification-style loss — no separate reward model, no unstable reinforcement learning. Why "your LM is secretly a reward model", and how DPO became the default alignment method.Read →
- ChinchillaThe compute-optimal scaling law that said models were too big. Parameters and training tokens should scale together — ~20 tokens per parameter — so a 70B model trained on 1.4T tokens beat the 280B giants. Why every model since trains on trillions of tokens.Read →