Papers › PyramidKV: Dynamic KV Cache Compression based on Pyramidal Information Funneling

PyramidKV: Dynamic KV Cache Compression based on Pyramidal Information Funneling

4 Jun 2024arXiv:2406.02069archive 2025-07-28

Zefan Cai, Yichi Zhang, Bofei Gao, Yuliang Liu, Yucheng Li, Tianyu Liu, Keming Lu, Wayne Xiong, Yue Dong, Junjie Hu, Wen Xiao

In this study, we investigate whether attention-based information flow inside large language models (LLMs) is aggregated through noticeable patterns for long context processing. Our observations reveal that LLMs aggregate information through Pyramidal Information Funneling where attention is scattering widely in lower layers, progressively consolidating within specific contexts, and ultimately focusing on critical tokens (a.k.a massive activation or attention sink) in higher layers. Motivated by these insights, we developed PyramidKV, a novel and effective KV cache compression method. This approach dynamically adjusts the KV cache size across different layers, allocating more cache in lower layers and less in higher ones, diverging from traditional methods that maintain a uniform KV cache size. Our experimental evaluations, utilizing the LongBench benchmark, show that PyramidKV matches the performance of models with a full KV cache while retaining only 12% of the KV cache, thus significantly reducing memory usage. In scenarios emphasizing memory efficiency, where only 0.7% of the KV cache is maintained, PyramidKV surpasses other KV cache compression techniques, achieving up to a 20.5 absolute accuracy improvement on TREC dataset. In the Needle-in-a-Haystack experiment, PyramidKV outperforms competing methods in maintaining long-context comprehension in LLMs; notably, retaining just 128 KV cache entries enables the LLAMA-3-70B model to achieve 100.0 Acc. performance.

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="2406.02069")

Code

Syntology Ran 14 of 15 code samples harvested from 1 repository linked to this paper; 1 has no recorded run. Of those that ran: 1 ran · violated contract; 3 ran · fixture could not drive it; 10 ran with no contract checked.

By repository: official repository: 14 samples from 1 repository, 13 ran; 1 identical to code first harvested elsewhere. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

zefan-cai/pyramidkv officialmentioned in paperpytorchMIT report
answerdotai/cold-compress mentioned on GitHubpytorch report
princeton-pli/prulong mentioned 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

15 samples harvested; 14 ran; 0 honoured the contract we drafted; 1 has 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 · violated contract
3ran · fixture could not drive it
10ran
1unverified

Licence: 1 of the 15 samples is 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 zefan-cai/pyramidkv. Some samples are identical code Syntology first harvested from another repository; for those, this paper's copy is not located and its licence is not recorded. “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 zefan-cai/pyramidkv/pyramidkv/pyramidkv_utils.py official repository ran · fixture could not drive it fingerprinted MIT (permissive) · 3c76e52815c5401d · report
build_stop_token_ids zefan-cai/pyramidkv/pyramidkv/eval_utils.py official repository ran MIT (permissive) · 6856f796db256e0a · report
compress_minicache_pair zefan-cai/pyramidkv/pyramidkv/minicache.py official repository ran MIT (permissive) · 042f3baac334e2d7 · report
get_headwise_projections zefan-cai/pyramidkv/pyramidkv/headinfer.py official repository ran MIT (permissive) · 50463bb67a0214ae · report
headinfer_slot zefan-cai/pyramidkv/pyramidkv/headinfer.py official repository ran fingerprinted MIT (permissive) · ad54d3a439b1ed31 · report
is_empty_past_key_values zefan-cai/pyramidkv/pyramidkv/generation_state.py official repository ran MIT (permissive) · 4fd25dca7e4d0ba3 · report
key_pruner_query_driven zefan-cai/pyramidkv/pyramidkv/pyramidkv_utils.py official repository ran · fixture could not drive it fingerprinted MIT (permissive) · 3597e5670a759378 · report
maybe_repeat_kv_before_cache zefan-cai/pyramidkv/pyramidkv/pyramidkv_utils.py official repository ran · fixture could not drive it MIT (permissive) · 6211e835b472f7ad · report
minicache_slerp zefan-cai/pyramidkv/pyramidkv/minicache.py official repository ran MIT (permissive) · dbe56944ebe0f117 · report
reduce_nacl_proxy_scores zefan-cai/pyramidkv/pyramidkv/nacl.py official repository ran MIT (permissive) · b453a87c0268a786 · report
select_minicache_retention_indices zefan-cai/pyramidkv/pyramidkv/minicache.py official repository ran MIT (permissive) · 0753fefeac56ae68 · report
select_nacl_tokens zefan-cai/pyramidkv/pyramidkv/nacl.py official repository ran MIT (permissive) · 6aa8f85d4f403b46 · report
str2bool zefan-cai/pyramidkv/pyramidkv/eval_utils.py official repository ran MIT (permissive) · d291b649166e280d · report
select_nacl_proxy_indices zefan-cai/pyramidkv/pyramidkv/nacl.py official repository unverified MIT (permissive) · 554279ac03f73d79 · report
create_window_attention_mask identical code first harvested elsewhere ran · violated contract licence of this copy not recorded · 472d821ef38be37d · report

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

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