通过滑动窗口压缩键值缓存,提升推理大模型的吞吐量。
KARA: Efficient Reasoning LLM Serving via Sliding-Window KV Cache Compression

- 基于最近生成内容的滑动窗口,动态选择重要键值对。
- 在多个数据集上将吞吐量提升1.3–2.1倍,内存占用降低50%以上。
- 适合高并发长文本推理场景,尤其适用于资源受限环境。
推理型语言模型常生成长链条思维(CoT),导致解码过程中累积大量键值(KV)缓存,引发高延迟和低吞吐。现有KV缓存压缩方法存在两大缺陷:一是阈值触发的压缩策略可能无法提升吞吐甚至降低性能,且会完全丢弃某些序列块的缓存,加剧信息丢失;二是通常仅保留孤立缓存或固定大小的块,难以灵活保留任意位置的重要语义片段。为此,我们提出Kara,一种仅在最近生成上下文上进行解码时压缩的滑动窗口方法。Kara利用双向注意力评分并选择关键缓存对,并设计Token2Chunk模块将部分选中的缓存对扩展为可变长度语义块。此外,我们将Kara适配至PagedAttention,构建了基于vLLM的KvLLM推理框架,显著降低KV缓存内存占用并有效提升输出吞吐。大量实验表明,Kara与KvLLM在多个基准测试中均实现一致的性能提升。
原文摘要 · Abstract (English)
Reasoning language models often generate long chain-of-thought (CoT), which accumulates a massive KV cache during the decoding phase and incurs high decoding latency and limited throughput. To address these issues, KV cache compression has emerged as a promising technique for reducing memory overhead by selectively removing unimportant KV pairs while preserving useful ones for subsequent decoding. Nevertheless, we identify two key limitations in existing KV cache compression methods: 1) their threshold-triggered compression policy may provide limited throughput improvement or even reduce throughput, and may fully eliminate KV pairs from certain blocks of the sequence, potentially worsening information loss. 2) they typically retain either isolated KV pairs or fixed-size chunks with rigid boundaries, failing to preserve important flexible-sized chunks at arbitrary token positions. To overcome these limitations, we propose Kara, a sliding-window KV cache compression method that performs decoding-time compression by operating only on the recently generated context. Kara leverages bidirectional attention to score and select informative KV pairs in the window. To enable flexible preservation of important semantic information, we design a Token2Chunk module to expand a subset of selected KV pairs into chunks. Furthermore, we adapt Kara to PagedAttention and develop KvLLM, an inference framework built upon vLLM, which reduces KV cache memory usage and effectively improves output throughput. Extensive experiments demonstrate consistent performance improvements of proposed Kara and KvLLM.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。