arXiv:2501.19392cs.LG2025-01ICML被引 19

通过自适应量化压缩大模型键值缓存,大幅节省显存且几乎不损失精度。

Cache Me If You Must: Adaptive Key-Value Quantization for Large Language Models

  • 利用层间键值依赖关系,设计轻量适配器实现高效压缩。
  • 在Llama 3.2上实现每值2-2.5比特,困惑度误差低于1%。
  • 仅需单卡1-6小时校准,适合大规模模型部署场景。

大语言模型(LLM)在真实世界中高效部署依赖于键值(KV)缓存以处理长文本输出,避免重复计算。对于长上下文,键值缓存可占用数十吉字节设备内存,因其需存储每个令牌和层的向量表示。近期工作表明,可通过量化、剪枝或合并压缩缓存向量,但这些方法常在高压缩率下牺牲质量。本文基于两个观察:1)不同层间键与值的内在依赖性;2)对内部网络状态的高压缩机制。提出AQUA-KV,一种自适应键值缓存量化方法,利用紧凑适配器挖掘现有键值依赖,并针对不可预测信息进行“最优”压缩。AQUA-KV显著提升压缩率,同时保持先进LLM家族的高精度。在Llama 3.2模型上,实现每值2-2.5比特的近无损推理,困惑度与LongBench得分相对误差均低于1%。该方法为一次性、简单且高效,可在单张GPU上1-6小时内完成70B模型的校准。

原文摘要 · Abstract (English)

Efficient real-world deployments of large language models (LLMs) rely on Key-Value (KV) caching for processing and generating long outputs, reducing the need for repetitive computation. For large contexts, Key-Value caches can take up tens of gigabytes of device memory, as they store vector representations for each token and layer. Recent work has shown that the cached vectors can be compressed through quantization, pruning or merging, but these techniques often compromise quality towards higher compression rates. In this work, we aim to improve Key & Value compression by exploiting two observations: 1) the inherent dependencies between keys and values across different layers, and 2) high-compression mechanisms for internal network states. We propose AQUA-KV, an adaptive quantization for Key-Value caches that relies on compact adapters to exploit existing dependencies between Keys and Values, and aims to "optimally" compress the information that cannot be predicted. AQUA-KV significantly improves compression rates, while maintaining high accuracy on state-of-the-art LLM families. On Llama 3.2 LLMs, we achieve near-lossless inference at 2-2.5 bits per value with under $1\%$ relative error in perplexity and LongBench scores. AQUA-KV is one-shot, simple, and efficient: it can be calibrated on a single GPU within 1-6 hours, even for 70B models.

量化大模型缓存优化

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