LLM Inference Speed: How Speculative Decoding Works and What Changes with Long Context

    This article breaks down why tokens/s numbers vary so much across setups, explains what speculative decoding actually saves, and shows how parallel drafting and long context reshape the gains. It includes a minimal benchmarking template, the round-time and speedup formulas, a note on precision and quantization as an underrated variable, and a practical tuning checklist for reproducible evaluation.

    1. Where the Problem Starts: Why Reported Speeds Differ So Much

    When people discuss decoding speed for a large model in community threads, the typical reply is a one-line conclusion plus a hardware list. In reality, at least five groups of variables determine tokens/s: model precision and quantization scheme, context length, batching strategy, whether speculative decoding is enabled, and the scheduling overhead of the runtime framework. Change any one of them and the number can swing by a multiple. The right way to discuss speed is to fix the measurement conditions first, then compare side by side.

    A minimal recording template:

    1. Hardware: accelerator model, memory capacity, interconnect
    2. Software: inference framework and version, driver and runtime versions
    3. Load settings: weight precision/quantization format, context limit, KV cache strategy
    4. Decoding settings: speculative decoding on/off, draft length, sampling temperature
    5. Metrics: time to first token, decode-phase tokens/s, average accepted length

    Numbers are only comparable if you also state the input length range and the output length range. Long-context continuation and short-request generation usually do not sit in the same order of magnitude.

    2. What Speculative Decoding Actually Saves

    Standard autoregressive decoding advances one token per round. At small batch sizes, every step moves the entire set of weights from memory into the compute units, arithmetic intensity is low, compute is often underutilized, and the bottleneck sits in memory bandwidth. Speculative decoding works like this: a lighter draft model proposes several candidate tokens in one pass, the target model verifies them in a single parallel pass, only the continuously accepted prefix is kept, and one extra token is produced.

    The key property: as long as verification and sampling rules are designed correctly, the output distribution matches token-by-token decoding from the target model, so the speedup does not change generation quality. What is saved is the repeated weight reads of multiple target-model forward passes, not precision.

    Let τ be the average number of tokens actually advanced per round (including the extra token the target model produces). Round time has four components:

    1. T_round ≈ T_draft + T_verify + T_sample + T_other
    2. speedup ≈ τ / (T_draft + T_verify + T_sample + T_other) × T_ar

    This explains a common misconception: a longer accepted length only enlarges the numerator. If drafting and verification themselves become more expensive, the denominator grows in step and the end-to-end gain is eaten up. Publicly reported research generally shows that verification takes the largest share of round time (commonly around seventy percent), so “a smarter draft head” and “cheaper verification” have to be optimized together.

    3. Parallel Drafting: Building Dependencies Along Network Depth

    Early approaches had the draft model emit tokens autoregressively one by one, so the drafting stage was itself serial over multiple rounds and the benefit was limited. Later, “draft an entire block in one forward pass” reduced drafting cost to a constant, but tokens inside the block lacked explicit dependencies, so accepted length stayed low.

    A natural improvement: at each layer of the draft model, incorporate the current predicted features of the later position from the earlier position, so dependencies between tokens propagate layer by layer along network depth. This keeps the low cost of drafting a whole block in one forward pass while improving the coherence of candidates inside the block. Public papers report gains of over twenty percent in average accepted length and over twenty percent in throughput on medium-sized models. Results like these show the direction works, but you still need to re-measure on your own model and configuration.

    4. Long Context Is the Real Dividing Line

    Good decode speed on short requests does not represent real workloads. For applications such as coding assistants and code agents, input length keeps growing, repository-level context often approaches the order of one hundred thousand tokens, and output is usually an irregular mix of code and natural language. Three things change here:

    1. KV cache read volume grows linearly with context, raising the marginal cost of the verification stage;
    2. output predictability drops, so average accepted length falls back;
    3. scheduling and state maintenance take a more visible share of round time.

    So an evaluation plan should cover at least three tiers: short requests, medium context, and long continuation close to the context limit. In public re-measurements, decode speed on short requests reached several hundred tokens per second, while long continuation at the hundred-thousand-token level often fell back to just over one hundred tokens per second, still about a threefold improvement over pure autoregressive decoding. That comparison is the useful input for capacity planning.

    5. Precision and Quantization: The Underrated Variable

    Speed differences for the same model across numeric formats often exceed the differences introduced by the decoding strategy. Low-bit quantization reduces the volume of weight movement and directly eases the bandwidth bottleneck; mixed-precision schemes keep higher precision on sensitive layers in exchange for stable output quality. Practical advice:

    • Fix the quality floor first, then pick the fastest format that satisfies it;
    • pay attention to the storage format of the KV cache after quantization, since this overhead is not negligible under long context;
    • re-run the same evaluation set after any change, and avoid treating framework defaults as the optimum.

    In cloud environments, general-purpose capabilities such as container platforms, image registries, and monitoring and alerting make experiments reproducible: pin the image version, freeze the configuration list, and collect time to first token and tokens/s into log services and monitoring dashboards. Only then do you get a baseline that supports continuous comparison.

    6. A Tuning Checklist You Can Apply

    1. 1. Fix the evaluation conditions: bucket input/output lengths, record precision and context limit
    2. 2. Tune the baseline first: batch size, KV cache strategy, memory usage cap
    3. 3. Then enable speculative decoding: start with a shorter draft length and increase gradually
    4. 4. Watch the two curves for τ and T_verify to find the point where gains level off
    5. 5. Evaluate long context separately; do not mix it with short requests in one table
    6. 6. Log every change and build a configuration-to-metrics comparison table

    7. Conclusion

    Decoding speed is not a single number that can be discussed apart from configuration. Speculative decoding delivers steady gains in small-batch, bandwidth-bound scenarios through “cheap drafting plus parallel verification,” and it works without changing the output distribution; drafting an entire block in parallel and injecting position features along depth further improves accepted length. Real engineering judgment, though, has to land on long context, the actual output distribution, and your own hardware: write the measurement conditions down clearly and look at numerator and denominator together, and only then can you tell how much of the gain survives in production.