Coders In Hoods
  • Courses
  • Roles
  • Blog
  • Setup

Coders In Hoods AI Academy

Every course is free. Sign in to start, and your progress, quiz scores and bookmarks follow you.

AI Academy

  • Courses
  • Paths
  • Setup guides
  • How we teach

Role roadmaps

  • AI Engineer
  • Forward Deployed Engineer
  • Machine Learning Engineer
  • All roles

Coders In Hoods

  • The agency
  • Coaching for teams
  • Blog
  • LinkedIn
  • X (Twitter)

Contact

codersinhoods@gmail.com

© Coders In Hoods · since 2019

Course overview

Serving Open-Weight Models

Free · sign in to start and track progress

1 · What the server does with your GPU

  • 1Inside an inference engine
  • 2GPU sizing arithmetic
  • 3Serving your adapter

2 · Smaller, faster, still correct

  • 4Quantisation with evidence
  • 5Latency, throughput and honest benchmarks
  • 6Speculative decoding in practice

    Exercise answers

    • Answer: Build a speculative decoder and prove it is lossless
    • Answer: n-gram speculation on a real server
  • 7Structured outputs and tool calls

3 · Ship it and run it

  • 8What self-hosting makes you responsible for
  • 9Deployment and rollout
  • 10Observability and operations
CapstoneShip the triage endpointReference implementation

Module 2 · Smaller, faster, still correct · Lesson 6

Speculative decoding in practice

A cheap drafter proposes several tokens and the model verifies them in one memory-bound step; rejection sampling keeps the output distribution exactly the target's, the win is real at low concurrency, and it fades when the GPU is already busy.

75 min 1 video 3 exercises 6-question quiz Answers
Setup for the exercises:Install Claude CodePython with uvServe a model with vLLMRun GPU code on ModalThe Quillmoor triage kit

By the end of this lesson you can

  • Explain draft-then-verify and show why rejection sampling leaves the output distribution unchanged
  • Compute expected accepted tokens per step from the acceptance rate and draft length, and read an engine's acceptance metrics correctly
  • Choose among n-gram lookup, EAGLE-style heads, multi-token prediction and a separate draft model for a given model and traffic
  • Configure speculative decoding in vLLM or SGLang and verify it with a benchmark rather than assume the gain
  • Recognise when speculation hurts, and why structured JSON output is the case where n-gram drafting shines

On this page

  • Intuition: guess, then verify in one pass
  • The mechanism, exactly
  • The method ladder
  • When it hurts
  • Configuring it
  • Worked example: the simulator
  • Connections
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01Intuition: guess, then verify in one pass
  2. 02The mechanism, exactly
  3. 03The method ladder
  4. 04When it hurts
  5. 05Configuring it
  6. 06Worked example: the simulator
  7. 07Connections
  8. 08Summary

Sources & further reading

  • Fast Inference from Transformers via Speculative DecodingPaper · Leviathan, Kalman, Matias · Google Research · 2022The seminal paper (ICML 2023). Section 3.3 has the expected-tokens formula; Appendix A the proof that speculative sampling preserves the target distribution.
  • Accelerating Large Language Model Decoding with Speculative SamplingPaper · Chen, Borgeaud, Irving, Lespiau, Sifre, Jumper · Google DeepMind · 2023The same idea derived independently, with the modified rejection sampling step written out in Algorithm 2 and a clean proof in Theorem 1.
  • EAGLE: Speculative Sampling Requires Rethinking Feature UncertaintyPaper · Li, Wei, Zhang, Zhang · 2024Drafting from the target's own hidden features with a small head, which is what the EAGLE-3 option in vLLM and SGLang descends from. Sections 3 and 4.
  • Unlocking Efficiency in Large Language Model Inference: A Comprehensive Survey of Speculative DecodingPaper · Xia, Yang, Dong, Wang, Li et al. · 2024The map of the method space (ACL 2024): independent drafters, self-drafting, verification strategies. Read Section 3 for the taxonomy the method ladder here follows.
  • An Introduction to Speculative Decoding for Reducing Latency in AI InferenceLab research · NVIDIA · 2025Draft-verify explained with acceptance rate, and the EAGLE-3 head against a draft-target pair in production terms.
  • vLLM speculative decodingDocs · vLLM`--speculative-config` and its methods (`ngram`, `suffix`, `eagle3`, `mtp`, `draft_model`), the statement of which workloads benefit, losslessness of the standard rejection sampler, and the per-request acceptance metrics page beside it.
  • SGLang speculative decodingDocs · SGLang`--speculative-algorithm EAGLE3 | NGRAM | STANDALONE`, the three draft-tree flags, and the measured tokens-per-second numbers quoted here.
Free · sign in to start

Sign in to keep reading.

Free, no card. We use your account to save progress, quiz scores, bookmarks and occasionally send updates from our team.

  • 8 more sections
  • 3 hands-on exercises
  • A 6-question quiz
  • Progress, quiz scores and bookmarks