Speculative Decoding and Multi-Token Prediction: Speeding Up LLM Inference

    This article explains how speculative decoding and Multi-Token Prediction (MTP) accelerate large language model inference by restructuring the decode loop instead of just making the model compute faster. It covers why autoregressive decoding becomes memory-bandwidth bound at small batch sizes, how a lightweight draft model proposes k candidate tokens that the target model verifies in a single parallel pass, and the probability-based accept/reject rules that keep output quality unchanged. It also compares draft model options, explains target activations and bounded KV cache sharing, and provides a practical rollout checklist covering k tuning, acceptance-rate measurement, fallback strategies, monitoring metrics, and common mistakes. Aimed at developers optimizing inference cost, it clarifies both where the gains appear and where speculative decoding can turn into a regression.

    1. Bottom Line Up Front: Inference Acceleration Is About Restructuring the Decode Loop

    The core problem in LLM inference optimization is not simply making the model “compute faster” — it is rethinking the computation flow of the generation phase. Autoregressive decoding produces one token per step, which leaves most matrix math under-parallelized. Speculative decoding and Multi-Token Prediction (MTP) invert that with “cheap guessing + parallel verification by the target model,” so a single expensive forward pass can cover more than one token and generation throughput goes up.

    Five conclusions up front:

    1. In small-batch generation, memory bandwidth usually becomes the bottleneck before compute does.
    2. The key to speculative decoding is that the draft model proposes several candidate tokens and the target model verifies them all in one parallel pass.
    3. Output quality holds only if the target model enforces a strict probability-based acceptance rule.
    4. The draft model does not have to be identical to the target model, but it must share the vocabulary, stay close enough in distribution, and remain cheap to run.
    5. Real gains depend on acceptance rate, draft length, batch size, cache reuse conditions, and framework support.

    2. Why LLM Generation Stalls on Memory Bandwidth

    Autoregressive decoding is inherently serial, token by token. Each forward pass produces a single next token, which is appended to the context before the next pass begins. This dependency chain means generation cannot be packed into one large matrix operation the way training can.

    Hardware utilization is the bigger issue. During generation with a small request batch, each forward pass still has to stream all of the model’s weights from VRAM to the compute units, but only one token actually takes part in the matrix math. Arithmetic intensity is therefore very low, and the bottleneck sits in memory bandwidth rather than in the compute cores. High-performance compute units spend much of their time waiting for data, so latency and cost end up dominated by memory movement.

    One caveat: the memory-bandwidth bottleneck does not hold in every scenario. With large request batches where compute is already saturated, or on systems that are compute-limited rather than bandwidth-limited, serial per-token decoding still costs something, but the improvement will not match the gains seen in low-batch, memory-bound settings.

    3. Speculative Decoding: Breaking the Serial Dependency With Parallelism

    The core idea: guess cheaply, then verify expensively.

    It introduces two roles:

    • Draft model: lightweight and low-overhead, used to quickly propose several candidate tokens.
    • Target model: full-sized and higher precision, used to verify the candidates in parallel.

    The typical flow: the draft model predicts k candidate tokens in the time the target model takes to complete one forward pass; the target model then runs a single parallel forward pass over those k candidates. If the target model endorses them, they can be accepted as a batch, letting one target-model computation advance across several tokens.

    Where the gain comes from: verifying k candidates with the target model usually costs about the same as generating one token on its own, because both are dominated by weight movement and forward-compute overhead. If the candidates are well accepted, the number of effective tokens produced can exceed k.

    Boundary conditions matter, though. When the batch is large, the context is long, compute is the limiting factor, or the draft overhead becomes too large a share of the work, the cost of parallel verification goes up and the benefit of speculative decoding shrinks — it can even become a net regression. So do not extrapolate the memory-bandwidth bottleneck to all scenarios; evaluate against model size, hardware, batching strategy, and acceptance rate.

    4. Multi-Token Prediction Draft Models: Design Goals and Options

    MTP is one common implementation of the draft stage in speculative decoding. The draft model’s goal is not to match the target model exactly, but to propose a candidate sequence that hits often enough — in less time than the target model needs for a single token.

    Draft design is usually a tradeoff between prediction accuracy and the draft’s own cost. The more accurate the guess, the higher the target model’s acceptance rate and the larger the speedup; but if the draft model is too heavy, it drags down the overall pace.

    Common draft approaches compared:

    Type Structure Training cost Hit rate Deployment complexity Best fit
    Standalone small model Separate small-parameter language model Medium Depends on domain similarity Two models must be loaded Strong general-purpose target model; draft can be maintained independently
    Target-model auxiliary MTP head Multi-step prediction head added on the target model or an adjacent structure Higher Usually closer to the target distribution Requires framework support for extra heads or training interfaces Stable acceptance rate and deeper integration
    Retrieval- or template-based draft Candidates generated from cache, repeated text, or rules Low Good for templated text Low to medium Code completion, fixed formats, repeated Q&A

    In practice, check first whether the draft model uses the same tokenizer as the target model. If the vocabulary or tokenization differs, candidate tokens cannot be aligned against the target model’s probability distribution, and the acceptance logic breaks down.

    5. Acceptance and Rejection: Why Output Quality Does Not Degrade

    Unlike a naive “small model approximates the big model” setup, speculative decoding does not inherently lose quality, because the target model has the final say. What matters is that the accept/reject decision is based on both the draft probability and the target probability.

    Let q(x) be the draft model’s probability for candidate token x, and p(x) the target model’s probability for the same token at the same position. The standard acceptance rule is:

    acceptance probability = min(1, p(x) / q(x))

    If the target model’s probability is at least as high as the draft’s, the acceptance probability is 1; if the target probability is lower, the token is rejected with the corresponding probability. On rejection, do not simply keep the remaining draft tokens — resample from a corrected distribution instead. That corrected distribution is normally max(0, p - q), normalized, which covers the mass the target model favors but the draft missed.

    If all k candidates are accepted, one more token still has to be sampled from the target model’s distribution at the extra position, so decoding can continue.

    Illustrative pseudocode:

    1. # Illustrative speculative decoding flow (pseudocode, not a concrete API)
    2. def speculative_step(draft_model, target_model, context, k):
    3. # 1) Draft model predicts k candidate tokens and their probability distributions
    4. draft_tokens, draft_probs = draft_model.predict(context, n=k, return_probs=True)
    5. # 2) Target model performs one parallel verification over the k candidates
    6. # and returns its probabilities at the corresponding positions
    7. target_probs = target_model.verify(context, draft_tokens)
    8. # 3) Compare one by one, accepting based on the draft and target probabilities
    9. accepted = 0
    10. for i in range(k):
    11. q = draft_probs[i]
    12. p = target_probs[i]
    13. x = draft_tokens[i]
    14. # Acceptance probability: min(1, p(x) / q(x))
    15. if random() < min(1.0, p[x] / q[x]):
    16. accepted += 1
    17. else:
    18. # Rejection position: resample from the corrected distribution max(0, p - q)
    19. residual = normalize([max(0.0, p[y] - q[y]) for y in vocab])
    20. corrected = sample(residual)
    21. return context + draft_tokens[:i] + corrected
    22. # 4) If everything is accepted, sample a new token from the target model's
    23. # distribution at the extra position
    24. extra_distribution = target_model.next_distribution(context, draft_tokens)
    25. extra_token = sample(extra_distribution)
    26. return context + draft_tokens + extra_token

    This mechanism ensures wrong guesses are corrected and discarded promptly. No matter how many tokens the draft model gets right, the sequence that is finally retained follows the target model’s distribution, so output quality does not systematically degrade because of speculative decoding.

    6. Target Activations: Letting the Draft “See” the Target Model’s Intent

    If the draft model predicts in complete isolation, its hit rate is often limited. To improve candidate quality, you can introduce a target activation mechanism so the draft model can reference internal signals from the target model.

    A common approach is to concatenate the output embedding from the target model’s last layer with the draft model’s own token embedding, then project it into the draft model’s hidden dimension as input for subsequent prediction. The draft model no longer relies only on its own limited context; it can use the target model’s understanding of the current semantics to calibrate the direction of its predictions.

    Across multiple prediction rounds, later rounds can also concatenate the draft model’s previous round output so that consecutive guesses stay coherent. This brings candidate tokens closer to the target model’s intent and raises the acceptance rate.

    Target activations are not unconditionally usable, however. They depend on whether the inference framework can reliably expose the target model’s hidden-layer signals, and on the layer count, hidden dimension, and vocabulary alignment between the two models. If the mapping cost is too high, or the extra communication and concatenation latency increases noticeably, it can cancel out the time saved in the draft stage.

    7. KV Cache Sharing: Reusing Attention Caches Within Limits

    If the draft model and target model each maintain their own attention key/value cache, you pay for duplicated computation and extra VRAM. KV cache sharing is therefore an important efficiency lever — but sharing has to rest on compatibility.

    Only when the draft and target models are compatible in structure and attention implementation, and the inference framework explicitly supports it, can the draft model share or attach to the target model’s cache; otherwise the draft model still needs to maintain its own KV. Forcing cache reuse across incompatible structures can produce incorrect attention results and even break output quality.

    Shared caches generally fall into two categories:

    1. Local attention cache. Applies when the target model uses a local window or short-range attention structure. The draft model can reuse the most recent local KV to cover neighboring context. This is cheap to implement and suits generation tasks with strong local dependency and a relatively stable context window.

    2. Global attention cache. Applies when the target model retains long-range global KV. The draft model attaches to the global cache of the target model’s last layer or a specified layer in order to cover long-range dependencies. This has higher upside, but puts stronger demands on framework cache management, layer alignment, and memory layout.

    The engineering principle is straightforward: cache sharing can lower cost, but never at the expense of correctness. If layer structure, number of heads, hidden dimension, position encoding, or attention masks do not match, prefer a separate cache first and then reduce overhead through framework-level optimizations.

    8. Engineering Checklist and Common Mistakes

    Speculative decoding is not an optimization that reliably pays off just by switching it on. You need a rollout checklist across four areas: model choice, parameters, monitoring, and fallback.

    8.1 Checklist

    1. Draft model selection

      • Does it use the same tokenizer as the target model?
      • Is it suited to your business domain?
      • Is its per-step cost significantly lower than the target model’s?
      • Can it fall back independently?
    2. Tuning k

      • Start with a small value, for example 1 to 3, then increase gradually.
      • If the acceptance rate is high, try a larger k.
      • If rejections cluster in the later part of the draft sequence, k may be too large.
      • Tune separately for code generation, templated tasks, and open-ended dialogue.
    3. Defining the acceptance rate

      • Accepted tokens divided by the total number of draft candidates.
      • Also track average accepted length — the effective tokens each draft round contributes on average.
      • Record the rejection position distribution as well, to tell whether the problem is draft quality, too large a k, or domain drift.
    4. Failure fallback

      • When the acceptance rate falls below a threshold, automatically fall back to ordinary per-token decoding.
      • When draft model inference times out or errors out, skip speculative decoding.
      • When VRAM is insufficient or cache sharing fails, degrade to separate caches or disable sharing.
      • Fallback should be smooth, avoiding request-level jitter that causes latency spikes.
    5. Monitoring metrics

      • Generation throughput: tokens per second.
      • Time to first token.
      • Time per output token.
      • Average accepted length or acceptance rate.
      • Share of time spent in the draft model.
      • VRAM usage, cache hit rate, timeout rate, and fallback rate.

    8.2 Common mistakes

    1. Chasing a larger k. A bigger k is not automatically faster. Later draft tokens drift further from the target distribution, and rising rejection rates turn into wasted computation.

    2. Ignoring tokenizer consistency. When the draft and target vocabularies differ, candidate tokens cannot be mapped correctly onto the target model’s probabilities, so the acceptance logic fails.

    3. Treating the acceptance rate as final quality. A high acceptance rate means the draft matches the target distribution well, but final quality should still be confirmed by the target model’s outputs and business evaluation.

    4. Forcing KV cache sharing across incompatible structures. Cache reuse requires compatible structure, attention implementation, and framework support; otherwise it can introduce incorrect attention results.

    5. Skipping benchmarks. In typical memory-bound, small-batch, high-acceptance settings, community practice commonly reports around 2–3x speedups, but actual gains must be measured against your own model and hardware.

    6. Ignoring batching effects. With larger request batches, the relative benefit of parallel verification by the target model can drop. Production should test both small-batch low-latency and large-batch high-throughput modes.

    9. Conclusion

    Speculative decoding and multi-token prediction represent an elegant engineering idea: instead of forcing the target model to compute faster in a single pass, use the draft model’s cheap guesses and the target model’s authoritative verification to reorganize the decode flow and put the compute that memory bandwidth was wasting back to work.

    From multi-token parallel prediction in the draft model, to one-shot parallel verification in the target model; from probability-based accept/reject rules, to target activations that align the draft with the target model’s intent; and on to bounded KV cache sharing and a complete engineering monitoring system — these mechanisms all point to one goal: significantly cutting generation latency and raising inference throughput without sacrificing output quality.

    For developers who want to reduce LLM inference cost, understanding how speculative decoding works is only the first step. What matters more is a systematic rollout against your model architecture, hardware, business scenario, and monitoring setup. Only by making clear tradeoffs among quality, latency, and throughput can this technique genuinely serve production.