SpeCache:面向大语言模型高效生成的推测式键值缓存
SpeCache: Speculative Key-Value Caching for Efficient Generation of LLMs
AI总结:
针对长序列下大语言模型KV缓存占用显存过高的瓶颈,提出SpeCache框架,通过CPU卸载完整KV缓存、低比特副本调度取回及推测预取实现计算通信并行,在高压缩比下兼顾显存效率与长序列性能。
摘要:
基于Transformer的大语言模型(LLM)已在长文本任务上取得显著成果,但有限的GPU显存(VRAM)资源难以满足随序列长度线性增长的键值(KV)缓存需求,这已成为LLM在长序列场景应用的瓶颈。现有的KV缓存压缩方法包括对KV缓存进行驱逐、合并或量化以减小其体积,但压缩会导致不可逆的信息遗忘,可能影响后续解码的准确性。本文提出SpeCache,充分利用容量大且易扩展的CPU内存来卸载完整的KV缓存,并通过显存中的低比特KV缓存副本衡量KV对的重要性,在每个解码步骤动态将KV对取回显存。为避免CPU与GPU通信带来的推理延迟,SpeCache会推测式预测下一个token可能关注的KV对,从而在下一个解码步骤开始前预取这些KV对,实现预取与计算的并行化。在LongBench和Needle-in-a-Haystack基准上的实验验证表明,SpeCache无需重新训练,在长序列场景下既能有效降低显存占用,又能避免信息遗忘,即便在10倍的高KV缓存压缩比下依然如此。
英文摘要:
Transformer-based large language models (LLMs) have already achieved remarkable results on long-text tasks, but the limited GPU memory (VRAM) resources struggle to accommodate the linearly growing demand for key-value (KV) cache as the sequence length increases, which has become a bottleneck for the application of LLMs on long sequences. Existing KV cache compression methods include eviction, merging, or quantization of the KV cache to reduce its size. However, compression results in irreversible information forgetting, potentially affecting the accuracy of subsequent decoding. In this paper, we propose SpeCache, which takes full advantage of the large and easily expandable CPU memory to offload the complete KV cache, and dynamically fetches KV pairs back in each decoding step based on their importance measured by low-bit KV cache copy in VRAM. To avoid inference latency caused by CPU-GPU communication, SpeCache speculatively predicts the KV pairs that the next token might attend to, allowing us to prefetch them before the next decoding step which enables parallelization of prefetching and computation. Experiments on LongBench and Needle-in-a-Haystack benchmarks verify that SpeCache effectively reduces VRAM usage while avoiding information forgetting for long sequences without re-training, even with a 10x high KV cache compression ratio.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。