Speculative Decoding for Faster Large Language Model Inference

    Speculative decoding accelerates autoregressive generation by using a lightweight draft model to propose multiple tokens and a larger target model to verify them in parallel. This article explains the architecture, semi-autoregressive generation process, confidence-aware scheduling, reported evaluation results, and the engineering considerations required to achieve reliable gains in production services.

    1. Technical Background: Why LLM Inference Is Constrained by Sequential Generation

    Large language models typically generate text autoregressively. At each step, the model predicts the next token from the existing context, appends that token to the input sequence, and then performs the next round of computation. Because token (t+1) depends on token (t), generation naturally has strong sequential dependencies.

    This limitation is relatively modest for smaller models, but it becomes significant in large-scale model serving. Generating a single token may require computation across many network layers, along with memory access, matrix operations, scheduling, and communication overhead. For requests that produce long outputs, the user-perceived latency mainly comes from repeated token-by-token generation rather than the time required to return the first token.

    Production systems commonly use batching, continuous batching, cache reuse, and operator fusion to improve overall throughput. However, higher throughput does not necessarily make each individual request complete faster. Under high concurrency, service operators must often balance processing more requests per unit of time against reducing the completion time of each request.

    The core idea of speculative decoding is to introduce a less expensive draft-generation module without changing the target model’s final output logic. The draft module proposes multiple tokens in advance, and the target model verifies those candidates in parallel. If the candidates have a high acceptance rate, the target model can confirm several tokens in a single forward pass, reducing the number of sequential iterations.

    2. Overall Architecture: Coordinating Draft Generation and Target Verification

    A complete speculative decoding pipeline usually contains two roles:

    1. Draft module: A smaller and faster model that predicts a sequence of candidate tokens from the current context.
    2. Target model: A larger model responsible for final output quality and for verifying or correcting the candidates.

    The basic workflow is:

    1. Input context
    2. ↓
    3. Draft module generates candidate tokens
    4. ↓
    5. Target model computes candidate positions in parallel
    6. ↓
    7. Candidate tokens are accepted or rejected according to verification rules
    8. ↓
    9. Confirmed tokens are retained and the next speculation round begins

    Let the current context be (x), and let the draft module generate:

    [
    y_1, y_2, \ldots, y_k
    ]

    The target model then evaluates these positions together. If the first several candidates are consistent with the target model’s distribution or sampling result, they can be accepted directly. Once a mismatch occurs, the later candidates are usually discarded, and generation resumes from the first inconsistent position.

    Speculative decoding does not simply skip the target model. Instead, it transforms the target model’s repeated sequential computations into one or a small number of batched verification steps. The speedup primarily depends on two factors:

    • The speed at which the draft module generates candidate tokens;
    • The number of consecutive candidates accepted by the target model.

    The more tokens accepted per round on average, the greater the benefit. If candidate quality is poor and the target model frequently rejects proposals, the additional draft computation may offset part of the gain.

    3. Semi-Autoregressive Generation: Balancing Sequential Dependencies and Parallel Computation

    Pure autoregressive generation requires every token to wait for the previous token, while fully parallel generation makes it difficult to maintain language quality and contextual consistency. Semi-autoregressive generation seeks a balance between these two approaches.

    In this architecture, the draft module generates multiple candidate tokens sequentially within a local window, while the target model processes those candidate positions as a batch. The candidate-generation stage retains the necessary sequential dependencies, whereas the verification stage uses parallel hardware as much as possible.

    This design provides three key benefits.

    1. Fewer Sequential Calls to the Target Model

    If the target model can confirm only one token per step, generating ten tokens requires multiple iterations. When the draft module proposes several candidates at once and the target model accepts most of them consecutively, the number of target-model scheduling events and generation loops can be reduced substantially.

    2. Better Hardware Utilization

    The target model is generally more efficient when processing workloads with sufficient batch size and sequence length. By grouping multiple candidate positions into one forward pass, speculative decoding can improve utilization of matrix-computation units and reduce fixed scheduling overhead per operation.

    3. Preserved Quality Control by the Target Model

    The target model remains responsible for confirming the final results, so the draft module does not need to replace it completely. The draft module acts as a fast proposal mechanism, while the target model serves as the quality-control and decision-making component.

    4. Confidence-Aware Scheduling: Candidate Verification Should Not Be Uniform

    Candidate tokens do not all have the same level of reliability. Common words, formatting symbols, and stable grammatical structures are often easier for the target model to accept. Professional terminology, long-range dependencies, code, numerical expressions, and semantic transitions may have greater uncertainty.

    As a result, a fixed candidate length and fixed threshold are not always optimal. A hardware-aware confidence scheduler may consider:

    • The draft module’s confidence in each candidate token;
    • The continuity of acceptance within the current candidate sequence;
    • Available target-model compute resources;
    • Current request concurrency and queueing delay;
    • The effect of candidate length on memory usage and batching efficiency;
    • Whether the task prioritizes accuracy or latency.

    For example, if the draft module has high confidence in the first several candidates, the candidate window can be expanded. If confidence drops rapidly, the window should be shortened to avoid generating many candidates that will ultimately be rejected.

    “Hardware-aware” means that scheduling decisions are based not only on model probabilities but also on the actual state of the serving device. Under high concurrency, increasing the batch size may improve overall throughput. However, when memory is constrained or request latency is already high, an excessively long candidate sequence may increase cache pressure and scheduling contention.

    An effective scheduler therefore needs to balance three categories of cost:

    [
    \text{Total cost} = \text{Draft generation cost} + \text{Target verification cost} + \text{Scheduling and cache overhead}
    ]

    Speculative decoding produces a practical benefit only when the reduction in sequential iterations is greater than these additional costs.

    5. Public Evaluation Results and Their Interpretation

    According to the available public evaluation results, tests on a series of target models showed that the average acceptance length increased by approximately 26.7% to 30.9% compared with one common speculative decoding approach, and by approximately 16.3% to 18.4% compared with another.

    A higher average acceptance length means that more candidate tokens can be confirmed consecutively in each speculation round. This is an important indicator of speculative decoding efficiency.

    In production serving scenarios, compared with a single-token generation baseline and while maintaining similar overall throughput, user-side generation speed increased by approximately 60% to 85% for lightweight model variants. For higher-capability model variants, the improvement was approximately 57% to 78%.

    These figures should not be interpreted as fixed acceleration rates for every workload. Actual results depend on many factors, including:

    • Input context length;
    • Output length;
    • Request concurrency;
    • Compatibility between the draft module and target model;
    • Task type, such as chat, summarization, code generation, or structured output;
    • Sampling parameters and randomness;
    • Device model, memory capacity, and batching strategy;
    • Server-side queueing and network transfer overhead.

    Engineering teams should therefore evaluate more than average generation speed. Important metrics include time to first token, end-to-end latency, P50/P95/P99 latency, acceptance rate, memory usage, target-model utilization, and the rate of error-triggered retries.

    6. Key Engineering Considerations for Production Deployment

    1. Matching the Draft Module with the Target Model

    The smallest draft module is not necessarily the best choice. A model that is too small may generate candidates quickly but with low quality, while a model that is too large may eliminate the cost advantage of speculative decoding. The combination should be evaluated according to the target model’s size, task type, and available hardware resources.

    2. Cache Management

    Speculative decoding simultaneously maintains context state, candidate state, and verification state. Poor cache management can increase memory consumption and cause request instability under high concurrency.

    Deployments should pay particular attention to cache reuse, candidate rollback, sequence truncation, and resource release when requests are canceled.

    3. Dynamic Batching

    Speculative decoding does not require every request to use the same candidate length. A serving system can adjust the strategy dynamically according to concurrency, request priority, and historical acceptance rates.

    For short requests, excessive speculation may add unnecessary overhead. For long-form generation, the benefits of batched verification are more likely to become apparent.

    4. Output-Consistency Verification

    If the system is expected to remain distributionally consistent with ordinary decoding, candidate acceptance, rejection, and correction rules must be implemented precisely.

    This is particularly important for random sampling. Random-number management, distribution correction, and fallback paths must be clearly defined to prevent implementation differences from unintentionally changing the output distribution.

    5. Monitoring and Failure Fallback

    An online system should continuously record candidate acceptance rate, average acceptance length, draft-generation time, verification time, fallback count, and memory utilization.

    When the acceptance rate declines persistently or the additional overhead exceeds the benefit, the system can automatically switch to a shorter candidate window. If necessary, it can fall back to the standard autoregressive generation path.

    7. Suitable Use Cases and Limitations

    Speculative decoding is generally better suited to scenarios with:

    • Long outputs;
    • High target-model computation costs;
    • High request volumes;
    • Strong local language regularities;
    • A need to improve the experience of continuous output streaming.

    The benefits may be limited for very short responses, highly random sampling, low candidate acceptance rates, or relatively small target models. In addition, speculative decoding mainly optimizes the generation stage and provides limited help during prompt encoding. It should therefore not be treated as a universal solution for every type of latency.

    It is also important to distinguish between improving single-user generation speed and increasing total system throughput. If more compute resources are allocated to improving the experience of individual requests, more careful batching and queue scheduling may be required to prevent a decline in overall serving capacity.

    8. Conclusion

    Speculative decoding uses a lightweight module for prediction and a more capable target model for verification. By confirming multiple candidate tokens in batches, it reduces the number of sequential loops required by conventional autoregressive generation. Semi-autoregressive generation provides the foundation for parallel execution, while confidence-aware scheduling dynamically balances candidate quality, hardware resources, and service latency.

    From an engineering perspective, speculative decoding is not simply a matter of adding a draft model. It is a complete inference-optimization approach involving model matching, candidate scheduling, cache management, batching, output-consistency control, production monitoring, and fallback handling.

    Only when acceptance rate, scheduling overhead, and hardware utilization are balanced consistently can the theoretical benefits of parallel verification translate into measurable improvements in real-world user experience.