Papers › SimLayerKV: A Simple Framework for Layer-Level KV Cache Reduction

SimLayerKV: A Simple Framework for Layer-Level KV Cache Reduction

17 Oct 2024arXiv:2410.13846archive 2025-07-28

Xuan Zhang, Cunxiao Du, Chao Du, Tianyu Pang, Wei Gao, Min Lin

Recent advancements in large language models (LLMs) have extended their capabilities to handle long contexts. However, increasing the number of model layers and the length of input sequences significantly escalates the memory required to store key-value (KV) cache, posing challenges for efficient inference. To mitigate this issue, we present SimLayerKV, a simple yet effective method that reduces inter-layer KV cache redundancies by selectively dropping cache in identified lazy layers. Our approach is based on the observation that certain layers in long-context LLMs exhibit "lazy" behavior, contributing less to modeling long-range dependencies compared to non-lazy layers. By analyzing attention weight patterns, we find that the behavior of these lazy layers is consistent across tokens during generation for a given input. This insight motivates our SimLayerKV, which identifies lazy layers and reduces their KV cache accordingly. SimLayerKV is training-free, generalizable, and can be implemented with only seven lines of code. We conduct extensive experiments on three representative LLMs, e.g., LLaMA2-7B, LLaMA3-8B, and Mistral-7B across 16 tasks from the LongBench benchmark. The results demonstrate that SimLayerKV achieves a KV cache compression ratio of 5× with only a 1.2% performance drop when combined with 4-bit quantization. Our code is available at https://github.com/sail-sg/SimLayerKV.

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.13846")

Code

Syntology Ran 11 of 14 code samples harvested from 1 repository linked to this paper; 3 have no recorded run. Of those that ran: 1 ran · honoured contract; 1 ran · violated contract; 2 ran · our draft was wrong; 7 ran with no contract checked.

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

sail-sg/simlayerkv 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

14 samples harvested; 11 ran; 1 honoured the contract we drafted; 3 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
1ran · violated contract
2ran · our draft was wrong
7ran
3unverified

Licence: 14 of the 14 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 sail-sg/simlayerkv. “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.

apply_rotary_pos_emb_single sail-sg/simlayerkv/LongBench/SimLayerKV_attention_llama.py official repository ran no licence file found · pointer only · 109fdfadb74e7b7e · report
count_score sail-sg/simlayerkv/LongBench/metrics.py official repository ran · honoured contract fingerprinted no licence file found · pointer only · b349b79d9cc2934b · report
normalize_answer sail-sg/simlayerkv/LongBench/metrics.py official repository ran · our draft was wrong fingerprinted no licence file found · pointer only · e7e75981cb464788 · report
normalize_zh_answer sail-sg/simlayerkv/LongBench/metrics.py official repository ran · our draft was wrong fingerprinted no licence file found · pointer only · 8c5c581f9264c810 · report
parse_args sail-sg/simlayerkv/LongBench/pred.py official repository ran no licence file found · pointer only · a5e6881df94a8792 · report
post_process sail-sg/simlayerkv/LongBench/pred.py official repository ran · violated contract fingerprinted no licence file found · pointer only · 4489113b536ca6eb · report
relative_top_filter sail-sg/simlayerkv/LongBench/SimLayerKV_llama.py official repository ran no licence file found · pointer only · fa0ead5eb565a101 · report
repeat_kv_quant sail-sg/simlayerkv/LongBench/KIVI/models/mistral_kivi.py official repository ran fingerprinted no licence file found · pointer only · fa013be990ccedab · report
scaled_dot_product_attention sail-sg/simlayerkv/LongBench/SimLayerKV_attention_llama.py official repository ran no licence file found · pointer only · 15435bf612fd7f6f · report
scaled_dot_product_attention sail-sg/simlayerkv/LongBench/SimLayerKV_attention_qwen.py official repository ran no licence file found · pointer only · 996f634b37f61510 · report
slerp sail-sg/simlayerkv/LongBench/SimLayerKV_llama.py official repository ran no licence file found · pointer only · 3a5da3106b298ea0 · report
build_chat sail-sg/simlayerkv/LongBench/pred.py official repository unverified no licence file found · pointer only · 324506640e971548 · report
ori_forward sail-sg/simlayerkv/LongBench/SimLayerKV_attention_llama.py official repository unverified no licence file found · pointer only · 7f2e8a952b2a3486 · report
ori_forward sail-sg/simlayerkv/LongBench/SimLayerKV_attention_qwen.py official repository unverified no licence file found · pointer only · 8bef8b8d37f07b4e · report

Tasks

Quantization

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