Skip to content
Inference Academy

Speculative decoding and LoRA hooks inside vLLM

Where speculative decoding and multi-LoRA serving plug into vLLM at v0.34.0. For speculation: draft tokens as extra known tokens, lookahead KV slots, verification with the rejection sampler, how rejected tokens are rolled back, the supported methods and the acceptance metrics. For LoRA: the max_loras limit in the scheduler, adapter keys in prefix-cache hashes, the Punica kernels and LoRA-aware CUDA graph capture.

By

Key takeaways

  • To the scheduler, draft tokens are known tokens without KV: it schedules them like any others, and reserves lookahead slots for drafters that keep their own KV.
  • The target model scores all drafts in one forward pass; the rejection sampler keeps the accepted prefix plus one token, and the scheduler rolls the computed-token count back by the rejected ones.
  • Speculation pays only when acceptance is high and the batch is small enough that the extra tokens are nearly free. Watch the per-position acceptance metric.
  • LoRA touches four places: the scheduler limits adapters per batch, the prefix cache keys on the adapter, Punica kernels apply many adapters in one batch, and CUDA graphs are captured per number of active adapters.
25 min · verified 2026-112 animated diagramsPro
Share

Goal: know where speculative decoding and multi-LoRA serving plug into the engine, so you can read their metrics, predict when they help, and find the code when one of them misbehaves.

You need: a checkout of vLLM at v0.34.0, and the earlier lessons of this track. Background: speculative decoding in depth and multi-LoRA and adapter serving.

Honest limits. At v0.34.0 vLLM supports many drafting methods, each with its own folder under vllm/v1/worker/gpu/spec_decode/, and options such as adaptive verification and dynamic draft lengths. This lesson follows the common path, a fixed number of draft tokens per step, and skips structured output's interaction with drafts. Check the method you use in its own folder.

#Speculative decoding

#Configuring it

Speculation is set with one JSON argument, for example n-gram lookup from the prompt:

bash
vllm serve <model> --speculative-config '{"method": "ngram", "num_speculative_tokens": 4, "prompt_lookup_max": 4}'

At v0.34.0 the method can be ngram, ngram_gpu, suffix, draft_model, the EAGLE family (eagle, eagle3), multi-token prediction heads (mtp and model-specific variants), dflash, dspark, and a few more (SpeculativeMethod in vllm/config/speculative.py). With a draft model, model names it.

Speculative decoding: guess cheap, verify in bulk
Animated

Draft model proposes (small, fast)

The quick brown fox

Output so far

Purple = token supplied by the big model (correction or bonus).

Tokens produced

0

Big-model passes

0

Speedup so far

–

Round 1 · Draft

A tiny, fast draft model guesses the next 4 tokens. Cheap, because the draft model is small.

The result is exactly what the big model would have produced alone. Only speed changes, and only when the draft model guesses well.

The rest is Pro

Keep reading the rest of this lesson

Pro unlocks the rest of this lesson, including 1 animated diagram, every advanced lesson, the hands-on labs and completion certificates.

One year

$25

365 days, no auto-renewal

Lifetime Best value

$75

pay once, keep it forever

7-day refund, no questions asked. One payment, no auto-renewal.Compare plansHave a licence key?

Sandip MaityBuilt by Sandip Maity, who runs self-hosted LLM inference in production.

Not ready? Keep learning free

Free lessons from vLLM Internals, no sign-up. Or follow the free roadmap →

Not ready? Take the free 5-day email course

One short email a day for five days, each built on a free lesson, then the occasional new lesson or offer. Unsubscribe in one click.

Still to come in this lesson

  1. LoRA
  2. Exercises
  3. Where to go next

You will be able to answer

  • A request has 3 draft tokens scheduled. The target model accepts the first one and rejects the second. What does the scheduler do with num_computed_tokens?
  • Speculative decoding with 4 draft tokens helps at concurrency 1 but slows the server at concurrency 64. Why?
  • Why does vLLM include the LoRA adapter's name and path in each block's prefix-cache hash?