How to Choose a Speculative Decoding Draft Model and Adjust Speculation Depth Dynamically Based on Entropy

    Speculative decoding accelerates LLM inference when memory bandwidth is the bottleneck, but its benefit depends heavily on the draft source and speculation length. This article explains what speculative decoding solves, the three metrics to evaluate (acceptance rate, average tokens per round, effective throughput), how to choose among four common draft sources, and how to tune speculation depth dynamically using context entropy and a sliding-average acceptance rate, including parameter starting points, adjustment rules, fallback logic, and benchmark methodology.

    1. What Problem Speculative Decoding Solves

    In autoregressive decoding, every generated token requires reading the model weights from GPU memory into the compute units. With small batch sizes, the compute units spend most of their time waiting for data, and latency is dominated by memory bandwidth. Speculative decoding works as follows: a draft model proposes k candidate tokens, then the target model verifies all k positions in a single forward pass. The verified prefix is kept, and the target model also contributes one extra token, so each round produces at least one token.

    2. Three Metrics to Evaluate First

    Evaluate any speculative decoding setup with three numbers: acceptance rate, average tokens produced per round, and effective throughput.

    Acceptance rate α is the proportion of candidate tokens accepted by the target model. When computing it, the numerator should only count draft-proposed tokens that were accepted — the extra token produced by the target model is excluded.

    Under the simplifying assumption that candidate tokens are independent, the average tokens produced per round is approximately (1 − α^(k+1)) / (1 − α). In real text, adjacent candidate tokens are often correlated, so actual values will deviate from this estimate — always rely on measurements.

    Per-round latency depends on the draft source:

    • Autoregressive small model as draft: per-round latency is roughly k × t_draft + t_verify, where t_draft is the draft model’s single-step latency and t_verify is one verification pass of the target model.
    • Multi-head prediction or lightweight head module: the draft completes in a single forward pass, so per-round latency is approximately t_head + t_verify. As k grows, the increase comes mainly from t_verify.
    • n-gram matching: lookups run on CPU and draft cost is usually negligible, so per-round cost is dominated by t_verify.

    t_verify grows with k because verification must compute k additional positions. When memory bandwidth is the bottleneck, this growth is usually slow, but the longer the speculation length, the more noticeable it becomes.

    Effective throughput equals average tokens per round divided by per-round latency, measured in tokens per second. A setup only pays off if this value is consistently higher than the non-speculative baseline.

    3. How to Choose a Draft Model

    There are four common draft sources, with very different costs and benefits:

    Draft source Extra GPU memory Acceptance rate potential Integration cost Best suited for
    Small model from the same family Medium Medium to high Low General chat
    Distilled draft model Medium High High — requires training data and time Fixed business domains
    Multi-head prediction or lightweight head Low Medium Medium — target model must support it Memory-constrained setups
    Prompt matching (n-gram) Nearly zero Depends on input repetitiveness Low Summarization, rewriting, code edits

    Selection follows three steps:

    1. Measure the baseline first. Sample real requests and record the acceptance rate and effective throughput of n-gram matching. It has almost no extra cost, so it should be done first.
    2. Test the candidates. For each candidate draft model, measure its single-step latency and acceptance rate separately.
    3. Compute effective throughput. Plug the numbers into the formula from the previous section and compare with the baseline. Eliminate any option below the baseline.

    Two hard constraints apply:

    • The draft model’s vocabulary and tokenizer must match the target model exactly. A mismatched tokenizer drives the acceptance rate close to zero — this is the most common rookie mistake.
    • The draft and target model must use the same sampling settings, including temperature and top-p. Otherwise their output distributions don’t match and the acceptance rate will be low.

    4. Dynamic Speculation Depth: Adjusting by Entropy and Acceptance Rate

    The problem with a fixed k is that content varies widely. Templated code and fixed-format fields are highly deterministic and tolerate more speculation, while open-ended creative text is highly divergent — longer speculation is more likely to be rejected mid-sequence, wasting verification compute.

    The dynamic approach uses two signals:

    • Context entropy H. Take the average entropy of the draft model’s output distributions over the last w positions, in bits. Use the distributions actually used for sampling, i.e., after temperature and top-p processing. The draft model has already computed these distributions, so the extra overhead is minimal. A w of 8 to 16 is recommended.
    • Sliding-average acceptance rate A. Computed as A = β × A_prev + (1 − β) × current-round acceptance rate, with β around 0.9. Low entropy doesn’t guarantee a reliable draft, so the acceptance rate acts as a safety net.

    The following parameters are starting points and need calibration on your own data:

    • h_low = 1.0 bit, h_high = 3.0 bit
    • a_high = 0.75, a_low = 0.50, a_floor = 0.30
    • k_min = 1, k_max = 6, adjustment step of 1
    • Update every 16 rounds to avoid frequent k oscillation

    Adjustment rules:

    1. If entropy is below h_low and A is at or above a_high, increase k by 1, capped at k_max.
    2. If entropy is above h_high, or A is below a_low, decrease k by 1, floored at k_min.
    3. Otherwise, keep k unchanged.
    4. When the two signals conflict, the acceptance rate wins. For example, if entropy is very low but A is below a_low, do not increase k.

    Fallback strategy:

    • If A stays below a_floor for 3 consecutive update cycles, or effective throughput stays below the baseline for 3 consecutive cycles, disable speculative decoding and fall back to standard decoding, with a 60-second cooldown.
    • After the cooldown, probe with k_min first. Only scale back up gradually once probing looks normal.

    Here is pseudocode for the dynamic adjustment logic. Production implementations also need request-level concurrency state handling:

    1. State: k = k_min, A = a_init, disabled = False, rounds = 0
    2. def on_round(draft_probs_window, accepted, proposed):
    3. rounds += 1
    4. H = mean(entropy_bits(p) for p in draft_probs_window) # last w positions
    5. round_rate = accepted / proposed
    6. A = beta * A + (1 - beta) * round_rate
    7. if disabled: return
    8. if rounds % 16 != 0: return
    9. if (A < a_floor for 3 consecutive windows) or (throughput below baseline for 3 consecutive windows):
    10. disabled = True
    11. cooldown_until = now + 60s
    12. return
    13. if H < h_low and A >= a_high:
    14. k = min(k + 1, k_max)
    15. elif H > h_high or A < a_low:
    16. k = max(k - 1, k_min)
    17. def next_k():
    18. if disabled:
    19. if now >= cooldown_until:
    20. disabled = False
    21. return k_min
    22. return 0 # 0 means standard decoding
    23. return k
    24. def entropy_bits(p):
    25. return -sum(p_i * log2(p_i) for p_i in p if p_i > 0)

    5. Benchmarking Methodology

    Benchmark results are only comparable when conditions are explicit. Standardize the following:

    • Traffic: sample real requests covering the actual prompt-length and output-length distributions. Do not use a single fixed prompt.
    • Warm-up: discard the first 1–2 minutes, or the first 200 requests.
    • Batch size: test 1, 4, 8, 16, and 32, recording each level separately.
    • Sampling parameters: fix and record temperature and top-p; use the same settings for both the baseline and the speculative group.
    • Metric definitions: acceptance rate = accepted draft tokens / proposed draft tokens; effective throughput = average tokens per round / per-round latency.