Speculative Decoding & Draft Models
A hardware acceleration technique for inferring large language models 2–3 times faster without quality loss through parallel verification of predictions from a fast draft model.
1. Concept Overview & Systemic Problem
Text generation with large language models (LLMs) suffers from a fundamental hardware bottleneck — Memory-Bandwidth Bound:
- GPUs possess colossal computational power (TFLOPs), but during sequential generation of one token at a time, computational units spend 95% of the time waiting for model weights to be transferred from VRAM.
- This limits the throughput of large models to 25–40 tokens per second, which is too slow for long agentic workflows.
Speculative Decoding elegantly addresses this issue by linking two models: a tiny draft model (Draft Model, e.g., 1B–3B) and the target large model (Target Model, e.g., 70B).
2. Architectural Taxonomy & Mental Model
┌─────────────────────────────────────────────────────────────┐
│ SPECULATIVE DECODING PIPELINE │
├─────────────────────────────────────────────────────────────┤
│ 1. DRAFT GENERATION (Tiny model 1B operates from GPU cache):│
│ • Quickly generates a hypothesis with K=5 tokens: │
│ ["const", " ", "user", " =", " "] │
│ • Takes only 5 milliseconds │
├─────────────────────────────────────────────────────────────┤
│ │ │
│ ▼ SINGLE PASS OF LARGE MODEL │
├─────────────────────────────────────────────────────────────┤
│ 2. TARGET VERIFICATION (Large model 70B in one pass): │
│ • Verifies all 5 tokens in parallel with one VRAM call │
│ • Verification result: │
│ [Token 1: OK] [Token 2: OK] [Token 3: OK] [Token 4: OK]│
│ [Token 5: REJECT -> Replace with " {"] │
├─────────────────────────────────────────────────────────────┤
│ 3. OUTPUT SPEEDUP: │
│ • 4.5 valid tokens generated per VRAM cycle │
│ • Actual speedup: 2.5x – 3.2x TPS │
└─────────────────────────────────────────────────────────────┘
3. Technical Pipeline & Internal Mechanics
01. Accelerating Agentic Code Cycles in vLLM
Launching a vLLM server with speculative decoding parameter:
vllm serve meta-llama/Llama-3.3-70B-Instruct \
--speculative-model meta-llama/Llama-3.2-1B-Instruct \
--num-speculative-tokens 5 \
--gpu-memory-utilization 0.95
Code generation speed increases from 35 to 95 tokens per second without any changes to client code.
02. Medusa & Eagle (Speculation Without a Separate Draft Model)
Cutting-edge architectures (Medusa Heads) utilize multiple additional output layers (Decoding Heads) on the target model itself instead of a separate model, saving GPU memory.
4. Production Engineering Scenarios
01. Acceptance Rate Degradation
If the draft model significantly differs in style or training data from the target, the large model will reject 80% of the proposed tokens. The speedup will vanish, and inference time may even increase. The draft model must be from the same family (e.g., Llama 1B for Llama 70B).
02. VRAM Costs for the Second Model
The draft model occupies an additional 2–4 GB of video memory, which can be critical on GPUs with a 24 GB limit.
5. Pitfalls, Common Mistakes & Security
Speculative decoding has become a mandatory standard for industrial inference. It provides autonomous agents with high reactivity and speed, critically reducing user wait times when performing complex tasks.
FAQ: Speculative Decoding & Draft Models
Related terms
Generation Speed (TPS / TTFT / Latency)
Key engineering performance metrics for language models: Time to First Token (response time to input context) and Tokens Per Second (streaming output text generation speed).
vLLM (High-Performance Inference Engine)
Leading open-source inference engine and LLM servicing framework that revolutionizes throughput with the PagedAttention memory virtualization algorithm and continuous batching.
Model Quantization
A mathematical compression technology for neural network weights and activations by transitioning from high precision (FP16/BF16) to low-bit formats (FP8, INT8, INT4, GGUF) for radical memory savings.
Paged Attention & KV-Cache Management
A GPU memory management algorithm that segments the KV-cache of a language model into contiguous virtual pages (similar to OS kernels), eliminating fragmentation and increasing throughput by four times.
Related Ecosystem Resources
Explore practical workflows, core terminology, and engineering tools
Serverless LLM Cold Start Optimization
A comprehensive set of engineering methods to reduce the cold start time of serverless containers with language models from 30–60 seconds to under 1 second: pre-warmed pools, chunked weight loading, and memory snapshots.
Continuous / Dynamic Batching
A mechanism for grouping incoming requests to neural networks at the token iteration level (Iteration-Level Scheduling), eliminating GPU idle time during parallel loads.
Part II. How to Work with Codex + Optimization/Security/Team
Codex is not just code autocomplete in a chat; it is a full-fledged engineering agent: it reads the repository, plans changes, edits files, runs tests, reviews its own diffs, and c...
GPT Image Generative Models Prompting Guide
OpenAI's gpt-image generative models are designed to produce production-quality visuals and fully controllable creative workflows. They are suitable for both professional design ta...
Revolut shifts 2,000 engineers to locally deployed GLM models for coding
Revolut moved about 2,000 engineers to locally deployed GLM models, cutting AI coding costs by roughly tenfold and reducing task completion time by 70%.
MIT researchers show GPT-6 Astra can improve other AI models by editing their weights
In an experiment, Astra raised Qwen3.5-0.8B's accuracy on MATH-500 from 7.9% to 48.1% by changing only 0.016% of the model's weights.