Skip to content
Inference Academy

Lab: tune speculative decoding and find where it stops paying

Enable speculative decoding three ways (n-gram lookup, a draft model or EAGLE-style head, and MTP where the model has it), measure acceptance rate and speed-up against the course's formula, then sweep load to find the batch size where speculation becomes a cost. Includes an output-equivalence check and a results table.

By

90 min · verified 2026-11Hands-on labPro
Share

Goal: turn speculative decoding on, measure what it really buys on your workload, and find the load at which it stops helping.

You need: one NVIDIA GPU (24 GB or more), vLLM or SGLang, a 7 to 8B instruct model (and, if possible, a model that ships MTP layers or has a published EAGLE head), loadgen.py from the baseline-to-3x lab, and about 90 minutes.

Honest limits. Speculation methods and their flags change often; use your engine's current documentation for the exact configuration syntax. Acceptance rates depend heavily on the prompts, so use prompts that look like your traffic.

#Step 0: two prompt sets

Prepare 50 prompts of each kind:

  • Repetitive: code editing ("rewrite this function with type hints", including the function), summarising a pasted document, JSON extraction. Output repeats the context.
  • Open-ended: creative writing or open questions at temperature 0.7.

Speculation should do much better on the first set. You will check whether it does.

Pro content

Keep reading with Inference Academy Pro

Unlock this full lab, plus every advanced lesson, hands-on lab, the larger playground models and completion certificates.

Still to come in this lab

  1. Step 1: predict
  2. Step 2: baseline
  3. Step 3: three speculation methods
  4. Step 4: check outputs are unchanged
  5. Step 5: fill the table
  6. Step 6: explain
  7. Self-check
  8. Stretch goals

You will be able to answer

  • Your measured acceptance rate is 0.7 with 4 draft tokens. What tokens per verification step does the course's formula predict?
  • Speculation speeds up batch-1 decode 2× but lowers goodput at 12 requests per second. Why?
  • How do you check that speculation did not change outputs?

Preparing for an interview?