arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2401.10774cs.LGcs.CL
收藏

Medusa:具有多个解码头的简单 LLM 推理加速框架

Medusa: Simple LLM Inference Acceleration Framework with Multiple Decoding Heads

Princeton University(普林斯顿大学);Together AI;University of Illinois Urbana-Champaign(伊利诺伊大学厄巴纳-香槟分校);Carnegie Mellon University(卡内基梅隆大学);University of Connecticut(康涅狄格大学)

Tianle Cai, Yuhong Li, Zhengyang Geng, Hongwu Peng, Jason D. Lee, Deming Chen, Tri Dao

AI总结:

Medusa 通过在冻结或联合微调的 LLM 上增加多个解码头并行预测并验证多个后续 token,以树注意力减少解码步骤,实现 2.2-3.6 倍无损推理加速。

摘要:

大型语言模型(LLMs)采用自回归解码,需要顺序计算,每一步都依赖于前一步的输出。这形成了一个瓶颈,因为每一步都需要将完整的模型参数从高带宽存储器(HBM)移动到加速器的缓存中。虽然诸如推测解码(speculative decoding)等方法已被提出来解决这一问题,但其实现受到获取和维护单独草稿模型相关挑战的阻碍。在本文中,我们提出了 Medusa,一种高效的方法,通过添加额外的解码头来并行预测多个后续 token,从而增强 LLM 推理。Medusa 使用基于树的注意力机制,构建多个候选续写,并在每个解码步骤中同时验证它们。通过利用并行处理,Medusa 大幅减少了所需的解码步骤数量。我们为 Medusa 提出了两个级别的微调流程,以满足不同使用场景的需求:Medusa-1:Medusa 直接在冻结的主干 LLM 之上进行微调,实现无损推理加速。Medusa-2:Medusa 与主干 LLM 一起微调,使 Medusa 头具有更好的预测精度和更高的加速比,但需要一种特殊的训练配方来保持主干模型的能力。此外,我们提出了几个扩展来改进或扩展 Medusa 的实用性,包括一种自蒸馏方法来处理没有训练数据可用的情形,以及一种典型接受方案来在保持生成质量的同时提高接受率。我们在不同规模和不同训练流程的模型上评估了 Medusa。我们的实验表明,Medusa-1 可以在不损害生成质量的情况下实现超过 2.2 倍的加速,而 Medusa-2 进一步将加速比提高到 2.3-3.6 倍。

英文摘要:

Large Language Models (LLMs) employ auto-regressive decoding that requires sequential computation, with each step reliant on the previous one's output. This creates a bottleneck as each step necessitates moving the full model parameters from High-Bandwidth Memory (HBM) to the accelerator's cache. While methods such as speculative decoding have been suggested to address this issue, their implementation is impeded by the challenges associated with acquiring and maintaining a separate draft model. In this paper, we present Medusa, an efficient method that augments LLM inference by adding extra decoding heads to predict multiple subsequent tokens in parallel. Using a tree-based attention mechanism, Medusa constructs multiple candidate continuations and verifies them simultaneously in each decoding step. By leveraging parallel processing, Medusa substantially reduces the number of decoding steps required. We present two levels of fine-tuning procedures for Medusa to meet the needs of different use cases: Medusa-1: Medusa is directly fine-tuned on top of a frozen backbone LLM, enabling lossless inference acceleration. Medusa-2: Medusa is fine-tuned together with the backbone LLM, enabling better prediction accuracy of Medusa heads and higher speedup but needing a special training recipe that preserves the backbone model's capabilities. Moreover, we propose several extensions that improve or expand the utility of Medusa, including a self-distillation to handle situations where no training data is available and a typical acceptance scheme to boost the acceptance rate while maintaining generation quality. We evaluate Medusa on models of various sizes and training procedures. Our experiments demonstrate that Medusa-1 can achieve over 2.2x speedup without compromising generation quality, while Medusa-2 further improves the speedup to 2.3-3.6x.

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

↑