FlexDraft: 通过注意力调节和奖励引导校准实现灵活的推测解码
FlexDraft: Flexible Speculative Decoding via Attention Tuning and Bonus-Guided Calibration
AI总结:
本文提出FlexDraft框架,通过注意力调节和奖励引导校准,灵活适应不同批处理大小,解决传统并行推测解码在大批次时的吞吐量下降问题。
摘要:
推测解码通过使用快速草稿生成多个候选标记并由目标模型并行验证,从而加速内存密集型LLM推理且不降低质量。然而,传统顺序推测解码面临草稿与验证之间的相互等待以及中间状态的反复交换,进一步增加内存访问开销。并行推测解码通过在单个目标前向传递中执行草稿和验证,允许在当前候选被验证的同时准备未来的草稿。尽管在小批次中有效,现有并行推测解码方法要么需要昂贵的持续预训练导致质量下降,要么验证接受率低。更重要的是,这种范式固有地面临奖励标记和接受长度的不确定性,导致草稿验证不匹配,从而在大批次时吞吐量收益崩溃。为了解决这些限制,我们引入了FlexDraft,一种无损的推测解码框架,通过三个关键设计灵活适应不同的批次大小。(1) 注意力调节通过仅调节最终几层的注意力投影器来实现块扩散草稿生成,同时保持自回归路径冻结以保留目标分布并生成高质量的草稿,同时使用最少的可训练参数。(2) 奖励引导校准使用一个轻量级的MLP,条件于已解决的奖励标记来校准草稿logits,缓解由奖励标记不确定性导致的草稿验证不匹配。(3) 灵活解码在小批次时动态切换于并行草稿和验证,而在大批次时切换为顺序草稿然后验证,并根据草稿信心调整验证长度以消除冗余计算。
英文摘要:
Speculative decoding accelerates memory-bound LLM inference without quality degradation by using a fast drafter to propose multiple candidate tokens and the target model to verify them in parallel. However, conventional sequential speculative decoding suffers from mutual waiting between drafting and verification, and repeated exchange of intermediate states further increases memory access overhead. Parallel speculative decoding addresses this limitation by performing drafting and verification within a single target forward pass, allowing future drafts to be prepared while current candidates are being verified. Although effective at small batch sizes, existing parallel speculative decoding methods either require costly continual pretraining with quality degradation or suffer from low acceptance rates. More importantly, this paradigm inherently suffers from uncertainty in both the bonus token and the accepted length, leading to draft verification mismatch and causing throughput gains to collapse at large batch sizes. To address these limitations, we introduce FlexDraft, a lossless speculative decoding framework that flexibly adapts to varying batch sizes through three key designs. (1) Attention Tuning enables block diffusion drafting by tuning only the attention projectors of the final few layers on mask tokens, while keeping the autoregressive path frozen to preserve the target distribution and produce high quality drafts with minimal trainable parameters. (2) Bonus-guided Calibration uses a lightweight MLP conditioned on the resolved bonus token to calibrate draft logits, mitigating draft verification mismatch caused by bonus token uncertainty. (3) Flex Decoding dynamically switches between parallel draft and verify at small batch sizes and sequential draft then verify at large batch sizes, and adjusts verification length based on draft confidence to eliminate redundant computation.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。