Speculative Decoding: Accelerating Local LLM Inference with a Draft Model

    Speculative decoding speeds up local LLM inference by using a smaller, faster draft model to propose candidate tokens and letting the target model verify multiple candidates in parallel. This article explains the memory-bandwidth bottleneck in decoding, the draft-and-verify mechanism, acceptance length as the key speedup metric, and engineering details such as vocabulary alignment, KV cache rollback, sampling consistency, concurrency trade-offs, and monitoring. It also outlines applicable boundaries and a deployment checklist for putting speculative decoding into practice.

    Speculative Decoding: Accelerating Local LLM Inference with a Draft Model

    The Bottleneck Is Data Movement, Not Compute

    Local LLM inference usually has two stages: prefill and decode. After the user enters a prompt, the model processes the entire context in the prefill stage, computes attention, and builds the KV Cache. This stage handles many tokens at once and is often more influenced by compute capacity. Once answer generation begins, the model enters the decode stage and generates one token at a time.

    The decode-stage bottleneck is typical: to generate the next token, the system must read model weights and the existing KV Cache, perform computation, and then write new key-value data back to the cache. Generating the next token repeats the process. For larger models, weights may reach tens of GB or even hundreds of GB, and a large amount of data must be moved for every token. At this point, speed is often determined not just by the number of compute units, but by memory bandwidth and data-movement efficiency. In other words, during decoding, a large model is often not so much computing itself as loading itself token by token.

    Speculative decoding changes how token generation is scheduled. It does not replace the GPU or continue compressing the target model. The core idea is to assign part of the easy-to-predict work to a smaller, faster draft model, and then let the target model focus on verifying candidate tokens. The draft model is small, so generating candidates is cheap. The target model does not need to run a full round for every token; instead, it checks multiple candidate positions in parallel through one forward pass, reducing the number of full weight reads.

    Core Mechanism: A Small Draft Model Proposes, the Large Model Verifies

    Suppose the user enters “The cat”. The draft model might propose “sat on my lap” as consecutive candidates. The target model then verifies these candidates: if the first two tokens match the target model’s probability distribution, they are accepted; the third token is rejected, subsequent candidates are discarded, and the target model generates a corrected token. Work that previously required three or four target-model rounds may now be compressed into one verification round.

    The process can be abstracted as follows:

    1. def speculative_decode(prompt, draft, target, K, max_new, sampler):
    2. ctx = prompt
    3. while len(ctx) < max_new:
    4. # The draft model autoregressively proposes K candidate tokens and their probabilities
    5. candidates, draft_probs = draft.propose(ctx, K)
    6. # The target model performs one forward pass and scores each position in the candidate prefix
    7. target_probs = target.score(ctx, candidates)
    8. accepted = []
    9. for i, token in enumerate(candidates):
    10. if sampler.accept(target_probs[i], draft_probs[i], token):
    11. accepted.append(token)
    12. else:
    13. # After rejection, sample from the corrected distribution to preserve output distribution consistency
    14. accepted.append(sampler.correct(target_probs[i], draft_probs[i]))
    15. break
    16. ctx.extend(accepted)
    17. return ctx

    This pseudocode omits engineering details, but it expresses the key point: the draft model guesses, and the target model verifies. Verification is not simply checking whether a candidate equals the target model’s greedy result. In sampling-based decoding, rejection sampling and a corrected distribution are needed so that the final output still matches the target model distribution under ideal conditions. For greedy decoding, the verification logic can be simplified to comparing whether the candidate token matches the target model’s choice. For temperature sampling, top-k, top-p, and similar scenarios, the draft and target must keep sampling parameters, random-number strategy, and vocabulary mapping consistent; otherwise, quality deviations can occur.

    Acceptance Length Sets the Speedup Ceiling

    Speculative decoding may look like a free lunch, but the metric that really determines the benefit is average acceptance length: how many draft tokens the target model accepts per round on average. If the draft model predicts four tokens at a time and three are accepted, one target-model computation advances multiple positions. If only one is accepted, or if rejection frequently happens at the first position, the draft cost plus verification cost may offset the benefit.

    As a rough estimate, if each round advances L tokens on average, the target model verification cost is C_target, and the draft generation cost is C_draft, the relative benefit depends on the ratio of “tokens advanced per round” to “total cost per round.” Because the decode stage is often limited by weight reads, verifying multiple candidates in one target-model pass increases computation but does not increase weight reads linearly with the number of candidates. Therefore, higher acceptance length is more likely to produce gains. Conversely, a larger draft length K is not always better: as K increases, draft autoregressive cost rises, the target model’s verification sequence length and attention overhead rise, and rejected candidates may be wasted.

    In engineering practice, K should be treated as a tunable parameter and adjusted dynamically based on measured acceptance length. When acceptance length is high, increase the number of candidates appropriately. When acceptance length is low, shorten the draft or reduce speculative frequency. Note also that acceptance length varies greatly across tasks, prompts, and sampling temperatures. Deterministic completion, formatted output, and code continuation are usually easier to predict. Open-ended creation, high-temperature sampling, and long-context reasoning depend more on consistency between the draft model and the target model.

    Key Engineering Details

    First, vocabulary and tokenization must be aligned. The draft model and target model need to share or strictly map the token vocabulary; otherwise, candidate tokens cannot be verified directly. Second, KV Cache management must be correct. The draft model has its own cache. After target-model verification, the cache corresponding to the accepted prefix can be retained, while rejected parts must be rolled back or discarded, and the corrected token must then be written. Implementations can use logical length, masks, and copy-on-write to manage the cache and avoid incorrect reuse that causes output drift. Third, sampling consistency requires regression testing. Numerical precision, random-number splitting, and top-p truncation order can all cause differences in an implementation that is “theoretically equivalent,” so fixed seeds and batch evaluation are needed to verify quality.

    Fourth, concurrency scenarios require a fresh benefit evaluation. In low-concurrency, single-request interactive generation, the decode stage is easily limited by memory bandwidth, and speculative decoding gains are more obvious. Under high concurrency, GPU compute gradually becomes saturated, batching already amortizes weight-read costs, and the extra computation and scheduling overhead of speculative decoding can erode gains. Existing public technical demonstrations show that specific single-request scenarios can achieve speedups close to several times, and with increased concurrency there may still be roughly a two-times throughput improvement, but actual results depend on model size, hardware, batch size, and acceptance length. Within a batch, different requests have different acceptance lengths, which can also cause mask and padding waste. Continuous batching, dynamic draft length, and per-request scheduling are needed to reduce idle work.

    Fifth, monitoring metrics should be complete. In addition to throughput and P50 latency, observe P95/P99 tail latency, average acceptance length, tokens advanced per round, draft cost share, peak memory usage, and quality regression results. It is advisable to first establish a baseline without speculative decoding, then enable features one by one; fix sampling parameters and stress-test both low and high concurrency; and run correctness tests for rejection rollback, cache reuse, long context, and edge inputs.

    Applicability and Deployment Checklist

    Speculative decoding is suitable for local interactive inference, low-concurrency generation, long-text continuation, and formatted output, provided that memory can hold both the target model and the draft model and that the draft model has some degree of match with the target task. If the target model itself is very small, draft quality is poor, concurrency has already saturated compute, or memory headroom is insufficient for a second model, gains may be limited or even negative. The draft model can be a smaller model with the same vocabulary, a domain-adapted small model, or a lightweight prediction head, but its value must be demonstrated through measured acceptance length and quality regression.

    A deployment checklist can proceed as follows: confirm memory capacity and peak usage; choose a draft model with the same vocabulary and low latency; measure baseline latency and throughput first; implement candidate generation, target verification, rejection correction, and cache rollback; fix sampling parameters and run quality regression; optimize with dynamic K and concurrency scheduling; and continuously monitor acceptance length, tail latency, and throughput. Speculative decoding is not a replacement for model capability. It is an engineering method for optimizing the token-generation path under existing hardware and model conditions. Only by handling acceptance length, sampling consistency, and cache management well can the “draft model” truly become an accelerator for local LLM inference.