arXiv:2607.17283cs.AIcs.LG2026-07

在消费级设备上实证分析推测解码的加速效果与瓶颈

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

  • 用小模型预估多个词元,大模型批量验证并采样
  • 最优配置达1.61倍速度提升,但三组配置反而变慢
  • 揭示批处理并行与模型延迟差是成功关键

单流自回归解码受限于内存带宽:每个生成词元需对目标模型完整前向一次,后续步骤无法并行。推测解码重构该计算流程:小型草稿模型自回归生成K个词元,目标模型一次性批量评分所有词元,通过拒绝采样规则可保证输出分布不变。本文实现一个从零开始、跨设备(CUDA/MPS/CPU)的版本,并在消费级Apple Silicon笔记本上对五种草稿/目标后端组合进行实证研究。在三个层面验证分布等价性,最终基于约9200个真实模型词元的两样本检验显示χ²=162.5,自由度=200,p=0.976,且贪婪序列完全一致。最佳配置在K=6时实现1.61倍的墙钟速度提升,接受率从K=1时的69.7%降至最优时的37.8%;其中三组配置反而减速,或因草稿模型未能超越小目标模型,或因量化Metal后端将‘并行’验证串行执行,该现象被分离并量化。失败案例与成功同等重要:推测解码仅在验证真正批处理并行且草稿与目标存在真实延迟差距时才有效。

原文摘要 · Abstract (English)

Single-stream autoregressive decoding of large language models 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 $K$ 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$, dof $= 200$, $p = 0.976$) and exact greedy-sequence agreement. The best configuration reaches a measured $1.61\times$ wall-clock speedup at $K=6$, on an acceptance profile declining from 69.7% at $K=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.

推理加速推测解码性能分析

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。