通过低秩压缩KV缓存,显著降低大模型推理内存占用。
LoRC: Low-Rank Compression for LLMs KV Cache with a Progressive Compression Strategy
- 对KV矩阵做低秩近似,无需重训练即可集成
- 在8B到70B模型上实现内存大幅降低,性能几乎不变
- 适用于通用场景,无需调参或任务适配
键值(KV)缓存是服务基于Transformer的自回归大语言模型的关键组件,通过存储先前计算的KV向量加速推理。然而,其内存消耗随序列长度和批量大小线性增长,成为大模型部署的主要瓶颈。现有方法包括:(1) 在升级阶段集成高效注意力机制,需大量参数调优,不适合预训练模型;(2) 测试时进行KV缓存压缩,主要依赖令牌剔除策略,常忽略层间依赖且具有任务特异性。本文提出一种正交方法:对KV权重矩阵进行低秩近似,可无须模型重训练地无缝集成至现有Transformer架构。为有效在权重层面压缩缓存,我们考虑分层敏感性,并引入渐进式压缩策略,其理论分析支持压缩误差在深层网络中的累积规律。该方法无需升级阶段调参或测试阶段的任务定制。在8B至70B参数的LLaMA系列模型上,跨多种任务的实验表明,本方法显著降低GPU内存占用,同时保持性能稳定。
原文摘要 · Abstract (English)
The Key-Value (KV) cache is a crucial component in serving transformer-based autoregressive large language models (LLMs), enabling faster inference by storing previously computed KV vectors. However, its memory consumption scales linearly with sequence length and batch size, posing a significant bottleneck in LLM deployment. Existing approaches to mitigate this issue include: (1) efficient attention variants integrated in upcycling stages, which requires extensive parameter tuning thus unsuitable for pre-trained LLMs; (2) KV cache compression at test time, primarily through token eviction policies, which often overlook inter-layer dependencies and can be task-specific. This paper introduces an orthogonal approach to KV cache compression. We propose a low-rank approximation of KV weight matrices, allowing for plug-in integration with existing transformer-based LLMs without model retraining. To effectively compress KV cache at the weight level, we adjust for layerwise sensitivity and introduce a progressive compression strategy, which is supported by our theoretical analysis on how compression errors accumulate in deep networks. Our method is designed to function without model tuning in upcycling stages or task-specific profiling in test stages. Extensive experiments with LLaMA models ranging from 8B to 70B parameters across various tasks show that our approach significantly reduces the GPU memory footprint while maintaining performance.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。