Speculative Decoding on Unified Memory Devices: Speedup Patterns and Selection Guide

    Speculative decoding is a lossless technique for accelerating LLM inference, but its real-world benefit depends on acceptance rate, draft overhead, and verification overhead. This article explains why the decode stage is bandwidth-bound on unified memory devices, how speculative decoding works, the three variables that determine speedup, why acceptance rate varies by task, and how to run reproducible benchmarks to make informed decisions about when and how to enable it. There are no China-specific sections in the original text to remove.

    1. Background: The Decode Stage Is the Bottleneck in Local Inference

    LLM inference consists of two phases. The prefill phase processes the entire input prompt at once; it is compute-intensive and can fully exploit parallel hardware. The decode phase generates output tokens one at a time, and every token requires reading the full model weights from memory. As a result, decoding is typically bounded by memory bandwidth rather than compute.

    A unified memory architecture lets the CPU and GPU share the same physical memory. This eliminates data copies, but it also means both processors share limited memory bandwidth. On such devices, even chips with high theoretical compute may hit the bandwidth ceiling during decoding. This is why decoding acceleration must focus on reducing the number of weight reads.

    Speculative decoding is built on exactly this idea: it lets the model verify multiple candidate tokens in a single pass, merging what would otherwise be several weight reads into one.

    2. How Speculative Decoding Works

    Speculative decoding introduces two model roles:

    • Draft model: small and fast; it predicts the next k tokens in one go.
    • Target model: the large model you actually want; it verifies the draft’s candidates.

    Each round proceeds as follows:

    1. The draft model autoregressively generates k candidate tokens.
    2. The target model evaluates the probability distributions at all k positions in a single forward pass.
    3. Starting from the first position, each candidate is compared: accepted candidates are kept; at the first rejected position, a token is resampled from the corrected distribution and all subsequent candidates are discarded.
    4. If all k candidates are accepted, the target model emits one additional token, so each round produces between 1 and k+1 new tokens.

    With standard rejection sampling, the output distribution is identical to decoding with the target model alone, so speculative decoding is theoretically lossless. Under greedy decoding, the outputs should match token-for-token. This is a key criterion for verifying implementation correctness, which we will revisit later.

    3. The Three Variables That Determine Speedup

    Whether speculative decoding actually speeds things up depends on three variables.

    1. Acceptance rate (α): the probability that the target model accepts a draft token. The higher the acceptance rate, the more effective tokens each round produces.

    2. Draft overhead (c_d): the time to generate one draft token. The larger the draft model, the higher this cost and the more it eats into the gains.

    3. Verification overhead (c_v): the time for the target model to verify k positions in one pass. On bandwidth-bound devices the extra compute for verifying multiple positions is usually small, but if the inference backend implements batched verification inefficiently, this cost can rise significantly.

    Assuming the acceptance of candidates is independent with rate α, the expected number of tokens produced per round is:

    E = (1 − α^(k+1)) / (1 − α)

    If the baseline decode time per token is c_t, the relative speedup is:

    S = E × c_t / (k × c_d + c_v)

    Take α = 0.7 and k = 2 as an example: E ≈ 2.19. With draft overhead c_d = 0.1 c_t and verification overhead c_v = 1.3 c_t, S ≈ 2.19 / 1.5 ≈ 1.46. If verification overhead rises to c_v = 1.8 c_t, then S ≈ 2.19 / 2.0 ≈ 1.10 — the benefit nearly vanishes.

    This example shows that the same acceptance rate can yield very different speedups. The problem often lies in verification overhead. Note that these numbers are hypothetical values used to illustrate the calculation; they do not represent measurements from any specific model or device.

    4. Why Acceptance Rate Varies by Task

    Acceptance rate depends on how closely the draft and target models agree on the predicted distribution for a given context.

    • Structured, predictable output — code completion, fixed-format data transformation, templated text — has sharp distributions. Both models tend to pick the same high-probability token, so acceptance rates are usually high.
    • Open-ended, high-entropy output — creative writing, role-play, high-temperature dialogue — spreads probability mass across many candidates. The two models diverge easily, so acceptance rates are usually low.
    • Reasoning and math tasks fall in between; the acceptance rate depends on how formulaic the reasoning steps are.

    Keep in mind that a high acceptance rate does not guarantee speedup. If verification overhead is too large, the speedup can still fall below 1 — slower than not using speculative decoding at all. When troubleshooting, look at acceptance rate, per-round latency, and overall throughput together rather than any single metric.

    5. A Reproducible Benchmarking Methodology

    Comparisons with and without speculative decoding must be done under controlled conditions. Recommended principles:

    • Fix the hardware, quantization method, context length, and sampling parameters. Set temperature to 0 when comparing deterministic outputs.
    • Prepare a fixed prompt set for each task category and record the category names to enable per-category statistics.
    • Warm up each configuration first, then run at least 5 repetitions and take the median to reduce the impact of sporadic variance.
    • Record prefill latency and decode throughput separately so neither masks the other.
    • On unified memory devices, also record memory usage and thermal state to rule out throttling under sustained load.

    Below is an example of summary and comparison code:

    1. import statistics
    2. from dataclasses import dataclass
    3. @dataclass
    4. class RunResult:
    5. category: str
    6. decode_tps: float # decode throughput (tokens/second)
    7. latency_s: float # end-to-end latency (seconds)
    8. accept_rate: float | None # acceptance rate for speculative decoding; None for baseline
    9. def summarize(results: list[RunResult]) -> dict[str, dict[str, float]]:
    10. """Summarize by task category, using medians to reduce outlier impact."""
    11. grouped: dict[str, list[RunResult]] = {}
    12. for r in results:
    13. grouped.setdefault(r.category, []).append(r)
    14. report: dict[str, dict[str, float]] = {}
    15. for category, runs in grouped.items():
    16. rates = [r.accept_rate for r in runs if r.accept_rate is not None]
    17. report[category] = {
    18. "median_tps": statistics.median(r.decode_tps for r in runs),
    19. "median_latency_s": statistics.median(r.latency_s for r in runs),
    20. "mean_accept_rate": statistics.fmean(rates) if rates else float("nan"),
    21. }
    22. return report
    23. def speedup(baseline: dict, spec: dict) -> dict[str, float]:
    24. """Compute decode-throughput speedup per category; >1 means speculative decoding is faster."""
    25. return {
    26. cat: spec[cat]["median_tps"] / baseline[cat]["median_tps"]
    27. for cat in baseline
    28. if cat in spec
    29. }

    Note that the speedup in decode throughput does not always match the speedup in end-to-end latency, because the prefill phase is generally unaffected by speculative decoding. Report both.

    6. Selection Recommendations

    Scenario Recommendation
    Code completion, structured output, templated text Enable by default; test different k values on these task types
    Reasoning and math tasks Benchmark first, then decide based on measured results
    Open-ended writing, role-play, high-temperature sampling Test first; gains are usually limited — consider disabling or reducing k
    High-concurrency server deployments Batching changes verification overhead; evaluate separately under target load

    Model size also affects the conclusion. Larger models have higher per-token cost, which can make the draft model’s relative overhead lower, but memory footprint grows as well. Mixture-of-experts models activate only part of their parameters per step, introducing a different set of trade-offs on bandwidth-bound devices. Final selection should weigh memory capacity, bandwidth, quality requirements, and latency budget together — not any single metric.

    7. Practical Notes for Deployment

    1. Verify correctness first: under greedy decoding, outputs with and without speculative decoding should match token-for-token. If they don’t, check the implementation and sampling logic before evaluating performance.
    2. Pin versions: speculative decoding implementations in inference frameworks are still evolving rapidly, and behavior can differ substantially across versions and backends. Re-test after every upgrade.
    3. Monitor in production: continuously record acceptance rate and throughput per task category. If a category’s speedup stays below 1, automatically fall back to standard decoding.
    4. Separate speed from quality: speedup only reflects throughput, not output quality. With non-standard sampling implementations, additionally evaluate whether the output distribution has shifted.

    In summary, the benefit of speculative decoding depends on the balance among acceptance rate, draft overhead, and verification overhead. Developers should make per-category decisions through controlled benchmarks rather than drawing conclusions from a single test or a single metric.