Papers
Topics
Authors
Recent
Search
2000 character limit reached

Lossless but Not Free: An Empirical Anatomy of Speculative Decoding on Consumer Hardware

Published 19 Jul 2026 in cs.AI and cs.LG | (2607.17283v1)

Abstract: Single-stream autoregressive decoding of LLMs is bound by memory bandwidth: each generated token requires one full forward pass through the target model, and successive passes cannot be parallelized. Speculative decoding restructures this computation: a small draft model proposes KK tokens autoregressively, the target model scores all of them in one batched pass, and a rejection-sampling rule provably preserves the target model's output distribution. We present a from-scratch, device-agnostic (CUDA/MPS/CPU) implementation and an empirical study across five draft/target backend configurations on a consumer Apple-silicon laptop. Distribution equivalence is verified at three levels, culminating in a two-sample test over roughly 9,200 real-model tokens per method (χ2=162.5χ^2 = 162.5, dof =200= 200, p=0.976p = 0.976) and exact greedy-sequence agreement. The best configuration reaches a measured 1.61×1.61\times wall-clock speedup at K=6K=6, on an acceptance profile declining from 69.7% at K=1K=1 to 37.8% at the optimum, while three of five configurations decelerate, either because the draft fails to out-speed a small target or because the quantized Metal backend executes "parallel" verification serially, an effect we isolate and quantify. The failures are as instructive as the successes: speculative decoding pays off only when verification is genuinely batch-parallel and the draft/target latency gap is real.

Authors (1)

Summary

  • The paper presents a device-agnostic speculative decoding implementation and validates exact output-distribution preservation through analytic proofs, sampling tests, decoder comparisons, and real-model experiments.
  • Consumer-hardware benchmarks show a peak 1.61× speedup at K=6 with a 0.5B draft and 3B target, while three of five configurations slow down despite acceptable token-match rates.
  • The results show that backend behavior—not acceptance alone—determines performance: genuinely batched MPS verification enables gains, whereas draft overhead and quantized Metal’s poor small-batch scaling cause substantial slowdowns.

Overview

"Lossless but Not Free: An Empirical Anatomy of Speculative Decoding on Consumer Hardware" (2607.17283) presents a from-scratch, device-agnostic implementation of two-model speculative decoding and an empirical study of its wall-clock behavior on a single consumer Apple-silicon laptop with 18 GB of unified memory. The paper's central contribution is not an algorithmic novelty — it implements the standard formulation of Leviathan et al. (Leviathan et al., 2022) and Chen et al. (Chen et al., 2023) — but rather a disciplined separation of the mathematical guarantee (exact output-distribution preservation) from the systems economics (when the bookkeeping actually saves time). The headline result is a measured 1.61× single-stream speedup at K=6K=6 for a 0.5B-draft/3B-target pairing; the equally important result is that three of five plausible configurations decelerate, for two backend-level reasons that have nothing to do with the algorithm.

Method

The engine follows the standard draft–verify–accept loop. A draft model proposes KK tokens autoregressively, retaining each draft distribution qiq_i; the target model scores all KK positions plus one bonus position in a single batched forward pass; an accept walk commits the longest prefix satisfying ri<min⁡(1,pi(xi)/qi(xi))r_i < \min(1, p_i(x_i)/q_i(x_i)); on the first rejection, the replacement token is drawn from the adjusted distribution proportional to max⁡(0,p−q)\max(0, p - q). The paper restates the standard proof that the emitted marginal is exactly p(⋅∣s)p(\cdot \mid s): accepted drafts contribute min⁡(p,q)\min(p, q) mass, rejection mass is exactly the normalizer of the adjusted distribution, and the two sum to pp. As T→0T \to 0 the rule degenerates to exact-match greedy acceptance, which the implementation handles explicitly without consuming RNG state.

Two methodological points deserve note. First, the idealized expected-yield expression KK0 assumes a position-independent acceptance rate KK1, and the paper shows empirically that this assumption fails: acceptance decays sharply with draft position, making the expression a loose upper bound at large KK2. Second, all sampling arithmetic — temperature scaling, the accept test, adjusted-distribution construction, multinomial draws — runs on CPU in float32 behind an explicit torch.Generator, independent of where the models execute. The paper measures this design choice rather than asserting it: sampling costs 0.88 ms per token, 2.2% of wall time in the best configuration, so the correctness-critical math is computationally free.

Implementation

The engine is organized as five blocks developed against a frozen interface file that fixes the model API, KV-cache choreography, and benchmark JSON schema. A single SpecModel abstraction exposes stateless forward and stateful incremental extend/truncate operations, with two implementations: a Hugging Face wrapper (fp16, DynamicCache) and a llama.cpp wrapper (GGUF q4_k_m/q8_0, Metal), the latter requiring logits_all=True so full-vocabulary logits exist at every drafted position — rejection sampling is impossible with top-KK3-truncated outputs. A single tokenizer is authoritative; pair construction validates vocabulary identity, which is why TinyLlama (32k Llama-2 vocabulary) cannot legally pair with Llama-3.1 (128,256-token vocabulary).

KV-cache choreography is handled carefully: the target cache is extended once with (last committed token + all KK4 drafts), the last KK5 logit rows are aligned so row KK6 predicts draft token KK7, and both caches are truncated to the accepted length after the walk. The paper identifies the "last KK8 rows" alignment as the classic off-by-one in speculative decoders and pins it with mock-model invariant tests.

Distribution equivalence

Correctness is gated at three levels rather than assumed. At the sampling-rule level, 50,000 trials against analytic ground truth over four synthetic KK9 families yield goodness-of-fit qiq_i0-values between 0.225 and 0.978 with qiq_i1. At the decoder level, deterministic mock models give a two-sample qiq_i2 (qiq_i3, qiq_i4) over 20,950 tokens per method, and greedy decoding is bit-identical to the baseline for every qiq_i5. At the real-model level, roughly 9,200 tokens per method under matched seeds give qiq_i6, qiq_i7, qiq_i8, with exact greedy sequence agreement on 5/5 prompts.

The paper is notably candid about two caveats here. The reported smoothed KL (0.471) is dominated by add-0.5 smoothing over sparse support and is not the calibrated instrument — the binned qiq_i9 is. More substantively, the greedy real-model leg runs on fp32 CPU because the quantized Metal backend is not batch-invariant: evaluating the same context with five tokens in a batch versus one at a time shifts logits by up to roughly 0.1, enough to flip argmax at near-ties (observed top-1/top-2 gaps of KK0 to KK1). Bit-exact greedy equivalence on the quantized backend is therefore unattainable for any implementation whose baseline and verifier use different batch shapes — a backend property, not an implementation defect, but one that bounds what any correctness test on that backend can claim.

Throughput results and the KK2-sweep

Across five configurations (draft/target backend cross-products over Qwen2.5 0.5B/1.5B/3B/7B), only the two whose verifier is Transformers-fp16-on-MPS exceed break-even:

Config Base tok/s Spec tok/s Speedup Accept.
mixed_3b 16.00 25.07 1.57 43.3%
mixed 26.38 36.91 1.40 51.0%
all_gguf 73.99 37.00 0.50 52.4%
stretch_7b 23.15 11.95 0.52 40.2%
primary 73.46 24.44 0.33 53.4%

The KK3-sweep for the best configuration peaks at KK4 with 27.17 tok/s (1.61×) and pooled acceptance of 37.8%, declining from 69.7% at KK5. The paper is careful to characterize the optimum honestly: KK6 form a statistical plateau (1.52–1.61×, overlapping standard deviations), and beyond it throughput decays as acceptance collapses into the mid-20% range. Adjacent-KK7 differences within one standard deviation should be read as ties.

Failure modes

The paper's diagnostic contribution lies in isolating why three configurations lose. The first failure mode is draft overhead: the primary configuration's Transformers-fp16-on-MPS draft costs 18.0 ms per draft step — more than the llama.cpp 1.5B target's entire 13.6 ms baseline step. At this scale, framework per-step overhead (Python dispatch, MPS kernel launch) dominates model size; a draft slower than its target cannot win at any KK8 or acceptance rate.

The second failure mode is subtler and more broadly relevant: the quantized Metal backend does not execute "parallel" verification in parallel. Verify cost on the 7B q4_k_m target grows nearly linearly for batches of 2–7 (51.0 ms at batch 2, 218.5 ms at batch 7) before dropping to a flat ~141 ms at batches 9–13 — the signature of a kernel-path switch from per-position quantized matrix–vector products (re-reading weights each time) to a matrix–matrix kernel that reads weights once. By contrast, the Transformers-MPS backend extends its cache with 5 tokens in 42.3 ms versus 35.2 ms for one, a 1.20 ratio. This single backend property cleanly partitions the results: MPS-GEMM verifiers sit above break-even; llama.cpp-Metal verifiers at speculative batch sizes sit below it. The stretch_7b configuration is the sharpest illustration — a textbook-asymmetric pair (8.5 ms draft steps against a 43 ms/token target) that still halves throughput at KK9 because each 5-token verify pass costs nearly four single-token steps.

Acceptance dynamics and where the time goes

Positional acceptance decays monotonically — for primary, 75.4%/57.7%/44.7%/35.9% across positions 1–4; for mixed_3b, 66.4%/48.0%/34.8%/24.2%. This compounding divergence is the mechanism behind the interior optimum in ri<min⁡(1,pi(xi)/qi(xi))r_i < \min(1, p_i(x_i)/q_i(x_i))0: each additional draft position is conditioned on a longer unverified prefix, so its marginal value shrinks geometrically while its cost is constant or growing. Notably, the pooled-ri<min⁡(1,pi(xi)/qi(xi))r_i < \min(1, p_i(x_i)/q_i(x_i))1 yield formula understates actual yield: measured 2.7 tokens per round at ri<min⁡(1,pi(xi)/qi(xi))r_i < \min(1, p_i(x_i)/q_i(x_i))2 versus the ≈1.7 the pooled rate predicts, because the pooled average masks the high early-position acceptance that dominates a round.

The latency decomposition for the best configuration (40.0 ms/token: 12.7 draft, 23.7 verify, 0.88 sampling, 2.8 other, against a 62.5 ms baseline) supports two conclusions stated above: the mathematically delicate rejection-sampling machinery is computationally negligible, and the draft is cheap enough that even 43% acceptance nets a large win when verification is genuinely batched. The paper proposes that implementations report a draft-step/target-step latency ratio and a verify-batch scaling curve alongside acceptance rates — without these, acceptance alone is uninterpretable as a speedup predictor.

Limitations

The paper enumerates its constraints plainly. All results are single-stream, batch-size-one, on one consumer machine with pinned software versions; server-side batching changes the economics entirely. Acceptance rates are properties of the specific same-family, instruction-tuned pair at ri<min⁡(1,pi(xi)/qi(xi))r_i < \min(1, p_i(x_i)/q_i(x_i))3 and will shift with different families, temperatures, or domains. The 8B-class CUDA pairing ships as a runnable Colab script but was not executed, so no numbers are claimed for it. The sampled-leg equivalence test has the statistical resolution of ~9,200 tokens per method — it bounds rather than eliminates distributional deviation, with exactness resting on the analytic proof and the bit-exact greedy limit. Peak-memory figures are process-wide high-water marks, hence upper bounds. Finally, sweep points use only 8 recorded prompts, limiting resolution within the plateau.

Conclusion

The paper's thesis is compactly stated: the guarantee is free; the speedup is a systems property. A verified-correct speculative decoding engine delivers 1.61× single-stream speedup on consumer hardware when verification is genuinely batch-parallel and the draft/target latency gap is real, and decelerates when either premise silently fails — as it does on quantized Metal backends below batch size 8. The specific open questions the paper leaves are concrete: how continuous batching interacts with accepted-length variance across streams, whether adaptive ri<min⁡(1,pi(xi)/qi(xi))r_i < \min(1, p_i(x_i)/q_i(x_i))4 driven by observed per-round positional acceptance can harvest the plateau without the tail, and whether the CUDA measurement (where batched verification is known to be parallel-efficient) confirms that the Metal serial-verification pathology, rather than the algorithm, is the binding constraint.

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.