Speculative decoding must produce outputs distribution identical to standard autoregressive generation-this output equivalence is not an optimization target but the defining criterion of valid speculative decoding. We demonstrate that all existing batch speculative decoding implementations violate this fundamental requirement, producing corrupted outputs ranging from repetitive tokens to gibberish. These failures stem from the ragged tensor problem: sequences in the same batch accept different numbers of draft tokens, desynchronizing position IDs, attention masks, and KV-cache state. We present the first authentic batch speculative decoding framework. We (1) formalize the synchronization invariants that valid batch speculative decoding must satisfy, (2) present EQSPEC, the first algorithm that guarantees output equivalence, and analyze its cost structure to show that alignment overhead grows superlinearly and consumes up to 40\% of computation, and (3) introduce EXSPEC, which reduces this overhead through cross-batch scheduling that dynamically groups same-length sequences. On SpecBench across Vicuna-7B/68M, Qwen3-8B/0.6B, and GLM-4-9B/0.6B pairs, our methods achieve up to 3x throughput improvement at batch size 8 while maintaining algorithmic correctness. Our methods achieve 95\% decoding-equivalence, with residual divergence attributable to floating-point non-determinism in GPU inference, not the synchronization failures that cause near-zero equivalence of prior methods. Our code is available at https://github.com/eBay/spec_dec.


翻译:推测解码必须产生与标准自回归生成完全相同的输出分布——这种输出等价性并非优化目标,而是有效推测解码的定义准则。我们证明所有现有的批处理推测解码实现都违反了这一基本要求,产生从重复标记到乱码的损坏输出。这些失败源于参差张量问题:同一批次中的序列接受不同数量的草稿标记,导致位置ID、注意力掩码和KV缓存状态失同步。我们提出了首个真正意义上的批处理推测解码框架。我们(1)形式化了有效批处理推测解码必须满足的同步不变条件,(2)提出首个保证输出等价性的算法EQSPEC,并通过分析其成本结构证明对齐开销呈超线性增长且最高消耗40%的计算资源,以及(3)引入EXSPEC,该方案通过动态分组等长序列的跨批次调度来降低此开销。在Vicuna-7B/68M、Qwen3-8B/0.6B和GLM-4-9B/0.6B模型对的SpecBench测试中,我们的方法在批次大小为8时实现了最高3倍的吞吐量提升,同时保持算法正确性。我们的方法达到95%的解码等价性,残余差异可归因于GPU推理中的浮点数非确定性,而非导致先前方法接近零等价性的同步失效问题。代码已开源:https://github.com/eBay/spec_dec。

0
下载
关闭预览

相关内容

【AAAI2023】学习为可解释序列数据建模选择原型部件
专知会员服务
20+阅读 · 2022年12月13日
【伯克利】再思考 Transformer中的Batch Normalization
专知会员服务
41+阅读 · 2020年3月21日
一文搞懂反向传播
机器学习与推荐算法
18+阅读 · 2020年3月12日
一个牛逼的 Python 调试工具
机器学习算法与Python学习
15+阅读 · 2019年4月30日
推荐系统BAT面试题:说说协同过滤的原理
七月在线实验室
50+阅读 · 2019年1月30日
变分自编码器VAE:一步到位的聚类方案
PaperWeekly
25+阅读 · 2018年9月18日
【干货】深入理解自编码器(附代码实现)
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Arxiv
0+阅读 · 2月11日
VIP会员
相关VIP内容
【AAAI2023】学习为可解释序列数据建模选择原型部件
专知会员服务
20+阅读 · 2022年12月13日
【伯克利】再思考 Transformer中的Batch Normalization
专知会员服务
41+阅读 · 2020年3月21日
相关资讯
一文搞懂反向传播
机器学习与推荐算法
18+阅读 · 2020年3月12日
一个牛逼的 Python 调试工具
机器学习算法与Python学习
15+阅读 · 2019年4月30日
推荐系统BAT面试题:说说协同过滤的原理
七月在线实验室
50+阅读 · 2019年1月30日
变分自编码器VAE:一步到位的聚类方案
PaperWeekly
25+阅读 · 2018年9月18日
【干货】深入理解自编码器(附代码实现)
相关基金
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员