BaKlaVa -- 长上下文推理中KV缓存的自适应内存分配
BaKlaVa -- Budgeted Allocation of KV cache for Long-context Inference
AI总结:
BaKlaVa通过估计各KV缓存重要性,为每个缓存分配最优内存预算,在LLaMA-3-8B和Qwen2.5-7B上实现高达70%压缩比且保持性能,高压缩下精度提升一个数量级。
摘要:
在大语言模型(LLM)推理中,键值(KV)缓存对于降低时间复杂度至关重要。然而,随着上下文长度的增长,它们会导致GPU内存线性增加。尽管近期工作探索了KV缓存驱逐和压缩策略以减少内存使用,但这些方法通常在所有注意力头上采用统一的KV缓存,导致性能次优。我们引入了BaKlaVa,一种通过估计每个KV缓存的重要性来为模型中各个KV缓存分配最优内存的方法。我们的实证分析表明,并非所有KV缓存对LLM性能都同等关键。利用一次性剖析方法,BaKLaVa为每个KV缓存分配最优内存预算。我们在LLaMA-3-8B和Qwen2.5-7B模型上评估了我们的方法,在保持基线性能的同时实现了高达70%的压缩比,并在更高压缩级别下提供了高达一个数量级的精度提升。
英文摘要:
In Large Language Model (LLM) inference, Key-Value (KV) caches (KV-caches) are essential for reducing time complexity. However, they result in a linear increase in GPU memory as the context length grows. While recent work explores KV-cache eviction and compression policies to reduce memory usage, they often consider uniform KV-caches across all attention heads, leading to suboptimal performance. We introduce BaKlaVa, a method to allocate optimal memory for individual KV-caches across the model by estimating the importance of each KV-cache. Our empirical analysis demonstrates that not all KV-caches are equally critical for LLM performance. Using a one-time profiling approach, BaKlaVa assigns optimal memory budgets to each KV-cache. We evaluated our method on LLaMA-3-8B, and Qwen2.5-7B models, achieving up to a 70\% compression ratio while keeping baseline performance and delivering up to an order-of-magnitude accuracy improvement at higher compression levels.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。