Aqib Mehedi
ExpertiseProjectsApproachArsenalBlogContactCoursesShopSign In
Hire Me
Aqib Mehedi
AI Engineering
9/6/2026
5 MIN READ

Speculative Decoding and Medusa Heads: How to Double LLM Token Generation Speed for Free

Architect
Architect
Lead AI Solutions Architect & Engineer
Speculative Decoding and Medusa Heads: How to Double LLM Token Generation Speed for Free

Double your LLM inference speed without quality loss. Explore the mechanics of speculative decoding, draft models, and Medusa multi-head architectures.

The primary bottleneck in serving Large Language Models is not raw compute power; it is memory bandwidth. During standard autoregressive decoding, generating each token requires streaming hundreds of gigabytes of model weights from High Bandwidth Memory (HBM) into the GPU compute cores just to compute a single matrix-vector multiplication.

As a result, modern GPUs run at single-digit arithmetic intensity during inference, severely underutilizing their Tensor Cores.

Speculative Decoding solves this by trading compute for memory efficiency, allowing models to generate 2 to 3 tokens per memory transfer with zero degradation in output quality.


The Mathematical Intuition of Speculative Decoding

Standard decoding is strictly serial: $$x_{t} \sim P(x | x_{<t})$$

In speculative decoding, we introduce a lightweight Draft Model $M_q$ (e.g. a 1B model) alongside our massive Target Model $M_p$ (e.g. a 70B model):

  1. Draft Phase: The fast draft model predicts $K$ future tokens speculatively in a burst ($x_{t+1}, x_{t+2}, \dots, x_{t+K}$). Because the draft model is tiny, this takes mere milliseconds.
  2. Verification Phase: The target model runs a single parallel forward pass on all $K+1$ candidate tokens simultaneously.
  3. Acceptance Criterion: Using modified rejection sampling, the target model accepts tokens matching its probability distribution. If the target model accepts 3 out of 4 tokens, we generate 3 tokens in the time of 1 target forward pass!
Speculative Decoding Sequence:
Draft Model (Fast):   [Token 1] ───> [Token 2] ───> [Token 3] ───> [Token 4]
                             │              │              │              │
Target Model (1 Pass): [Verify 1: ✓]  [Verify 2: ✓]  [Verify 3: ✓]  [Verify 4: ✗ (Resampled)]

Medusa: Speculative Decoding Without a Separate Draft Model

While classical speculative decoding requires managing two models in memory, Medusa introduces extra decoding heads directly on top of the original model's final hidden state.

Each Medusa head is a lightweight feedforward layer trained to predict subsequent token offsets:

  • Head 0 predicts $t+1$
  • Head 1 predicts $t+2$
  • Head 2 predicts $t+3$

By using a tree-structured attention mask, Medusa generates candidate token trees and verifies them in a single step, boosting generation speeds by 2.2x to 2.8x on models like Llama 3 70B with zero additional model management overhead.


Production Implementation with vLLM / TensorRT-LLM

Both vLLM and TensorRT-LLM feature out-of-the-box support for speculative decoding:

# Serving Llama 3.3 70B with Llama 3.2 1B as Speculative Drafter
python3 -m vllm.entrypoints.openai.api_server \
    --model meta-llama/Llama-3.3-70B-Instruct \
    --speculative-model meta-llama/Llama-3.2-1B-Instruct \
    --num-speculative-tokens 5 \
    --gpu-memory-utilization 0.92 \
    --tensor-parallel-size 4

Economic Impact on Infrastructure Budgets

For a company processing 100 million tokens daily:

  • Standard generation throughput: 45 tokens/sec per GPU.
  • Speculative decoding throughput: 105 tokens/sec per GPU.
  • Hardware requirement drops from 16x H100 GPUs to 8x H100 GPUs, cutting monthly cloud hosting expenditure in half.

Continue Exploring

LangGraph vs CrewAI: Choosing the Right Framework for Production Agents

LangGraph vs CrewAI: Choosing the Right Framework for Production Agents

Model Context Protocol (MCP) in Production: Architecture Patterns for Enterprise Agent Integration

Model Context Protocol (MCP) in Production: Architecture Patterns for Enterprise Agent Integration

DeepSeek R1 & Open-Source Reasoning: How Distillation Is Disrupting Enterprise LLM Costs

DeepSeek R1 & Open-Source Reasoning: How Distillation Is Disrupting Enterprise LLM Costs

Have a specific architectural challenge?

Let's discuss how we can implement these patterns in your next high-scale production system.

SCHEDULE A CONSULTATION
Aqib Mehedi

Senior Solutions Architect specializing in the intersection of AI, Mobile Engineering, and Scalable Cloud Infrastructure.

Gulshan, Dhaka, Bangladesh

Navigation

  • Project Portfolio
  • Expertise
  • Hire / Contact
  • Blogs

Connect

  • LinkedIn
  • GitHub
  • Facebook
  • Email

© 2026 Aqib Mehedi. All rights reserved.

Engineering Intelligence. Delivering Impact.

Architect's Note

The full technical whitepaper for this topic is available upon request for enterprise clients. I frequently update these entries as state-of-the-art patterns evolve in the AI and Mobile ecosystems.

Architect
ArchitectBASIS National ICT Award Winner

Lead AI Solutions Architect in Bangladesh specializing in Custom Large Language Models, Enterprise Agentic RAG, and High-Scale Mobile Architecture. Explore architectural blueprints & consulting →

Store & Digital Products

Production Software & Tools

Instant access to standalone desktop suites, agentic AI engines, mobile applications, and white-label source code.

Explore Store
KeyNest - Zero-Knowledge Encrypted Password & Vault App
Mobile App

KeyNest - Zero-Knowledge Encrypted Password & Vault App

Overview KeyNest is an encrypted mobile credential vault engineered for personal and fami...

Price৳100
View Details
Foldify - Windows Folder Customizer
Desktop Software

Foldify - Windows Folder Customizer

Overview Foldify is a native desktop productivity utility designed to enhance visual orga...

Price৳100
View Details
RoomLens Pro – Smart Multi-Participant Virtual Camera & Room Splitter
Desktop Software

RoomLens Pro – Smart Multi-Participant Virtual Camera & Room Splitter

Overview RoomLens Pro is a specialized virtual camera software utility engineered for mod...

Price৳100
View Details
DoodoMe
Mobile App

DoodoMe

Overview DoodoMe is an interactive earlylearning sensory discovery mobile application des...

Free Download
View Details
ResumeMe
Digital

ResumeMe

ResumeMe AIPowered Interactive Resume Builder ResumeMe is a featurerich, interactive re...

Free Download
View Details
Obsidian Movies
Digital

Obsidian Movies

Obsidian Movies Product Specifications and Description Executive Summary Obsidian Movi...

Free Download
View Details
GitBridge
Digital

GitBridge

GitBridge: EnterpriseGrade Git Migration and Repository Synchronization Desktop Suite Gi...

Free Download
View Details
BD Jobs Finder
Digital

BD Jobs Finder

BD Jobs Finder A smart desktop app that scrapes 5,800+ live jobs from bdjobs.com and mat...

Free Download
View Details
Modio – Netflix-Style Movie Streaming App
Mobile App

Modio – Netflix-Style Movie Streaming App

Overview Modio is a premium mobile video streaming client designed with a modern entertai...

Free Download
View Details
DevGarbage Cleaner – Professional Storage Optimizer
Desktop Software

DevGarbage Cleaner – Professional Storage Optimizer

Overview DevGarbage Cleaner is an automated storage optimization utility designed specifi...

Free Download
View Details
Prometheus Lab (Zero Cost)
Digital

Prometheus Lab (Zero Cost)

Prometheus Lab: The Ultimate AIPowered Content Creation Studio Transform ideas into capt...

Price৳599
View Details
Milo AI – Personal Second Brain & Task Orchestrator
Productivity Suite

Milo AI – Personal Second Brain & Task Orchestrator

Overview Milo AI is a personal secondbrain desktop workspace and task orchestration hub. ...

Price৳250
View Details
Contragraviton – Agentic Project Manager
AI Tool

Contragraviton – Agentic Project Manager

Overview Contragraviton is an autonomous Agentic Process Orchestrator (APO) engineered fo...

Price৳699
View Details
CamTow – Phone Camera to PC Webcam Utility
Mobile App

CamTow – Phone Camera to PC Webcam Utility

Overview CamTow is a companion utility system that transforms your highresolution mobile ...

Free Download
View Details
SleeperAI D-LLM Android Service
Mobile App

SleeperAI D-LLM Android Service

Overview SleeperAI is an ondevice distributed language model service designed for Android...

Price৳100
View Details
Shelldon Portable Encrypted Browser
Desktop Software

Shelldon Portable Encrypted Browser

Overview Shelldon is a portable, zerofootprint web browser engineered for secure, isolate...

Free Download
View Details
PC-to-WWW P2P Tunneling Utility
Digital

PC-to-WWW P2P Tunneling Utility

PCtoWWW — Firebase & WebRTC Serverless P2P Tunnel PCtoWWW is a reusable, serverless peer...

Price৳100
View Details
MarkCamera – White-Label Watermark App
Software

MarkCamera – White-Label Watermark App

A complete, productionready whitelabel watermarking app built with Flutter. MarkCamera all...

Price৳100
View Details
KeyNest - Zero-Knowledge Encrypted Password & Vault App
Mobile App

KeyNest - Zero-Knowledge Encrypted Password & Vault App

Overview KeyNest is an encrypted mobile credential vault engineered for personal and fami...

Price৳100
View Details
Foldify - Windows Folder Customizer
Desktop Software

Foldify - Windows Folder Customizer

Overview Foldify is a native desktop productivity utility designed to enhance visual orga...

Price৳100
View Details
RoomLens Pro – Smart Multi-Participant Virtual Camera & Room Splitter
Desktop Software

RoomLens Pro – Smart Multi-Participant Virtual Camera & Room Splitter

Overview RoomLens Pro is a specialized virtual camera software utility engineered for mod...

Price৳100
View Details
DoodoMe
Mobile App

DoodoMe

Overview DoodoMe is an interactive earlylearning sensory discovery mobile application des...

Free Download
View Details
ResumeMe
Digital

ResumeMe

ResumeMe AIPowered Interactive Resume Builder ResumeMe is a featurerich, interactive re...

Free Download
View Details
Obsidian Movies
Digital

Obsidian Movies

Obsidian Movies Product Specifications and Description Executive Summary Obsidian Movi...

Free Download
View Details
GitBridge
Digital

GitBridge

GitBridge: EnterpriseGrade Git Migration and Repository Synchronization Desktop Suite Gi...

Free Download
View Details
BD Jobs Finder
Digital

BD Jobs Finder

BD Jobs Finder A smart desktop app that scrapes 5,800+ live jobs from bdjobs.com and mat...

Free Download
View Details
Modio – Netflix-Style Movie Streaming App
Mobile App

Modio – Netflix-Style Movie Streaming App

Overview Modio is a premium mobile video streaming client designed with a modern entertai...

Free Download
View Details
DevGarbage Cleaner – Professional Storage Optimizer
Desktop Software

DevGarbage Cleaner – Professional Storage Optimizer

Overview DevGarbage Cleaner is an automated storage optimization utility designed specifi...

Free Download
View Details
Prometheus Lab (Zero Cost)
Digital

Prometheus Lab (Zero Cost)

Prometheus Lab: The Ultimate AIPowered Content Creation Studio Transform ideas into capt...

Price৳599
View Details
Milo AI – Personal Second Brain & Task Orchestrator
Productivity Suite

Milo AI – Personal Second Brain & Task Orchestrator

Overview Milo AI is a personal secondbrain desktop workspace and task orchestration hub. ...

Price৳250
View Details
Contragraviton – Agentic Project Manager
AI Tool

Contragraviton – Agentic Project Manager

Overview Contragraviton is an autonomous Agentic Process Orchestrator (APO) engineered fo...

Price৳699
View Details
CamTow – Phone Camera to PC Webcam Utility
Mobile App

CamTow – Phone Camera to PC Webcam Utility

Overview CamTow is a companion utility system that transforms your highresolution mobile ...

Free Download
View Details
SleeperAI D-LLM Android Service
Mobile App

SleeperAI D-LLM Android Service

Overview SleeperAI is an ondevice distributed language model service designed for Android...

Price৳100
View Details
Shelldon Portable Encrypted Browser
Desktop Software

Shelldon Portable Encrypted Browser

Overview Shelldon is a portable, zerofootprint web browser engineered for secure, isolate...

Free Download
View Details
PC-to-WWW P2P Tunneling Utility
Digital

PC-to-WWW P2P Tunneling Utility

PCtoWWW — Firebase & WebRTC Serverless P2P Tunnel PCtoWWW is a reusable, serverless peer...

Price৳100
View Details
MarkCamera – White-Label Watermark App
Software

MarkCamera – White-Label Watermark App

A complete, productionready whitelabel watermarking app built with Flutter. MarkCamera all...

Price৳100
View Details
KeyNest - Zero-Knowledge Encrypted Password & Vault App
Mobile App

KeyNest - Zero-Knowledge Encrypted Password & Vault App

Overview KeyNest is an encrypted mobile credential vault engineered for personal and fami...

Price৳100
View Details
Foldify - Windows Folder Customizer
Desktop Software

Foldify - Windows Folder Customizer

Overview Foldify is a native desktop productivity utility designed to enhance visual orga...

Price৳100
View Details
RoomLens Pro – Smart Multi-Participant Virtual Camera & Room Splitter
Desktop Software

RoomLens Pro – Smart Multi-Participant Virtual Camera & Room Splitter

Overview RoomLens Pro is a specialized virtual camera software utility engineered for mod...

Price৳100
View Details
DoodoMe
Mobile App

DoodoMe

Overview DoodoMe is an interactive earlylearning sensory discovery mobile application des...

Free Download
View Details
ResumeMe
Digital

ResumeMe

ResumeMe AIPowered Interactive Resume Builder ResumeMe is a featurerich, interactive re...

Free Download
View Details
Obsidian Movies
Digital

Obsidian Movies

Obsidian Movies Product Specifications and Description Executive Summary Obsidian Movi...

Free Download
View Details
GitBridge
Digital

GitBridge

GitBridge: EnterpriseGrade Git Migration and Repository Synchronization Desktop Suite Gi...

Free Download
View Details
BD Jobs Finder
Digital

BD Jobs Finder

BD Jobs Finder A smart desktop app that scrapes 5,800+ live jobs from bdjobs.com and mat...

Free Download
View Details
Modio – Netflix-Style Movie Streaming App
Mobile App

Modio – Netflix-Style Movie Streaming App

Overview Modio is a premium mobile video streaming client designed with a modern entertai...

Free Download
View Details
DevGarbage Cleaner – Professional Storage Optimizer
Desktop Software

DevGarbage Cleaner – Professional Storage Optimizer

Overview DevGarbage Cleaner is an automated storage optimization utility designed specifi...

Free Download
View Details
Prometheus Lab (Zero Cost)
Digital

Prometheus Lab (Zero Cost)

Prometheus Lab: The Ultimate AIPowered Content Creation Studio Transform ideas into capt...

Price৳599
View Details
Milo AI – Personal Second Brain & Task Orchestrator
Productivity Suite

Milo AI – Personal Second Brain & Task Orchestrator

Overview Milo AI is a personal secondbrain desktop workspace and task orchestration hub. ...

Price৳250
View Details
Contragraviton – Agentic Project Manager
AI Tool

Contragraviton – Agentic Project Manager

Overview Contragraviton is an autonomous Agentic Process Orchestrator (APO) engineered fo...

Price৳699
View Details
CamTow – Phone Camera to PC Webcam Utility
Mobile App

CamTow – Phone Camera to PC Webcam Utility

Overview CamTow is a companion utility system that transforms your highresolution mobile ...

Free Download
View Details
SleeperAI D-LLM Android Service
Mobile App

SleeperAI D-LLM Android Service

Overview SleeperAI is an ondevice distributed language model service designed for Android...

Price৳100
View Details
Shelldon Portable Encrypted Browser
Desktop Software

Shelldon Portable Encrypted Browser

Overview Shelldon is a portable, zerofootprint web browser engineered for secure, isolate...

Free Download
View Details
PC-to-WWW P2P Tunneling Utility
Digital

PC-to-WWW P2P Tunneling Utility

PCtoWWW — Firebase & WebRTC Serverless P2P Tunnel PCtoWWW is a reusable, serverless peer...

Price৳100
View Details
MarkCamera – White-Label Watermark App
Software

MarkCamera – White-Label Watermark App

A complete, productionready whitelabel watermarking app built with Flutter. MarkCamera all...

Price৳100
View Details