arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2307.02628cs.CL
收藏

SkipDecode:面向高效大语言模型推理的带批处理与缓存的自回归跳跃解码

SkipDecode: Autoregressive Skip Decoding with Batching and Caching for Efficient LLM Inference

Microsoft Research(微软研究院)

Luciano Del Corro, Allie Del Giorno, Sahaj Agarwal, Bin Yu, Ahmed Awadallah, Subhabrata Mukherjee

AI总结:

SkipDecode 提出一种令牌级提前退出方法,通过为批次中每个令牌设置单一且单调递减的退出点并绕过中低层计算,实现与批处理和 KV 缓存兼容的 2 至 5 倍大语言模型推理加速。

摘要:

自回归大语言模型(LLMs)在各种自然语言生成任务中取得了显著进展。然而,由于自回归逐令牌生成的方式,它们会产生高昂的计算成本和延迟。为了解决这一问题,已有若干方法被提出,利用提前退出策略来降低计算成本。这些策略能够在不将完整计算图应用于每个令牌的情况下,以更少的计算实现更快的文本生成。虽然现有的令牌级提前退出方法在在线推理中表现出良好效果,但它们难以直接应用于批处理推理和键值(Key-Value,KV)缓存。这是因为它们必须等到一个批次中的最后一个令牌退出后才能停止计算。这严重限制了此类技术的实际应用。在本文中,我们提出了一种简单而有效的令牌级提前退出方法 SkipDecode,其设计目标是能够与批处理推理和 KV 缓存无缝协作。它通过在每个序列位置上为批次中的每个令牌设置一个单一的退出点,克服了此前的约束。它还保证了退出点的单调递减,从而消除了为前面令牌重新计算 KV 缓存的需要。与先前工作中提前终止计算的做法不同,我们的方法绕过较低层到中间层,将大部分计算资源用于较高层,从而使后续令牌能够受益于先前令牌所投入的计算开销。我们的实验结果表明,SkipDecode 可以在各种任务上获得 2 倍到 5 倍的推理加速,同时性能回退几乎可以忽略不计。这一结果是在 13 亿参数和 67 亿参数的 OPT 模型上取得的,并且始终能够直接兼容批处理和 KV 缓存优化技术。

英文摘要:

Autoregressive large language models (LLMs) have made remarkable progress in various natural language generation tasks. However, they incur high computation cost and latency resulting from the autoregressive token-by-token generation. To address this issue, several approaches have been proposed to reduce computational cost using early-exit strategies. These strategies enable faster text generation using reduced computation without applying the full computation graph to each token. While existing token-level early exit methods show promising results for online inference, they cannot be readily applied for batch inferencing and Key-Value caching. This is because they have to wait until the last token in a batch exits before they can stop computing. This severely limits the practical application of such techniques. In this paper, we propose a simple and effective token-level early exit method, SkipDecode, designed to work seamlessly with batch inferencing and KV caching. It overcomes prior constraints by setting up a singular exit point for every token in a batch at each sequence position. It also guarantees a monotonic decrease in exit points, thereby eliminating the need to recompute KV Caches for preceding tokens. Rather than terminating computation prematurely as in prior works, our approach bypasses lower to middle layers, devoting most of the computational resources to upper layers, allowing later tokens to benefit from the compute expenditure by earlier tokens. Our experimental results show that SkipDecode can obtain 2x to 5x inference speedups with negligible regression across a variety of tasks. This is achieved using OPT models of 1.3 billion and 6.7 billion parameters, all the while being directly compatible with batching and KV caching optimization techniques.

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

↑