TokenSelect:通过动态令牌级KV缓存选择实现LLM的高效长上下文推理与长度外推
TokenSelect: Efficient Long-Context Inference and Length Extrapolation for LLMs via Dynamic Token-Level KV Cache Selection
AI总结:
针对长上下文推理中性能下降和推理慢的问题,本文提出无需训练的TokenSelect方法,通过动态令牌级KV缓存选择和软投票机制,实现高达23.84倍注意力加速和2.28倍端到端加速,性能优于现有方法。
摘要:
大型语言模型(LLMs)的快速发展推动了当代应用中对处理扩展上下文序列的需求。然而,这一进展面临两个挑战:由于序列长度超出分布导致的性能下降,以及注意力机制的二次方计算复杂度引起的过长推理时间。这些问题限制了LLM在长上下文场景中的应用。在本文中,我们提出了动态令牌级KV缓存选择(TokenSelect),一种无需训练的方法,用于高效且准确的长上下文推理。TokenSelect基于非连续注意力稀疏性的观察,使用QK点积在令牌级别衡量每个头的KV缓存关键性。通过逐头软投票机制,TokenSelect在不牺牲准确性的情况下,选择性地将少量关键KV缓存令牌纳入注意力计算。为了进一步加速TokenSelect,我们基于连续查询相似性的观察设计了选择缓存,并实现了高效的Paged点积内核,显著减少了选择开销。对TokenSelect的全面评估表明,在注意力计算中实现了高达23.84倍的加速,端到端延迟加速高达2.28倍,同时与最先进的长上下文推理方法相比,提供了优越的性能。
英文摘要:
Rapid advances in Large Language Models (LLMs) have spurred demand for processing extended context sequences in contemporary applications. However, this progress faces two challenges: performance degradation due to sequence lengths out-of-distribution, and excessively long inference times caused by the quadratic computational complexity of attention. These issues limit LLMs in long-context scenarios. In this paper, we propose Dynamic Token-Level KV Cache Selection (TokenSelect), a training-free method for efficient and accurate long-context inference. TokenSelect builds upon the observation of non-contiguous attention sparsity, using QK dot products to measure per-head KV Cache criticality at token-level. By per-head soft voting mechanism, TokenSelect selectively involves a few critical KV cache tokens in attention calculation without sacrificing accuracy. To further accelerate TokenSelect, we design the Selection Cache based on observations of consecutive Query similarity and implemented the efficient Paged Dot Product Kernel, significantly reducing the selection overhead. A comprehensive evaluation of TokenSelect demonstrates up to $23.84\times$ speedup in attention computation and up to $2.28\times$ acceleration in end-to-end latency, while providing superior performance compared to state-of-the-art long-context inference methods.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。