arXiv:2507.08045cs.CLcs.AI2025-07被引 1

动态调整压缩策略,让大模型对话恢复更快更省空间。

Krul: Efficient State Restoration for Multi-turn Conversations with Dynamic Cross-layer KV Sharing

  • 根据对话特征动态选压缩方案,避免固定策略导致精度下降。
  • 相比顶尖方法,首次响应时间缩短1.5到2.68倍,缓存占用减少1.33到2.35倍。
  • 适合高并发、长对话场景的高效推理系统,尤其对资源受限部署有帮助。

大规模语言模型在多轮对话中的高效状态恢复仍是关键挑战,主要源于需重新计算或加载全部历史标记的键值(KV)缓存所造成的开销。现有方法通过压缩相邻层间具有高度相似注意力模式的KV缓存来缓解问题,但通常采用统一压缩策略,未考虑不同对话中注意力相似性的差异,导致准确率明显下降。本文提出Krul,一种支持精准且高效的多轮对话推理系统。Krul基于层间注意力相似性动态选择压缩策略,并采用重计算-加载流水线恢复KV缓存。其核心创新包括:1)预判式压缩策略选择器,保留未来对话轮次的关键上下文并为每轮对话定制策略;2)基于标记级别的异构注意力相似性估计算法,降低生成过程中的计算与存储开销;3)无气泡恢复调度器,消除因压缩缓存导致的重计算与加载不平衡带来的延迟。在真实任务上的实证评估表明,与当前最优方法相比,Krul在不牺牲生成质量的前提下,实现了1.5x–2.68x的首次响应时间(TTFT)降低和1.33x–2.35x的KV缓存存储减少。

原文摘要 · Abstract (English)

Efficient state restoration in multi-turn conversations with large language models (LLMs) remains a critical challenge, primarily due to the overhead of recomputing or loading full key-value (KV) caches for all historical tokens. To address this, existing approaches compress KV caches across adjacent layers with highly similar attention patterns. However, these methods often apply a fixed compression scheme across all conversations, selecting the same layer pairs for compression without considering conversation-specific attention dynamics. This static strategy overlooks variability in attention pattern similarity across different conversations, which can lead to noticeable accuracy degradation. We present Krul, a multi-turn LLM inference system that enables accurate and efficient KV cache restoration. Krul dynamically selects compression strategies based on attention similarity across layer pairs and uses a recomputation-loading pipeline to restore the KV cache. It introduces three key innovations: 1) a preemptive compression strategy selector to preserve critical context for future conversation turns and selects a customized strategy for the conversation; 2) a token-wise heterogeneous attention similarity estimator to mitigate the attention similarity computation and storage overhead during model generation; 3) a bubble-free restoration scheduler to reduce potential bubbles brought by the imbalance of recomputing and loading stream due to compressed KV caches. Empirical evaluations on real-world tasks demonstrate that Krul achieves a 1.5x-2.68x reduction in time-to-first-token (TTFT) and a 1.33x-2.35x reduction in KV cache storage compared to state-of-the-art methods without compromising generation quality.

多轮对话推理优化缓存压缩LLM

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。