arXiv:2509.05165cs.LG2025-09被引 4

用复合令牌压缩KV缓存,让大模型长文本推理更快更省内存。

KVCompose: Efficient Structured KV Cache Compression with Composite Tokens

  • 按注意力得分选重要令牌,分层生成复合令牌保持结构统一
  • 在多个数据集上压缩率超60%,推理精度损失小于1%
  • 无需特殊算子,直接兼容现有推理引擎,适合部署落地

大型语言模型(LLMs)依赖键值(KV)缓存实现高效自回归解码,但缓存大小随上下文长度和模型深度线性增长,成为长文本推理的主要瓶颈。现有压缩方法或依赖僵化启发式规则,或因每注意力头差异破坏张量布局,或需专用计算内核。本文提出一种基于注意力引导、层自适应复合令牌的简单而有效的KV缓存压缩框架。该方法通过聚合注意力得分估算令牌重要性,独立选择各注意力头的代表性令牌,并将其对齐为符合现有推理引擎所需统一结构的复合令牌。全局分配机制进一步跨层动态调整保留预算,将更多容量分配给信息量高的层。该方法在显著降低内存占用的同时保持高精度,持续优于先前的结构化与半结构化方法。关键优势在于完全兼容标准推理流水线,为高效长上下文LLM部署提供实用且可扩展的解决方案。

原文摘要 · Abstract (English)

Large language models (LLMs) rely on key-value (KV) caches for efficient autoregressive decoding; however, cache size grows linearly with context length and model depth, becoming a major bottleneck in long-context inference. Prior KV cache compression methods either enforce rigid heuristics, disrupt tensor layouts with per-attention-head variability, or require specialized compute kernels. We propose a simple, yet effective, KV cache compression framework based on attention-guided, layer-adaptive composite tokens. Our method aggregates attention scores to estimate token importance, selects head-specific tokens independently, and aligns them into composite tokens that respect the uniform cache structure required by existing inference engines. A global allocation mechanism further adapts retention budgets across layers, assigning more capacity to layers with informative tokens. This approach achieves significant memory reduction while preserving accuracy, consistently outperforming prior structured and semi-structured methods. Crucially, our approach remains fully compatible with standard inference pipelines, offering a practical and scalable solution for efficient long-context LLM deployment.

KV缓存压缩长文本推理优化

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