CriticalKV: Optimizing KV Cache Eviction from an Output Perturbation Perspective

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Feng, Yuan, Lv, Junlin, Guo, Haoyu, Cao, Yukun, Zhou, S Kevin, Xie, Xike
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866911725547159552
author Feng, Yuan
Lv, Junlin
Guo, Haoyu
Cao, Yukun
Zhou, S Kevin
Xie, Xike
author_facet Feng, Yuan
Lv, Junlin
Guo, Haoyu
Cao, Yukun
Zhou, S Kevin
Xie, Xike
contents Large language models have revolutionized natural language processing but face significant challenges of high storage and runtime costs, due to the transformer architecture's reliance on self-attention, particularly the large KV cache for long-sequence inference. Recent efforts to reduce KV cache size by pruning less critical entries based on attention weights remain empirical and lack formal grounding. This paper presents a formal study on identifying critical KV cache entries by analyzing attention output perturbation. Our analysis reveals that, beyond attention weights, the value states within KV entries and pretrained parameter matrices are also crucial. Based on this, we propose a perturbation-constrained selection algorithm that optimizes the worst-case output perturbation to identify critical entries. We demonstrate that our algorithm is a universal, plug-and-play enhancement that incurs negligible computational overhead. When integrated with three state-of-the-art cache eviction methods on three distinct LLMs, our algorithm significantly reduces the compression loss by more than \textit{half} on average across 29 datasets from the Ruler and LongBench benchmarks. Further perturbation analysis, at both the head and layer levels, confirms the principles underlying our effectiveness. This work offers a new, formally grounded perspective to cache eviction , opening promising avenues for future research. The code is publicly available at https://github.com/FFY0/DefensiveKV.
format Preprint
id arxiv_https___arxiv_org_abs_2502_03805
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle CriticalKV: Optimizing KV Cache Eviction from an Output Perturbation Perspective
Feng, Yuan
Lv, Junlin
Guo, Haoyu
Cao, Yukun
Zhou, S Kevin
Xie, Xike
Computation and Language
Large language models have revolutionized natural language processing but face significant challenges of high storage and runtime costs, due to the transformer architecture's reliance on self-attention, particularly the large KV cache for long-sequence inference. Recent efforts to reduce KV cache size by pruning less critical entries based on attention weights remain empirical and lack formal grounding. This paper presents a formal study on identifying critical KV cache entries by analyzing attention output perturbation. Our analysis reveals that, beyond attention weights, the value states within KV entries and pretrained parameter matrices are also crucial. Based on this, we propose a perturbation-constrained selection algorithm that optimizes the worst-case output perturbation to identify critical entries. We demonstrate that our algorithm is a universal, plug-and-play enhancement that incurs negligible computational overhead. When integrated with three state-of-the-art cache eviction methods on three distinct LLMs, our algorithm significantly reduces the compression loss by more than \textit{half} on average across 29 datasets from the Ruler and LongBench benchmarks. Further perturbation analysis, at both the head and layer levels, confirms the principles underlying our effectiveness. This work offers a new, formally grounded perspective to cache eviction , opening promising avenues for future research. The code is publicly available at https://github.com/FFY0/DefensiveKV.
title CriticalKV: Optimizing KV Cache Eviction from an Output Perturbation Perspective
topic Computation and Language
url https://arxiv.org/abs/2502.03805