动态内存压缩:改造 LLMs 以实现加速推理
Dynamic Memory Compression: Retrofitting LLMs for Accelerated Inference
AI总结:
提出动态内存压缩(DMC)方法,通过持续预训练改造预训练 LLMs 实现推理时在线键值缓存压缩,在保持性能的同时提升吞吐量并适应更长上下文。
摘要:
Transformers 已成为大型语言模型(LLMs)的骨干。然而,由于需要在内存中存储过去 token 的键值表示缓存,其大小随输入序列长度和批处理大小线性增长,导致生成效率依然低下。作为解决方案,我们提出了动态内存压缩(DMC),一种在推理时进行在线键值缓存压缩的方法。最重要的是,模型学习在不同的头和层中应用不同的压缩率。我们将预训练的 LLMs(如 Llama 2(7B、13B 和 70B))改造为 DMC Transformers,在 NVIDIA H100 GPU 上的自回归推理过程中实现了高达 7 倍的吞吐量提升。DMC 通过在原始数据的极小百分比上进行持续预训练来应用,且不增加任何额外参数。DMC 在高达 4 倍缓存压缩下保持了原始的下游性能,优于向上训练的分组查询注意力(GQA)和键值驱逐策略(H$_2$O、TOVA)。GQA 和 DMC 甚至可以结合使用以获得复合增益。因此,DMC 可以作为现有 LLMs 中 KV 缓存的直接替代方案,以便在任何给定的内存预算内适应更长的上下文和更大的批次。
英文摘要:
Transformers have emerged as the backbone of large language models (LLMs). However, generation remains inefficient due to the need to store in memory a cache of key-value representations for past tokens, whose size scales linearly with the input sequence length and batch size. As a solution, we propose Dynamic Memory Compression (DMC), a method for online key-value cache compression at inference time. Most importantly, the model learns to apply different compression ratios in different heads and layers. We retrofit pre-trained LLMs such as Llama 2 (7B, 13B and 70B) into DMC Transformers, achieving up to 7x throughput increase during auto-regressive inference on an NVIDIA H100 GPU. DMC is applied via continued pre-training on a negligible percentage of the original data without adding any extra parameters. DMC preserves the original downstream performance with up to 4x cache compression, outperforming up-trained grouped-query attention (GQA) and key-value eviction policies (H$_2$O, TOVA). GQA and DMC can be even combined to obtain compounded gains. Hence, DMC can serve as a drop-in replacement for KV caching in existing LLMs to fit longer contexts and larger batches within any given memory budget.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。