ShadowKV:面向高吞吐量长上下文LLM推理的影子KV Cache
ShadowKV: KV Cache in Shadows for High-Throughput Long-Context LLM Inference
AI总结:
提出ShadowKV,通过存储低秩键缓存并卸载值缓存及精确KV选择策略,在A100上支持6倍批处理和3.04倍吞吐提升,无损精度服务长上下文LLM。
摘要:
随着长上下文大型语言模型(LLM)的广泛部署,对高效支持高吞吐量推理的需求日益增长。然而,随着序列长度的增加,键值(KV)缓存不断扩展,其不断增大的内存占用以及每个token生成时都需要访问它的需求,均导致在服务长上下文LLM时吞吐量低下。尽管已有多种动态稀疏注意力方法被提出以在保持生成质量的同时加速推理,但它们要么无法充分降低GPU内存消耗,要么因将KV缓存卸载到CPU而引入显著的解码延迟。我们提出了ShadowKV,这是一个高吞吐量的长上下文LLM推理系统,它存储低秩键缓存并卸载值缓存,以减少内存占用,从而支持更大的批处理大小和更长的序列。为了最小化解码延迟,ShadowKV采用了一种精确的KV选择策略,能够即时重建最少的稀疏KV对。通过在包括RULER、LongBench和Needle In A Haystack在内的广泛基准测试,以及Llama-3.1-8B、Llama-3-8B-1M、GLM-4-9B-1M、Yi-9B-200K、Phi-3-Mini-128K和Qwen2-7B-128K等模型上评估ShadowKV,我们证明它可以在A100 GPU上支持高达6倍的批处理大小,并将吞吐量提升高达3.04倍,且不牺牲准确性,甚至超越了在假设GPU内存无限的情况下无限批处理大小所能达到的性能。代码可在https://github.com/bytedance/ShadowKV获取。
英文摘要:
With the widespread deployment of long-context large language models (LLMs), there has been a growing demand for efficient support of high-throughput inference. However, as the key-value (KV) cache expands with the sequence length, the increasing memory footprint and the need to access it for each token generation both result in low throughput when serving long-context LLMs. While various dynamic sparse attention methods have been proposed to speed up inference while maintaining generation quality, they either fail to sufficiently reduce GPU memory consumption or introduce significant decoding latency by offloading the KV cache to the CPU. We present ShadowKV, a high-throughput long-context LLM inference system that stores the low-rank key cache and offloads the value cache to reduce the memory footprint for larger batch sizes and longer sequences. To minimize decoding latency, ShadowKV employs an accurate KV selection strategy that reconstructs minimal sparse KV pairs on-the-fly. By evaluating ShadowKV on a broad range of benchmarks, including RULER, LongBench, and Needle In A Haystack, and models like Llama-3.1-8B, Llama-3-8B-1M, GLM-4-9B-1M, Yi-9B-200K, Phi-3-Mini-128K, and Qwen2-7B-128K, we demonstrate that it can support up to 6$\times$ larger batch sizes and boost throughput by up to 3.04$\times$ on an A100 GPU without sacrificing accuracy, even surpassing the performance achievable with infinite batch size under the assumption of infinite GPU memory. The code is available at https://github.com/bytedance/ShadowKV.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。