Skip to main content
← PROBLEMS / AI-SYSTEMS
An end-to-end domain learning journey

Speculative Decoding for
Faster LLM Inference.

Accelerate memory-bandwidth-bound LLM decoding 2.5x without changing the output distribution by having a small draft model propose K tokens that the large target model verifies in one parallel forward pass.
Start the journey5 stages
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

When a single bottleneck threatens end-to-end availability, because autoregressive LLM decoding is HBM-bandwidth-bound rather than compute-bound, verifying K=5 draft tokens in a single batched target pass costs nearly the same latency as generating 1 target token.

TL;DR30-second simplified summary
▾

Core Mechanics: Serving Llama-3-70B (BF16, ~140 GB weights across 8x H100 80GB NVLink GPUs, TP=8, 3.35 TB/s HBM3 bandwidth) achieves < 2% Tensor Core utilization at small batch sizes (1–8).

Visual & Structural Flow: Depicts 1B-3B Draft Proposes K=5 Tokens; 70B Verifies All in 1 Pass (Draft (1B/Eagle) -> Target 70B (TP=8) -> Paged KV Cache); Speculative Step & KV-Cache Rollback States (DRAFT K=5 -> VERIFY 70B -> ROLLBACK KV).

Trade-Offs & Production: Two common mistakes break speculative decoding: Using argmax(p) == argmax(q) when temperature > 0: Breaks mathematical equivalence to target sampling, distorting diversity and quality. Achieve >= 2.4x speedup (>= 60 tok/s) with exact target-model distribution: Replicated Draft / Eagle-2 Head: Run the draft model unsharded (TP=1 replicated, or.

Failure Modes & Application: Speculative decoding is built into production inference engines (vLLM, TensorRT-LLM, SGLang): Interactive Coding Copilots: High token-acceptance rates on boilerplate syntax push 70B models past 70–90 tok/s.

Full walkthrough · 5 stages
01
STAGE 01 · WHY IT MATTERSL4 · FUNDAMENTALS

Why 70B LLM decoding is HBM-bandwidth-bound at 24 tokens/sec.

Why this matters: The mechanism: understand how Why 70B LLM decoding is HBM-bandwidth-bound at 24 tokens/sec works from first principles.

Think of Why 70B LLM decoding is HBM-bandwidth-bound at 24 tokens/sec as the intuition layer for Speculative Decoding for Faster LLM Inference: The mechanism: understand how Why 70B LLM decoding is HBM-bandwidth-bound at 24 tokens/sec works from first principles.

Serving Llama-3-70B (BF16, ~140 GB weights across 8x H100 80GB NVLink GPUs, TP=8, 3.35 TB/s HBM3 bandwidth) achieves < 2% Tensor Core utilization at small batch sizes (1–8). Every single generated token must stream all 140 GB of weights from HBM (~42 ms/token), capping single-request throughput at ~24 tokens/sec.

02
STAGE 02 · IMPACTL5 · APPLIED DESIGN

Wasted Tensor Core FLOPS and high interactive TTFT/TPOT latency.

Why this matters: The problem: see what breaks without Wasted Tensor Core FLOPS and high interactive TTFT/TPOT latency under real concurrency or scale.

Because HBM reads dominate 98% of decode wall-clock time, processing 1 token vs.

6 tokens in parallel takes nearly identical time (~42 ms vs ~45 ms).

Draft-Then-Verify Loop

1B-3B Draft Proposes K=5 Tokens; 70B Verifies All in 1 Pass

Draft (1B/Eagle)Target 70B (TP=8)Paged KV Cache1. Gen K=5 tokens + q_i(x) (<10ms)2. Send K+1 tokens for 1 parallelpass3. Compute p_1..p_6 in ~45ms (1 HBM read)4. Reject at i=4 -> rollback KV +sample

Verifying K=5 draft tokens in one 70B forward pass yields ~4 accepted tokens per ~55ms step (>= 60 tok/s).

Engineering Decision Framework
Problem
How to implement Speculative Decoding for Faster LLM Inference without hitting unbounded tail latency, state divergence, or operational fragility.
Naive Solution
Use a single unpartitioned path with unbounded retries and synchronous global coordination.
Why It Fails
Global coordination serializes throughput under load, while unbounded retries amplify transient stalls into full outages.
Alternatives
Compare synchronous strict-consistency paths against bounded asynchronous replication, local caching, or partitioned ownership.
Engineering Decision
When a single bottleneck threatens end-to-end availability, because autoregressive LLM decoding is HBM-bandwidth-bound rather than compute-bound, verifying K=5 draft tokens in a single batched target pass costs nearly the same latency as generating 1 target token.
Trade-Offs
Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
Decision Exercise · Make the Call

When Speculative Decoding for Faster LLM Inference experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?

03
STAGE 03 · NAIVE SOLUTIONL5 · APPLIED DESIGN

Why greedy argmax checks and TP=8 draft models break.

Why this matters: The problem: see what breaks without Why greedy argmax checks and TP=8 draft models break under real concurrency or scale.

Two common mistakes break speculative decoding:

  • Using argmax(p) == argmax(q) when temperature > 0: Breaks mathematical equivalence to target sampling, distorting diversity and quality.
  • Sharding the tiny 1B draft model across TP=8: Adds 8x NVLink AllReduce sync overhead (~0.3 ms/layer) per draft token, blowing past the < 15 ms draft budget.
Design Trade-Off

Why greedy argmax checks and TP=8 draft models break

Before · Static Batch + Raw Prompt
  • Head-of-line blocking on long prompts
  • O(N^2) KV fragmentation
  • Unfiltered RAG leaks ACLs
After · PagedAttention + Guardrails
  • Zero-waste paged KV blocks
  • Pre-retrieval ACL & RRF rerank
  • Continuous batching boosts tok/s
04
STAGE 04 · ENTERPRISE SOLUTIONL6 · SCALE & TRADE-OFFS

Enterprise solution: Lossless Rejection Sampling + Eagle/Replicated Draft.

Why this matters: Operational control: configure bounds, failure handling, and safe production defaults.

Achieve >= 2.4x speedup (>= 60 tok/s) with exact target-model distribution:

  • Replicated Draft / Eagle-2 Head: Run the draft model unsharded (TP=1 replicated, or Eagle-2 speculative head) in < 10 ms for K=5 tokens, fitting comfortably inside the 62.5 GB/GPU remaining HBM.
  • Single Parallel Target Verification (~45 ms): Run one 70B forward pass over K+1 tokens to obtain p_1..p_{K+1}.
  • Lossless Modified Rejection Sampling: Accept token xix_i if r<min⁡(1,pi(xi)/qi(xi))r < \min(1, p_i(x_i) / q_i(x_i)). On first rejection at ii, discard draft tokens i..Ki..K, roll back their KV-cache blocks (PagedAttention), and sample 1 corrected token from norm(max⁡(0,pi−qi))\text{norm}(\max(0, p_i - q_i))—guaranteeing 2–6 tokens per step with zero quality loss.
Lossless Verification

Speculative Step & KV-Cache Rollback States

K+1 tokens + q_i(x)all K accepted (+bonus)r >= p_i/q_i at pos iresume from pos i+1DRAFT K=5TP=1 / Eagle (<10ms)VERIFY 70B1 parallel pass (~45ms)ROLLBACK KVSample norm(max(0,p-q))

Modified rejection sampling guarantees the exact output distribution of Llama-3-70B while amortizing HBM weight reads.

05
STAGE 05 · SYSTEM DESIGN APPLICATIONSL7 · STAFF / PRINCIPAL

Where speculative decoding accelerates AI serving.

Why this matters: Scope boundary: identify where this pattern fits best and where simpler or async alternatives win.

Speculative decoding is built into production inference engines (vLLM, TensorRT-LLM, SGLang):

  • Interactive Coding Copilots: High token-acceptance rates on boilerplate syntax push 70B models past 70–90 tok/s.
  • Prompt-Lookup / N-gram Speculation: Uses input context spans as zero-cost drafts for RAG & summarization.
  • Quantized Draft + BF16 Target: Pairs an FP8/INT4 draft head with a lossless BF16 verifier.
Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

Why does verifying K=5 draft tokens in a single 70B target forward pass take nearly the same time (~45 ms) as generating 1 token (~42 ms)?

Recommended Learning Flow