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

CacheGen:面向快速大语言模型服务的KV缓存压缩与流式传输

CacheGen: KV Cache Compression and Streaming for Fast Large Language Model Serving

University of Chicago(芝加哥大学);Microsoft(微软公司);Stanford University(斯坦福大学)
Yuhan Liu, Hanchen Li, Yihua Cheng, Siddhant Ray, Yuyang Huang, Qizheng Zhang, Kuntai Du, Jiayi Yao, Shan Lu, Ganesh Ananthanarayanan, Michael Maire, Henry Hoff… 展开作者

Yuhan Liu, Hanchen Li, Yihua Cheng, Siddhant Ray, Yuyang Huang, Qizheng Zhang, Kuntai Du, Jiayi Yao, Shan Lu, Ganesh Ananthanarayanan, Michael Maire, Henry Hoffmann, Ari Holtzman, Junchen Jiang

AI总结:

CacheGen通过自定义张量编码器和自适应压缩级别,压缩并流式传输KV缓存,减少带宽占用和上下文加载延迟,同时保持生成质量,相比现有系统缓存大小减少3.5-4.3倍,总延迟减少3.2-3.7倍。

摘要:

随着大语言模型(LLMs)承担复杂任务,其输入会补充更长的上下文,这些上下文包含领域知识。然而,使用长上下文具有挑战性,因为在LLM处理完整个上下文之前,无法生成任何内容。虽然可以通过在不同输入间重用上下文的KV缓存来减少上下文处理延迟,但通过网络获取包含大型张量的KV缓存可能会导致较高的额外网络延迟。CacheGen是面向LLM系统的快速上下文加载模块。首先,CacheGen使用自定义张量编码器,利用KV缓存的分布特性将KV缓存编码为更紧凑的比特流表示,且解码开销可忽略不计,以节省带宽使用。其次,CacheGen自适应调整KV缓存不同部分的压缩级别,以应对可用带宽的变化,从而保持较低的上下文加载延迟和较高的生成质量。当可用带宽下降时,CacheGen可能会提高上下文某部分的压缩级别,或即时重新计算其KV缓存。我们在流行的LLM和数据集上测试了CacheGen。与近期重用KV缓存的系统相比,CacheGen将KV缓存大小减少了3.5-4.3倍,并将获取和处理上下文的总延迟减少了3.2-3.7倍,对LLM响应质量的影响可忽略不计。我们的代码位于:https://github.com/UChi-JCL/CacheGen。

英文摘要:

As large language models (LLMs) take on complex tasks, their inputs are supplemented with longer contexts that incorporate domain knowledge. Yet using long contexts is challenging, as nothing can be generated until the whole context is processed by the LLM. While the context-processing delay can be reduced by reusing the KV cache of a context across different inputs, fetching the KV cache, which contains large tensors, over the network can cause high extra network delays. CacheGen is a fast context-loading module for LLM systems. First, CacheGen uses a custom tensor encoder, leveraging KV cache's distributional properties to encode a KV cache into more compact bitstream representations with negligible decoding overhead, to save bandwidth usage. Second, CacheGen adapts the compression level of different parts of a KV cache to cope with changes in available bandwidth, in order to maintain low context-loading delay and high generation quality. % When available bandwidth drops, CacheGen may raise the compression level for a part of the context or recompute its KV cache on the fly. We test CacheGen on popular LLMs and datasets. Compared to the recent systems that reuse the KV cache, CacheGen reduces the KV cache size by 3.5-4.3x and the total delay in fetching and processing contexts by 3.2-3.7x with negligible impact on the LLM response quality. Our code is at: https://github.com/UChi-JCL/CacheGen.

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

↑