Speculative Decoding with Dynamic Draft Models: An Inference Optimization Practice for Large Language Models

    This article explains how speculative decoding can speed up large language model inference. A smaller draft model proposes candidate tokens, and the target model verifies them in batches. The article covers the core workflow, dynamic draft path selection based on acceptance rate and context entropy, key performance metrics, common deployment issues, and a recommended validation process.

    1. Technical Background: From Autoregressive Generation to Speculative Decoding

    Large language models usually generate text autoregressively. At each step, the model predicts only the next token and appends it to the context before the next computation. This process is strictly sequential. Even when hardware offers high parallel compute capacity, the generation stage remains limited by the need to wait for each token.

    When the input context is long, the output is lengthy, or the service handles high concurrency, this serial approach tends to cause the following problems:

    1. Frequent single-step computation launches: Each generated token triggers a decoding pass, so scheduling and memory access overhead accumulates.
    2. Underused compute resources: The compute workload in the generation stage is typically smaller than in the prefill stage, so part of the available compute may not be fully used.
    3. Compounding latency: Latency at each step adds up to the final result, which directly affects how fast the model continues generating after the first token.
    4. Clear resource contention under high concurrency: When many requests decode at the same time, memory bandwidth, cache space, and scheduling queues easily become bottlenecks.

    The core idea of speculative decoding is to introduce a lower-cost draft model. The draft model quickly generates a sequence of candidate tokens, and then the more capable target model verifies them in a batch. If a large share of the candidate sequence passes verification, one target model computation can replace several token-by-token computations. This improves overall generation efficiency.

    2. Basic Workflow of Speculative Decoding

    A complete speculative decoding process typically includes four stages.

    1. Draft Generation

    The draft model generates several candidate tokens in sequence based on the current context. Compared with the target model, the draft model has fewer parameters or lower computational complexity, so it can predict the candidate sequence faster.

    The draft model does not need to be fully independent of the target model. In practice, the two models usually need compatible vocabularies, positional encoding methods, and input formats so that the target model can verify the draft output directly.

    2. Batch Verification

    The target model receives the original context and the candidate tokens from the draft model. In one or a few computation steps, it checks in parallel whether each token fits its own probability distribution.

    Verification can produce the following outcomes:

    • Several candidate tokens are accepted in a row;
    • A candidate token is rejected at some position;
    • A prefix is accepted, and the subsequent tokens are resampled;
    • All candidate tokens pass, and generation continues with new content.

    Speculative decoding does not accept draft output unconditionally. The target model makes the final decision. As long as the verification mechanism is implemented correctly, output quality stays within the standard of the target model.

    3. Acceptance and Rollback

    When the target model finds that a candidate token differs from its own prediction, the system must roll back at the rejected position and continue generation with the target model’s output. This process is key to the correctness of speculative decoding.

    If the distribution difference between the draft and target models is large, the acceptance rate drops. The system then rolls back often, and the extra verification cost may offset the speedup. Therefore, the optimization goal of speculative decoding is not simply to raise draft generation speed. It also has to balance candidate quality with the verification efficiency of the target model.

    4. Iterative Execution

    After each verification round, the system writes the confirmed tokens back into the context and starts the next round of draft generation and target verification. This continues until a stop condition is met. Stop conditions can include an end-of-sequence token, reaching the maximum output length, or request cancellation.

    3. Design of Dynamic Path Selection

    A fixed-length draft sequence is simple to implement, but it does not suit every text scenario. Different contexts have different levels of uncertainty. In low-entropy scenarios, the model’s prediction of the next token is stable, so the draft model can more easily predict several tokens correctly in a row. In high-entropy scenarios, the candidate distribution is more spread out, and an overly long draft sequence can lead to a higher rejection rate.

    Dynamic draft strategies can therefore adjust the generation path based on runtime conditions. They mainly consider the following factors:

    1. Adjusting Draft Length Based on Historical Acceptance Rate

    The system can track the number of accepted tokens in recent verification rounds and use that to estimate whether the current context suits a longer draft.

    • When the acceptance rate is high, the draft length can increase to reduce the number of target model calls.
    • When the acceptance rate drops, the candidate sequence should be shortened to reduce wasted computation.
    • When the acceptance rate fluctuates continuously, a conservative length can be used to avoid the scheduling overhead of frequent adjustments.

    2. Selecting a Path Based on Context Uncertainty

    The entropy of the token distribution can serve as an uncertainty indicator. Low entropy means the model favors a few candidates, so the draft model is more likely to hit. High entropy means the prediction is highly uncertain. In that case, the speculative window should be shortened, or the system should use the standard decoding path directly.

    Entropy alone does not determine the whole strategy. An engineering implementation also needs to consider the draft model’s historical performance, the target model’s verification latency, current concurrency, and GPU memory status.

    3. Scheduling by Request Type

    In online inference services, different requests have different goals. Some requests prioritize low latency, while others care more about overall throughput. Dynamic path selection can apply different strategies by request type:

    • Low-concurrency interactive requests: prioritize reducing per-response latency;
    • Batch generation requests: prioritize overall throughput;
    • Long-context requests: focus on controlling cache and GPU memory usage;
    • High-uncertainty tasks: avoid relying too heavily on draft predictions.

    4. Key Metrics for Performance Optimization

    Evaluating speculative decoding should not rely on a single token speed. A multi-dimensional set of metrics is needed.

    1. Single-Request Decoding Speed

    In single-concurrency scenarios, record the number of tokens generated per unit time. This measures the sustained output speed that users perceive. In the reported tests, under specific conditions (a particular target model, hardware count, tensor parallel configuration, and a long, low-entropy context), single-concurrency speed reached about 288.2 tokens/s. That is roughly 3.41 times the speed of native autoregressive decoding.

    These figures reflect only the specific experimental conditions. They should not be extrapolated to all models, tasks, or hardware environments. In actual deployment, also record time to first token, end-to-end latency, and sustained speed across different output lengths.

    2. Concurrent Throughput

    Under high concurrency, measure the total number of tokens generated per unit time across all requests. The reported tests showed that at 64 concurrent requests, total throughput reached about 608.71 tokens/s, about 44.9% higher than the native approach.

    A large gain in single-request speed paired with a smaller gain in total throughput usually means the system hits shared resource limits as concurrency increases. Those limits can include memory bandwidth, cache capacity, scheduling overhead, or compute saturation during target model verification.

    3. Candidate Acceptance Rate

    The acceptance rate is one of the main indicators of draft model effectiveness. It can be defined as:

    1. Acceptance rate = Number of draft tokens confirmed by the target model / Total number of candidate tokens generated by the draft model

    A higher acceptance rate means each target model verification confirms more tokens, so the benefit of speculative decoding is usually larger. However, the acceptance rate must be analyzed together with draft generation time. If the draft model is very slow, the overall benefit may remain limited even with a high acceptance rate.

    4. Resource Utilization

    Monitor target model compute utilization, draft model compute utilization, GPU memory usage, memory bandwidth, cache hit rate, and run queue length separately. Only when the bottleneck is clear can you determine whether the problem comes from the model architecture, the inference runtime, the parallelism strategy, or the hardware.

    5. Common Issues in Engineering Deployment

    1. Incompatibility Between Draft and Target Models

    If the two models use different vocabularies, positional handling, or input formats, verification results may be abnormal. Before deployment, establish unified input and output constraints, and specifically test boundary tokens, stop tokens, and special characters.

    2. High Cost of Switching Dynamic Strategies

    Dynamic path selection itself adds decision overhead. If every token triggers complex analysis, that overhead can offset the gains of speculative decoding. Strategy decisions should therefore be lightweight, using sliding windows, seg