Unit 12 of 12 · about 5 hours · implement, measure
Engine integration, versioned fallback, and benefit and loss regions
Integration is where paper gains meet serving reality. A path without fallback and without a measured loss region is a demo, not an engine change.
You'll be able to
- Integrate one quantized or speculative path into an engine with a versioned configuration and a tested fallback.
- Measure a benefit region and a loss region across batch size and sequence length with quality held fixed.
- Explain each region from format, kernel coverage, acceptance, draft cost or workload evidence.
Covers
Read
In this order, only the parts listed
0 of 3 done
- Hands-on speculative decoding and the concurrency crossoverHands-On LLM Serving and Optimization - Quantization (Chapter 6) and Speculative Decoding (Chapter 7)
Chapter 7, Hands-on Speculative Decoding (printed pp. 240 to 242): the four vLLM server setups (vanilla, n-gram, improved n-gram, EAGLE-3) compared at concurrency 1 and 16, with the TTFT versus ITL trade-off discussion
Reproduce the comparison shape on your model and GPU: n-gram and EAGLE gains at low concurrency fading or reversing at high concurrency. The book numbers are its hardware, not your target.
- vLLM speculative configuration schemavLLM Speculative Decoding and Quantization (v0.31.0)
--speculative-configschema with the common keys (method,model,num_speculative_tokens) and the n-gram keys (prompt_lookup_min,prompt_lookup_max), plus the lossless-guarantees and per-request acceptance-metrics notesFor each method you integrate, first write its correctness contract, the engine support it needs, and a predicted winning and losing workload, then run it. The schema keys are v0.31.0 keys; older releases differ.
- Chapter 18 speculation sweep toolingAI Systems Performance Engineering companion code - Chapters 16, 18 and 19 labs
code/ch18/speculative_decode/spec_config_sweep.pywithcode/ch18/spec_configs: sweeping speculator configs and emitting acceptance rate, chunk size, throughput, TTFT and TPOT per configUse the sweep shape and metric set on your engine; regenerate every number on your hardware. Its config keys (
chunk_size,max_spec_tokens,fallback_chunk_size) drive the chapter's own benchmark, not the vLLM speculative config.
Focus on
- Version the full path: method, model or drafter artifact, quantization format, engine version and every speculation flag. Fallback is a config switch back to the validated baseline, tested before it is needed.
- Map two axes at least: batch size and sequence length. Speculation typically wins small-batch decode and loses large-batch or prefill-heavy load; quantization wins memory-bound shapes and loses where kernels are missing.
- Hold quality fixed across the map with the slice checks from the methods unit. A faster region with failed quality is not a benefit region.
- Attribute each region to a mechanism: acceptance and draft cost, kernel coverage, dequantization overhead, or scheduler interaction. Name the shifted bottleneck on the losing side.
Common mistakes · 3
- Shipping without exercising fallback. An untested fallback fails exactly when the primary path does; trigger it deliberately under load before relying on it.
- Sweeping one axis. A batch-1 win that reverses at batch 16 is the normal shape, not an anomaly; the map needs both axes plus a long-context point.
- Changing sampling or prompts between configs. Any output difference voids both the quality and the latency comparison; pin the contract first.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.What belongs in a versioned speculation configuration?Answer
Method, drafter artifact and version, target model, engine version, draft length and lookup bounds, sampling parameters, and the fallback revision. Anything missing cannot be rolled back to exactly.
2.N-gram speculation wins at concurrency 1 and loses at 16. What mechanism explains the crossover?Answer
At low concurrency verification rides idle arithmetic; at high concurrency the batch already consumes it, so proposing and verifying add cost while acceptance stays the same. The book also names the extra CPU work of proposing.
3.A quantized path is faster but fails the code slice. Is that a benefit region?Answer
No. Benefit regions require the quality contract to hold; report it as a loss region with the slice failure as the cause.
4.How do you test fallback before an incident?Answer
Flip the config switch under replayable load, confirm outputs match the baseline contract and latency returns to baseline, and keep the evidence with the version.
You're done when
Your contract predicts a win and a loss region before the run, the measurements confirm the shape with quality held, and fallback flips cleanly under load.
Only when you can do this without notes.
Leads to
Notes
Resources · 3 for this unit, 10 more in the section
- Hands-On LLM Serving and Optimization - Quantization (Chapter 6) and Speculative Decoding (Chapter 7)Chi Wang and Peiheng Hu (O'Reilly) · primary
Read "Model Compression" in Chapter 6 for quantization and "Speculative Decoding" in Chapter 7, with its hands-on example. For each method write its correctness contract, the engine support it needs and a predicted winning and losing workload before running it.
- vLLM Speculative Decoding and Quantization (v0.31.0)vLLM Project · required
Use the speculative decoding page for the supported proposers (draft model, n-gram, EAGLE, MTP) and its losslessness notes, and the quantization page for the hardware support table. Check every method against your GPU's compute capability before planning a run.
- AI Systems Performance Engineering companion code - Chapters 16, 18 and 19 labsChris Fregly · required
Use Chapter 16 AWQ, GPTQ and SmoothQuant pairs, Chapter 18 speculation sweeps and Chapter 19 dynamic quantized cache. Run one family at a time, require quality or numerical parity, and regenerate results on available hardware.
Also in this section
- MIT 6.5940 TinyML and Efficient Deep Learning Computing - Quantization LecturesMIT Han Lab · required
Use Lectures 5 and 6 for quantization fundamentals and Lecture 13, Efficient LLM Deployment, for SmoothQuant and AWQ with TinyChat. Implement a small affine quantizer and an outlier experiment before using a pre-quantized checkpoint.
- SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language ModelsMIT and NVIDIA · required
Study activation outliers and the offline smoothing transformation. Reproduce the algebra on one linear layer and compare calibration-sensitive quality with an unmodified reference.
- AWQ: Activation-Aware Weight Quantization for LLM Compression and AccelerationMIT Han Lab · required
Focus on salient-weight protection, group scaling and the distinction between simulated quality and real kernel speed. Compare one supported AWQ path with the same unquantized workload.
- Fast Inference from Transformers via Speculative DecodingDeepMind · required
Derive acceptance and correction probabilities and implement the exact categorical simulator. Prove distributional equality on tiny distributions before adding a model or engine.
- AI Systems Performance Engineering - Chapters 15 and 16, speculation and quantizationChris Fregly (O'Reilly) · support
Read "Speculative Decoding and Parallel Token Generation Techniques" in Chapter 15 (draft models, EAGLE, self-speculation, Medusa) and "Quantization Approaches for Real-Time Inference" in Chapter 16.
- 100 Days of LLM Inference - Days 13, 14 and 15Elizabeth Thomas · support
Use the numeric-format, quantization-algorithm and speculative-decoding notebooks as compact preparation. Keep their synthetic demos separate from production-engine and hardware evidence.
- TensorTonic Language Modeling from Scratch - Perform Exact Speculative SamplingTensorTonic · support
Solve after the acceptance-rule unit, then check your implementation's output distribution against the target by exact enumeration on a tiny vocabulary.
- LLM Inference: From scratch, one token at a time - Module 08Tushar Amrit · support
Work the Speculative Decoding module's acceptance arithmetic and checkpoint before the speedup-model unit.
- AI Performance Engineering - Quantization and Speculative DecodingWafer · reference
A curated index. Use Section 4 only to find a quantization or speculation paper the other entries lack.
- Inference Engineering - Section 5.1, QuantizationPhilip Kiely (Baseten Books) · support
Read 5.1.1 Number Formats for the format table and Precision/Type/Scale-factor with Dynamic range/Granularity, 5.1.2 for PTQ versus QAT and the what-to-quantize decisions, and 5.1.3 for the perplexity, benchmark and custom-eval quality checks.