压缩可组合的KV缓存复用,显著提升长文本推理速度
C$^2$KV: Compressed and Composable KV Cache Reuse for Efficient LLM Inference

- 设计可压缩、可组合的KV缓存框架,支持灵活复用
- 在长上下文下实现最高17倍推理加速,保持生成质量
- 适合需要高效长文本推理的应用场景
长上下文推理是现代大语言模型应用(如检索增强生成和多文档推理)的核心。为缓解推理成本上升,现有方法探索通过重用键值(KV)缓存来减少冗余预填充计算。然而,现有方法主要关注计算节省,忽略了长上下文服务中的关键瓶颈:大规模KV缓存的存储与访问开销。虽然KV压缩看似自然互补,但将压缩与非前缀缓存复用简单结合常导致严重精度下降。本文提出C²KV,一个统一的非前缀KV缓存复用框架,联合优化提取与推理时拼接。C²KV学习一个可组合且压缩的KV缓存流形,明确设计为位置无关。方法引入轻量级侧车提取器,配备可学习压缩令牌和结构化注意力流,实现模块化表示,可灵活复用与拼接,无需修改冻结的基础模型。进一步采用压缩-拼接联合训练策略,对齐提取阶段表示与其下游重用行为。在多个长上下文基准与模型族上的大量实验表明,C²KV显著降低KV缓存存储与传输成本,在长上下文下实现最高17倍推理加速,同时保持生成质量。
原文摘要 · Abstract (English)
Long-context inference is central to modern large language model (LLM) applications such as retrieval-augmented generation and multi-document reasoning. To mitigate the growing inference cost, recent work has explored key-value (KV) cache reuse to reduce redundant prefill computation. However, existing reuse methods primarily focus on computation savings and overlook a critical bottleneck in long-context LLM serving: the cost of storing and accessing large KV caches. While KV compression appears to be a natural complement, naively combining compression with non-prefix KV reuse often leads to severe accuracy degradation. In this work, we propose C$^2$KV, a unified framework for non-prefix KV reuse that jointly optimizes KV extraction and inference-time concatenation. C$^2$KV learns a composable and compressed KV cache manifold that is explicitly designed to be position-agnostic. Our approach introduces a lightweight sidecar Extractor with learnable compression tokens and a structured attention flow, enabling modular KV representations that can be flexibly reused and concatenated without modifying the frozen base model. We further employ a compression-concatenation co-training strategy to align extraction-time representations with their downstream reuse behavior. Extensive experiments across multiple long-context benchmarks and model families demonstrate that C$^2$KV significantly reduces KV cache storage and transfer costs, achieving up to 17$\times$ inference speedup under long contexts, while preserving generation quality.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。