Speculative Decoding Performance Pitfalls and Tuning Practices for On-Device LLMs
This article examines why speculative decoding can slow down rather than speed up on-device LLMs. Starting from a benchmark where enabling Multi-Token Prediction (MTP) speculative decoding dropped decode throughput from 36.4 to 31.7 tokens/s (a 0.87x speedup) and raised end-to-end latency from 31.5s to 36.6s, it explains where the gains actually come from, why acceptance rate is the decisive metric while speed is only the result, and how to tell a buggy implementation apart from a weak model. It breaks performance down by task domain, provides a debugging checklist and a benchmarking methodology, compares dense versus sparse-expert (MoE) architectures on unified-memory devices, and closes with a practical engineering deployment checklist for turning speculative decoding into a measurable, regression-testable throughput optimization.
1. Starting From an Anomalous Benchmark Result
A typical on-device comparison test produced this result: after enabling multi-token prediction (MTP) speculative decoding on the same roughly 10B-parameter dense model, overall decode throughput fell instead of rising—from 36.4 tokens/s to 31.7 tokens/s, a speedup of 0.87x—and end-to-end average latency stretched from 31.5s to 36.6s. The only category that improved was code, where throughput rose by 18%.
This was not a driver problem, nor a quantization-accuracy problem. It exposed a structural fact about speculative decoding on unified-memory edge devices: speculative decoding is not a “free accelerator”—it is a trade that spends verification cost to reduce the number of memory accesses. When the price of that trade is miscalculated, it will reliably make you slower.
This article addresses four questions: where the gains actually come from, what acceptance rate means, why “a buggy implementation” is often more suspect than “a weak model,” and how to choose between dense and sparse-expert architectures on this kind of device.
2. Where the Gains Come From: Compressing K Memory Accesses Into One
Autoregressive decoding has two independent bottlenecks, and understanding the difference between them is the prerequisite for understanding speculative decoding:
- Memory-bound: single-token decoding has extremely low arithmetic intensity—every generated token requires moving all the weights from memory to the compute units again. On edge devices, almost all the time is spent reading weights while the compute units sit largely idle.
- Sequential dependency: the t-th token cannot begin until the (t-1)-th finishes, so you cannot fill the pipeline by increasing batch size.
Speculative decoding attacks both at once. A cheap “proposer” (an independent small model, or a multi-token prediction head that shares parameters with the backbone) proposes K candidate tokens in one shot. The target model then performs a single forward pass, uses a causal mask to verify all K+1 positions in parallel, accepts the longest correct prefix, and resamples one token from the backbone’s distribution starting at the first rejected position as compensation.
The essence of the gain is this: what was originally K+1 “read all weights” operations becomes 1 “read all weights + slightly wider compute.” But this equality only holds when the verification stage remains in the memory-bound regime. Once the verification batch width pushes arithmetic intensity past the hardware’s ridge point, verification becomes compute-bound and its cost grows roughly linearly—which is the fundamental reason speculative-decoding gains on edge devices are less stable than on cloud servers.
The difference between a multi-token prediction head and an independent draft model comes down to this too: the former shares the backbone and adds almost no extra weight reads, making it theoretically better suited to bandwidth-limited devices; the cost is that it is tightly coupled to the backbone in training, so once the backbone’s own “next-token predictability” is insufficient, there is no fallback for the acceptance rate.
3. Acceptance Rate Is the Only Core Metric; Speed Is Just the Result
Let the average per-token acceptance rate be α and the draft length be K (that is, K draft tokens per verification round plus the backbone’s 1 compensation token). Under a per-token independent-and-identically-distributed approximation, the expected number of tokens produced per verification round is:
E(α, K) = (1 - α^(K+1)) / (1 - α)
Plugging in a few typical values:
| α | K=1 | K=2 | K=3 | K=5 |
|---|---|---|---|---|
| 0.90 | 1.90 | 2.71 | 3.44 | 4.69 |
| 0.75 | 1.75 | 2.17 | 2.49 | 2.99 |
| 0.63 | 1.63 | 2.04 | 2.34 | 2.72 |
| 0.50 | 1.50 | 1.75 | 1.88 | 1.97 |
Two key corollaries:
First, α has a marginal-gain cliff. Dropping α from 0.9 to 0.63, the expected output at K=2 falls from 2.71 to 2.04, shrinking by 25%; meanwhile raising K from 2 to 5 only recovers 2.04 to 2.72 while verification cost nearly doubles. Increasing draft length in low-α scenarios is a negative optimization.
Second, the true speedup is E divided by round cost. Let the cost of a verification round be expressed as c times a normal single-step decode; then speedup ≈ E(α, K) / c. A well-implemented memory-bound system should theoretically have c ≈ 1.0–1.3. Applying this model to the opening data: with α = 0.6355 and K = 2, E ≈ 2.04, while the measured speedup is 0.87x, which back-solves to c ≈ 2.34—the verification path costs more than twice a normal decode step, almost entirely consuming the theoretical gains of speculative decoding.
4. Three Patterns in the Task-Level Data
Breaking the measured data down by task domain is far more valuable than looking at the aggregate average:
| Task domain | Baseline throughput | Speculative throughput | Speedup | Avg. acceptance rate |
|---|---|---|---|---|
| coding | 36.15 | 42.83 | 1.18x | 0.761 |
| rag | 37.08 | 36.26 | 0.98x | 0.809 |
| roleplay | 34.26 | 29.41 | 0.86x | 0.614 |
| multilingual | 36.65 | 30.47 | 0.83x | 0.724 |
| humanities | 37.45 | 31.43 | 0.84x | 0.575 |
| writing | 34.66 | 25.75 | 0.74x | 0.582 |
| overall | 36.42 | 31.67 | 0.87x | 0.636 |
Pattern 1: Acceptance rate correlates strongly with output predictability. Code has indentation, closing brackets, fixed templates, and high-frequency identifiers; extraction and summarization tasks have converging sentence structures. In contrast, creative writing, roleplay, and multilingual generation are high-entropy tasks where the draft model’s and the backbone’s distributions diverge faster. Back-solving E: coding’s α = 0.761 with K = 2 corresponds to E ≈ 2.34, and its actual 1.18x speedup corresponds to c ≈ 1.98; writing’s α = 0.582 corresponds to E ≈ 1.88, and 0.74x speedup corresponds to c ≈ 2.54. c drifts across task domains, indicating that the cost term is strongly correlated with sequence shape rather than being a fixed constant.
Pattern 2: High acceptance rate does not equal high speedup. Retrieval-augmented Q&A has an acceptance rate as high as 0.809 yet shows almost no speedup (0.98x). This suggests the bottleneck is not the acceptance rate but the fixed overhead of the verification path and kernel-shape adaptation—when more than 2 tokens are accepted every round, the gains should be significant, and missing gains at that point almost certainly point to the implementation layer.
Pattern 3: Aggregate averages hide regressions. The 0.87x figure both masks the 1.18x gain in code scenarios and the severe 0.74x regression in creative scenarios. Any conclusion about “whether it is faster overall” is uninformative.
5. A Checklist for Diagnosing a “Buggy Implementation”
When the acceptance rate is stable at 0.5–0.6 regardless of task, or even diverges into high acceptance rate with no throughput gain, prioritize suspecting implementation correctness rather than model capability. A usable minimal verification method is: fix greedy decoding, force the draft and the backbone to use exactly the same sampling parameters and random seed, in which case mathematically the draft tokens must either be fully accepted or truncated at the first mismatch. If the acceptance rate is still below 0.5 under these ideal conditions, it is almost certainly a defect rather than a model characteristic.
Checklist items ordered by diagnostic payoff:
- KV Cache rollback and pollution. Rejected candidate tokens have already been written into the cache and must be truncated at the rejection point with the length pointer rolled back. Typical symptoms of getting this wrong are output quality slowly degrading as generation length grows, and acceptance rate monotonically declining over time.
- Position-encoding baseline misalignment. When verifying K+1 positions, each position’s rotary or absolute position encoding must strictly match its true index in the final sequence. Using different position baselines for draft and backbone causes systematic mismatch, and the acceptance rate gets stuck near a fixed value.
- Sampling-parameter consistency. temperature, top-p, top-k, and repetition penalty must be strictly aligned between the draft and verification sides. On non-greedy paths, the way random numbers are consumed must also be consistent, or the mathematical acceptance criterion breaks down.
- Causal mask and kernel branching. The mask shape for multi-token verification differs from single-token decoding; if the runtime takes a suboptimal kernel or even falls back to a generic implementation, you get the “high acceptance, zero speedup” behavior described in Pattern 2.
- Inconsistent quantization tiers. If the draft head and the backbone use different quantization configurations, or the draft runs at lower precision, it causes distribution shift and a systematic acceptance-rate decline.
- Early termination and special tokens. When the draft crosses a stop token, verification ends early and the effective draft length degrades; in addition, per-round mask reconstruction, post-sampling processing, and host-device synchronization copies are all constant-level overheads that get amortized as the sequence grows, so short-output tasks (such as multilingual tasks that are only ~6s end-to-end) are the most affected.
A verification-loop skeleton that can expose the issues above:
def speculative_step(model, ctx, k):# 1. Draft proposal: a multi-token prediction head sharing the backbone, one forward pass onlydrafts, draft_kv = model.draft(ctx, k)# 2. Target verification: K+1 positions in a single forward pass, strictly causal masklogits = model.verify(ctx, drafts, num_pos=k + 1)# 3. Compare position by position, accept the longest correct prefixn = 0for i in range(k):if sample(logits[i]) == drafts[i]:n += 1else:break# 4. Compensation sampling: sample from the true distribution at the first rejected positionbonus = sample(logits[n])# 5. Critical: roll back the KV written by rejected candidates so the context stays uncontaminatedctx.rollback(len(drafts) - n)ctx.append(drafts[:n] + [bonus])return n + 1, n / max(k, 1) # tokens produced this round, acceptance rate this round
6. Choosing Between Dense and Sparse-Expert Architectures on Unified-Memory Devices
On architectures where CPU, GPU, and NPU share the same physical memory and bandwidth, weight reading is almost the only main cost term, and this premise determines the architectural choice:
Dense models: every token reads all parameters, so decode speed is roughly inversely linear to parameter count, but the bandwidth-utilization curve is gentle, tail latency is predictable, runtime behavior and memory footprint are highly deterministic, and toolchain maturity is high.
Sparse-expert (MoE) architectures: each token routes to only a few experts, so the effective weight-read volume drops significantly, yielding higher output per unit bandwidth on bandwidth-limited devices—which is also why they can maintain high throughput at larger parameter scales. The costs are equally clear: routing itself has overhead; expert weights must stay resident, increasing capacity pressure and swap-in/swap-out jitter; in batch scenarios different tokens hit different experts, diluting bandwidth utilization; and the shared-expert portion still requires full reads, setting a floor on speed.
A practical decision framework:
| Scenario characteristic | Preferred choice | Main reason |
|---|---|---|
| Single-stream interaction, low concurrency, tight bandwidth | Sparse expert | Minimal effective per-token memory access |
| Strict tail latency and predictable memory footprint required | Dense | No routing jitter, no paging risk |
| Capacity-limited on device, cannot keep all weights resident | Dense (smaller scale) | The capacity advantage of sparse architecture cannot be realized |
| High-concurrency batch, dispersed expert hits | Dense | Avoids bandwidth waste from expert dispersion |
| Already layered with speculative decoding | Combine cautiously | Backbone has already partially parallelized memory access, diluting gains |
The last item is especially important: the gains of sparse architectures and speculative decoding do not simply add up. A sparse backbone has already obtained some “speculative-like” gains by reducing per-token weight reads; layering MTP on top makes the expert-routing overhead in the verification stage more pronounced, pushes c up more noticeably, and the speedup easily degrades toward 1.0.
7. How to Make Credible Benchmark Conclusions
- Fix the variables: the same quantization format, the same context and generation-length range, the same sampling parameters, the same batch of prompts, and the same warm state. Any single inconsistency makes the speedup non-comparable.
- Separate the metrics: report decode throughput (tokens/s) separately from prefill throughput; for end-to-end, give time-to-first-token, average per-token latency, and total duration together. In the opening data, coding’s 1.18x throughput speedup corresponds to a 1.17x latency speedup—the two agree; whereas in some scenarios throughput is 1.00x but latency is 1.03x, indicating that total time still includes prefill and post-sampling processing, and looking at throughput alone misses this.
- Sweep K rather than fixing K: plot the (throughput, acceptance rate, K) surface to find the inflection point. The optimum in most scenarios falls at K = 2–4 and drifts with the task domain.
- Per-domain statistics + report dispersion: aggregate averages are only meaningful when all domains agree; also give variance or confidence intervals, since single-sample timing jitter is enough to mask real differences.
- Long-context regression testing: speculative decoding’s cache overhead for both draft and verification rises on long sequences, so re-test at 4K/8K/32K length tiers.
def sweep_draft_len(runtime, prompts, k_list, repeats=3):report = []for k in k_list:for domain, batch in group_by_domain(prompts):tps, acc, lat = [], [], []for _ in range(repeats):m = runtime.bench(batch, draft_len=k) # same params, same quantization, warmtps.append(m.decode_tokens_per_s)acc.append(m.accept_rate) # cumulative over accepted/proposedlat.append(m.e2e_latency)report.append({"k": k, "domain": domain,"tps": median(tps), "accept": median(acc),"latency": median(lat),# Gate on the change in throughput vs. baseline, not on "whether it is enabled""speedup": median(tps) / baseline_tps[k, domain],})return report
8. Engineering Deployment Checklist
- Default off; enable by task-domain whitelist. Prioritize low-entropy scenarios such as code generation, structured extraction, and templated summarization; keep creative writing, multilingual, and open dialogue off or lower K.
- Adaptive draft length. Track the acceptance rate over a sliding window online; shorten K when it declines consecutively, and tentatively lengthen it again once it recovers. This is more robust than any static configuration.
- Make internal metrics observable. Acceptance rate, actual tokens produced per round, verification-time share, and KV-rollback count should enter logs and connect to monitoring and alerting; a sudden change in acceptance rate is often the earliest signal of an implementation defect or an input-distribution drift.
- Gate on throughput, not on the switch. Any conclusion about “whether it is faster once enabled” must come from a per-domain throughput comparison, not from whether a configuration flag took effect.
- Cloud-deployment engineering support. A container platform can host the inference runtime and perform canary traffic splitting, model weights can live in object storage and be pulled on demand, benchmark metrics can be collected via a logging service, and monitoring/alerting can do regression comparison—this combination is vendor-agnostic and is a portable, general practice.
9. Conclusion
The 0.87x result from the opening does not mean speculative decoding is useless; it shows two things: the ceiling on gains is determined by the entropy of the task, while the actual gains are determined by the implementation quality of the verification path. When the acceptance rate fluctuates between 0.57 and 0.81, increasing draft length cannot compensate for the nearly 2x extra overhead of the verification path; whereas on highly predictable code tasks, the same mechanism immediately yields a positive 18% gain.
The direct implication for engineering practice is: do not ask “should I enable speculative decoding,” but ask “for this task domain, this draft length, and this runtime implementation, what is the cost coefficient of the verification path.” Measure and optimize the acceptance rate and the verification cost separately, then layer on a model architecture matched to the deployment form, and speculative decoding can turn from “a switch that looks faster” into “a measurable, regression-testable, deployable throughput optimization.”
