KeepKV: Achieving Periodic Lossless KV Cache Compression for Efficient LLM Inference

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Tian, Yuxuan, Wang, Zihan, Peng, Yebo, Yuan, Aomufei, Wang, Zhiming, Yi, Bairen, Liu, Xin, Cui, Yong, Yang, Tong
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866917106785714176
author Tian, Yuxuan
Wang, Zihan
Peng, Yebo
Yuan, Aomufei
Wang, Zhiming
Yi, Bairen
Liu, Xin
Cui, Yong
Yang, Tong
author_facet Tian, Yuxuan
Wang, Zihan
Peng, Yebo
Yuan, Aomufei
Wang, Zhiming
Yi, Bairen
Liu, Xin
Cui, Yong
Yang, Tong
contents Efficient inference of large language models (LLMs) is hindered by an ever-growing key-value (KV) cache, making KV cache compression a critical research direction. Traditional methods selectively evict less important KV cache entries, which leads to information loss and hallucinations. Recently, merging-based strategies have been explored to retain more information by merging KV pairs that would be discarded; however, these existing approaches inevitably introduce inconsistencies in attention distributions before and after merging, causing degraded generation quality. To overcome this challenge, we propose KeepKV, a novel adaptive KV cache merging method designed to preserve performance under strict memory constraints, achieving single-step lossless compression and providing error bounds for multi-step compression. KeepKV introduces the Electoral Votes mechanism that records merging history and adaptively adjusts attention scores. Moreover, it further leverages a novel Zero Inference-Perturbation Merging method, compensating for attention loss resulting from cache merging. Extensive experiments on various benchmarks and LLM architectures demonstrate that KeepKV substantially reduces memory usage while successfully retaining essential context information, achieving over 2x inference throughput improvement and maintaining superior generation quality even with only 10% KV cache budgets.
format Preprint
id arxiv_https___arxiv_org_abs_2504_09936
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle KeepKV: Achieving Periodic Lossless KV Cache Compression for Efficient LLM Inference
Tian, Yuxuan
Wang, Zihan
Peng, Yebo
Yuan, Aomufei
Wang, Zhiming
Yi, Bairen
Liu, Xin
Cui, Yong
Yang, Tong
Machine Learning
Artificial Intelligence
Computation and Language
Efficient inference of large language models (LLMs) is hindered by an ever-growing key-value (KV) cache, making KV cache compression a critical research direction. Traditional methods selectively evict less important KV cache entries, which leads to information loss and hallucinations. Recently, merging-based strategies have been explored to retain more information by merging KV pairs that would be discarded; however, these existing approaches inevitably introduce inconsistencies in attention distributions before and after merging, causing degraded generation quality. To overcome this challenge, we propose KeepKV, a novel adaptive KV cache merging method designed to preserve performance under strict memory constraints, achieving single-step lossless compression and providing error bounds for multi-step compression. KeepKV introduces the Electoral Votes mechanism that records merging history and adaptively adjusts attention scores. Moreover, it further leverages a novel Zero Inference-Perturbation Merging method, compensating for attention loss resulting from cache merging. Extensive experiments on various benchmarks and LLM architectures demonstrate that KeepKV substantially reduces memory usage while successfully retaining essential context information, achieving over 2x inference throughput improvement and maintaining superior generation quality even with only 10% KV cache budgets.
title KeepKV: Achieving Periodic Lossless KV Cache Compression for Efficient LLM Inference
topic Machine Learning
Artificial Intelligence
Computation and Language
url https://arxiv.org/abs/2504.09936