SWIFT:用于LLM推理加速的即时自推测解码
SWIFT: On-the-Fly Self-Speculative Decoding for LLM Inference Acceleration
AI总结:
针对推测解码需额外训练草稿模型的问题,提出即插即用的自推测解码算法SWIFT,通过自适应跳过LLM中间层实现1.3-1.6倍推理加速且不改变生成分布。
摘要:
推测解码(SD)已成为一种广泛使用的范式,用于在不损害质量的前提下加速LLM推理。其工作原理是首先使用一个紧凑模型高效地起草多个token,然后使用目标LLM对它们进行并行验证。尽管该技术取得了显著的加速效果,但现有大多数方法需要额外参数或大量训练来构建有效的草稿模型,从而限制了它们在不同LLM和任务中的适用性。为了解决这一局限性,我们探索了一种基于层跳跃的新型即插即用SD解决方案,将目标LLM的中间层跳过作为紧凑草稿模型。我们的分析表明,LLM通过层稀疏性展现出巨大的自加速潜力,且这种稀疏性具有任务特定性。基于这些洞察,我们提出了SWIFT,这是一种即时自推测解码算法,在推理过程中自适应地选择LLM的中间层进行跳过。SWIFT不需要辅助模型或额外训练,使其成为加速跨多种输入数据流LLM推理的即插即用解决方案。我们在广泛的模型和下游任务上的大量实验表明,SWIFT能实现超过1.3倍至1.6倍的加速,同时保持生成文本的原始分布。我们在https://github.com/hemingkx/SWIFT发布了代码。
英文摘要:
Speculative decoding (SD) has emerged as a widely used paradigm to accelerate LLM inference without compromising quality. It works by first employing a compact model to draft multiple tokens efficiently and then using the target LLM to verify them in parallel. While this technique has achieved notable speedups, most existing approaches necessitate either additional parameters or extensive training to construct effective draft models, thereby restricting their applicability across different LLMs and tasks. To address this limitation, we explore a novel plug-and-play SD solution with layer-skipping, which skips intermediate layers of the target LLM as the compact draft model. Our analysis reveals that LLMs exhibit great potential for self-acceleration through layer sparsity and the task-specific nature of this sparsity. Building on these insights, we introduce SWIFT, an on-the-fly self-speculative decoding algorithm that adaptively selects intermediate layers of LLMs to skip during inference. SWIFT does not require auxiliary models or additional training, making it a plug-and-play solution for accelerating LLM inference across diverse input data streams. Our extensive experiments across a wide range of models and downstream tasks demonstrate that SWIFT can achieve over a 1.3x-1.6x speedup while preserving the original distribution of the generated text. We release our code in https://github.com/hemingkx/SWIFT.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。