arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2510.22876cs.CLcs.AI
收藏

正确实现批量推测解码

Correctness Forensics for Batch Speculative Decoding: Diagnosing the Ragged Tensor Problem

The Pennsylvania State University, University Park, PA, USA(宾夕法尼亚州立大学)

Ranran Haoran Zhang, Soumik Dey, Ashirbad Mishra, Hansi Wu, Binbin Li, Rui Zhang

AI总结:

本文提出首个保证输出等价的批量推测解码框架,通过同步不变量和跨批次调度提升吞吐量并保持正确性。

摘要:

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

英文摘要:

Inference optimizations are routinely evaluated by throughput alone, without verifying output correctness. We conduct a forensic analysis of batch speculative decoding and find that several widely-used implementations silently produce corrupted outputs (repetitive tokens, <unk> symbols) while reporting competitive speed; failures invisible to metrics like ROUGE. We trace the root cause to the ragged tensor problem: variable token acceptance desynchronizes position IDs, attention masks, and KV-cache across a batch. We formalize the synchronization invariants (rectangular alignment and position-ID contiguity) that valid batched inference must preserve and show that maintaining them incurs superlinear alignment overhead under contiguous layouts. EQSPEC enforces the invariants without custom kernels; EXSPEC schedules same-length sequences to bypass realignment. On SpecBench across three model families, EXSPEC reaches 3 x throughput at batch size 8 with 95% exact match to standard decoding; residual divergence traces to floating-point non-determinism, not synchronization error. Code:https://github.com/eBay/spec_dec

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑