重新审视大模型服务中的键值缓存压缩技术,发现其实际部署中的性能瓶颈。
Rethinking Key-Value Cache Compression Techniques for Large Language Model Serving
- 从实际应用出发,系统评估主流压缩方法的优劣。
- 发现压缩虽省内存,但可能降低吞吐量并增加延迟。
- 开源工具助力未来研究与生产落地。
键值缓存(KV cache)压缩已成为优化大语言模型(LLM)服务的有前景技术,主要通过降低KV缓存内存占用来减少计算开销。尽管已有多种压缩算法,但在生产环境中的应用仍不普遍。本文从实用角度重新审视主流KV缓存压缩方案。首先,全面回顾现有算法设计与基准研究,识别出性能评估中的缺失环节,可能阻碍其实际采用。其次,实证评估代表性压缩方法,揭示两个影响计算效率的关键问题:(1) 虽然压缩能减少内存消耗,但当前实现(如FlashAttention、PagedAttention)未针对生产级LLM服务优化,导致吞吐量不佳;(2) 压缩可能导致输出变长,从而增加端到端延迟。进一步分析单个样本的准确率表现,揭示了在特定任务中KV缓存压缩的内在局限性。最后,提供工具以指导未来研究,并促进其在生产环境中的部署,相关代码已开源至https://github.com/LLMkvsys/rethink-kv-compression。
原文摘要 · Abstract (English)
Key-Value cache (\texttt{KV} \texttt{cache}) compression has emerged as a promising technique to optimize Large Language Model (LLM) serving. It primarily decreases the memory consumption of \texttt{KV} \texttt{cache} to reduce the computation cost. Despite the development of many compression algorithms, their applications in production environments are still not prevalent. In this paper, we revisit mainstream \texttt{KV} \texttt{cache} compression solutions from a practical perspective. Our contributions are three-fold. First, we comprehensively review existing algorithmic designs and benchmark studies for \texttt{KV} \texttt{cache} compression and identify missing pieces in their performance measurement, which could hinder their adoption in practice. Second, we empirically evaluate representative \texttt{KV} \texttt{cache} compression methods to uncover two key issues that affect the computational efficiency: (1) while compressing \texttt{KV} \texttt{cache} can reduce memory consumption, current implementations (e.g., FlashAttention, PagedAttention) do not optimize for production-level LLM serving, resulting in suboptimal throughput performance; (2) compressing \texttt{KV} \texttt{cache} may lead to longer outputs, resulting in increased end-to-end latency. We further investigate the accuracy performance of individual samples rather than the overall performance, revealing the intrinsic limitations in \texttt{KV} \texttt{cache} compression when handling specific LLM tasks. Third, we provide tools to shed light on future \texttt{KV} \texttt{cache} compression studies and facilitate their practical deployment in production. They are open-sourced in \href{https://github.com/LLMkvsys/rethink-kv-compression}{https://github.com/LLMkvsys/rethink-kv-compression}.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。