Speculative Decoding for LLM Inference: Principles, Measurement, and Practical Trade-offs

    This article explains how speculative decoding speeds up LLM inference. It covers the metrics needed to measure generation speed fairly, why autoregressive decoding is serial, how draft and target models verify candidate tokens, and how output quality, cost, and serving conditions affect real gains. It also outlines a method for running fair benchmarks.

    1. Define a Consistent Measurement Before Comparing Speeds

    “What is your tokens-per-second rate?” is a common question in LLM deployment, but a single speed number says little about real performance. Even with models of the same parameter size, hardware, numerical precision, context length, and serving configuration can produce large differences.

    One practical observation reported a jump from about 40 tokens/s to nearly 120 tokens/s when a draft model worked with a target model. This shows what happened in one setup. Without the hardware configuration, test workload, statistical method, and output quality checks, the result cannot be treated as a reproducible performance guarantee.

    To discuss this kind of speedup, you need to separate at least the following metrics.

    1. Time to First Token

    Time to first token (TTFT) is the time from sending a request to receiving the first output token. It can include request queuing, input processing, prompt computation, and the first decoding step.

    In long-document analysis, input processing can take a large share of this time. Even when generation speeds up significantly, the wait before the user sees the first part of the answer may not shrink by the same amount.

    2. Decoding-Phase Generation Speed

    This metric measures how many tokens are generated per unit of time after the model starts producing output. It suits analysis of token-by-token generation efficiency, and speculative decoding affects it most directly.

    When you measure it, specify whether input processing time is excluded, whether only tokens that are delivered in the final output are counted, and whether the compute spent on rejected drafts is included in the elapsed time. Discarded candidates must not count as valid output.

    3. Overall Service Throughput

    Overall throughput usually means the total number of tokens a service delivers in a given period. It is a different concept from the speed of a single request.

    Larger batch sizes can raise overall throughput but increase the wait time for each request. Reducing the number of decoding rounds per request can also add extra draft computation. Interactive experience and service capacity should therefore be evaluated separately.

    2. Why Traditional Autoregressive Decoding Has a Serial Bottleneck

    An autoregressive model usually predicts the next token from the existing context, appends that token to the context, and then predicts the next one.

    This process has a clear dependency: each later token depends on the earlier ones. Even when the model can run many computations in parallel internally, the output sequence still advances serially.

    During token-by-token decoding, the system repeatedly handles model weight access, attention computation, cache reads, task scheduling, and synchronization. In some low-batch inference scenarios, memory bandwidth and weight movement can become bottlenecks before raw arithmetic capacity does.

    Speedup therefore does not have to come only from making a single computation faster. Another option is to have one relatively expensive target model pass confirm several output positions, which reduces the number of serial rounds needed to generate the same amount of text.

    Speculative decoding is built around this idea.

    3. The Core of Speculative Decoding: Propose Candidates, Then Verify

    Speculative decoding generally involves two roles:

    • Draft model: predicts a sequence of candidate tokens at a lower cost.
    • Target model: verifies the candidates and decides the final output.

    The draft model is not a document retriever in the sense of a search engine. More precisely, it is a candidate sequence proposer. Based on the current context, it quickly generates continuations that the target model may accept.

    1. Draft Phase: Propose Consecutive Candidates at Low Cost

    Assume the current context is fixed. The draft model then predicts several tokens in sequence, producing a candidate sequence.

    The closer the candidates are to the target model’s predictions, the more of them are usually accepted. The draft model still needs compute time and memory, so its cost cannot be ignored just because the model is smaller.

    2. Verification Phase: Process Multiple Candidate Positions at Once

    The target model runs one forward pass over the candidate sequence and produces the predicted distribution at each candidate position.

    Because the candidates have already been proposed, the target model can use causal attention to process several positions in one forward pass. Ordinary generation, by contrast, advances the target model once for each confirmed token.

    This does not mean generation has become fully parallel, and it does not mean the target model can independently decide any number of future tokens at once. It only organizes the verification of proposed candidates into a more efficient computation.

    3. Acceptance and Correction: Keep Accepted Prefixes

    Candidates are usually verified in order. When a position fails the acceptance condition, the prefix accepted before it can be kept. The rejected position and the unconfirmed candidates after it cannot become final output.

    The system then generates a correction token according to the applicable rule and continues to the next round. Therefore, the claim that one wrong guess forces recomputation of everything before it does not accurately describe speculative decoding.

    When the entire candidate sequence is accepted, some standard procedures can use the distribution from this verification pass to produce one additional token. How this is handled depends on the decoding algorithm and cache implementation. Not every approach produces a fixed number of extra tokens.

    4. Does Speculative Decoding Change Output Quality?

    To understand speculative decoding, you must distinguish greedy decoding from random sampling.

    1. Consistency in Greedy Decoding

    Greedy decoding selects the token with the highest probability under the target model at each step. A draft candidate is accepted only if it matches the target model’s choice.

    If the implementation is correct and the numerical and execution conditions match, speculative decoding can preserve the target model’s greedy output. However, different numerical precision, operator paths, or numerical error can still affect choices between tokens with nearly equal probabilities.

    2. Probability Correction in Random Sampling

    Random sampling cannot be handled by accepting a draft token whenever it equals the token the target model sampled, resampling otherwise, and then claiming the distribution is unchanged.

    Exact speculative sampling uses the relationship between the target distribution and the draft distribution to compute an acceptance probability. When a candidate is rejected, the system must sample from a corresponding correction distribution.

    If the algorithm’s prerequisites are met and it is implemented correctly, this approach can preserve the target model’s original sampling distribution. If an implementation uses an approximate acceptance rule for speed, its effect on output quality and distribution should be evaluated separately.

    So assessing a scheme requires more than checking speed. You also need to confirm which verification rule it uses, whether it keeps the original sampling semantics, and whether the tests used the same sampling configuration.

    5. Factors That Together Determine the Speedup

    The gain from speculative decoding comes from the target model running fewer rounds. The costs come from draft generation, batched verification, and state management.

    The following simplified relationship helps explain it:

    Effective generation speed ≈ final tokens kept per round ÷ total time per round

    Total time per round includes at least:

    • the time the draft model takes to generate candidates;
    • the time the target model takes to verify candidates;
    • the time for acceptance decisions and sampling;
    • the time for cache updates, rollback, and scheduling.

    This relationship is not a precise performance prediction formula. It does help identify the main bottlenecks.

    1. A High Acceptance Rate Does Not Guarantee Speedup

    If the draft model closely matches the target model, the acceptance rate may be high. However, if drafting is expensive, the target model time it saves may be offset by that cost.

    A more useful metric is how much valid output each unit of extra computation produces, rather than the highest possible acceptance rate in isolation.

    2. Longer Drafts Do Not Always Give Bigger Gains

    A longer draft gives one verification pass the chance to confirm more tokens. It also increases draft computation, verification computation, and cache usage.

    If rejection happens early, the computation spent on later candidates may produce no valid output. The draft length should be determined by measuring real workloads, not by simply increasing it.

    3. Task Distribution Affects Acceptance

    Different tasks have different prediction difficulty and different text patterns. Outputs with stable structure may be easier for a draft model to predict accurately. Open-ended writing, complex reasoning, or specialized domain content may behave differently.

    These are general influencing factors and cannot replace measurement. Evaluation should cover the prompt types and output lengths used in your actual business workloads.

    4. High Concurrency Can Change the Cost Structure

    When batching already keeps the target model’s hardware highly utilized, the extra computation from the draft model may compete with the target model for resources. This can reduce the marginal benefit of speculative decoding.

    Results measured at low concurrency should not be extrapolated directly to high-concurrency serving.

    6. Key Engineering Details

    1. Consistency of the Attention Key-Value Cache

    Inference services usually use an attention key-value cache to avoid recomputing historical context. In speculative decoding, candidates take part in verification but are not always accepted.

    The implementation must clearly separate confirmed state from staged state. After a rejection, subsequent computation must depend only on the valid prefix, so unaccepted candidates do not contaminate later context.

    The draft and target models usually maintain their own states. You must keep them synchronized on the confirmed text.

    2. Controlling Cache and Memory Overhead

    The draft model’s weights, its separate cache, and the staging area for candidates all consume resources. Even when the target model decodes faster, the extra memory use can reduce the number of concurrent requests the service can support.

    Rollout evaluation should record peak GPU memory, request capacity, and overall throughput together. Reporting single-request speed alone is not enough.

    3. Reducing Scheduling Overhead Outside Verification

    Probability checks, data transfers between devices, cache maintenance, and task submission can all affect real gains. If these steps synchronize often or move large amounts of data, the algorithmic advantage can be weakened by engineering overhead.

    Optimization should follow profiling results. First identify where the time goes, then choose the optimization direction.

    4. Keep a Disable and Fallback Path

    Not every workload benefits from speculative decoding. A production system should be able to turn off the speculative path and return to standard decoding when the acceptance rate is low, resources are tight, or stability problems appear.

    If you use dynamic draft lengths, validate the adjustment policy through experiments. Frequent switching can add overhead and cause performance fluctuations.

    7. How to Run a Credible Comparison Test

    Set up two experiment groups, one with standard decoding and one with speculative decoding. Keep the target model, hardware, numerical precision, input data, and sampling configuration the same.

    Test at least the following dimensions:

    1. Input length: short, medium, and long inputs.
    2. Output length: short answers and long-form generation.
    3. Concurrency: single request, typical business concurrency, and high load.
    4. Task type: question answering, summarization, structured output, and domain-specific tasks.
    5. Runtime state: clearly distinguish cold start, warmed-up operation, and cache-hit conditions.

    The report should include time to first token, end-to-end latency, effective generation speed, overall throughput, resource usage, and output quality validation results. For latency, report the median and high percentiles so that any long-tail variation is visible.

    For random sampling, you cannot judge correctness by checking whether two outputs match, because the target model itself may produce different results. Validate with algorithm checks, distribution tests, and task quality evaluation.

    8. Conclusion: Focus on Useful Output per Round, Not a Single Speed Number

    The core idea of speculative decoding is to use cheap candidate generation to give an expensive target model the chance to confirm several tokens at once. It does not simply let a small model replace a large one. It does not accept every draft unconditionally, and it does not recompute all prior output after a rejection.

    The result of moving from about 40 tokens/s to nearly 120 tokens/s suggests this optimization direction can offer substantial potential. The speed difference is useful only when the test conditions are complete and the quality constraints are consistent.

    Developers need to answer three questions: how many valid tokens each round keeps, how much extra compute the scheme costs, and whether the gains hold under real business concurrency and task distributions. Evaluating algorithm correctness, resource cost, and user experience together turns speculative decoding from a promising experiment into a reliable inference optimization.