Speculative decoding tries to produce several output tokens for less expensive target-model work. A cheaper draft model proposes a continuation. The target checks it, and the server keeps only tokens allowed by the verification procedure. The correctness question is whether this produces the same probability distribution over outputs as sampling from the target alone. A plausible-looking answer or a high acceptance rate cannot establish that property.

For greedy decoding, a verifier can compare a proposal with the token the target would choose, subject to consistent tie-breaking and execution. Sampling is different. A target may assign probability to many tokens, and an exact sampler must preserve those probabilities rather than accept only its favorite. The proposed argmax check over-rejects valid alternatives. Sampling from the ordinary target distribution after that rejection also fails to account for probability mass already delivered through accepted drafts.

For one position, let p be the normalized target distribution and q the normalized distribution that actually generated the draft token at the same prefix. A distribution specifies the probability of each possible token. Draw a proposal x from q, then accept it with probability min(1, p(x) / q(x)). A sampled proposal has positive q(x), so that ratio is defined. Upon rejection, sample the replacement from the normalized positive part of p - q.

Here is a hypothetical two-token vocabulary. The target assigns p(A)=0.6 and p(B)=0.4, while the draft assigns q(A)=0.9 and q(B)=0.1. An A proposal is accepted with probability 0.6/0.9 = 2/3. A B proposal is always accepted because 0.4/0.1 exceeds one. Across attempts, accepted proposals contribute probability 0.6 to A and 0.1 to B. Rejection happens with probability 0.3, all from excess A proposals.

The positive part of p-q has mass zero on A and 0.3 on B, so every correction selects B. The final probabilities are therefore 0.6 for A and 0.1+0.3=0.4 for B, exactly the target distribution. If the implementation instead sampled from p after rejection, it would add 0.18 to A and 0.12 to B, producing 0.78 and 0.22 overall. That simple calculation exposes the bias without relying on fluent text examples.

More generally, accepted proposals contribute min(p(x), q(x)) to each token. The correction supplies the missing positive mass. This is the construction developed in the original speculative decoding paper. When p and q are identical, every proposal is accepted and the residual need not be sampled. When the draft never proposes a token the target allows, the correction path can still supply it.

Speculative sampling accepts a draft token or corrects the first rejection

For a block of four proposals, target scoring must use the correct preceding tokens at each position. With causal attention, a target pass over the draft continuation can provide those conditional distributions. Verify in order. At the first rejection, sample a correction and discard the unverified draft suffix because those tokens were proposed under a prefix that is no longer valid. If all four are accepted, the usual algorithm samples an additional target token from the distribution after that accepted prefix. Later iterations continue from verified output.

The effective distributions must include the actual sampling transformations. Temperature changes how concentrated probabilities are, and top-p restricts sampling to a probability-ranked subset. The acceptance calculation must use the p and q that correspond to the implemented proposal and target sampler, with consistent normalization and constraints. Comparing raw logits while proposing from a truncated q breaks the argument. The models also need a shared token space for this simple algorithm. Different tokenizers require a different, explicitly justified method.

Pin the draft-model version for a request, or retain the exact q associated with each proposal and demonstrate that all verification state remains consistent. Pinning is usually the simpler contract. A target-model or sampling-policy change also changes the distribution being preserved and must be versioned. On rejection, discard any speculative cache suffix and ensure the correction occupies the right position. Never stream unverified draft tokens or execute their proposed tool calls.

Test enumerable tiny vocabularies, zero-probability cases, full acceptance, early rejection and stop conditions before measuring speed. Compare empirical frequencies with target-only sampling, alongside deterministic checks of the probability calculation. Exact sampling means distributional equivalence, not identical strings under the same seed. After correctness, evaluate latency and cost per successful task. Draft overhead and rejected work can erase a theoretical speed advantage.