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

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Liu, Yuhan, Li, Hanchen, Cheng, Yihua, Ray, Siddhant, Huang, Yuyang, Zhang, Qizheng, Du, Kuntai, Yao, Jiayi, Lu, Shan, Ananthanarayanan, Ganesh, Maire, Michael, Hoffmann, Henry, Holtzman, Ari, Jiang, Junchen
Format: Preprint
Published: 2023
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866929428130430976
author Liu, Yuhan
Li, Hanchen
Cheng, Yihua
Ray, Siddhant
Huang, Yuyang
Zhang, Qizheng
Du, Kuntai
Yao, Jiayi
Lu, Shan
Ananthanarayanan, Ganesh
Maire, Michael
Hoffmann, Henry
Holtzman, Ari
Jiang, Junchen
author_facet Liu, Yuhan
Li, Hanchen
Cheng, Yihua
Ray, Siddhant
Huang, Yuyang
Zhang, Qizheng
Du, Kuntai
Yao, Jiayi
Lu, Shan
Ananthanarayanan, Ganesh
Maire, Michael
Hoffmann, Henry
Holtzman, Ari
Jiang, Junchen
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2310_07240
institution arXiv
publishDate 2023
record_format arxiv
spellingShingle CacheGen: KV Cache Compression and Streaming for Fast Large Language Model Serving
Liu, Yuhan
Li, Hanchen
Cheng, Yihua
Ray, Siddhant
Huang, Yuyang
Zhang, Qizheng
Du, Kuntai
Yao, Jiayi
Lu, Shan
Ananthanarayanan, Ganesh
Maire, Michael
Hoffmann, Henry
Holtzman, Ari
Jiang, Junchen
Networking and Internet Architecture
Machine Learning
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.
title CacheGen: KV Cache Compression and Streaming for Fast Large Language Model Serving
topic Networking and Internet Architecture
Machine Learning
url https://arxiv.org/abs/2310.07240