Multi-Token Prediction and Speculative Decoding: Principles and Engineering Optimization

    This article explains why autoregressive decoding becomes a bottleneck, clarifies the difference between multi-token prediction and speculative decoding, and describes how draft and target models work together. It also covers the conditions required to preserve output quality, three ways to improve candidate hit rates, a simple model for estimating speedup, and a deployment validation workflow for correctness, candidate length, workload behavior, and dynamic fallback.

    1. The Inference Bottleneck in Token-by-Token Generation

    Autoregressive language models typically generate content by reading the context, predicting the next token, and appending it to the sequence. Because each subsequent prediction depends on previously generated results, this process is highly serial. For applications that need to produce long outputs continuously, repeated decoding can accumulate noticeable latency even when single-step computation is already optimized.

    Understanding this problem requires distinguishing two inference stages:

    • Context preprocessing: The input sequence is processed once to build the intermediate state needed for subsequent generation.
    • Autoregressive decoding: Each step usually adds only a small number of tokens, but model weights and attention caches must be accessed repeatedly.

    In low-concurrency, small-batch decoding scenarios, compute devices may not be fully utilized. Performance may instead be limited by memory bandwidth, cache access, and execution scheduling. In this case, optimization is not only about reducing arithmetic operations. It is also about making one expensive target-model computation confirm more valid output.

    Multi-token prediction and speculative decoding target this goal: use a lower-cost method to propose several candidate tokens, then have the target model verify them in a concentrated step, reducing the number of target-model calls needed to advance the output.

    Decoding is not always memory-bandwidth-bound. As concurrency, batch size, context length, and model architecture change, the bottleneck may shift to compute throughput, cache capacity, or inter-device communication. Therefore, the real bottleneck must be identified before adopting an acceleration scheme.

    2. Multi-Token Prediction and Speculative Decoding Are Not the Same Concept

    Multi-token prediction describes a prediction capability or training objective: the model learns not only the immediately next token but also attempts to predict multiple future positions. Implementations may use multiple prediction heads, lightweight auxiliary networks, or other structures.

    Speculative decoding is an inference execution strategy: candidate sequences are generated first, then verified by the target model, and the verification results determine which candidates enter the final output.

    The two can be combined, but they are not equivalent:

    1. Multi-token prediction can serve as a candidate source for speculative decoding.
    2. Speculative decoding can also use a small model running step by step to generate candidates.
    3. Being able to propose multiple tokens at once does not automatically mean the target model’s output distribution is preserved.
    4. Preserving the output distribution requires correct verification, acceptance, and correction mechanisms.

    In addition, “predicting multiple positions simultaneously” and “having the target model verify multiple candidate positions in parallel” are different stages. Some draft-generation processes still contain serial steps, so the entire system should not be described simply as fully parallel generation.

    3. How Draft Models and Target Models Collaborate

    A typical speculative decoding cycle includes the following process.

    3.1 Generate drafts from the confirmed prefix

    The draft model reads the already determined context and proposes a candidate sequence of length k. Its purpose is not to replace the target model but to generate content likely to be accepted by the target model at lower cost.

    If the draft model is too small, it may generate quickly but predict incorrectly frequently. If it is too large, it may offset the benefit of reducing target-model calls. Therefore, the valuable objective is not draft accuracy alone but the combination of draft cost and effective accepted length.

    3.2 Batch-compute candidate positions with the target model

    Once the candidate sequence is known, the target model can use a causal attention mask to compute conditional distributions for multiple candidate positions in one forward pass.

    This still follows autoregressive dependencies: the distribution at a later position is based on the prefix formed by earlier candidate tokens. Parallel verification does not allow the model to ignore context. Instead, it uses known candidates to organize multiple positions into one computation.

    3.3 Accept the valid prefix and handle the rejected position

    The system checks candidates in order according to the verification rules. At the first rejected position, it usually accepts the candidates that have already passed, handles the current rejected position, and discards subsequent unconfirmed drafts.

    If all candidates are accepted, a typical implementation can also use the subsequent distribution already computed by the target model to advance one more token. The exact behavior depends on the algorithm used.

    3.4 Synchronize state and enter the next round

    Tokens that are finally committed must be synchronized with the sequence state and cache. Temporary states corresponding to rejected drafts must be rolled back or isolated; otherwise, the next round may continue from an incorrect context.

    Speculative decoding is therefore not simply adding a small model in front of the normal generation flow. It requires complete mechanisms for candidate management, verification, commitment, and rollback.

    4. What “No Quality Loss” Requires

    The most common misunderstanding about speculative decoding is that “the target model checks at the end, so the output must be completely unchanged.” In fact, whether the original behavior is preserved depends on the decoding method and algorithm implementation.

    Greedy decoding: token-by-token consistency

    In greedy decoding, the system selects the highest-probability token at each step. During verification, a candidate token is accepted only if it matches the target model’s choice under the same confirmed prefix.

    Provided that numerical computation, tied-probability handling, and stopping rules are consistent, this approach can preserve the same greedy generation path as running the target model directly.

    Stochastic sampling: distributional consistency

    Stochastic sampling cannot achieve strict distribution preservation merely by checking whether a candidate equals another sample from the target model.

    Let q be the draft probability of a candidate token and p be the target model probability. Classical speculative sampling determines the acceptance probability based on the ratio of the two:

    Acceptance probability = min(1, p / q)

    Once a candidate is rejected, sampling must be performed from a corrected residual distribution rather than replacing the token arbitrarily. This residual distribution is related to the part where the target-model probability exceeds the draft probability.

    Temperature scaling, probability truncation, and other sampling transformations must also be incorporated into a consistent probability definition. Inconsistent implementation details can change the final output distribution.

    A more precise statement is therefore: When the algorithm’s assumptions are satisfied and distribution correction is implemented correctly, speculative sampling can preserve the target model’s sampling distribution. This does not mean that every run with the same random seed will produce exactly the same text token by token.

    If approximate acceptance rules are used, output quality should be evaluated separately, and the conclusion of strict distribution preservation should not be carried over without verification.

    5. Three Types of Optimization for Improving Candidate Hit Rates

    5.1 Use target-model hidden states to assist prediction

    Building drafts only from input tokens may fail to fully use context information already extracted by the target model. Some approaches combine target-model hidden states with token embeddings, project them into the draft network’s hidden dimension, and then perform subsequent prediction.

    This design can provide richer contextual representations to the draft network, but several points require attention:

    • Target-model hidden states are not equivalent to input token embeddings.
    • Feature concatenation, projection method, and readout position must match the training design.
    • Hidden-state transfer and projection themselves also incur computation and bandwidth costs.

    For multi-round draft prediction, it is also necessary to specify whether later rounds use target-model features, the draft’s own state, or a combination of both. Different structures should not be conflated.

    5.2 Reuse attention caches under compatible conditions

    Attention mechanisms usually cache keys and values for historical positions to reduce repeated computation. If the target model and draft network are designed for compatibility, the draft side can read part of the target model’s cache, reducing the cost of repeatedly storing and accessing historical state.

    However, cache reuse cannot be implemented directly between arbitrary models. Attention head layout, feature dimensions, positional encoding, inter-layer mapping, and visibility scope can all affect compatibility.

    For structures that contain both local attention and global attention, the cache source and access scope must be determined separately. The same cache name does not mean the semantics are identical.

    5.3 Reduce the cost of large-vocabulary output computation

    After the main computation of a lightweight draft network is reduced, the cost of scoring the entire vocabulary at the output layer may become prominent. Hierarchical organization, candidate filtering, or cluster retrieval can be considered to reduce candidate search overhead.

    Such methods must distinguish between “accelerating candidate proposal” and “accurately computing candidate probabilities.” Some speculative sampling algorithms require draft probabilities for acceptance and correction. If vocabulary pruning changes the actual draft distribution, the algorithm must be adjusted accordingly.

    Approximate probabilities should not be used while claiming strict distributional consistency without validation.

    6. How to Determine Whether Acceleration Is Truly Effective

    Let T be the average latency of one normal target-model decoding step, D be the latency of one draft-generation round, V be verification latency, R be state-management overhead, and A be the average number of committed tokens. A rough analysis can use the following relationship:

    Speedup ≈ A × T ÷ (D + V + R)

    This relationship is not a universal performance guarantee, but it highlights several important points.

    First, a high acceptance rate does not necessarily mean high speedup. If the draft network is too expensive to run, end-to-end gains may remain limited even when most candidates are accepted.

    Second, longer drafts are not always better. Increasing candidate length expands verification computation, and farther positions are usually more likely to be rejected. Benefits may decline after a certain length.

    Third, verifying multiple positions is not free. It can reduce scheduling rounds and improve compute utilization, but it still adds actual computation and cache access.

    Fourth, single-request acceleration does not mean service throughput improves. Under high concurrency, the target model may already achieve high utilization through batching, and additional draft computation may compete for resources.

    Therefore, fixed speedup promises should not be made without considering the model, hardware, task, and service load.

    7. Validation and Tuning Workflow Before Deployment

    Step 1: Establish a reliable baseline

    With speculative decoding disabled, record time to first token, subsequent token latency, end-to-end latency, output throughput, peak memory, and device utilization.

    Tests should cover realistic input lengths, output lengths, and concurrency distributions, not just a small set of fixed short questions.

    Step 2: Verify correctness

    In greedy mode, check whether token-by-token output and stopping positions match. In stochastic sampling mode, review probability transformations and distribution-correction logic, and perform statistical tests.

    Run targeted tests for structured output, long text, special symbols, repeated fragments, and frequent early stopping. Focus on cache rollback and stopping-condition handling.

    Step 3: Sweep candidate length

    Adjust draft length incrementally and record average accepted length, distribution of the first rejection position, draft latency, and verification latency.

    If accepted length is significantly shorter than candidate length, much computation is being wasted on drafts that will never be committed. In that case, shorten candidates or improve draft prediction capability.

    Step 4: Test different workloads

    Test low-concurrency interactive use, high-concurrency serving, and long-text batch generation separately. Short responses may not amortize additional scheduling costs, while long responses are more likely to accumulate gains, but actual measurements should still determine the result.

    Tail latency should also be checked to avoid a situation where average speed improves but some requests experience noticeable jitter.

    Step 5: Establish a dynamic fallback mechanism

    When acceptance rate continues to decline, device load rises, or draft overhead becomes abnormal, candidate length can be reduced and, if necessary, the system can fall back to normal decoding.

    Dynamic strategies should use smoothed statistics to avoid frequent switching caused by single-round fluctuations. At the same time, request state must be maintained clearly so that fallback does not break cache and committed-sequence consistency.

    8. Conclusion

    The core value of multi-token prediction and speculative decoding is to combine low-cost candidate generation with high-quality target-model verification, allowing one expensive computation to advance more valid tokens.

    What ultimately determines deployment effectiveness is not a single draft-model metric but the overall coordination among candidate hit rate, verification efficiency, cache management, sampling correctness, and service load. For developers, the most reliable practice path is to locate the bottleneck first, prove correctness, then use realistic workloads to find an appropriate candidate length and runtime strategy, and finally judge the value of the scheme by end-to-end latency, throughput, and resource cost.