<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Deepseek-V3 on lo0 — Tech Blog</title><link>https://blog.lo0.es/en/tags/deepseek-v3/</link><description>Recent content in Deepseek-V3 on lo0 — Tech Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Sat, 30 May 2026 08:00:00 +0200</lastBuildDate><atom:link href="https://blog.lo0.es/en/tags/deepseek-v3/index.xml" rel="self" type="application/rss+xml"/><item><title>MoE inference: the call centre with 256 specialists and 8 taking each call — fundamentals, expert parallel and the economics of DeepSeek-V3</title><link>https://blog.lo0.es/en/posts/moe-inference-fundamentals-expert-parallel-deepseek-economics/</link><pubDate>Sat, 30 May 2026 08:00:00 +0200</pubDate><guid>https://blog.lo0.es/en/posts/moe-inference-fundamentals-expert-parallel-deepseek-economics/</guid><description>&lt;blockquote>
&lt;p>This post goes into an architectural decision in the Deploy stage of the &lt;a href="https://blog.lo0.es/en/posts/six-stage-llmops-pipeline-architecture-and-deep-dive/">six-stage LLMOps pipeline&lt;/a>. It complements those on &lt;a href="https://blog.lo0.es/en/posts/kv-cache-working-memory-llm-inference/">KV cache&lt;/a> (which does not change with MoE), &lt;a href="https://blog.lo0.es/en/posts/flashattention-librarian-io-awareness-async-blackwell-asymmetry/">FlashAttention&lt;/a> (still the attention kernel, also dense in every current MoE), &lt;a href="https://blog.lo0.es/en/posts/quantization-llm-inference-fp8-int4-gguf/">Quantization&lt;/a> (FP8/NVFP4 over expert weights is what lets DeepSeek-V3 fit into a modest cluster) and &lt;a href="https://blog.lo0.es/en/posts/speculative-decoding-fundamentals-maths-state-of-play/">Speculative decoding&lt;/a> (MTP in DeepSeek-V3 is native speculative decoding).&lt;/p>
&lt;/blockquote>
&lt;h2 id="you-are-here-deploy">You are here: DEPLOY&lt;/h2>
&lt;div class="diagram" style="max-width:780px;margin:1rem auto;">
&lt;svg viewBox="0 0 780 90" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="you are here: Deploy">
&lt;style>.box{stroke:#444;stroke-width:1.4;rx:6}.active{fill:#7ad88f;stroke-width:3}.idle{fill:#f4f4f4}.lbl{font:600 12px sans-serif;fill:#222}.arr{stroke:#666;stroke-width:1.4;fill:none;marker-end:url(#moem)}.cyc{stroke:#888;stroke-width:1.2;fill:none;stroke-dasharray:4 2;marker-end:url(#moem)}&lt;/style>
&lt;defs>&lt;marker id="moem" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto">&lt;path d="M0,0 L10,5 L0,10 z" fill="#666"/>&lt;/marker>&lt;/defs>
&lt;text x="390" y="20" text-anchor="middle" class="lbl">You are here: DEPLOY · compute sparsity without memory sparsity&lt;/text>
&lt;rect x="30" y="35" width="110" height="35" class="box idle"/>&lt;text x="85" y="58" text-anchor="middle" class="lbl">1 · Data&lt;/text>
&lt;rect x="155" y="35" width="110" height="35" class="box idle"/>&lt;text x="210" y="58" text-anchor="middle" class="lbl">2 · Tune&lt;/text>
&lt;rect x="280" y="35" width="110" height="35" class="box idle"/>&lt;text x="335" y="58" text-anchor="middle" class="lbl">3 · Eval&lt;/text>
&lt;rect x="405" y="35" width="110" height="35" class="box active"/>&lt;text x="460" y="58" text-anchor="middle" class="lbl">4 · Deploy&lt;/text>
&lt;rect x="530" y="35" width="110" height="35" class="box idle"/>&lt;text x="585" y="58" text-anchor="middle" class="lbl">5 · Observe&lt;/text>
&lt;rect x="655" y="35" width="110" height="35" class="box idle"/>&lt;text x="710" y="58" text-anchor="middle" class="lbl">6 · Retrain&lt;/text>
&lt;path class="arr" d="M140,52 L155,52"/>&lt;path class="arr" d="M265,52 L280,52"/>&lt;path class="arr" d="M390,52 L405,52"/>&lt;path class="arr" d="M515,52 L530,52"/>&lt;path class="arr" d="M640,52 L655,52"/>
&lt;path class="cyc" d="M710,72 L710,82 L85,82 L85,72"/>
&lt;/svg>
&lt;/div>
&lt;h2 id="tldr">TL;DR&lt;/h2>
&lt;p>A Mixture of Experts (MoE) replaces the transformer&amp;rsquo;s dense FFN layer with &lt;strong>N parallel experts plus a router&lt;/strong> that picks the &lt;code>k&lt;/code> experts relevant to each token. The operational consequence is that the model&amp;rsquo;s &lt;strong>total&lt;/strong> parameters (how many were trained and how many must be loaded into VRAM) decouple from the &lt;strong>active parameters per token&lt;/strong> (how many take part in each forward). DeepSeek-V3 has 671 B total but only 37 B active per token; Qwen3-235B-A22B is 235 B total and 22 B active; Mixtral 8x22B is 141 B and 39 B; Llama 4 Maverick is 400 B and 17 B. Compute per token falls to &lt;code>2·N_active&lt;/code> FLOPs, half that of a dense Llama-3-70B in DeepSeek-V3&amp;rsquo;s case, but memory stays proportional to &lt;code>N_total&lt;/code>: MoE &lt;em>sparsity&lt;/em> is &lt;strong>compute sparsity, not memory sparsity&lt;/strong>. Since each expert sees only &lt;code>batch·k/N&lt;/code> tokens per step, the memory-bound regime persists at a much higher batch than in dense. Serving DeepSeek-V3 671 B FP8 at low latency requires &lt;strong>expert parallel&lt;/strong> (EP) at scale, EP=32 in prefill and EP=144 in decode in DeepSeek&amp;rsquo;s production deployment, where the dominant bottleneck stops being HBM and becomes the &lt;strong>all-to-all of dispatch and combine&lt;/strong> between GPUs. As of May 2026, the pieces that make this viable are &lt;strong>DeepEP&lt;/strong> (FP8-native all-to-all CUDA kernels, intra-node NVLink plus inter-node RDMA), &lt;strong>EPLB&lt;/strong> (balancing by replicating &lt;em>hot&lt;/em> experts) and &lt;strong>Wide-EP&lt;/strong> on NVL72 (72 GPUs in one coherent NVLink domain). This post takes apart the mechanism, the maths (FLOPs/token, all-to-all bytes), the updated table of MoE models as of May 2026, the parallelisms (TP / EP / DP+EP / Wide-EP), the operational pitfalls (memory wall, cold experts, imbalance) and the real reproducible numbers on H100, B200 and GB200 NVL72.&lt;/p>
&lt;h2 id="the-analogy-the-call-centre-with-256-specialists">The analogy: the call centre with 256 specialists&lt;/h2>
&lt;p>A serious call centre handling complex technical queries runs on &lt;strong>specialists&lt;/strong>, not generalists. You have 256 operators on the payroll, each an expert in their sub-domain: employment law, mortgages, income tax, probate, and so on. But each incoming call only needs the attention of &lt;strong>eight&lt;/strong> specific specialists (top-8 routing): a client&amp;rsquo;s query about tax relief on a mortgage for an inherited second home involves the income tax person, the mortgage person, the capital gains person, and so on. The receptionist (the router) listens to the first second of the call, decides which eight specialists are relevant, conferences them in and combines their answers with weights.&lt;/p>
&lt;p>Three immediate consequences, identical to those of MoE in production:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>You pay 256 salaries&lt;/strong> (every expert is loaded in VRAM) but you only &lt;strong>spend the time of 8&lt;/strong> (only k experts take part in the forward of each token). Your payroll cost scales with &lt;code>N_total&lt;/code>; your cost per minute of call scales with &lt;code>N_active&lt;/code>.&lt;/li>
&lt;li>&lt;strong>If all the operators fit in one office&lt;/strong> (a single GPU), fine: paper just moves between desks. But &lt;strong>if they do not fit&lt;/strong>, you have to open branches: the conference call between operators in different branches goes over a telephone line between buildings (intra-node NVLink, inter-node InfiniBand) and that line &lt;strong>becomes the dominant bottleneck&lt;/strong> once dozens of branches are coordinating.&lt;/li>
&lt;li>&lt;strong>If one week every client asks about income tax&lt;/strong>, the three income tax operators saturate while the probate ones sit idle. You need &lt;strong>a system that replicates the hot operators&lt;/strong> across several branches to absorb peaks, and that &lt;strong>pairs hot with cold&lt;/strong> so that no branch goes idle.&lt;/li>
&lt;/ol>
&lt;p>The receptionist is the &lt;strong>router&lt;/strong>. The branches are the GPUs. The conference call between branches is the &lt;strong>all-to-all&lt;/strong> (dispatch plus combine). The system for replicating hot operators is &lt;strong>EPLB&lt;/strong>. The good telephone line is &lt;strong>DeepEP&lt;/strong>. And when someone designs a building where all 72 branches fit together with very fast internal cabling, that is &lt;strong>NVL72&lt;/strong>.&lt;/p>
&lt;h2 id="the-bare-mechanism">The bare mechanism&lt;/h2>
&lt;p>A classic MoE layer replaces the dense FFN (&lt;code>y = FFN(x) = down(act(up(x) · gate(x)))&lt;/code> in SwiGLU) with:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Router&lt;/strong>: a linear projection &lt;code>g(x) = W_router · x&lt;/code> produces &lt;code>N&lt;/code> scores. A softmax over those scores gives affinity probabilities.&lt;/li>
&lt;li>&lt;strong>Top-k selection&lt;/strong>: the &lt;code>k&lt;/code> experts with the highest score are chosen. Their &lt;code>softmax_topk&lt;/code> weights are normalised to sum to 1.&lt;/li>
&lt;li>&lt;strong>Parallel compute&lt;/strong>: each of the &lt;code>k&lt;/code> selected experts runs its own FFN over &lt;code>x&lt;/code>. The &lt;code>N - k&lt;/code> not selected sit idle for this token.&lt;/li>
&lt;li>&lt;strong>Weighted combination&lt;/strong>: the output is &lt;code>y = Σ_{i ∈ topk} w_i · Expert_i(x)&lt;/code>.&lt;/li>
&lt;/ol>
&lt;p>Variants the market consolidated in 2025-2026:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Shared experts&lt;/strong>: on top of the &lt;code>k&lt;/code> routed ones, there are &lt;code>s&lt;/code> experts that always run (1 or 2). They capture general knowledge every token needs. DeepSeek-V3 uses 1 shared + 8 routed; Mixtral uses 0 shared.&lt;/li>
&lt;li>&lt;strong>Fine-grained experts&lt;/strong>: more small experts instead of a few large ones (DeepSeek: 256 vs Mixtral: 8). This allows better specialisation because the top-k combination covers more sub-domains.&lt;/li>
&lt;li>&lt;strong>Auxiliary-loss-free routing&lt;/strong> (DeepSeek-V3): instead of adding a balancing loss during training, it dynamically adjusts a bias in the routing. It keeps balance without polluting the main loss.&lt;/li>
&lt;/ul>
&lt;p>Attention is still &lt;strong>dense&lt;/strong> in every current MoE model (Mixtral, DeepSeek, Qwen3-MoE, Llama 4, Kimi K2). Only the FFN is replaced. That is why FlashAttention v3/v4 is still used as-is; DeepSeek&amp;rsquo;s MLA is an optimisation orthogonal to MoE.&lt;/p>
&lt;h2 id="the-relevant-moe-models-in-may-2026">The relevant MoE models in May 2026&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Model&lt;/th>
&lt;th>Date&lt;/th>
&lt;th>Total&lt;/th>
&lt;th>Active&lt;/th>
&lt;th>Experts&lt;/th>
&lt;th>Top-k&lt;/th>
&lt;th>Shared&lt;/th>
&lt;th>Notes&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Mixtral 8x7B&lt;/td>
&lt;td>Dec 2023&lt;/td>
&lt;td>47 B&lt;/td>
&lt;td>13 B&lt;/td>
&lt;td>8&lt;/td>
&lt;td>2&lt;/td>
&lt;td>0&lt;/td>
&lt;td>The one that normalised MoE in open weights&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Mixtral 8x22B&lt;/td>
&lt;td>Apr 2024&lt;/td>
&lt;td>141 B&lt;/td>
&lt;td>39 B&lt;/td>
&lt;td>8&lt;/td>
&lt;td>2&lt;/td>
&lt;td>0&lt;/td>
&lt;td>—&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Grok-1 (open)&lt;/td>
&lt;td>Mar 2024&lt;/td>
&lt;td>314 B&lt;/td>
&lt;td>~86 B&lt;/td>
&lt;td>8&lt;/td>
&lt;td>2&lt;/td>
&lt;td>0&lt;/td>
&lt;td>Weights opened by xAI&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>DeepSeekMoE 16B&lt;/td>
&lt;td>Jan 2024&lt;/td>
&lt;td>16 B&lt;/td>
&lt;td>2.8 B&lt;/td>
&lt;td>64+2&lt;/td>
&lt;td>6&lt;/td>
&lt;td>2&lt;/td>
&lt;td>Introduces fine-grained + shared&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>DeepSeek-V2&lt;/td>
&lt;td>May 2024&lt;/td>
&lt;td>236 B&lt;/td>
&lt;td>21 B&lt;/td>
&lt;td>160+2&lt;/td>
&lt;td>6&lt;/td>
&lt;td>2&lt;/td>
&lt;td>+ MLA&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Snowflake Arctic&lt;/td>
&lt;td>Apr 2024&lt;/td>
&lt;td>480 B&lt;/td>
&lt;td>17 B&lt;/td>
&lt;td>128&lt;/td>
&lt;td>2&lt;/td>
&lt;td>10 B dense residual&lt;/td>
&lt;td>Dense-MoE hybrid&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Hunyuan-Large&lt;/td>
&lt;td>Nov 2024&lt;/td>
&lt;td>389 B&lt;/td>
&lt;td>52 B&lt;/td>
&lt;td>16+1&lt;/td>
&lt;td>1+shared&lt;/td>
&lt;td>1&lt;/td>
&lt;td>Cross-layer KV cache&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>DeepSeek-V3&lt;/strong>&lt;/td>
&lt;td>Dec 2024&lt;/td>
&lt;td>671 B&lt;/td>
&lt;td>37 B&lt;/td>
&lt;td>256+1&lt;/td>
&lt;td>8&lt;/td>
&lt;td>1&lt;/td>
&lt;td>MLA + MTP, aux-loss-free, FP8 training&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Llama 4 Scout&lt;/td>
&lt;td>Apr 2025&lt;/td>
&lt;td>109 B&lt;/td>
&lt;td>17 B&lt;/td>
&lt;td>16&lt;/td>
&lt;td>1+shared&lt;/td>
&lt;td>1&lt;/td>
&lt;td>Designed for 1 H100 node&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Llama 4 Maverick&lt;/td>
&lt;td>Apr 2025&lt;/td>
&lt;td>400 B&lt;/td>
&lt;td>17 B&lt;/td>
&lt;td>128&lt;/td>
&lt;td>1+shared&lt;/td>
&lt;td>1&lt;/td>
&lt;td>—&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Qwen3-235B-A22B&lt;/td>
&lt;td>Apr 2025&lt;/td>
&lt;td>235 B&lt;/td>
&lt;td>22 B&lt;/td>
&lt;td>128&lt;/td>
&lt;td>8&lt;/td>
&lt;td>0&lt;/td>
&lt;td>—&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Kimi K2 (Moonshot)&lt;/td>
&lt;td>2025&lt;/td>
&lt;td>1 T&lt;/td>
&lt;td>32 B&lt;/td>
&lt;td>384&lt;/td>
&lt;td>8&lt;/td>
&lt;td>(MLA)&lt;/td>
&lt;td>Trained with MuonClip&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>DeepSeek-V3.2-Exp&lt;/td>
&lt;td>Sep 2025&lt;/td>
&lt;td>671 B&lt;/td>
&lt;td>37 B&lt;/td>
&lt;td>256+1&lt;/td>
&lt;td>8&lt;/td>
&lt;td>1&lt;/td>
&lt;td>+ DeepSeek Sparse Attention&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Three operational observations:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>The active/total ratio falls with every generation&lt;/strong>: Mixtral 8x7B was 28 %, DeepSeek-V3 is 5.5 %, Llama 4 Maverick is 4.3 %. What the industry discovered is that &lt;strong>sparsity can be very aggressive without losing quality&lt;/strong>, provided &lt;code>N&lt;/code> is large enough and the routing is well learned. Fine specialisation is worth more than per-expert capacity.&lt;/li>
&lt;li>&lt;strong>The flagships of the large providers (OpenAI, Anthropic, Google) are almost certainly MoE&lt;/strong>, but the architectures are not published. The only semi-credible leak (Hotz, Jul 2023) claimed GPT-4 was an 8×~220 B MoE; no official confirmation.&lt;/li>
&lt;li>&lt;strong>DeepSeek-V3 marks the inflection point&lt;/strong>: open weights, frontier-class, MoE with aggressive sparsity and compatible with FP8 quantisation. It is the model that forced the ecosystem (vLLM, SGLang, TensorRT-LLM) to optimise wide-EP in 2025.&lt;/li>
&lt;/ol>
&lt;h2 id="the-maths-that-matters">The maths that matters&lt;/h2>
&lt;p>Three numbers drive the whole architectural decision with MoE.&lt;/p>
&lt;p>&lt;strong>Compute per token.&lt;/strong> A dense transformer spends roughly &lt;code>2N&lt;/code> FLOPs per token in the forward pass (with &lt;code>N&lt;/code> = total parameters). A MoE spends &lt;code>2·N_active&lt;/code> FLOPs per token (the &lt;code>N_total - N_active&lt;/code> experts do not take part). For DeepSeek-V3: 2 × 37 B = &lt;strong>74 GFLOPs/token&lt;/strong>. For dense Llama-3-70B: 2 × 70 B = &lt;strong>140 GFLOPs/token&lt;/strong>. &lt;strong>DeepSeek does half the compute per token&lt;/strong> of Llama-3-70B while offering capacity equivalent to a model almost 10 × larger.&lt;/p>
&lt;p>&lt;strong>Total memory.&lt;/strong> But &lt;strong>all&lt;/strong> the experts must be loaded in VRAM at some point in the forward pass. The sparsity is in compute, not memory. Weight memory:&lt;/p>
$$\text{Memory}_{\text{weights}} \approx N_{\text{total}} \cdot \text{bytes per param}$$
&lt;p>For DeepSeek-V3 FP8 (1 byte): 685 GB. It does not fit in 8×H100 SXM (640 GB). You need either extra quantisation or 16+ GPUs. For Mixtral 8x22B FP8: 141 GB, comfortably inside 2×H100. For Qwen3-235B-A22B FP8: 235 GB, fits in 4×H100.&lt;/p>
&lt;p>&lt;strong>All-to-all bytes per MoE layer.&lt;/strong> When experts are spread across GPUs (EP), each token has to travel to the GPUs where its &lt;code>k&lt;/code> experts live. The volume per MoE layer is roughly:&lt;/p>
$$\text{bytes a2a/layer} \approx 2 \cdot \text{batch} \cdot \text{seq len} \cdot d_{\text{model}} \cdot k \cdot \text{bytes}$$
&lt;p>(the factor 2 is dispatch plus combine). For DeepSeek-V3 with &lt;code>d_model = 7168&lt;/code>, &lt;code>k = 8&lt;/code>, &lt;code>batch = 4096&lt;/code>, FP8 (1 byte): each MoE layer moves ~470 MB; multiplied by 61 MoE layers in DeepSeek-V3, the complete step adds &lt;strong>~29 GB of inter-GPU traffic&lt;/strong> in MoE comms alone. That is of the order of a GPU&amp;rsquo;s HBM bandwidth in a single step. This is why bandwidth and NVLink/InfiniBand topology determine how large EP can be before comms saturate.&lt;/p>
&lt;p>&lt;strong>Persistent memory-bound regime.&lt;/strong> Here is the least intuitive consequence. In dense, raising the batch moves the operation from memory-bound to compute-bound: with enough tokens per batch, the weights are amortised over more operations. In MoE, each expert sees only &lt;code>batch · k / N&lt;/code> tokens. For Qwen3-235B (k=8, N=128) with batch=128, each expert processes &lt;strong>8 tokens per step&lt;/strong>. To reach the compute-bound regime of the tensor cores (arithmetic intensity ~100-200 FLOPs/byte) you need batches in the &lt;strong>thousands&lt;/strong>, around 1,600 according to recent estimates for Qwen3 (Memory-Bound MoE Serving, arXiv:2512.09277). The operational consequence: &lt;strong>MoE scales throughput with batch more linearly than dense&lt;/strong>, but it also needs far larger batches to get close to its compute ceiling.&lt;/p>
&lt;h2 id="expert-parallel-and-the-all-to-all-bottleneck">Expert parallel and the all-to-all bottleneck&lt;/h2>
&lt;p>There are three main ways to parallelise a MoE across GPUs:&lt;/p>
&lt;p>&lt;strong>Tensor Parallel (TP, Megatron-style).&lt;/strong> Splits each weight matrix across GPUs by width or height. Every GPU processes all tokens and all layers. Comms per layer: 2 all-reduces. It works well for dense; for MoE it leaves the routing sparsity unexploited (each GPU holds fragments of every expert).&lt;/p>
&lt;p>&lt;strong>Expert Parallel (EP).&lt;/strong> Splits &lt;strong>whole experts&lt;/strong> across GPUs: 256 experts / 32 GPUs = 8 experts per GPU. Each token, after routing, travels to the GPUs where its top-k &lt;code>k&lt;/code> experts live. Comms per MoE layer: an &lt;strong>all-to-all dispatch&lt;/strong> (tokens towards experts) plus an &lt;strong>all-to-all combine&lt;/strong> (outputs back). The cost grows with EP size and becomes the bottleneck when EP &amp;gt; 8.&lt;/p>
&lt;p>&lt;strong>DP + EP / Wide-EP.&lt;/strong> Replicates the model across DP groups; inside each group, EP shards the experts. &lt;strong>Wide-EP&lt;/strong> takes EP to the full dimension of a rack (NVL72, 72 GPUs in a coherent NVLink domain). Each expert receives more tokens per step, so arithmetic intensity in each expert&amp;rsquo;s GEMMs improves and per-GPU throughput rises. vLLM reports &lt;strong>1.8× throughput per GPU with wide-EP&lt;/strong> against smaller setups on DeepSeek-V3 (vLLM blog, Dec 2025).&lt;/p>
&lt;div class="diagram" style="max-width:780px;margin:1.5rem auto;">
&lt;svg viewBox="0 0 780 380" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Expert Parallel with all-to-all dispatch and combine">
&lt;style>
.gpu{fill:#eaf3ff;stroke:#1f5fa8;stroke-width:1.4;rx:8}
.exp{fill:#fff4d6;stroke:#a48000;stroke-width:1.2;rx:4}
.tok{fill:#cdebd0;stroke:#2a7a40;stroke-width:1.2;rx:4}
.router{fill:#e6d0ff;stroke:#5a2db0;stroke-width:1.4;rx:6}
.lbl{font:600 12px sans-serif;fill:#222}
.sub{font:400 10px sans-serif;fill:#555}
.disp{stroke:#cc6622;stroke-width:1.5;fill:none;marker-end:url(#mma)}
.comb{stroke:#226699;stroke-width:1.5;fill:none;stroke-dasharray:4 2;marker-end:url(#mma)}
&lt;/style>
&lt;defs>&lt;marker id="mma" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto">&lt;path d="M0,0 L10,5 L0,10 z" fill="#444"/>&lt;/marker>&lt;/defs>
&lt;text x="20" y="22" class="lbl">MoE layer with Expert Parallel: EP=4 (4 GPUs, 8 experts/GPU)&lt;/text>
&lt;rect x="20" y="40" width="170" height="60" class="router"/>
&lt;text x="105" y="62" text-anchor="middle" class="lbl">Router (W_router)&lt;/text>
&lt;text x="105" y="78" text-anchor="middle" class="sub">softmax → top-k=2&lt;/text>
&lt;text x="105" y="92" text-anchor="middle" class="sub">per token&lt;/text>
&lt;rect x="20" y="115" width="80" height="35" class="tok"/>&lt;text x="60" y="138" text-anchor="middle" class="lbl">tokens&lt;/text>
&lt;text x="220" y="60" class="sub">all-to-all dispatch (FP8)&lt;/text>
&lt;path class="disp" d="M195,75 L300,160"/>
&lt;path class="disp" d="M195,80 L450,160"/>
&lt;path class="disp" d="M195,85 L600,160"/>
&lt;path class="disp" d="M195,90 L720,160"/>
&lt;rect x="240" y="160" width="120" height="120" class="gpu"/>
&lt;text x="300" y="178" text-anchor="middle" class="lbl">GPU 0&lt;/text>
&lt;rect x="252" y="190" width="42" height="20" class="exp"/>&lt;text x="273" y="204" text-anchor="middle" class="sub">E0&lt;/text>
&lt;rect x="296" y="190" width="42" height="20" class="exp"/>&lt;text x="317" y="204" text-anchor="middle" class="sub">E1&lt;/text>
&lt;rect x="252" y="215" width="42" height="20" class="exp"/>&lt;text x="273" y="229" text-anchor="middle" class="sub">E2&lt;/text>
&lt;rect x="296" y="215" width="42" height="20" class="exp"/>&lt;text x="317" y="229" text-anchor="middle" class="sub">E3&lt;/text>
&lt;text x="300" y="255" text-anchor="middle" class="sub">experts 0-7&lt;/text>
&lt;text x="300" y="270" text-anchor="middle" class="sub">(8 experts)&lt;/text>
&lt;rect x="390" y="160" width="120" height="120" class="gpu"/>
&lt;text x="450" y="178" text-anchor="middle" class="lbl">GPU 1&lt;/text>
&lt;rect x="402" y="190" width="42" height="20" class="exp"/>&lt;text x="423" y="204" text-anchor="middle" class="sub">E8&lt;/text>
&lt;rect x="446" y="190" width="42" height="20" class="exp"/>&lt;text x="467" y="204" text-anchor="middle" class="sub">E9&lt;/text>
&lt;text x="450" y="255" text-anchor="middle" class="sub">experts 8-15&lt;/text>
&lt;rect x="540" y="160" width="120" height="120" class="gpu"/>
&lt;text x="600" y="178" text-anchor="middle" class="lbl">GPU 2&lt;/text>
&lt;rect x="552" y="190" width="42" height="20" class="exp"/>&lt;text x="573" y="204" text-anchor="middle" class="sub">E16&lt;/text>
&lt;rect x="596" y="190" width="42" height="20" class="exp"/>&lt;text x="617" y="204" text-anchor="middle" class="sub">E17&lt;/text>
&lt;text x="600" y="255" text-anchor="middle" class="sub">experts 16-23&lt;/text>
&lt;rect x="660" y="160" width="100" height="120" class="gpu"/>
&lt;text x="710" y="178" text-anchor="middle" class="lbl">GPU 3&lt;/text>
&lt;rect x="668" y="190" width="42" height="20" class="exp"/>&lt;text x="689" y="204" text-anchor="middle" class="sub">E24&lt;/text>
&lt;rect x="712" y="190" width="42" height="20" class="exp"/>&lt;text x="733" y="204" text-anchor="middle" class="sub">E25&lt;/text>
&lt;text x="710" y="255" text-anchor="middle" class="sub">experts 24-31&lt;/text>
&lt;text x="220" y="310" class="sub">all-to-all combine (weighted sum returns to the origin)&lt;/text>
&lt;path class="comb" d="M300,280 L195,330"/>
&lt;path class="comb" d="M450,280 L195,330"/>
&lt;path class="comb" d="M600,280 L195,330"/>
&lt;path class="comb" d="M710,280 L195,330"/>
&lt;rect x="100" y="325" width="200" height="35" class="tok"/>
&lt;text x="200" y="346" text-anchor="middle" class="lbl">y = Σ w_i · Expert_i(x)&lt;/text>
&lt;/svg>
&lt;/div>
&lt;p>Quick decision table:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Case&lt;/th>
&lt;th>Recommendation&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Small MoE that fits in 1 node (Mixtral 8x7B, Llama 4 Scout)&lt;/td>
&lt;td>TP only or EP=2 intra-node&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Medium MoE (Mixtral 8x22B, Qwen3-235B) on 1-2 H100 nodes&lt;/td>
&lt;td>EP=8 intra-node, optionally TP=2&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Large MoE (DeepSeek-V3) on a multi-node cluster&lt;/td>
&lt;td>TP × EP cross-node (e.g. TP=4 × EP=8 on 32 GPUs)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Large MoE with NVL72 available&lt;/td>
&lt;td>Wide-EP=72 (decode), EP=32 (prefill)&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>DeepSeek&amp;rsquo;s production deployment combines &lt;strong>Prefill EP=32&lt;/strong> (4 nodes × 8 GPUs) with &lt;strong>Decode EP=144&lt;/strong> (18 nodes × 8 GPUs). The prefill/decode split fits conceptually with &lt;a href="https://blog.lo0.es/en/posts/disaggregated-serving-prefill-decode-specialised-pods/">Disaggregated serving&lt;/a>: prefill is compute-bound and benefits from moderate EP; decode is memory-bound and benefits from Wide-EP, which raises the tokens per expert per step.&lt;/p>
&lt;h2 id="deepep-eplb-and-wide-ep-the-pieces-that-unblocked-2025">DeepEP, EPLB and Wide-EP: the pieces that unblocked 2025&lt;/h2>
&lt;p>&lt;strong>DeepEP&lt;/strong> (DeepSeek, opened in February 2025) is a library of all-to-all CUDA kernels optimised specifically for MoE EP. Four important properties:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Native FP8 dispatch&lt;/strong>: tokens travel in FP8, halving the bandwidth consumed.&lt;/li>
&lt;li>&lt;strong>Mixing intra-node NVLink with inter-node RDMA&lt;/strong>: the kernel picks the optimal route according to topology.&lt;/li>
&lt;li>&lt;strong>CPU bypass&lt;/strong>: the GPU→GPU dispatch goes over RDMA without touching the host.&lt;/li>
&lt;li>&lt;strong>Aligned with DeepSeek-V3&amp;rsquo;s group-limited gating&lt;/strong>: the routing prefers experts in the same node group where possible, minimising inter-node traffic.&lt;/li>
&lt;/ul>
&lt;p>In 2025 Tencent contributed optimisations that added +30 % on the normal kernels. There is a ROCm port for AMD.&lt;/p>
&lt;p>&lt;strong>EPLB (Expert Parallelism Load Balancer)&lt;/strong> solves the runtime imbalance problem: even when the model is well balanced in global distribution, &lt;strong>a specific batch can heavily activate certain experts&lt;/strong> (prompts in a single language, a single domain). EPLB &lt;strong>replicates the hot experts&lt;/strong> across several GPUs (redundant experts) and packs them heuristically with cold experts to minimise load variance. It has two modes: hierarchical (for prefill with medium EP) and global (for decode with Wide-EP). It is integrated into SGLang and vLLM.&lt;/p>
&lt;p>&lt;strong>Wide-EP on NVL72&lt;/strong> is the peak setup of 2026: 72 Blackwell GPUs in a coherent NVLink domain (1.8 TB/s bidirectional per GPU, intra-rack). Each expert receives many more tokens per step, so arithmetic intensity improves and so does throughput per GPU. Combined with NVFP4 over expert weights and FP8 over attention, SGLang reported on GB200 NVL72 &lt;strong>26,156 tok/s/GPU in prefill and 13,386 tok/s/GPU in decode&lt;/strong> for DeepSeek-V3 (LMSYS, Sep 2025), a &lt;strong>3.8× prefill and 4.8× decode versus H100&lt;/strong>.&lt;/p>
&lt;h2 id="operational-pitfalls">Operational pitfalls&lt;/h2>
&lt;p>&lt;strong>HBM fragmentation from expert weights.&lt;/strong> With EP=8 in 1 node, each GPU holds N/8 experts, each a tuple of matrices (&lt;code>gate&lt;/code>, &lt;code>up&lt;/code>, &lt;code>down&lt;/code>). If N=256, that is 32 FFNs per GPU. The allocator can fragment; in some cases you need a more conservative &lt;code>--gpu-memory-utilization&lt;/code> than usual.&lt;/p>
&lt;p>&lt;strong>Cold experts.&lt;/strong> In real distributions some experts are activated by &amp;lt;1 % of tokens. EPLB compensates by replicating hot ones, but the cold ones sit occupying HBM without taking part, &amp;ldquo;dead&amp;rdquo; memory. When real demand diverges a lot from the training distribution, this shows.&lt;/p>
&lt;p>&lt;strong>Continuous batching.&lt;/strong> It works with MoE, but the effective batch size per expert is &lt;code>batch_total · k / N&lt;/code>. With large N and a moderate batch, each expert sees very few tokens per step. You need a &lt;code>batch_total&lt;/code> far larger than in dense to match per-GPU throughput.&lt;/p>
&lt;p>&lt;strong>Speculative decoding + MoE.&lt;/strong> They interact &lt;strong>well&lt;/strong>. MoE sparsity keeps the memory-bound regime at high batch, which is exactly the regime where speculative decoding wins most. DeepSeek-V3 integrates &lt;strong>MTP&lt;/strong> (Multi-Token Prediction), speculative decoding native to the model, with no external draft, with acceptance around 85-90 % on the second token (see &lt;a href="https://blog.lo0.es/en/posts/speculative-decoding-fundamentals-maths-state-of-play/">Speculative decoding&lt;/a> for the mechanism).&lt;/p>
&lt;p>&lt;strong>MLA and FlashMLA are not MoE.&lt;/strong> DeepSeek-V3 combines MoE with &lt;strong>Multi-head Latent Attention&lt;/strong> (MLA), an attention variant that reduces the KV cache ~10× against standard MHA. MLA and MoE are orthogonal: MLA optimises attention, MoE optimises the FFN. For serving DeepSeek you use the specific &lt;strong>FlashMLA&lt;/strong> kernel (not FA3 directly).&lt;/p>
&lt;p>&lt;strong>DSA (DeepSeek Sparse Attention)&lt;/strong> in DeepSeek-V3.2-Exp (Sep 2025) introduces sparsity in attention too. The first time at the frontier that sparsity is applied in both attention and FFN.&lt;/p>
&lt;h2 id="implications-for-on-premise-hardware">Implications for on-premise hardware&lt;/h2>
&lt;p>&lt;strong>On an RTX 4090 (24 GB).&lt;/strong> Large MoEs are out of reach. What does fit: Mixtral 8x7B AWQ-INT4 (~24 GB of weights, no headroom for KV cache, so it really requires TP=2 across two 4090s); DeepSeekMoE 16B BF16 (~33 GB, does not fit whole; INT4 ~8 GB, fits with room to spare). The interesting case is &lt;strong>llama.cpp with &lt;code>--n-cpu-moe&lt;/code>&lt;/strong>: expert weights offloaded to RAM (CPU), attention and shared experts on the GPU. It lets you run DeepSeek-V3 IQ4 (~400 GB) on a workstation with 1-2 GPUs plus 512 GB of RAM at modest throughput, but it opens the door to a low-budget setup.&lt;/p>
&lt;p>&lt;strong>On a generic 4×H100 SXM cluster (320 GB, NVLink, native FP8).&lt;/strong> These fit comfortably:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Mixtral 8x22B FP8&lt;/strong> (~141 GB) with TP=2 or EP=4. Low latency, excellent throughput.&lt;/li>
&lt;li>&lt;strong>Qwen3-235B-A22B FP8&lt;/strong> (~235 GB) with TP=4 or EP=4. Plenty of room.&lt;/li>
&lt;li>&lt;strong>Llama 4 Scout 109B FP8&lt;/strong> (~110 GB) with TP=2 or TP=4. Designed by Meta to serve well on one H100 node.&lt;/li>
&lt;/ul>
&lt;p>What does &lt;strong>not&lt;/strong> fit in 4×H100: DeepSeek-V3 FP8 (~685 GB) without aggressive quantisation. Options: (1) scale to 8-16 H100; (2) use AWQ INT4 over routed experts plus FP16 over activated ones (~400 GB), which fits in 8×H100; (3) wait for Blackwell or use AMD MI300X (192 GB/GPU, so DeepSeek-V3 FP8 on 4×MI300X).&lt;/p>
&lt;p>The rule of thumb as of May 2026: &lt;strong>one 4×H100 node comfortably serves MoEs up to ~200 B total in FP8; for DeepSeek-V3 you have to scale to 2 nodes or wait for B200 NVL72&lt;/strong> (where the whole model fits with room for enormous batches).&lt;/p>
&lt;h2 id="what-we-have-not-covered">What we have not covered&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>MLA and FlashMLA in detail&lt;/strong>: DeepSeek&amp;rsquo;s KV cache optimisation, orthogonal to MoE.&lt;/li>
&lt;li>&lt;strong>DeepSeek Sparse Attention (DSA)&lt;/strong> introduced in V3.2-Exp: the first production implementation of attention sparsity for frontier models.&lt;/li>
&lt;li>&lt;strong>MoE during training&lt;/strong>: load balancing losses, drop policies, auxiliary terms vs aux-loss-free, Kimi K2&amp;rsquo;s MuonClip.&lt;/li>
&lt;li>&lt;strong>MoE + LoRA&lt;/strong>: how adapter fine-tuning is done on a MoE, and what happens to the routing.&lt;/li>
&lt;li>&lt;strong>LLM-d&lt;/strong> and other open-source platforms that materialise Wide-EP on Kubernetes.&lt;/li>
&lt;/ul>
&lt;h2 id="see-also">See also&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/kv-cache-working-memory-llm-inference/">KV cache: working memory&lt;/a> — structurally the KV cache is the same as in dense (attention is dense in every current MoE); MLA is the specific optimisation DeepSeek adds on top.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/pagedattention-vllm-block-manager/">PagedAttention deep dive&lt;/a> — handling the KV cache in physical blocks stays identical under MoE; only the FFN changes.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/flashattention-librarian-io-awareness-async-blackwell-asymmetry/">FlashAttention v1/v2/v3/v4&lt;/a> — the attention kernel is reused as-is; FlashMLA is the variant specific to DeepSeek&amp;rsquo;s MLA, adding a latent compression step to the FA pattern.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/quantization-llm-inference-fp8-int4-gguf/">Quantization for LLM inference&lt;/a> — FP8/NVFP4 over expert weights is what makes DeepSeek-V3 fit into a modest cluster and what lets NVL72 reach its peak numbers.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/speculative-decoding-fundamentals-maths-state-of-play/">Speculative decoding&lt;/a> — MTP in DeepSeek-V3 is native speculative decoding; MoE&amp;rsquo;s persistent memory-bound regime means speculative wins more in MoE than in dense at medium batch.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/disaggregated-serving-prefill-decode-specialised-pods/">Disaggregated serving: prefill and decode&lt;/a> — DeepSeek&amp;rsquo;s real deployment separates prefill (EP=32) and decode (EP=144) pools; disaggregation is a prerequisite for Wide-EP.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/continuous-batching-orca-vllm-chunked-prefill-goodput/">Continuous batching&lt;/a> — the other side of the coin. MoE needs far larger batches than dense for the same per-GPU throughput because each expert sees &lt;code>batch · k / N&lt;/code> tokens per step; the iterative scheduler is what makes it viable at scale.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/six-stage-llmops-pipeline-architecture-and-deep-dive/">The six-stage LLMOps pipeline&lt;/a> — the master map where Deploy is stage 4.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/capacity-planning-on-premise-llm-inference/">Capacity planning for on-premise LLM inference&lt;/a> — MoE sizing differs from dense: the &amp;ldquo;MoE case&amp;rdquo; section there quantifies the VRAM cost dominated by total weights and the TPOT dominated by active weights per token.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/device-native-architectures-fine-grained-moe-pre-attention-router/">Device-native architectures: fine-grained MoE and pre-attention router&lt;/a> — MoE taken to the fine-grained extreme and designed from scratch for device: the pre-attention router prefetches experts from SSD in parallel with attention, hiding the storage I/O.&lt;/li>
&lt;/ul>
&lt;h2 id="references">References&lt;/h2>
&lt;ul>
&lt;li>Shazeer, N. et al. &lt;em>Outrageously Large Neural Networks: The Sparsely-Gated Mixture-of-Experts Layer&lt;/em>. ICLR 2017. &lt;a href="https://arxiv.org/abs/1701.06538">https://arxiv.org/abs/1701.06538&lt;/a>&lt;/li>
&lt;li>Lepikhin, D. et al. &lt;em>GShard: Scaling Giant Models with Conditional Computation&lt;/em>. ICLR 2021. &lt;a href="https://arxiv.org/abs/2006.16668">https://arxiv.org/abs/2006.16668&lt;/a>&lt;/li>
&lt;li>Fedus, W., Zoph, B., Shazeer, N. &lt;em>Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient Sparsity&lt;/em>. JMLR 2022. &lt;a href="https://arxiv.org/abs/2101.03961">https://arxiv.org/abs/2101.03961&lt;/a>&lt;/li>
&lt;li>Gale, T., Narayanan, D., Young, C., Zaharia, M. &lt;em>MegaBlocks: Efficient Sparse Training with Mixture-of-Experts&lt;/em>. MLSys 2023. &lt;a href="https://arxiv.org/abs/2211.15841">https://arxiv.org/abs/2211.15841&lt;/a>&lt;/li>
&lt;li>Mistral AI. &lt;em>Mixtral of Experts&lt;/em>. 2024. &lt;a href="https://arxiv.org/abs/2401.04088">https://arxiv.org/abs/2401.04088&lt;/a>&lt;/li>
&lt;li>DeepSeek-AI. &lt;em>DeepSeekMoE: Towards Ultimate Expert Specialization in Mixture-of-Experts Language Models&lt;/em>. 2024. &lt;a href="https://arxiv.org/abs/2401.06066">https://arxiv.org/abs/2401.06066&lt;/a>&lt;/li>
&lt;li>DeepSeek-AI. &lt;em>DeepSeek-V2&lt;/em>. 2024. &lt;a href="https://arxiv.org/abs/2405.04434">https://arxiv.org/abs/2405.04434&lt;/a>&lt;/li>
&lt;li>DeepSeek-AI. &lt;em>DeepSeek-V3 Technical Report&lt;/em>. 2024. &lt;a href="https://arxiv.org/abs/2412.19437">https://arxiv.org/abs/2412.19437&lt;/a>&lt;/li>
&lt;li>Tencent. &lt;em>Hunyuan-Large&lt;/em>. 2024. &lt;a href="https://arxiv.org/abs/2411.02265">https://arxiv.org/abs/2411.02265&lt;/a>&lt;/li>
&lt;li>DeepEP repo: &lt;a href="https://github.com/deepseek-ai/DeepEP">https://github.com/deepseek-ai/DeepEP&lt;/a>&lt;/li>
&lt;li>EPLB repo: &lt;a href="https://github.com/deepseek-ai/EPLB">https://github.com/deepseek-ai/EPLB&lt;/a>&lt;/li>
&lt;li>DeepSeek open-infra-index, &lt;em>V3/R1 Inference System Overview&lt;/em>: &lt;a href="https://github.com/deepseek-ai/open-infra-index">https://github.com/deepseek-ai/open-infra-index&lt;/a>&lt;/li>
&lt;li>vLLM blog, &lt;em>Large-Scale Serving DeepSeek&lt;/em> (Dec 2025): &lt;a href="https://blog.vllm.ai/2025/12/17/large-scale-serving.html">https://blog.vllm.ai/2025/12/17/large-scale-serving.html&lt;/a>&lt;/li>
&lt;li>vLLM blog, &lt;em>WideEP en GB200&lt;/em> (Feb 2026): &lt;a href="https://blog.vllm.ai/2026/02/03/dsr1-gb200-part1.html">https://blog.vllm.ai/2026/02/03/dsr1-gb200-part1.html&lt;/a>&lt;/li>
&lt;li>LMSYS blog, &lt;em>DeepSeek 96 H100 PD+EP&lt;/em> (May 2025): &lt;a href="https://www.lmsys.org/blog/2025-05-05-large-scale-ep/">https://www.lmsys.org/blog/2025-05-05-large-scale-ep/&lt;/a>&lt;/li>
&lt;li>LMSYS blog, &lt;em>DeepSeek GB200 NVL72 part II&lt;/em> (Sep 2025): &lt;a href="https://www.lmsys.org/blog/2025-09-25-gb200-part-2/">https://www.lmsys.org/blog/2025-09-25-gb200-part-2/&lt;/a>&lt;/li>
&lt;li>NVIDIA Dynamo + GB200 NVL72 for MoE: &lt;a href="https://developer.nvidia.com/blog/how-nvidia-gb200-nvl72-and-nvidia-dynamo-boost-inference-performance-for-moe-models/">https://developer.nvidia.com/blog/how-nvidia-gb200-nvl72-and-nvidia-dynamo-boost-inference-performance-for-moe-models/&lt;/a>&lt;/li>
&lt;li>Tensor Economics, &lt;em>MoE Inference Economics from First Principles&lt;/em>: &lt;a href="https://www.tensoreconomics.com/p/moe-inference-economics-from-first">https://www.tensoreconomics.com/p/moe-inference-economics-from-first&lt;/a>&lt;/li>
&lt;li>Cohere, &lt;em>Why MoE models get more from speculative decoding&lt;/em>: &lt;a href="https://cohere.com/blog/mixture-of-experts-models-get-more-from-speculative-decoding">https://cohere.com/blog/mixture-of-experts-models-get-more-from-speculative-decoding&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>Speculative decoding: the secretary who types ahead of the boss — fundamentals, maths and state of play in May 2026</title><link>https://blog.lo0.es/en/posts/speculative-decoding-fundamentals-maths-state-of-play/</link><pubDate>Fri, 29 May 2026 11:00:00 +0200</pubDate><guid>https://blog.lo0.es/en/posts/speculative-decoding-fundamentals-maths-state-of-play/</guid><description>&lt;blockquote>
&lt;p>This post complements &lt;a href="https://blog.lo0.es/en/posts/kv-cache-working-memory-llm-inference/">KV cache: the working memory&lt;/a> and &lt;a href="https://blog.lo0.es/en/posts/quantization-llm-inference-fp8-int4-gguf/">Quantisation for LLM inference&lt;/a>. Both are acceleration levers &lt;strong>inside a single forward pass&lt;/strong>. Speculative decoding is the complementary lever: instead of making each forward pass cheaper, it tries to &lt;strong>produce more tokens per forward pass&lt;/strong>. It is orthogonal to quantisation and to the KV cache, and it stacks multiplicatively with both.&lt;/p>
&lt;/blockquote>
&lt;h2 id="you-are-here-deploy">You are here: DEPLOY&lt;/h2>
&lt;div class="diagram" style="max-width:780px;margin:1rem auto;">
&lt;svg viewBox="0 0 780 90" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="you are here: Deploy">
&lt;style>.box{stroke:#444;stroke-width:1.4;rx:6}.active{fill:#7ad88f;stroke-width:3}.idle{fill:#f4f4f4}.lbl{font:600 12px sans-serif;fill:#222}.arr{stroke:#666;stroke-width:1.4;fill:none;marker-end:url(#spm)}.cyc{stroke:#888;stroke-width:1.2;fill:none;stroke-dasharray:4 2;marker-end:url(#spm)}&lt;/style>
&lt;defs>&lt;marker id="spm" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto">&lt;path d="M0,0 L10,5 L0,10 z" fill="#666"/>&lt;/marker>&lt;/defs>
&lt;text x="390" y="20" text-anchor="middle" class="lbl">You are here: DEPLOY · more tokens per forward pass without touching quality&lt;/text>
&lt;rect x="30" y="35" width="110" height="35" class="box idle"/>&lt;text x="85" y="58" text-anchor="middle" class="lbl">1 · Data&lt;/text>
&lt;rect x="155" y="35" width="110" height="35" class="box idle"/>&lt;text x="210" y="58" text-anchor="middle" class="lbl">2 · Tune&lt;/text>
&lt;rect x="280" y="35" width="110" height="35" class="box idle"/>&lt;text x="335" y="58" text-anchor="middle" class="lbl">3 · Eval&lt;/text>
&lt;rect x="405" y="35" width="110" height="35" class="box active"/>&lt;text x="460" y="58" text-anchor="middle" class="lbl">4 · Deploy&lt;/text>
&lt;rect x="530" y="35" width="110" height="35" class="box idle"/>&lt;text x="585" y="58" text-anchor="middle" class="lbl">5 · Observe&lt;/text>
&lt;rect x="655" y="35" width="110" height="35" class="box idle"/>&lt;text x="710" y="58" text-anchor="middle" class="lbl">6 · Retrain&lt;/text>
&lt;path class="arr" d="M140,52 L155,52"/>&lt;path class="arr" d="M265,52 L280,52"/>&lt;path class="arr" d="M390,52 L405,52"/>&lt;path class="arr" d="M515,52 L530,52"/>&lt;path class="arr" d="M640,52 L655,52"/>
&lt;path class="cyc" d="M710,72 L710,82 L85,82 L85,72"/>
&lt;/svg>
&lt;/div>
&lt;h2 id="tldr">TL;DR&lt;/h2>
&lt;p>Autoregressive LLM inference has a structural problem: every new token needs a complete forward pass of the model, and decode forward passes are memory-bandwidth-bound, not compute-bound (the detail is in &lt;a href="https://blog.lo0.es/en/posts/kv-cache-working-memory-llm-inference/">KV cache&lt;/a>). The GPU spends most of its time waiting for the next weight to arrive from HBM. &lt;strong>Speculative decoding&lt;/strong> uses that dead time by doing two things in parallel: a small, cheap model (&lt;em>draft&lt;/em>) generates γ tokens autoregressively, fast but imprecise, and the large model (&lt;em>target&lt;/em>) verifies those γ tokens &lt;strong>in a single parallel forward pass&lt;/strong>, at almost the same cost as a single-token forward pass. An acceptance rule based on rejection sampling decides how many draft tokens are accepted, and the maths proves, it does not approximate, it proves, that the output distribution matches sampling directly from the target exactly. The technique has a ceiling: you never generate more than &lt;code>1/(1-α)&lt;/code> tokens per step, with α the acceptance rate. The five dominant families in May 2026 are &lt;strong>vanilla SD&lt;/strong> (Leviathan 2023), &lt;strong>Medusa&lt;/strong> (extra parallel heads), &lt;strong>EAGLE-1/2/3&lt;/strong> (a draft that operates at the level of hidden states), &lt;strong>MTP&lt;/strong> (multi-token prediction native to DeepSeek-V3) and &lt;strong>P-EAGLE&lt;/strong> (a draft that produces the γ tokens in a single forward pass, integrated in vLLM 0.16+). On low-concurrency workloads with short prompts and long outputs, the typical case of the on-premise conversational assistant, the real speedup sits between 2× and 4× on modern hardware.&lt;/p>
&lt;h2 id="the-analogy-the-secretary-who-types-ahead-and-the-boss-who-validates">The analogy: the secretary who types ahead and the boss who validates&lt;/h2>
&lt;p>Picture a crowded press conference with a real-time transcription setup. Two people are working:&lt;/p>
&lt;p>The &lt;strong>secretary&lt;/strong> sits at the keyboard. They know the subject, they have read the briefings and they know the boss&amp;rsquo;s verbal tics. As soon as the boss opens their mouth, the secretary starts typing what they think is coming. They are fast, three or four words ahead of the boss, but they sometimes get it wrong, especially when the boss takes an unexpected turn.&lt;/p>
&lt;p>The &lt;strong>boss&lt;/strong> periodically reads the secretary&amp;rsquo;s screen. They read a whole block at once, three or four words, and mentally compare what is written with what they would have said. If it matches their intent, they leave the text and carry on. If the secretary drifted at some point, they correct right there, and whatever the secretary typed after the divergence is discarded (it could be wrong because of the earlier error). If the whole block was fine, the boss takes the chance to add one more word while correcting.&lt;/p>
&lt;p>The result: the final text is identical to what the boss would have dictated alone, but it comes out faster because the secretary works ahead.&lt;/p>
&lt;p>The analogy holds on four details:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>The secretary is the draft model&lt;/strong>. Small, cheap, fast, approximate.&lt;/li>
&lt;li>&lt;strong>The boss is the target model&lt;/strong>. Slow, expensive, but the only authority on output quality.&lt;/li>
&lt;li>&lt;strong>The block the boss reads at once is the target&amp;rsquo;s parallel forward pass&lt;/strong> over &lt;code>prompt + γ draft tokens&lt;/code>. Verifying γ tokens costs almost the same as generating one, because the bottleneck is loading the weights from HBM, not the operations.&lt;/li>
&lt;li>&lt;strong>The &amp;ldquo;correct right where it diverged&amp;rdquo; rule is the rejection sampling&lt;/strong> that preserves the target distribution.&lt;/li>
&lt;/ul>
&lt;p>From here we go into the mechanism and into why quality is preserved exactly, not approximately.&lt;/p>
&lt;h2 id="the-bare-mechanism">The bare mechanism&lt;/h2>
&lt;p>Call &lt;code>p&lt;/code> the target distribution (what it would produce if it were the only one speaking) and &lt;code>q&lt;/code> the draft&amp;rsquo;s. The speculative decoding iteration has three steps:&lt;/p>
&lt;p>&lt;strong>Step 1 — Draft.&lt;/strong> The draft generates γ tokens autoregressively: &lt;code>x_1, x_2, ..., x_γ&lt;/code>. Each one through its own forward pass. Since the draft is small, the γ steps cost little. Typically γ ∈ [4, 8].&lt;/p>
&lt;p>&lt;strong>Step 2 — Verify.&lt;/strong> The target runs a single forward pass over the complete sequence &lt;code>prompt + x_1 ... x_γ&lt;/code>. Because attention is causal, that forward pass simultaneously produces the distributions &lt;code>p(·|prompt, x_&amp;lt;i)&lt;/code> for each position &lt;em>i&lt;/em>. In other words, in a single step it obtains the verification of the γ tokens and, on top of that, an extra distribution &lt;code>p(·|prompt, x_1...x_γ)&lt;/code> for the next token.&lt;/p>
&lt;p>&lt;strong>Step 3 — Accept/reject token by token.&lt;/strong> For each &lt;code>x_i&lt;/code> from left to right it applies:&lt;/p>
&lt;ul>
&lt;li>If &lt;code>p(x_i) ≥ q(x_i)&lt;/code>: always accept.&lt;/li>
&lt;li>If &lt;code>p(x_i) &amp;lt; q(x_i)&lt;/code>: accept with probability &lt;code>p(x_i)/q(x_i)&lt;/code>.&lt;/li>
&lt;li>If it rejects: stop, sample a replacement token from the normalised residual distribution &lt;code>norm(max(0, p − q))&lt;/code>, and discard the rest.&lt;/li>
&lt;li>If it reaches the end having accepted the γ tokens: append a &lt;strong>bonus token&lt;/strong> sampled directly from &lt;code>p(·|prompt, x_1...x_γ)&lt;/code>, which is already in the logits of the target&amp;rsquo;s forward pass.&lt;/li>
&lt;/ul>
&lt;p>Result per iteration: between 1 and γ+1 new tokens. In the best case (all accepted + bonus) γ+1 tokens are generated at the cost of &lt;strong>a single target forward pass plus γ draft forward passes&lt;/strong>, against γ+1 target forward passes in the version without speculative.&lt;/p>
&lt;div class="diagram" style="max-width:780px;margin:1.5rem auto;">
&lt;svg viewBox="0 0 780 340" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Speculative decoding mechanism">
&lt;style>
.dbox{fill:#fff4d6;stroke:#a48000;stroke-width:1.4;rx:6}
.tbox{fill:#d4ecff;stroke:#1f5fa8;stroke-width:1.4;rx:6}
.acc{fill:#cdebd0;stroke:#2a7a40;stroke-width:1.4;rx:6}
.rej{fill:#f6caca;stroke:#a52a2a;stroke-width:1.4;rx:6}
.bon{fill:#e6d0ff;stroke:#5a2db0;stroke-width:1.4;rx:6}
.lbl{font:600 12px sans-serif;fill:#222}
.sub{font:400 11px sans-serif;fill:#555}
.arr{stroke:#666;stroke-width:1.4;fill:none;marker-end:url(#spec1)}
&lt;/style>
&lt;defs>&lt;marker id="spec1" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto">&lt;path d="M0,0 L10,5 L0,10 z" fill="#666"/>&lt;/marker>&lt;/defs>
&lt;text x="20" y="25" class="lbl">1. Draft model (q) generates γ=4 tokens autoregressively&lt;/text>
&lt;rect x="20" y="35" width="80" height="35" class="dbox"/>&lt;text x="60" y="58" text-anchor="middle" class="lbl">x₁&lt;/text>
&lt;rect x="120" y="35" width="80" height="35" class="dbox"/>&lt;text x="160" y="58" text-anchor="middle" class="lbl">x₂&lt;/text>
&lt;rect x="220" y="35" width="80" height="35" class="dbox"/>&lt;text x="260" y="58" text-anchor="middle" class="lbl">x₃&lt;/text>
&lt;rect x="320" y="35" width="80" height="35" class="dbox"/>&lt;text x="360" y="58" text-anchor="middle" class="lbl">x₄&lt;/text>
&lt;text x="420" y="58" class="sub">4 cheap forward passes&lt;/text>
&lt;text x="20" y="105" class="lbl">2. Target model (p) verifies the 4 tokens in ONE parallel forward pass&lt;/text>
&lt;rect x="20" y="115" width="380" height="40" class="tbox"/>&lt;text x="210" y="140" text-anchor="middle" class="lbl">single forward pass over [prompt, x₁, x₂, x₃, x₄]&lt;/text>
&lt;text x="420" y="140" class="sub">obtains p(·|prompt, x&amp;lt;i) for i=1..5&lt;/text>
&lt;text x="20" y="180" class="lbl">3. Left-to-right rejection sampling&lt;/text>
&lt;rect x="20" y="190" width="80" height="35" class="acc"/>&lt;text x="60" y="208" text-anchor="middle" class="lbl">x₁ ✓&lt;/text>&lt;text x="60" y="221" text-anchor="middle" class="sub">p≥q&lt;/text>
&lt;rect x="120" y="190" width="80" height="35" class="acc"/>&lt;text x="160" y="208" text-anchor="middle" class="lbl">x₂ ✓&lt;/text>&lt;text x="160" y="221" text-anchor="middle" class="sub">accepted&lt;/text>
&lt;rect x="220" y="190" width="80" height="35" class="acc"/>&lt;text x="260" y="208" text-anchor="middle" class="lbl">x₃ ✓&lt;/text>&lt;text x="260" y="221" text-anchor="middle" class="sub">accepted&lt;/text>
&lt;rect x="320" y="190" width="80" height="35" class="rej"/>&lt;text x="360" y="208" text-anchor="middle" class="lbl">x₄ ✗&lt;/text>&lt;text x="360" y="221" text-anchor="middle" class="sub">rejected&lt;/text>
&lt;text x="20" y="255" class="lbl">4. Result of this iteration&lt;/text>
&lt;rect x="20" y="265" width="80" height="35" class="acc"/>&lt;text x="60" y="288" text-anchor="middle" class="lbl">x₁&lt;/text>
&lt;rect x="120" y="265" width="80" height="35" class="acc"/>&lt;text x="160" y="288" text-anchor="middle" class="lbl">x₂&lt;/text>
&lt;rect x="220" y="265" width="80" height="35" class="acc"/>&lt;text x="260" y="288" text-anchor="middle" class="lbl">x₃&lt;/text>
&lt;rect x="320" y="265" width="80" height="35" class="rej"/>&lt;text x="360" y="288" text-anchor="middle" class="lbl">x'₄&lt;/text>
&lt;text x="420" y="280" class="sub">x'₄ = sample from norm(max(0, p−q)) at pos 4&lt;/text>
&lt;text x="420" y="295" class="sub">bonus dropped (only if all accepted)&lt;/text>
&lt;text x="20" y="325" class="sub">→ 4 new tokens in a single target iteration. Without speculative it would be 4 iterations.&lt;/text>
&lt;/svg>
&lt;/div>
&lt;h2 id="why-quality-does-not-degrade-the-proof">Why quality does not degrade (the proof)&lt;/h2>
&lt;p>This is the part of the technique that confuses people most the first time. It looks like magic: how can sampling from an arbitrary draft and then &amp;ldquo;validating&amp;rdquo; produce exactly the same distribution as sampling from the original target?&lt;/p>
&lt;p>The proof fits in two lines. For any token &lt;code>x&lt;/code>, the final probability of emitting it is the sum of two disjoint events: the draft proposes it and it is accepted, or the draft proposes something else, it is rejected, and sampling from the residual yields &lt;code>x&lt;/code>. Formally:&lt;/p>
$$P(\text{emit } x) = q(x) \cdot \min\!\left(1, \frac{p(x)}{q(x)}\right) + P(\text{reject}) \cdot \frac{\max(0, p(x)-q(x))}{\sum_y \max(0, p(y)-q(y))}$$
&lt;p>The first term is &lt;code>min(p(x), q(x))&lt;/code>. The second is &lt;code>max(0, p(x) − q(x))&lt;/code> (the total rejected mass &lt;code>Σ max(0, p−q)&lt;/code> cancels the denominator exactly). Adding them: &lt;code>min(p(x), q(x)) + max(0, p(x) − q(x)) = p(x)&lt;/code>. The output is statistically indistinguishable from sampling directly from the target, down to floating-point numerical differences.&lt;/p>
&lt;p>This matters operationally: it means speculative decoding is not perceptual compression, it is not a quality-speed trade-off, it does not require extra validation with evals. If the target would have passed a given eval, the system with speculative passes it too.&lt;/p>
&lt;h2 id="the-maths-that-matters-ceiling-and-speedup">The maths that matters: ceiling and speedup&lt;/h2>
&lt;p>Call α the &lt;strong>acceptance rate&lt;/strong>: the expected probability that an individual draft token is accepted. Assuming that acceptances of consecutive tokens are independent (a reasonable approximation in practice), the expected number of tokens generated per iteration is:&lt;/p>
$$E[\text{tokens per step}] = \sum_{k=0}^{\gamma} \alpha^k + \alpha^{\gamma+1} = \frac{1 - \alpha^{\gamma+1}}{1 - \alpha}$$
&lt;p>And the &lt;strong>theoretical speedup&lt;/strong> relative to generating one token per target iteration, with &lt;code>c = T_draft / T_target&lt;/code> the relative cost of the draft, is:&lt;/p>
$$\text{Speedup} = \frac{1 - \alpha^{\gamma+1}}{(1 - \alpha)(\gamma c + 1)}$$
&lt;p>There is a ceiling that many implementations try to beat and cannot: as &lt;code>γ → ∞&lt;/code>, the speedup converges to:&lt;/p>
$$\lim_{\gamma \to \infty} E[\text{tokens per step}] = \frac{1}{1 - \alpha}$$
&lt;p>It is an algorithmic ceiling, not a hardware one. With α = 0.7 you never generate more than 3.33 tokens per iteration no matter how much the hardware improves. With α = 0.8 → 5. With α = 0.9 → 10. That is why EAGLE-3, which targets α &amp;gt; 0.8 on many benchmarks, is not an incremental improvement over vanilla SD (α ≈ 0.5-0.6): it is a change of regime, because it raises the ceiling instead of merely getting closer to it.&lt;/p>
&lt;p>A concrete numerical example, Llama 3 70B as target with a draft giving α = 0.75, γ = 5, c = 0.1:&lt;/p>
&lt;ul>
&lt;li>Expected tokens per step: &lt;code>(1 − 0.75⁶) / (1 − 0.75) = (1 − 0.178) / 0.25 = 3.29&lt;/code>&lt;/li>
&lt;li>Speedup: &lt;code>3.29 / (5 × 0.1 + 1) = 3.29 / 1.5 = 2.19×&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>If we raise α to 0.85 with the same configuration: tokens per step = &lt;code>(1 − 0.85⁶) / 0.15 = (1 − 0.377) / 0.15 = 4.16&lt;/code>, speedup = &lt;code>4.16 / 1.5 = 2.77×&lt;/code>. A change of α = 0.75 → 0.85 (10 absolute points) raises the speedup by 27 %. That is why the research of the last two years focuses on pushing α: that is where the prize is.&lt;/p>
&lt;h2 id="the-five-modern-families-may-2026">The five modern families (May 2026)&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Family&lt;/th>
&lt;th>Year&lt;/th>
&lt;th>Core idea&lt;/th>
&lt;th>Draft size&lt;/th>
&lt;th>Typical α / τ&lt;/th>
&lt;th>Speedup&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;strong>Vanilla SD&lt;/strong>&lt;/td>
&lt;td>2023&lt;/td>
&lt;td>Same-family target + draft pair, rejection sampling&lt;/td>
&lt;td>1/10 – 1/100 of target&lt;/td>
&lt;td>0.5 – 0.8&lt;/td>
&lt;td>2-3×&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Medusa&lt;/strong>&lt;/td>
&lt;td>2024&lt;/td>
&lt;td>N extra heads in parallel predict t+1, t+2, &amp;hellip;; tree attention verifies several candidates&lt;/td>
&lt;td>no draft, +1-2 % params&lt;/td>
&lt;td>top-5 &amp;gt; 0.8&lt;/td>
&lt;td>2.18-2.83×&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>EAGLE-1/2/3&lt;/strong>&lt;/td>
&lt;td>2024-25&lt;/td>
&lt;td>Autoregressive draft at the level of &lt;strong>features (hidden states)&lt;/strong>, not tokens. Reuses the target&amp;rsquo;s embedding&lt;/td>
&lt;td>1 transformer block (~0.5-2 % params)&lt;/td>
&lt;td>EAGLE-3: α &amp;gt; 0.8, τ up to 7.5&lt;/td>
&lt;td>up to 6.5× peak&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>MTP&lt;/strong> (DeepSeek-V3)&lt;/td>
&lt;td>2024&lt;/td>
&lt;td>Multi-token heads trained from scratch as part of the model; at inference they act as a &amp;ldquo;free&amp;rdquo; draft&lt;/td>
&lt;td>14B params in V3 671B&lt;/td>
&lt;td>α &amp;gt; 0.8 (MTP1)&lt;/td>
&lt;td>1.5-1.8×&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>P-EAGLE&lt;/strong>&lt;/td>
&lt;td>2026&lt;/td>
&lt;td>EAGLE but producing the γ drafts in &lt;strong>a single forward pass&lt;/strong> (parallel, not autoregressive)&lt;/td>
&lt;td>same as EAGLE&lt;/td>
&lt;td>+30 % over EAGLE-3&lt;/td>
&lt;td>4-5× vs AR&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Three operational observations:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>EAGLE dominates in production&lt;/strong> because its overhead is minimal (one transformer block, ~1 % of the target in parameters) and its α is high. The draft does not need its own &amp;ldquo;complete&amp;rdquo; KV cache because it shares features with the target.&lt;/li>
&lt;li>&lt;strong>Medusa mattered historically&lt;/strong>, it showed that speculative was possible without a separate draft, but EAGLE beat it on every published benchmark through 2024-2025.&lt;/li>
&lt;li>&lt;strong>MTP is special&lt;/strong>: it is not something you add to an existing model. It is something the model trained natively. If you buy DeepSeek-V3, MTP comes free and gives around 1.8× without touching anything. If you buy Llama 3, there is no MTP to be had; use EAGLE-3.&lt;/li>
&lt;/ol>
&lt;p>There are also two related techniques that deserve a brief mention, both without a draft model: &lt;strong>Lookahead decoding&lt;/strong> (Fu et al. 2024), which formulates decoding as Jacobi iteration and extracts n-grams from the trajectory; and &lt;strong>REST&lt;/strong> (He et al. 2024), which keeps an n-gram datastore and proposes drafts by longest-prefix match against the last generated tokens. Both give 1.5-2× with no extra VRAM. Useful when you have no trained draft model and do not want to maintain one.&lt;/p>
&lt;h2 id="real-implementations-in-may-2026">Real implementations in May 2026&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>vLLM v0.16+&lt;/strong>: unified support for EAGLE-1/2/3, P-EAGLE, Medusa, native MTP (DeepSeek-V3 and variants), n-gram/suffix decoding without a draft, an arbitrary draft model and MLP speculators. The canonical flag is &lt;code>--speculative-config '{&amp;quot;method&amp;quot;:&amp;quot;eagle3&amp;quot;, &amp;quot;model&amp;quot;:&amp;quot;...&amp;quot;, &amp;quot;num_speculative_tokens&amp;quot;: 5}'&lt;/code>.&lt;/li>
&lt;li>&lt;strong>SGLang&lt;/strong>: native EAGLE-3 support with &lt;code>--speculative-algorithm EAGLE3&lt;/code>. For DeepSeek-V3 it uses MTP through an EAGLE adapter. It has its own draft training framework (SpecForge).&lt;/li>
&lt;li>&lt;strong>TensorRT-LLM&lt;/strong>: Medusa, EAGLE (a simplified variant without a tree), ReDrafter, Lookahead. They report around 2.2× with EAGLE.&lt;/li>
&lt;li>&lt;strong>llama.cpp&lt;/strong>: basic speculative only with a draft model (&lt;code>--model-draft&lt;/code>). No native EAGLE/Medusa/MTP as far as I have verified. Typical speedup 1.5-2.5× single-user.&lt;/li>
&lt;/ul>
&lt;h2 id="when-speculative-does-not-help">When speculative does NOT help&lt;/h2>
&lt;p>The technique has three important blind spots:&lt;/p>
&lt;p>&lt;strong>Large batch.&lt;/strong> The GPU moves from memory-bound (decode at low concurrency) to compute-bound (decode at high concurrency). In the compute-bound regime the &amp;ldquo;almost free&amp;rdquo; target forward passes stop being free: γ tokens start costing γ times more instead of nearly 1. The typical crossover is at &lt;strong>batch 16-32 for dense models&lt;/strong>; for MoE with few active parameters per token the crossover happens later. At load peaks, speculative can worsen aggregate throughput per GPU.&lt;/p>
&lt;p>&lt;strong>Prefill / TTFT.&lt;/strong> Speculative decoding does not touch prefill. The phase that processes the whole prompt stays identical. TTFT does not improve and can get marginally worse because of the draft setup. If the SLA is TTFT-bound (assistants with short outputs, search, RAG with brief answers), this is not the right tool.&lt;/p>
&lt;p>&lt;strong>Short outputs.&lt;/strong> If the model generates 10-20 tokens and the answer is over, the fixed setup overhead is not amortised. Speculative shines with long outputs (300+ tokens): generative assistants, extended code completion, drafting.&lt;/p>
&lt;h2 id="operational-pitfalls">Operational pitfalls&lt;/h2>
&lt;p>&lt;strong>Extra VRAM for the draft.&lt;/strong> In vanilla SD, loading a complete draft plus its KV cache is expensive. Llama 3 8B in BF16 as the draft for a 70B is about 16 GB of weights plus KV cache. On an H100 80 GB with the target already nearly filling it, that can force you to shrink the target&amp;rsquo;s KV cache and lower maximum concurrency. EAGLE solves this: the draft is one transformer block (~1 GB for a 70B) and reuses the target&amp;rsquo;s features.&lt;/p>
&lt;p>&lt;strong>Draft quantisation.&lt;/strong> Quantising the draft to INT4 with GPTQ degrades α substantially (errors in the logits accumulate in the comparison against &lt;code>p&lt;/code>). AWQ holds up better but also lowers α. &lt;strong>Common practice in 2026: target in FP8 or INT4, draft in FP16/BF16&lt;/strong>. The draft is small enough that the VRAM saved by quantising it does not compensate for the drop in α and therefore in speedup. The detail of each format is in &lt;a href="https://blog.lo0.es/en/posts/quantization-llm-inference-fp8-int4-gguf/">Quantisation&lt;/a>.&lt;/p>
&lt;p>&lt;strong>Interaction with continuous batching.&lt;/strong> It does not break it, but it creates &lt;em>nested raggedness&lt;/em>: each request in the batch can accept a different number of tokens on each iteration. vLLM&amp;rsquo;s PagedAttention absorbs it, but the scheduler loses efficiency. At low QPS (conversational assistant, low simultaneous concurrency) the combination is excellent. At high QPS there is real tension, and work such as &lt;em>Goodput-optimized speculative decoding&lt;/em> (Liu et al., 2024) optimises γ dynamically according to the state of the batch.&lt;/p>
&lt;p>&lt;strong>Sampling temperature.&lt;/strong> α falls with high temperatures. At T = 1.0 with creative outputs (free-form writing), α can drop 10-15 points relative to T = 0 with the same model-draft pair. The speedup scales accordingly.&lt;/p>
&lt;h2 id="implications-on-on-premise-hardware">Implications on on-premise hardware&lt;/h2>
&lt;h3 id="on-an-rtx-4090-24-gb-ada-lovelace">On an RTX 4090 (24 GB, Ada Lovelace)&lt;/h3>
&lt;p>The classic use is &lt;strong>vanilla SD with two quantised models&lt;/strong>: for instance, Llama 3 70B AWQ-INT4 as target (~35 GB → needs TP=2 across two 4090s) and Llama 3 8B AWQ-INT4 as draft. In practice, the most realistic single-card case is &lt;strong>Llama 3 8B target + a 1B model as draft&lt;/strong> or &lt;strong>Qwen 3 14B target + Qwen 3 0.5B as draft&lt;/strong>: they fit comfortably and give 1.8-2.5× on conversational tasks. For EAGLE on consumer cards, the official drafts for popular families (Llama 3, Qwen 3) are published on Hugging Face and take up 0.5-2 GB extra.&lt;/p>
&lt;h3 id="on-a-generic-4h100-sxm-cluster-320-gb-nvlink-native-fp8">On a generic 4×H100 SXM cluster (320 GB, NVLink, native FP8)&lt;/h3>
&lt;p>Here EAGLE-3 shines:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Llama 3 70B FP8 + EAGLE-3 draft in FP16&lt;/strong>: the draft takes about 0.7 GB; the target about 70 GB with TP=2 (35 GB per GPU). The speedup observed in reproducible benchmarks is between 2.5× and 4× at batch 1-4, falling to almost break-even at batch 32.&lt;/li>
&lt;li>&lt;strong>DeepSeek-V3 671B FP8 + native MTP&lt;/strong>: the model ships with MTP trained in; there is nothing to add. The speedup is 1.5-1.8× with zero extra VRAM. It is the most efficient option operationally: zero additional pieces.&lt;/li>
&lt;li>&lt;strong>Combining with disaggregated serving&lt;/strong>: as &lt;a href="https://blog.lo0.es/en/posts/disaggregated-serving-prefill-decode-specialised-pods/">Disaggregated serving&lt;/a> explains, prefill and decode can live in separate pods. Speculative applies only in the decode pods, which fits the separation perfectly (prefill is compute-bound and would not benefit).&lt;/li>
&lt;/ul>
&lt;p>The rule of thumb on an H100 cluster in May 2026: &lt;strong>if the model is DeepSeek-V3 / V4 → native MTP, nothing else; if it is Llama 3 / Qwen 3 → EAGLE-3 with the official draft; if it is exotic → vanilla SD with a draft from the same family&lt;/strong>.&lt;/p>
&lt;h2 id="what-we-have-not-covered">What we have not covered&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>Training custom EAGLE drafts&lt;/strong> with SpecForge: how to collect target trajectories and train the draft on-policy.&lt;/li>
&lt;li>&lt;strong>Speculative Prefill&lt;/strong> (arXiv:2502.02789): a variant for accelerating TTFT, a different mechanism from the decode one described here.&lt;/li>
&lt;li>&lt;strong>Tree attention in detail&lt;/strong>: how Medusa and EAGLE-2 verify several candidates at once with specific attention masks.&lt;/li>
&lt;li>&lt;strong>MoE + speculative&lt;/strong>: the combination has non-trivial interactions with the expert router. Low activated params keep the memory-bound regime in place even at high batch, which changes the rules.&lt;/li>
&lt;/ul>
&lt;h2 id="see-also">See also&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/kv-cache-working-memory-llm-inference/">KV cache: the working memory that holds up LLM inference&lt;/a> — speculative would not exist without the memory-bound nature of decode, which is a direct consequence of the KV cache; that post gives the framework.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/pagedattention-vllm-block-manager/">PagedAttention deep dive&lt;/a> — vLLM&amp;rsquo;s scheduler has to manage the nested raggedness of the γ tokens accepted per request; PagedAttention is what makes that possible without reserving fixed blocks per session.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/quantization-llm-inference-fp8-int4-gguf/">Quantisation for LLM inference&lt;/a> — a lever orthogonal to and multiplicative with speculative; that post explains why the draft is usually left in BF16 even when the target is in FP8/INT4.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/disaggregated-serving-prefill-decode-specialised-pods/">Disaggregated serving: prefill and decode in specialised pods&lt;/a> — speculative applies only in decode; disaggregation makes that specialisation easy without touching prefill.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/moe-inference-fundamentals-expert-parallel-deepseek-economics/">MoE inference: the call centre with 256 specialists&lt;/a> — the persistent memory-bound regime of MoE means speculative gains more on MoE than on dense at medium batch. MTP in DeepSeek-V3 is speculative decoding native to the model (no external draft) with acceptance around 85-90 % on the second token.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/continuous-batching-orca-vllm-chunked-prefill-goodput/">Continuous batching&lt;/a> — the scheduler where speculative lives. Speculative breaks the symmetry of the batch (each request accepts between 1 and γ+1 tokens per iteration); at high QPS it can reduce goodput if the draft consumes slots from the decode pool.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/six-stage-llmops-pipeline-architecture-and-deep-dive/">The six-stage LLMOps pipeline&lt;/a> — the master map where Deploy is stage 4.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/mixed-nvidia-intel-environments-llm-inference/">Mixed NVIDIA + Intel environments&lt;/a> — the &amp;ldquo;drafter near edge on an Intel NUC + target on a central H100&amp;rdquo; pattern as the canonical case of speculative decoding deployed heterogeneously.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/optimising-decode-vllm-squeezing-every-token-small-hardware/">Optimising decode in vLLM&lt;/a> — the concrete vLLM parameters for turning on speculative decoding in production (&lt;code>--speculative-model&lt;/code>, &lt;code>--num-speculative-tokens&lt;/code>) with reference configs for RTX 4090 and L40.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/knowledge-distillation-teaching-small-model-think-like-big-one/">Knowledge distillation&lt;/a> — the best drafters are not small versions of the base model: they are students distilled specifically to predict the verifier&amp;rsquo;s distribution; distillation explains why EAGLE beats a plain generic 0.5B.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/llm-pruning-cutting-without-amputating/">Pruning LLM models&lt;/a> — an alternative to the distilled drafter: a pruned draft model (layer dropping from the base) as a cheap approximation of the verifier; it works worse than EAGLE but needs no extra training.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/self-speculative-decoding-model-gets-ahead-of-itself/">Self-speculative decoding: the model that gets ahead of itself&lt;/a> — the variant without a separate draft: the model itself run in early-exit acts as the draft and is verified with the full forward pass, zero extra VRAM. It is the form of speculative that fits small models and on-device deployment.&lt;/li>
&lt;/ul>
&lt;h2 id="references">References&lt;/h2>
&lt;ul>
&lt;li>Leviathan, Y., Kalman, M., Matias, Y. &lt;em>Fast Inference from Transformers via Speculative Decoding&lt;/em>. ICML 2023. &lt;a href="https://arxiv.org/abs/2211.17192">https://arxiv.org/abs/2211.17192&lt;/a>&lt;/li>
&lt;li>Chen, C., Borgeaud, S., Irving, G., Lespiau, J.B., Sifre, L., Jumper, J. &lt;em>Accelerating Large Language Model Decoding with Speculative Sampling&lt;/em>. DeepMind 2023. &lt;a href="https://arxiv.org/abs/2302.01318">https://arxiv.org/abs/2302.01318&lt;/a>&lt;/li>
&lt;li>Cai, T., Li, Y., Geng, Z., Peng, H., Lee, J.D., Chen, D., Dao, T. &lt;em>Medusa: Simple LLM Inference Acceleration with Multiple Decoding Heads&lt;/em>. ICML 2024. &lt;a href="https://arxiv.org/abs/2401.10774">https://arxiv.org/abs/2401.10774&lt;/a>&lt;/li>
&lt;li>Li, Y., Wei, F., Zhang, C., Zhang, H. &lt;em>EAGLE: Speculative Sampling Requires Rethinking Feature Uncertainty&lt;/em>. ICML 2024. &lt;a href="https://arxiv.org/abs/2401.15077">https://arxiv.org/abs/2401.15077&lt;/a>&lt;/li>
&lt;li>Li, Y., Wei, F., Zhang, C., Zhang, H. &lt;em>EAGLE-2: Faster Inference of Language Models with Dynamic Draft Trees&lt;/em>. EMNLP 2024. &lt;a href="https://arxiv.org/abs/2406.16858">https://arxiv.org/abs/2406.16858&lt;/a>&lt;/li>
&lt;li>Li, Y., Wei, F., Zhang, C., Zhang, H. &lt;em>EAGLE-3: Scaling up Inference Acceleration of Large Language Models via Training-Time Test&lt;/em>. NeurIPS 2025. &lt;a href="https://arxiv.org/abs/2503.01840">https://arxiv.org/abs/2503.01840&lt;/a>&lt;/li>
&lt;li>DeepSeek-AI. &lt;em>DeepSeek-V3 Technical Report&lt;/em> — Multi-Token Prediction. &lt;a href="https://arxiv.org/abs/2412.19437">https://arxiv.org/abs/2412.19437&lt;/a>&lt;/li>
&lt;li>Fu, Y., Bailis, P., Stoica, I., Zhang, H. &lt;em>Break the Sequential Dependency of LLM Inference Using Lookahead Decoding&lt;/em>. ICML 2024. &lt;a href="https://arxiv.org/abs/2402.02057">https://arxiv.org/abs/2402.02057&lt;/a>&lt;/li>
&lt;li>He, Z., Zhong, Z., Cai, T., Lee, J.D., He, D. &lt;em>REST: Retrieval-Based Speculative Decoding&lt;/em>. NAACL 2024. &lt;a href="https://arxiv.org/abs/2311.08252">https://arxiv.org/abs/2311.08252&lt;/a>&lt;/li>
&lt;li>vLLM speculative decoding docs: &lt;a href="https://docs.vllm.ai/en/latest/features/speculative_decoding/">https://docs.vllm.ai/en/latest/features/speculative_decoding/&lt;/a>&lt;/li>
&lt;li>SGLang speculative decoding docs: &lt;a href="https://docs.sglang.ai/advanced_features/speculative_decoding.html">https://docs.sglang.ai/advanced_features/speculative_decoding.html&lt;/a>&lt;/li>
&lt;li>TensorRT-LLM speculative sampling: &lt;a href="https://nvidia.github.io/TensorRT-LLM/advanced/speculative-decoding.html">https://nvidia.github.io/TensorRT-LLM/advanced/speculative-decoding.html&lt;/a>&lt;/li>
&lt;li>vLLM blog &lt;em>Speculative Decoding in vLLM&lt;/em> (oct 2024): &lt;a href="https://blog.vllm.ai/2024/10/17/spec-decode.html">https://blog.vllm.ai/2024/10/17/spec-decode.html&lt;/a>&lt;/li>
&lt;li>vLLM blog &lt;em>P-EAGLE: Parallel Speculative Decoding in vLLM&lt;/em> (mar 2026): &lt;a href="https://vllm.ai/blog/2026-03-13-p-eagle">https://vllm.ai/blog/2026-03-13-p-eagle&lt;/a>&lt;/li>
&lt;li>Official EAGLE repo: &lt;a href="https://github.com/SafeAILab/EAGLE">https://github.com/SafeAILab/EAGLE&lt;/a>&lt;/li>
&lt;li>Official Medusa repo: &lt;a href="https://github.com/FasterDecoding/Medusa">https://github.com/FasterDecoding/Medusa&lt;/a>&lt;/li>
&lt;/ul></description></item></channel></rss>