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

Quest:用于高效长上下文LLM推理的查询感知稀疏性

Quest: Query-Aware Sparsity for Efficient Long-Context LLM Inference

Shanghai Jiao Tong University(上海交通大学);MIT(麻省理工学院);University of Washington(华盛顿大学);NVIDIA(英伟达)

Jiaming Tang, Yilong Zhao, Kan Zhu, Guangxuan Xiao, Baris Kasikci, Song Han

AI总结:

提出查询感知的KV缓存选择算法Quest,通过跟踪Key极值并利用Query向量评估页面关键性,仅加载Top-K关键页面进行注意力计算,实现2.23倍自注意力加速与7.03倍延迟降低且几乎无精度损失。

摘要:

随着对长上下文大型语言模型(LLMs)需求的增加,具有高达128K或1M tokens上下文窗口的模型正变得越来越普遍。然而,长上下文LLM推理具有挑战性,因为随着序列长度的增加,推理速度会显著下降。这种减速主要是由在自注意力机制期间加载大型KV缓存引起的。先前的工作表明,少量关键tokens将主导注意力结果。然而,我们观察到token的关键性高度依赖于query。为此,我们提出了Quest,一种查询感知的KV缓存选择算法。Quest跟踪KV缓存页面中的最小和最大Key值,并使用Query向量估计给定页面的关键性。通过仅加载Top-K关键KV缓存页面进行注意力计算,Quest在不牺牲准确性的情况下显著加速了自注意力。我们表明,Quest可以实现高达2.23倍的自注意力加速,将推理延迟降低7.03倍,同时在具有长依赖的任务上表现良好且准确性损失可忽略不计。代码可在http://github.com/mit-han-lab/Quest获取。

英文摘要:

As the demand for long-context large language models (LLMs) increases, models with context windows of up to 128K or 1M tokens are becoming increasingly prevalent. However, long-context LLM inference is challenging since the inference speed decreases significantly as the sequence length grows. This slowdown is primarily caused by loading a large KV cache during self-attention. Previous works have shown that a small portion of critical tokens will dominate the attention outcomes. However, we observe the criticality of a token highly depends on the query. To this end, we propose Quest, a query-aware KV cache selection algorithm. Quest keeps track of the minimal and maximal Key values in KV cache pages and estimates the criticality of a given page using Query vectors. By only loading the Top-K critical KV cache pages for attention, Quest significantly speeds up self-attention without sacrificing accuracy. We show that Quest can achieve up to 2.23x self-attention speedup, which reduces inference latency by 7.03x while performing well on tasks with long dependencies with negligible accuracy loss. Code is available at http://github.com/mit-han-lab/Quest .

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

↑