ZigZagkv: Dynamic KV Cache Compression for Long-context Modeling based on Layer Uncertainty

Meizhi Zhong, Xikai Liu, Chen Zhang, Yikun Lei, Yan Gao +3 more
12/12/2024
cs.CL

No confident code implementation found for this paper.

Abstract

Large Language models (LLMs) have become a research hotspot. To accelerate the inference of LLMs, storing computed caches in memory has become the standard technique. However, as the inference length increases, growing KV caches might lead to out-of-memory issues. Many existing methods address this issue through KV cache compression, primarily by preserving key tokens throughout all layers to reduce information loss. Most of them allocate a uniform budget size for each layer to retain. However, we observe that the minimum budget sizes needed to retain essential information vary across layers and models based on the perspectives of attention and hidden state output. Building on this observation, this paper proposes a simple yet effective KV cache compression method that leverages layer uncertainty to allocate budget size for each layer. Experimental results show that the proposed method can reduce memory usage of the KV caches to only $\sim$20\% when compared to Full KV inference while achieving nearly lossless performance.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{zhong2024zigzagkv,
  title  = {ZigZagkv: Dynamic KV Cache Compression for Long-context Modeling based on Layer Uncertainty},
  author = {Meizhi Zhong and Xikai Liu and Chen Zhang and Yikun Lei and Yan Gao and Yao Hu and Kehai Chen and Min Zhang},
  year   = {2024},
  eprint = {2412.09036},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2412.09036v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2412.09036.svg)](https://codeofpaper.com/paper/2412.09036)

Discussion