CORM: Cache Optimization with Recent Message for Large Language Model Inference

Fuente: arXiv
Guardado en:
Detalles Bibliográficos
Autores principales: Dai, Jincheng, Huang, Zhuowei, Jiang, Haiyun, Chen, Chen, Cai, Deng, Bi, Wei, Shi, Shuming
Formato: Preprint
Publicado: 2024
Materias:
Acceso en línea:
Etiquetas: Agregar Etiqueta
Sin Etiquetas, Sea el primero en etiquetar este registro!
_version_ 1866929393006280704
author Dai, Jincheng
Huang, Zhuowei
Jiang, Haiyun
Chen, Chen
Cai, Deng
Bi, Wei
Shi, Shuming
author_facet Dai, Jincheng
Huang, Zhuowei
Jiang, Haiyun
Chen, Chen
Cai, Deng
Bi, Wei
Shi, Shuming
contents Large Language Models (LLMs), despite their remarkable performance across a wide range of tasks, necessitate substantial GPU memory and consume significant computational resources. Beyond the memory taken up by model weights, the memory used by the KV cache rises linearly with sequence length, becoming a primary bottleneck for inference. In this paper, we introduce an innovative method for optimizing the KV cache, which considerably minimizes its memory footprint. Upon thorough investigation, we discover that in most Transformer models, (i) there is a striking similarity between adjacent tokens' query vectors, and (ii) the attention calculation of the current query can rely exclusively on the attention information of a small fraction of preceding queries. Based on these observations, we present CORM, a KV cache eviction policy that dynamically retains essential key-value pairs for inference without the need for model fine-tuning. Our validation shows that CORM reduces the inference memory usage of KV cache by up to 70\% with negligible performance degradation across six tasks in LongBench. Furthermore, we demonstrate that CORM is compatible with GQA for further compression rate.
format Preprint
id arxiv_https___arxiv_org_abs_2404_15949
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle CORM: Cache Optimization with Recent Message for Large Language Model Inference
Dai, Jincheng
Huang, Zhuowei
Jiang, Haiyun
Chen, Chen
Cai, Deng
Bi, Wei
Shi, Shuming
Computation and Language
Artificial Intelligence
Machine Learning
Large Language Models (LLMs), despite their remarkable performance across a wide range of tasks, necessitate substantial GPU memory and consume significant computational resources. Beyond the memory taken up by model weights, the memory used by the KV cache rises linearly with sequence length, becoming a primary bottleneck for inference. In this paper, we introduce an innovative method for optimizing the KV cache, which considerably minimizes its memory footprint. Upon thorough investigation, we discover that in most Transformer models, (i) there is a striking similarity between adjacent tokens' query vectors, and (ii) the attention calculation of the current query can rely exclusively on the attention information of a small fraction of preceding queries. Based on these observations, we present CORM, a KV cache eviction policy that dynamically retains essential key-value pairs for inference without the need for model fine-tuning. Our validation shows that CORM reduces the inference memory usage of KV cache by up to 70\% with negligible performance degradation across six tasks in LongBench. Furthermore, we demonstrate that CORM is compatible with GQA for further compression rate.
title CORM: Cache Optimization with Recent Message for Large Language Model Inference
topic Computation and Language
Artificial Intelligence
Machine Learning
url https://arxiv.org/abs/2404.15949