arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2407.12820cs.CLcs.AIcs.LG
收藏

PQCache:基于乘积量化的KVCache用于长上下文LLM推理

PQCache: Product Quantization-based KVCache for Long Context LLM Inference

Peking University(北京大学);Purdue University(普渡大学);Baichuan Inc.(百川智能)

Hailin Zhang, Xiaodong Ji, Yilin Chen, Fangcheng Fu, Xupeng Miao, Xiaonan Nie, Weipeng Chen, Bin Cui

AI总结:

PQCache利用乘积量化管理KVCache,将存储检索视为嵌入检索问题,在保持模型质量的同时降低服务延迟,实验显示在InfiniteBench上提升4.60%且延迟低。

摘要:

随着大型语言模型(LLMs)领域的持续发展,推理过程中的上下文长度正在稳步增长。键值缓存(KVCache)作为LLM推理中令牌的中间表示,由于GPU内存有限,现已成为主要的内存瓶颈。当前方法选择性地确定适合LLM自注意力计算的键和值来解决该问题。然而,它们要么在保持模型质量方面有所欠缺,要么导致较高的服务延迟。受数据管理社区中先进的嵌入检索技术的启发,我们将KVCache的存储和检索视为一个典型的嵌入检索问题。我们提出了PQCache,它采用乘积量化(PQ)来管理KVCache,在保持模型质量的同时确保低服务延迟。在预填充阶段,我们对每个LLM层和头的令牌键应用PQ。在自回归解码阶段,我们使用PQ码和质心近似识别重要的先前令牌,然后获取相应的键值对进行自注意力计算。通过精心设计的重叠和缓存机制,我们最小化了两个阶段中的任何额外计算和通信开销。大量实验表明,PQCache在有效性和效率方面均表现出色,在InfiniteBench上比现有方法提高了4.60%的分数,并且在预填充和解码阶段均具有低系统延迟。

英文摘要:

As the field of Large Language Models (LLMs) continues to evolve, the context length in inference is steadily growing. Key-Value Cache (KVCache), the intermediate representations of tokens within LLM inference, has now become the primary memory bottleneck due to limited GPU memory. Current methods selectively determine suitable keys and values for self-attention computation in LLMs to address the issue. However, they either fall short in maintaining model quality or result in high serving latency. Drawing inspiration from advanced embedding retrieval techniques prevalent in the data management community, we consider the storage and retrieval of KVCache as a typical embedding retrieval problem. We propose PQCache, which employs Product Quantization (PQ) to manage KVCache, maintaining model quality while ensuring low serving latency. During the prefilling phase, we apply PQ to tokens' keys for each LLM layer and head. During the autoregressive decoding phase, we use PQ codes and centroids to approximately identify important preceding tokens, then fetch the corresponding key-value pairs for self-attention computation. Through meticulous design of overlapping and caching, we minimize any additional computation and communication overhead during both phases. Extensive experiments demonstrate that PQCache achieves both effectiveness and efficiency, with 4.60% score improvement over existing methods on InfiniteBench and low system latency in both prefilling and decoding.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑