Skip to content

Speculative Decoding in llama.cpp: Draft Models, N-gram and Setup (2026)

7–10 minutes
Woman in a home lab with a PC tower holding a tablet with a SPEC DECODING card, hook free speed boost for LLMs

Speculative decoding is the closest thing to a free speed boost for local LLMs. A small, fast “draft” guesses the next few tokens, and your big model checks them all at once. When the guesses are right, you get several tokens for the price of one, with exactly the same output quality.

llama.cpp’s llama-server now supports a whole family of methods: classic draft models, EAGLE-3, DFlash and its variants, Multi Token Prediction heads, and several draft-free n-gram methods that need no extra model at all.

This guide explains how speculative decoding works, which method to pick, the exact commands for each, the flags that matter, how to read the acceptance statistics, and how to tell whether it is actually helping. It follows the llama.cpp docs/speculative.md page as of November 2026.

TL;DR

  • Idea: a cheap draft proposes tokens; the main model verifies them in one batch. Same output, faster generation.
  • Easiest start: llama-server -m model.gguf --spec-default turns on the draft-free ngram-mod method.
  • Classic draft model: -md small-model.gguf from the same family and tokenizer.
  • Best acceptance: EAGLE-3 or DFlash drafts trained for your exact model (--spec-type draft-eagle3 / draft-dflash).
  • Code editing and summaries: n-gram methods (ngram-simple, ngram-mod) shine when text repeats.
  • Check it works: watch the “draft acceptance rate” in the log and compare t/s with and without.

How Speculative Decoding Works

Normally an LLM generates one token at a time. Each step loads all the model weights from memory, which is why generation is much slower than reading a prompt. The llama.cpp docs sum up the trick: computing n tokens in a batch is more efficient than computing them one after another.

  1. A fast drafter proposes the next few tokens (for example 3 to 16).
  2. The main (target) model checks all of them in a single batched pass.
  3. Every token up to the first mismatch is accepted; the target model supplies the correct token at that point.
  4. Repeat. If most guesses are right, you get several tokens per expensive step.

Because the big model verifies every token, greedy output is identical to normal decoding. With sampling, methods that support probabilistic verification keep the same distribution.

The speed-up depends on the acceptance rate: how often the draft guesses correctly. Easy, predictable text (code, structured output, repeated content) gets bigger gains than creative writing.

Every Method in llama.cpp

Type (--spec-type) Needs extra model? How it drafts
draft-simple Yes, a small LLM A smaller model from the same family generates the draft
draft-eagle3 Yes, trained for the target One-layer draft that reads the target’s hidden states
draft-dflash Yes, trained for the target Block-diffusion draft: a whole block of tokens per pass
draft-dflash2, draft-dspark, draft-lilicorr Yes DFlash variants with extra heads (selector, Markov head, scorer)
draft-mtp No (built-in heads) Uses Multi Token Prediction heads in models that ship them
ngram-cache No Statistics of short token sequences, optionally from files
ngram-simple No Finds the last matching n-gram in history and copies what followed
ngram-map-k, ngram-map-k4v No Hash maps of repeated patterns in the context
ngram-mod No Rolling-hash pool shared across server slots, about 16 MB

You can combine one draft-model method with draft-free methods in a comma-separated list. When both are active, the draft-free method takes precedence.

Which Method Should You Use?

Your situation Try
Just want a quick boost, no downloads --spec-default (ngram-mod)
Code refactoring, editing docs, summaries, reasoning models repeating their thinking ngram-simple or ngram-mod
General chat on a popular model with an EAGLE-3 or DFlash draft available draft-eagle3 or draft-dflash
Model family with a tiny sibling (for example 0.6B with 32B) draft-simple with -md
Model ships MTP heads draft-mtp

Quick Start: Draft-Free n-gram Methods

  1. Start your server as usual and add --spec-default: llama-server -m model.gguf -ngl 99 --spec-default
  2. Send a request that repeats content, such as “rewrite this function with type hints” plus the code.
  3. Check the log for draft acceptance rate.
  4. For code editing, try --spec-type ngram-simple --spec-draft-n-max 64.
  5. For long repetitions, try the docs’ example: --spec-type ngram-map-k4v --spec-ngram-map-k4v-size-n 8 --spec-ngram-map-k4v-size-m 8 --spec-ngram-map-k4v-min-hits 2 --spec-draft-n-max 64

The docs’ tips for ngram-mod: small n values are not recommended, MoE models need long drafts, and dense models can use smaller --spec-ngram-mod-n-min and --spec-ngram-mod-n-max. Defaults are match 24, min 48, max 64.

Use a Small Draft Model

The classic approach pairs your target model with a much smaller model that shares the same tokenizer, usually from the same family.

llama-server -m Qwen3-32B-Q4_K_M.gguf -ngl 99 \
  -md Qwen3-0.6B-Q8_0.gguf -ngld 99 \
  --spec-draft-n-max 8 -fa on
  • -md (or --spec-draft-model) loads the draft file; -hfd pulls it from Hugging Face.
  • -ngld sets how many draft layers go on the GPU (auto by default).
  • --spec-draft-n-max is how many tokens to draft per step (default 3).
  • --spec-draft-p-min stops drafting when the draft is not confident enough.

The draft model needs VRAM too. Keep it small (around 1-5% of the target’s size) and quantize it; use -ctkd/-ctvd to shrink its KV cache.

EAGLE-3 Drafts

EAGLE-3 drafts are tiny one-layer models trained for a specific target. Because they read the target’s hidden states, they reach higher acceptance than a standalone draft of the same size.

  1. Download an EAGLE-3 checkpoint for your model, for example AngelSlim/Qwen3-4B_eagle3 for Qwen3-4B.
  2. Convert it, pointing at the target model so it inherits the tokenizer: python convert_hf_to_gguf.py AngelSlim/Qwen3-4B_eagle3 --target-model-dir Qwen/Qwen3-4B --outtype bf16 --outfile Qwen3-4B-eagle3.gguf
  3. Run: llama-server -m Qwen3-4B.gguf -md Qwen3-4B-eagle3.gguf --spec-type draft-eagle3

The docs list supported drafts for Llama 3.1 8B and 3.3 70B, Gemma 4 31B and 26B-A4B, Qwen3 (1.7B to 32B and the 30B MoE) and gpt-oss 20B and 120B, among others.

DFlash, DFlash2, DSpark and LiliCorr

DFlash drafts produce a whole block of tokens in one forward pass using block diffusion, which keeps drafting fast on GPUs.

python convert_hf_to_gguf.py z-lab/Qwen3-4B-DFlash \
  --target-model-dir Qwen/Qwen3-4B --outtype bf16 --outfile Qwen3-4B-DFlash.gguf

llama-server -m Qwen3-4B.gguf -md Qwen3-4B-DFlash.gguf \
  --spec-type draft-dflash --spec-draft-n-max 15 -fa on --jinja
  • DFlash2 adds a local convolution and a candidate selector (--spec-type draft-dflash2).
  • DSpark adds a semi-autoregressive Markov head, for example deepseek-ai/dspark_qwen3_4b_block7; currently only Qwen3-backbone drafts are supported.
  • LiliCorr adds a candidate scorer (--spec-type draft-lilicorr).
  • Without --spec-type, llama.cpp detects the type from the draft model, and --spec-draft-n-max is clamped to the draft’s trained block size.

We covered one of these in practice in our DSpine draft model guide for Qwen3.8-27B.

Key Flags

Flag Default Purpose
--spec-type none Comma-separated list of methods
--spec-default off Enable the default config (ngram-mod)
-md / -hfd unused Draft model file / Hugging Face repo
--spec-draft-n-max 3 Max tokens drafted per step
--spec-draft-n-min 0 Min draft tokens to use
--spec-draft-p-min 0.00 Stop drafting below this confidence
-ngld auto Draft model layers on GPU
-devd auto Device(s) for the draft model
-ctkd / -ctvd f16 Draft KV cache types
--spec-draft-n-ubatch same as target Smaller draft batch to save VRAM

Most flags also have environment variables, such as LLAMA_ARG_SPEC_TYPE and LLAMA_ARG_SPEC_DRAFT_MODEL, handy in Docker. For the rest of the server options, see our llama-server guide.

Read the Acceptance Statistics

Each method prints statistics in the server log, for example:

draft acceptance rate = 0.70312 (   90 accepted /   128 generated)
statistics ngram_mod: #calls = 810, #gen drafts = 15, #acc drafts = 15, #gen tokens = 960, #acc tokens = 730
  • Acceptance rate: the share of drafted tokens the main model kept. Higher is better.
  • #gen drafts / #acc drafts: drafts proposed and (at least partly) accepted.
  • #gen tokens / #acc tokens: drafted tokens, including rejected ones, and tokens kept.

If acceptance is low (say under 0.3), drafting is mostly wasted work; try a better-matched draft, fewer draft tokens, or a different method.

Measure the Real Speed-Up

  1. Run the same prompt with and without speculative decoding and compare generation t/s in the server log.
  2. Use realistic prompts: chat, code and long-form writing behave very differently.
  3. For a proper test, the docs point to the SPEED-Bench client in tools/server/bench/speed-bench, which compares baseline and speculative runs against a running server.
  4. Use greedy sampling (temperature 0) when you want to confirm the output is identical.

Want raw model speed numbers first? Our llama-bench guide shows how to benchmark the target model on its own.

Troubleshooting

Problem Fix
No speed-up or slower Low acceptance or the draft is too big; use a smaller draft, fewer draft tokens, or an n-gram method
Out of memory after adding a draft Quantize the draft, lower -ngld, use -ctkd q8_0, or set --spec-draft-n-ubatch
Speculative decoding not initialized The --spec-type does not match the draft’s head (for example DSpark needs draft-dspark); leave the type out to auto-detect
Draft rejected or gibberish Draft and target must share a tokenizer; convert EAGLE/DFlash drafts with --target-model-dir
Outputs differ run to run Sampling and backend floating-point differences; use greedy sampling for exact matching
n-gram method never drafts Your text has little repetition, or min-hits/size settings are too strict

FAQ

Does speculative decoding reduce quality?

No. The main model verifies every token, so greedy output is the same as normal decoding.

How much faster is it?

It depends on acceptance. Repetitive tasks like code editing can speed up a lot; creative chat gains less. Always measure on your own prompts.

Do I need a second model?

Not for the n-gram methods or draft-mtp. Draft-model methods need a small extra GGUF.

Which draft model should I pick?

One trained for your target (EAGLE-3 or DFlash) is best. Otherwise, the smallest model from the same family with the same tokenizer.

Does it work with llama-cli?

The docs describe the methods for llama-server; some options such as synthetic acceptance testing also apply to llama-cli.

Does Ollama support speculative decoding?

This guide covers llama.cpp’s own server. Check your app’s release notes for its support.

What is –spec-default?

A shortcut that turns on the recommended default configuration, which currently enables the draft-free ngram-mod method.

Sources

Free weekly email

Get new AI guides every week

One short weekly email with our newest local AI, ComfyUI and AI tool guides. No spam, no pop-ups, just the good stuff.

Free. Unsubscribe anytime in one click. We only use your email to send this newsletter. See our privacy policy.

Woman in a home lab with a PC tower holding a tablet with a SPEC DECODING card, hook free speed boost for LLMs