05.03

Speculative decoding

skillmaxingInference EngineeringSpeculative decoding
Visual lesson

Speculative decoding

Included with Pro · 4:23
Lessons · 1,105 words

Decode is slow for a reason that has little to do with arithmetic. At small batch sizes, each decode step reads every weight of the model out of GPU memory to produce a single token, and the compute cores spend most of that step waiting for the bytes to arrive. A forward pass over five tokens reads the same weights once and does five tokens' worth of math, so it costs barely more wall-clock time than a pass over one. The spare compute is sitting there, unused.

Speculative decoding spends it. A cheap proposer guesses the next few tokens. The model you actually serve, the target, runs one forward pass over all of those guesses at once and checks each one. Every guess that matches what the target would have produced is kept, and the target contributes one more token of its own at the first disagreement. When the guesses are good, one expensive step emits three or four tokens instead of one.

Pro

Continue reading

Pro unlocks every video lesson, the full notes, worked sizing and cost calculations, and runnable configs across the Inference Engineering course, from GPUs and kernels to quantization, speculative decoding, disaggregation and production autoscaling.

Unlock full access to
Python with AIInference EngineeringAI researchComplete system design
30% off with LAUNCH30first payment
Buy now
View all plans ·Already Pro? Sign in