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

Deja Vu:面向高效大语言模型推理的上下文稀疏性

Deja Vu: Contextual Sparsity for Efficient LLMs at Inference Time

Rice University(莱斯大学);Zhe Jiang University(浙江大学);Stanford University(斯坦福大学);University of California, San Diego(加利福尼亚大学圣迭戈分校);ETH Zurich(苏黎世联邦理工学院);Adobe Research(Adobe研究院);Meta AI (FAIR)(Meta AI(FAIR));Carnegie Mellon University(卡内基梅隆大学)

Zichang Liu, Jue Wang, Tri Dao, Tianyi Zhou, Binhang Yuan, Zhao Song, Anshumali Shrivastava, Ce Zhang, Yuandong Tian, Christopher Re, Beidi Chen

AI总结:

本文提出DejaVu系统,通过实时预测并利用输入相关的上下文稀疏性(注意力头与MLP参数子集),在不损失模型质量和上下文学习能力的前提下,将OPT-175B推理延迟相比FasterTransformer降低超过2倍。

摘要:

拥有数千亿参数的大语言模型(LLMs)引发了一波令人兴奋的AI应用新浪潮。然而,它们在推理时的计算开销十分高昂。稀疏化是降低这一成本的自然方法,但现有方法要么需要昂贵的重新训练,要么不得不放弃LLM的上下文学习能力,要么无法在现代硬件上实现实际运行时间的加速。我们提出假设:上下文稀疏性——即针对给定输入,由少量依赖输入的注意力头和MLP参数组成的集合,其输出与稠密模型近似相同——能够解决这些问题。我们证明了上下文稀疏性的存在,证明它可以被准确预测,并且我们能够利用它在实际运行时间上加速LLM推理,同时不损害LLM的质量或上下文学习能力。基于这些见解,我们提出了DejaVu,这是一个系统,它使用一种低成本算法在给定各层输入时实时预测上下文稀疏性,并采用异步且硬件感知的实现来加速LLM推理。我们验证了DejaVu能够将OPT-175B的推理延迟相比最先进的FasterTransformer降低超过2倍,相比广泛使用的Hugging Face实现降低超过6倍,且不损害模型质量。代码可在https://github.com/FMInference/DejaVu获取。

英文摘要:

Large language models (LLMs) with hundreds of billions of parameters have sparked a new wave of exciting AI applications. However, they are computationally expensive at inference time. Sparsity is a natural approach to reduce this cost, but existing methods either require costly retraining, have to forgo LLM's in-context learning ability, or do not yield wall-clock time speedup on modern hardware. We hypothesize that contextual sparsity, which are small, input-dependent sets of attention heads and MLP parameters that yield approximately the same output as the dense model for a given input, can address these issues. We show that contextual sparsity exists, that it can be accurately predicted, and that we can exploit it to speed up LLM inference in wall-clock time without compromising LLM's quality or in-context learning ability. Based on these insights, we propose DejaVu, a system that uses a low-cost algorithm to predict contextual sparsity on the fly given inputs to each layer, along with an asynchronous and hardware-aware implementation that speeds up LLM inference. We validate that DejaVu can reduce the inference latency of OPT-175B by over 2X compared to the state-of-the-art FasterTransformer, and over 6X compared to the widely used Hugging Face implementation, without compromising model quality. The code is available at https://github.com/FMInference/DejaVu.

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

↑