Speculative Decoding for LLM Inference: Parallel Drafting and Confidence-Based Verification

    This article breaks down a speculative decoding approach for large language model inference that combines parallel drafting, lightweight sequential correction, and confidence-based verification scheduling. It explains the latency-throughput tradeoff in online serving, contrasts autoregressive and parallel draft strategies, and shows how to keep verification lossless while adapting draft length to system load. Readers will also find a four-dimension evaluation framework and a practical rollout sequence for production inference services.

    1. The Problem: Latency and Throughput Pressure in Online Inference

    Online LLM inference services are usually pulled in two conflicting directions. From the end user’s perspective, what matters is time to first token and per-token generation speed (TPS). From the server’s perspective, what matters is overall throughput and resource utilization. Batching improves throughput significantly, but it lengthens queueing and decoding time for individual requests. Shrinking the batch size improves the single-user experience but leaves compute idle.

    Speculative decoding has become a mainstream inference optimization precisely because it tries to improve both sides at once without sacrificing output quality.

    The core idea is “draft first, verify after.” A lightweight draft source proposes several candidate tokens in one shot, and the target model then performs a single parallel forward pass over those candidates, accepts the longest matching prefix, and discards and recomputes the rest. Because the target model can evaluate multiple positions in parallel, one verification step often confirms several tokens, effectively compressing the number of serial decoding steps. The critical point is that, as long as verification and sampling are designed correctly (for example, using a rejection-sampling-style acceptance rule), the final output distribution is identical to token-by-token decoding from the target model. This makes it lossless acceleration rather than approximate acceleration.

    2. Two Drafting Strategies and the Tradeoff Between Them

    In practice, draft sources fall into two broad categories.

    The first is the autoregressive draft route, typically represented in the industry by schemes that reuse multi-layer features plus a lightweight head. It generates drafts token by token, naturally models sequential dependencies, and achieves a high acceptance rate. However, the drafting stage is itself serial: producing k candidates requires k small-model forward passes, so latency grows linearly with draft length, and under high concurrency it consumes additional scheduling and memory bandwidth.

    The second is the parallel draft route, which outputs an entire candidate block in a single forward pass. Its draft cost is nearly independent of length, but it lacks modeling of dependencies between tokens. The further back a position is, the weaker its conditioning information, which produces a decay effect where “the prefix is accepted but the suffix is rejected.” The effective accepted length in practice is often well below the theoretical value.

    A pragmatic compromise is to keep the overall efficiency of parallel generation while introducing lightweight sequential modeling inside the draft, buying back suffix acceptance at very little extra cost. The structure can be expressed as the following pseudocode:

    1. # Parallel drafting + lightweight sequential correction + confidence-scheduled verification
    2. draft = parallel_head(prefix_hidden) # one forward pass produces k candidates
    3. for i in range(1, k): # in-block sequential correction only, far cheaper than full autoregression
    4. draft[i] = sequential_head(prefix_hidden, draft[:i])
    5. accept_len = 0
    6. for i, tok in enumerate(draft):
    7. p = target_model.logits(prefix + draft[:i])[i]
    8. if accept(tok, p): # acceptance rule that preserves the target distribution
    9. accept_len += 1
    10. else:
    11. break
    12. verify_len = schedule(confidence(draft), system_load) # dynamically decide the verification prefix length

    3. Three Key Design Points

    3.1 Parallel Draft Generation: From Linear Cost to Near-Constant Cost

    A parallel draft head shares the upper-layer hidden states of the target model and produces the whole candidate block in one forward pass, making draft overhead insensitive to block length. The engineering benefit is that drafting no longer competes for the critical path, so the scheduler can concentrate compute on the verification stage, whose parallelism is exactly the shape that GPU-class accelerators handle best.

    3.2 Semi-Autoregressive Correction: In-Block Dependencies Only, Not Full Serial Decoding

    Semi-autoregressive generation runs in parallel across blocks while modeling dependencies within a block through a sequential head. Compared with fully autoregressive drafting, it avoids the token-by-token serial chain; compared with purely parallel drafting, it mitigates suffix rejection caused by insufficient conditioning. In practice this layer is usually kept very “light,” for example by reusing the same hidden states, sharing parameters, and limiting the number of correction steps, so the extra latency stays controllable. When evaluating such designs, two metrics matter: average accepted length (the number of tokens confirmed per verification round) and the draft amplification factor (the ratio of draft length to verification cost). Together they determine the net gain.

    3.3 Confidence-Scheduled Verification: Adapting Verification Length to Load

    A fixed draft length is not optimal under real traffic. When confidence is low, extra candidates only waste verification compute; under high load, an overly long verification makes queueing worse. Confidence-scheduled verification uses the estimated probability that each candidate will be accepted by the target model together with the current system load to dynamically trim the prefix length sent to verification, reducing wasted verification work. The decision logic can be abstracted as:

    1. If mean confidence is high and system load is low -> lengthen the verification prefix to pursue a longer acceptance chain
    2. If mean confidence is low or system load is high -> shorten the verification prefix to cut wasted compute and queueing

    The value of this mechanism is that it turns the speedup ratio from a static hyperparameter into a runtime policy that self-adjusts with traffic, which matters especially for online services with pronounced peaks and troughs.

    4. How to Evaluate Such a Solution

    Evaluating this kind of solution on a single-point TPS number is not enough. A four-dimension evaluation framework is recommended:

    • Quality: consistency between the verified output distribution and the target model, plus no degradation on downstream task metrics;
    • Latency: per-user TPS, time to first token, and tail P99;
    • Throughput: requests per second under a fixed SLA and accelerator utilization;
    • Stability: fluctuation in accepted length across different load levels and input length distributions.

    It is worth noting that any specific speedup figure depends heavily on model size, draft head structure, batching strategy, and hardware. Cross-scheme comparisons must be run on the same target model, the same dataset, and the same serving configuration; otherwise the numbers are not comparable.

    5. Deployment Recommendations

    To put this technique into practice in your own inference service, a reasonable order is: first establish baseline load testing and a metrics dashboard (log services and monitoring/alerting capabilities help accumulate the data); then use an offline dataset to measure the accepted length distribution and set initial values for draft block length and correction steps; next, enable the dynamic scheduling policy and feed load signals into the verification length decision; finally, observe tail latency and resource watermarks in a small-traffic canary and ramp up gradually. For deployment shape, a container platform handles elastic scaling, a message queue absorbs request spikes, and object storage holds evaluation samples and versioned artifacts. Combined, these general-purpose capabilities support a rollback-capable acceleration rollout. Baidu AI Cloud likewise emphasizes observability and canary releases to keep such inference optimization changes smooth.

    6. Conclusion

    From autoregressive drafting to parallel drafting, and then to parallel generation with lightweight sequential correction and confidence-scheduled verification, the throughline of this evolution is finding a better tradeoff among draft cost, accepted length, and verification cost. For developers, what really needs to be mastered is not a specific implementation but this evaluation and tuning methodology: take losslessness as the premise, accepted length as the optimization target, and load adaptivity as the landing point, so that inference speedup gains can be captured reliably under real traffic.