ThinK: Thinner Key Cache by Query-Driven Pruning

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Xu, Yuhui, Jie, Zhanming, Dong, Hanze, Wang, Lei, Lu, Xudong, Zhou, Aojun, Saha, Amrita, Xiong, Caiming, Sahoo, Doyen
Format: Preprint
Publié: 2024
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866916632379523072
author Xu, Yuhui
Jie, Zhanming
Dong, Hanze
Wang, Lei
Lu, Xudong
Zhou, Aojun
Saha, Amrita
Xiong, Caiming
Sahoo, Doyen
author_facet Xu, Yuhui
Jie, Zhanming
Dong, Hanze
Wang, Lei
Lu, Xudong
Zhou, Aojun
Saha, Amrita
Xiong, Caiming
Sahoo, Doyen
contents Large Language Models (LLMs) have revolutionized the field of natural language processing, achieving unprecedented performance across a variety of applications. However, their increased computational and memory demands present significant challenges, especially when handling long sequences. This paper focuses on the long-context scenario, addressing the inefficiencies in KV cache memory consumption during inference. Unlike existing approaches that optimize the memory based on the sequence length, we identify substantial redundancy in the channel dimension of the KV cache, as indicated by an uneven magnitude distribution and a low-rank structure in the attention weights. In response, we propose ThinK, a novel query-dependent KV cache pruning method designed to minimize attention weight loss while selectively pruning the least significant channels. Our approach not only maintains or enhances model accuracy but also achieves a reduction in KV cache memory costs by over 20% compared with vanilla KV cache eviction and quantization methods. For instance, ThinK integrated with KIVI can achieve a 2.8x reduction in peak memory usage while maintaining nearly the same quality, enabling up to a 5x increase in batch size when using a single GPU. Extensive evaluations on the LLaMA and Mistral models across various long-sequence datasets verified the efficiency of ThinK, establishing a new baseline algorithm for efficient LLM deployment without compromising performance. Our code has been made available at https://github.com/SalesforceAIResearch/ThinK.
format Preprint
id arxiv_https___arxiv_org_abs_2407_21018
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle ThinK: Thinner Key Cache by Query-Driven Pruning
Xu, Yuhui
Jie, Zhanming
Dong, Hanze
Wang, Lei
Lu, Xudong
Zhou, Aojun
Saha, Amrita
Xiong, Caiming
Sahoo, Doyen
Computation and Language
Artificial Intelligence
Large Language Models (LLMs) have revolutionized the field of natural language processing, achieving unprecedented performance across a variety of applications. However, their increased computational and memory demands present significant challenges, especially when handling long sequences. This paper focuses on the long-context scenario, addressing the inefficiencies in KV cache memory consumption during inference. Unlike existing approaches that optimize the memory based on the sequence length, we identify substantial redundancy in the channel dimension of the KV cache, as indicated by an uneven magnitude distribution and a low-rank structure in the attention weights. In response, we propose ThinK, a novel query-dependent KV cache pruning method designed to minimize attention weight loss while selectively pruning the least significant channels. Our approach not only maintains or enhances model accuracy but also achieves a reduction in KV cache memory costs by over 20% compared with vanilla KV cache eviction and quantization methods. For instance, ThinK integrated with KIVI can achieve a 2.8x reduction in peak memory usage while maintaining nearly the same quality, enabling up to a 5x increase in batch size when using a single GPU. Extensive evaluations on the LLaMA and Mistral models across various long-sequence datasets verified the efficiency of ThinK, establishing a new baseline algorithm for efficient LLM deployment without compromising performance. Our code has been made available at https://github.com/SalesforceAIResearch/ThinK.
title ThinK: Thinner Key Cache by Query-Driven Pruning
topic Computation and Language
Artificial Intelligence
url https://arxiv.org/abs/2407.21018