Phase 19 · Lesson 14 of 85

Capstone 14 — Speculative-Decoding Inference Server

Speculative decoding — a cheap draft proposes tokens, the target model verifies them in one pass — is now a production-ready optimization, not a research trick. EAGLE-3 in vLLM 0.7 ships 2.5-3x throughput on real traffic. P-EAGLE (AWS 2026) pushed parallel speculation even further. SGLang's SpecForge trained draft heads at scale. Red Hat's Speculators hub published aligned drafts for common open models. TensorRT-LLM made speculative decoding first-class on NVIDIA. The 2026 production serving stack is vLLM or SGLang with EAGLE-family drafts, FP8 or INT4 quantization, and HPA on queue-wait. This capstone is to serve two open models at 2.5x+ baseline throughput with a full tail-latency report.

Lesson 14 of 85Capstone30 hoursPython (serving), C++ / CUDA (kernel inspection), YAML (configs)

Before this: Phase 3 (deep learning), Phase 7 (transformers), Phase 10 (LLMs from scratch), Phase 17 (infrastructure)

On this page

Problem

Speculative decoding became a commodity in 2026. EAGLE-3 draft heads train on the target model's hidden states and predict N tokens ahead; the target model verifies in a single pass. Acceptance rates of 60-80% translate to 2-3x end-to-end throughput. vLLM 0.7 integrates this natively. SGLang + SpecForge gives you the training pipeline. Red Hat's Speculators publishes aligned drafts for Llama 3.3 70B, Qwen3-Coder-30B MoE, GPT-OSS-120B.

The craft is in the serving operations, not the model. Acceptance rate drifts with the traffic distribution (ShareGPT vs code vs domain data). Tail latency under rejection is worse than without speculation — you must report p99 at multiple batch sizes, not just steady-state tokens/sec. Cost per 1M tokens vs Anthropic / OpenAI API is the credibility lever.

Concept

Speculative decoding has two layers. A draft model (EAGLE-3 head, ngram, or smaller target-aligned model) proposes k candidate tokens per step. The target model verifies all k in one pass; any prefix accepted replaces the greedy path. Acceptance rate depends on draft-target alignment and the input distribution.

EAGLE-3 beats ngram drafts on most traffic. P-EAGLE runs parallel speculation for deeper draft trees. The trade-off: P99 latency on rejection is higher because the verify pass is larger. The serving config must report batch-size-bucketed latency to surface this.

Deployment is Kubernetes. vLLM 0.7 runs one replica per GPU or tensor-parallel shard. HPA autoscales on queue-wait rather than CPU. FP8 (Marlin) and INT4 (AWQ) quants keep GPU memory inside an H100 / H200 envelope. The end-to-end report is throughput, acceptance rate, p50/p99 at batch 1/8/32, and $/1M tokens.

Architecture

request ingress
    |
    v
vLLM server (0.7) or SGLang (0.4)
    |
    +-- draft: EAGLE-3 heads | P-EAGLE parallel | ngram fallback
    +-- target: Llama 3.3 70B | Qwen3-Coder-30B | GPT-OSS-120B
    |     quantized FP8-Marlin or INT4-AWQ
    |
    v
verify pass: batch k draft tokens through target
    |
    v (accept prefix; resample for rejected suffix)
    v
token stream back to client
    |
    v
Prometheus metrics: throughput, acceptance rate, queue wait, latency p50/p99
    |
    v
HPA on queue-wait metric

Stack

  • Serving: vLLM 0.7 or SGLang 0.4
  • Speculative methods: EAGLE-3 draft heads, P-EAGLE parallel speculation, ngram fallback
  • Draft training: SpecForge (SGLang) or Red Hat Speculators
  • Target models: Llama 3.3 70B, Qwen3-Coder-30B MoE, GPT-OSS-120B
  • Quantization: FP8 (Marlin), INT4 AWQ
  • Deployment: Kubernetes + NVIDIA device plugin; HPA on queue-wait metric
  • Eval: ShareGPT, MT-Bench-v2, GSM8K, HumanEval for domain-spread acceptance measurement
  • Reference: TensorRT-LLM speculative decoding for a vendor baseline
cf-spec-decode

Build It

  1. Target model prep. Pick Llama 3.3 70B. Quantize to FP8 via Marlin. Deploy under vLLM 0.7 on 1xH100 (or 2x tensor-parallel).

  2. Draft source. Pull an aligned EAGLE-3 draft head from Red Hat Speculators (or train one via SpecForge). Load into vLLM's speculative-decoding config.

  3. Baseline numbers. Before speculation: tokens/s at batch 1/8/32, p50/p99 latency, GPU utilization. Publish.

  4. Enable EAGLE-3. Flip config; rerun the same benchmark. Report speedup, acceptance rate, p99 tail-latency delta.

  5. P-EAGLE. Enable parallel speculation; measure deeper draft tree vs serial EAGLE-3. Report the inflection where P-EAGLE helps vs hurts.

  6. Domain traffic. Run ShareGPT vs HumanEval vs domain-specific traffic through the same server. Measure acceptance rate per distribution. Identify when drafts drift.

  7. Second target model. Run the same pipeline on Qwen3-Coder-30B MoE. Draft is trickier (MoE routing noise). Report.

  8. K8s HPA. Deploy under K8s with HPA tracking queue_wait_ms. Demonstrate scale-out when load triples.

  9. Cost comparison. Compute $/1M tokens vs Anthropic Claude Sonnet 4.7 and OpenAI GPT-5.4 on the same eval. Publish.

Use It

$ curl https://infer.example.com/v1/chat/completions -d '{"messages":[...]}'
[serve]     vLLM 0.7, Llama 3.3 70B FP8, EAGLE-3 active
[decode]    bs=8, accepted_tokens_per_step=3.2, acceptance_rate=0.76
[latency]   first-token 42ms, full-response 980ms (620 tokens)
[cost]      $0.34 per 1M output tokens at sustained throughput

Ship It

outputs/skill-inference-server.md describes the deliverable. A measured serving stack with speculative decoding, a full benchmark report, and a K8s deployment.

Weight Criterion How it is measured
25 Measured speedup vs baseline 2.5x+ throughput at matched quality on two models
20 Acceptance rate on realistic traffic Per-distribution acceptance-rate report
20 P99 tail-latency discipline p99 at batch 1/8/32 with and without speculation
20 Ops K8s deploy, HPA on queue-wait, rollout smooth
15 Write-up and methodology Clear explanation of what changed and why
100

Exercises

  1. Measure acceptance-rate degradation when the draft is one version behind the target (e.g., Llama 3.3 -> 3.4 drift). Build a monitoring alert.

  2. Implement ngram-fallback: if EAGLE-3 acceptance drops below a threshold, switch to ngram drafts. Report reliability improvement.

  3. Run a controlled MoE experiment: same Qwen3-Coder-30B with routing noise injected vs without. Measure draft acceptance sensitivity.

  4. Extend to H200 (141 GB). Report the model-size-per-replica headroom gained and whether you can serve an unquantized Llama 3.3 70B.

  5. Benchmark TensorRT-LLM speculative decoding on the same H100 hardware. Report where it wins vs vLLM.

Key Terms

Term What people say What it actually means
Draft model "Speculator" Small model that proposes N tokens for the target to verify
EAGLE-3 "2026 draft architecture" Draft head trained on target hidden states; ~75% acceptance
P-EAGLE "Parallel speculation" Tree of draft branches verified in one target pass
Acceptance rate "Hit rate" Fraction of drafted tokens accepted without resampling
Quantization "FP8 / INT4" Lower-precision weights to fit more model in GPU memory
Queue wait "HPA metric" Time a request waits in the pending queue before inference starts
Speculators hub "Aligned drafts" Red Hat Neural Magic hub of EAGLE drafts for common open models

Further Reading

Check yourself

Quick quiz

  1. What is the two-layer mechanism behind speculative decoding?

    1. Two target models alternate per token
    2. An embedding model and a synthesizer
    3. A retrieval cache and a reranker
    4. A draft model proposes k candidate tokens; the target model verifies them in a single pass
    Show the answer

    D. A draft model proposes k candidate tokens; the target model verifies them in a single pass

  2. What does EAGLE-3 do that ngram drafts do not?

    1. It avoids tokenization entirely
    2. It runs only on CPUs
    3. It trains draft heads on the target model's hidden states for higher acceptance rates
    4. It replaces the target model
    Show the answer

    C. It trains draft heads on the target model's hidden states for higher acceptance rates

  3. Why is p99 tail latency reported across batch sizes 1, 8, and 32?

    1. Steady-state tokens-per-second can hide that the verify pass on rejection is more expensive than vanilla decoding
    2. vLLM cannot serve batch sizes below 8
    3. p99 only matters at batch size 32
    4. Tail latency is independent of batch size
    Show the answer

    A. Steady-state tokens-per-second can hide that the verify pass on rejection is more expensive than vanilla decoding

  4. Why does acceptance rate drift when the traffic distribution shifts?

    1. Draft alignment depends on the input distribution: ShareGPT, code, and domain data exercise different patterns
    2. The OS scheduler reshuffles GPU memory
    3. Quantization changes at runtime
    4. vLLM rotates models hourly
    Show the answer

    A. Draft alignment depends on the input distribution: ShareGPT, code, and domain data exercise different patterns

  5. Which Kubernetes HPA signal does the deployment scale on?

    1. Disk IOPS
    2. CPU utilization
    3. Queue-wait time on inference requests
    4. Cluster autoscaler nodes
    Show the answer

    C. Queue-wait time on inference requests

  6. What does P-EAGLE add over serial EAGLE-3?

    1. Quantization to FP4 weights
    2. Removal of the target model
    3. Parallel speculation across a tree of draft branches verified in one target pass
    4. Automatic dataset curation
    Show the answer

    C. Parallel speculation across a tree of draft branches verified in one target pass

  7. Which throughput target does the rubric demand against the non-speculative baseline?

    1. At least 2.5x at matched quality on two models
    2. Any improvement above baseline
    3. Roughly 1.1x at matched quality
    4. Exactly 10x throughput at any quality
    Show the answer

    A. At least 2.5x at matched quality on two models

Questions people ask

What is speculative decoding in AI?

It is a speed trick for text generation. A small draft model quickly proposes several tokens, and the large target model checks them all at once. Tokens it agrees with are kept, and the rest are regenerated. The final text matches what the large model would have written alone.

Does speculative decoding reduce answer quality?

Not when done correctly. The large model verifies every drafted token, so the output follows its own distribution. The gain depends on how often the draft model guesses right. When guesses are often wrong, the speedup shrinks, but quality stays the same.

Next lessonCapstone 15 — Constitutional Safety Harness + Red-Team RangePrevious: Capstone 13: Stateless MCP Server with Registry and Governance

Lessons from AI Engineering from Scratch by Rohit Ghumare and contributors, MIT license. Notes for owners by Lozo. License

Next step

Rather have it built for you?

Reading is optional. Tell me what's stuck and I'll build it into the business you already run.

  • A real conversation, not a pitch
  • You keep your accounts
  • Nothing sends without your yes