ZSMerge: Zero-Shot KV Cache Compression for Memory-Efficient Long-Context LLMs

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Liu, Xin, Wang, Xudong, Liu, Pei, Tang, Guoming
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866916989049503744
author Liu, Xin
Wang, Xudong
Liu, Pei
Tang, Guoming
author_facet Liu, Xin
Wang, Xudong
Liu, Pei
Tang, Guoming
contents The linear growth of key-value (KV) cache memory and quadratic computational in attention mechanisms complexity pose significant bottlenecks for large language models (LLMs) in long-context processing. While existing KV cache optimization methods address these challenges through token pruning or feature merging, they often incur irreversible information loss or require costly parameter retraining. To this end, we propose ZSMerge, a dynamic KV cache compression framework designed for efficient cache management, featuring three key operations: (1) fine-grained memory allocation guided by multi-dimensional token importance metrics at head-level granularity, (2) a residual merging mechanism that preserves critical context through compensated attention scoring, and (3) a zero-shot adaptation mechanism compatible with diverse LLM architectures without requiring retraining. ZSMerge significantly enhances memory efficiency and inference speed with negligible performance degradation across LLMs. When applied to LLaMA2-7B, it demonstrates a 20:1 compression ratio for key-value cache retention (reducing memory footprint to 5\% of baseline) while sustaining comparable generation quality, coupled with triple throughput gains at extreme 54k-token contexts that eliminate out-of-memory failures. The code is available at https://github.com/SusCom-Lab/ZSMerge.
format Preprint
id arxiv_https___arxiv_org_abs_2503_10714
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle ZSMerge: Zero-Shot KV Cache Compression for Memory-Efficient Long-Context LLMs
Liu, Xin
Wang, Xudong
Liu, Pei
Tang, Guoming
Computation and Language
Artificial Intelligence
The linear growth of key-value (KV) cache memory and quadratic computational in attention mechanisms complexity pose significant bottlenecks for large language models (LLMs) in long-context processing. While existing KV cache optimization methods address these challenges through token pruning or feature merging, they often incur irreversible information loss or require costly parameter retraining. To this end, we propose ZSMerge, a dynamic KV cache compression framework designed for efficient cache management, featuring three key operations: (1) fine-grained memory allocation guided by multi-dimensional token importance metrics at head-level granularity, (2) a residual merging mechanism that preserves critical context through compensated attention scoring, and (3) a zero-shot adaptation mechanism compatible with diverse LLM architectures without requiring retraining. ZSMerge significantly enhances memory efficiency and inference speed with negligible performance degradation across LLMs. When applied to LLaMA2-7B, it demonstrates a 20:1 compression ratio for key-value cache retention (reducing memory footprint to 5\% of baseline) while sustaining comparable generation quality, coupled with triple throughput gains at extreme 54k-token contexts that eliminate out-of-memory failures. The code is available at https://github.com/SusCom-Lab/ZSMerge.
title ZSMerge: Zero-Shot KV Cache Compression for Memory-Efficient Long-Context LLMs
topic Computation and Language
Artificial Intelligence
url https://arxiv.org/abs/2503.10714