Model and Inference EngineeringQuality and decoding trade-offsPrincipal
How can speculative decoding preserve target probabilities when draft and target vocabularies differ?
By Amit Kumar3 min readWorked answer includedReviewed 28 Sept 2026
The question
Interview question
A draft model and target model split some words into different tokens. The serving team proposes retokenizing drafts and applying the ordinary speculative acceptance ratio to the original draft probabilities. Explain the flaw. Give one precisely scoped distribution-preserving alternative, show why target-only tokens remain possible, and distinguish a mathematical guarantee from the modes actually supported by a serving engine.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
Speculative decoding uses a cheap model to propose work that a more expensive target model verifies. Exactness means that the final tokens have the same distribution as target-only sampling under the specified sampling rules. It does not mean both paths emit the same string under one seed. Different tokenizers make the guarantee harder because a probability for one draft token may describe a different event from a probability for one target token.
For example, the draft may represent a word with one token while the target needs two. The probability of the draft’s whole-word token cannot be substituted for the probability of the target’s first subword. Simply decoding text and encoding it again does not supply the missing proposal probabilities. The original speculative sampling paper gives the acceptance-and-correction construction for compatible token events. Its proof cannot be applied to unrelated token IDs without establishing a common event space.
One bounded alternative is Token-Level Intersection, or TLI, in Algorithm 4 of the heterogeneous-vocabulary paper. Establish an unambiguous mapping of shared token events, restrict the drafter to that intersection and renormalize its probabilities. Call the resulting proposal distribution q-prime on the target vocabulary, with zero probability outside the intersection. Apply ordinary speculative verification using the target distribution p and this actual proposal q-prime. The mapping must preserve the intended token meaning and history. Matching superficially normalized strings is not sufficient when tokenizer decoding, special tokens or byte boundaries differ.
For one step, propose x from q-prime and accept it with probability min(1,p(x)/q-prime(x)). After rejection, draw a correction with probability proportional to max(p(x)-q-prime(x),0) over the target vocabulary. A sampled proposal has nonzero proposal probability, so the acceptance ratio is defined there. The accepted mass for each token is min(p(x),q-prime(x)). The correction supplies the remaining mass. Together they sum to p(x). The proposal must be the renormalized distribution actually used, rather than the drafter’s probabilities before filtering.
Consider a hypothetical shared intersection containing A and B. Let q-prime assign them 0.75 and 0.25, while the target assigns A,B,C probabilities 0.50,0.20,0.30. Accepted proposal mass is 0.50 for A and 0.20 for B. Total rejection probability is 0.30, and the residual places all correction mass on C. The emitted distribution is therefore 0.50,0.20,0.30. C remains possible even though the drafter cannot propose it. Restricting the target itself to A and B would destroy that property.
This construction deliberately gives up proposals that span incompatible token boundaries. If the usable intersection is empty, fall back to target-only decoding rather than renormalizing an empty set. A string-level method can use more draft text, but it needs its own verification algorithm and treatment of alternative token segmentations. A heuristic alignment rule is not a replacement for that probability accounting.
An implementation also has to keep each model’s history consistent after accepted tokens and corrections, including re-encoding where the algorithm requires it. Verify spaces, Unicode, byte fragments, duplicate decoded forms and special tokens. First test the probability accounting on a tiny exactly enumerable example. Then compare greedy paths and sample distributions on controlled cases. Statistical agreement can detect bugs, but cannot prove the algorithm correct for every history.
Finally inspect the selected engine and version. vLLM’s speculative-decoding documentation describes supported serving methods, whose availability and sampling contracts can change. Do not infer cross-vocabulary stochastic support from the existence of an option for a different method. Record the actual proposal distribution, alignment rule and acceptance/correction code before making an exactness claim. Measure accepted target tokens per pass and end-to-end latency after correctness is established. A theoretically exact method can still be slower when alignment and rejected drafts cost more than the saved target passes.
Related questions
Keep practising model and inference engineering
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux