Papers › Not All Heads Matter: A Head-Level KV Cache Compression Method with Integrated...

Not All Heads Matter: A Head-Level KV Cache Compression Method with Integrated Retrieval and Reasoning

25 Oct 2024arXiv:2410.19258archive 2025-07-28

Yu Fu, Zefan Cai, Abedelkadir Asi, Wayne Xiong, Yue Dong, Wen Xiao

Key-Value (KV) caching is a common technique to enhance the computational efficiency of Large Language Models (LLMs), but its memory overhead grows rapidly with input length. Prior work has shown that not all tokens are equally important for text generation, proposing layer-level KV cache compression to selectively retain key information. Recognizing the distinct roles of attention heads in generation, we propose HeadKV, a head-level KV cache compression method, and HeadKV-R2, which leverages a novel contextual reasoning ability estimation for compression. Our approach operates at the level of individual heads, estimating their importance for contextual QA tasks that require both retrieval and reasoning capabilities. Extensive experiments across diverse benchmarks (LongBench, LooGLE), model architectures (e.g., Llama-3-8B-Instruct, Mistral-7B-Instruct), and long-context abilities tests demonstrate that our head-level KV cache compression significantly outperforms strong baselines, particularly in low-resource settings (KV size = 64 & 128). Notably, our method retains just 1.5% of the KV cache while achieving 97% of the performance of the full KV cache on the contextual question answering benchmark.Codes are available at https://github.com/FYYFU/HeadKV

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2410.19258")

Code

Syntology Ran 5 of 9 code samples harvested from 1 repository linked to this paper; 4 have no recorded run. Of those that ran: 1 ran · honoured contract; 3 ran · our draft was wrong; 1 ran · fixture could not drive it.

By repository: official repository: 9 samples from 1 repository, 5 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

fyyfu/headkv officialmentioned in papermentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

9 samples harvested; 5 ran; 1 honoured the contract we drafted; 4 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · honoured contract
3ran · our draft was wrong
1ran · fixture could not drive it
4unverified

Licence: 9 of the 9 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from fyyfu/headkv. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

repeat_kv fyyfu/headkv/headkv/snapkv_utils.py official repository ran · fixture could not drive it fingerprinted no licence file found · pointer only · 3c76e52815c5401d · report
build_chat fyyfu/headkv/run_longbench.py official repository ran · our draft was wrong fingerprinted no licence file found · pointer only · 3ddd62fbad41e698 · report
count_score fyyfu/headkv/metrics.py official repository ran · honoured contract fingerprinted no licence file found · pointer only · b349b79d9cc2934b · report
normalize_answer fyyfu/headkv/metrics.py official repository ran · our draft was wrong fingerprinted no licence file found · pointer only · e7e75981cb464788 · report
normalize_zh_answer fyyfu/headkv/metrics.py official repository ran · our draft was wrong fingerprinted no licence file found · pointer only · 8c5c581f9264c810 · report
fixed_LlamaModel_forward fyyfu/headkv/headkv/fixed_llama_hijack.py official repository unverified no licence file found · pointer only · 1ff384226516c0cb · report
fixed_MistralModel_forward fyyfu/headkv/headkv/fixed_mistral_hijack.py official repository unverified no licence file found · pointer only · ea5369d01a779749 · report
get_cuda_bare_metal_version fyyfu/headkv/csrc/build.py official repository unverified no licence file found · pointer only · f678f94474df1f5a · report
parse_args fyyfu/headkv/eval_babilong.py official repository unverified no licence file found · pointer only · db4b28c72d99c354 · report

Tasks

AllComputational EfficiencyQuestion AnsweringText Generation

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

AttentionSoftmax

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections