{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/spindlekv-a-novel-kv-cache-reduction-method","title":"SpindleKV: A Novel KV Cache Reduction Method Balancing Both Shallow and Deep Layers","arxiv_id":"2507.06517","date":"2025-07-09","proceeding":null,"authors":["Zicong Tang","Shi Luohe","Zuchao Li","Baoyuan Qi","Guoming Liu","Lefei Zhang","Ping Wang"],"abstract":"Large Language Models (LLMs) have achieved impressive accomplishments in recent years. However, the increasing memory consumption of KV cache has possessed a significant challenge to the inference system. Eviction methods have revealed the inherent redundancy within the KV cache, demonstrating its potential for reduction, particularly in deeper layers. However, KV cache reduction for shallower layers has been found to be insufficient. Based on our observation that, the KV cache exhibits a high degree of similarity. Based on this observation, we proposed a novel KV cache reduction method, SpindleKV, which balances both shallow and deep layers. For deep layers, we employ an attention weight based eviction method, while for shallow layers, we apply a codebook based replacement approach which is learnt by similarity and merging policy. Moreover, SpindleKV addressed the Grouped-Query Attention (GQA) dilemma faced by other attention based eviction methods. Experiments on two common benchmarks with three different LLMs shown that SpindleKV obtained better KV cache reduction effect compared to baseline methods, while preserving similar or even better model performance.","url_abs":"https://arxiv.org/abs/2507.06517v1","url_pdf":"https://arxiv.org/pdf/2507.06517v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"spindlekv-a-novel-kv-cache-reduction-method","repo_url":"https://github.com/tyxqc/spindlekv","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2507.06517","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2507.06517"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"deterministic:regex_extraction","url":"https://github.com/tyxqc/SpindleKV","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":6,"ran_draft_wrong":1,"unverified":2},"by_repo_kind":{"official":{"samples":9,"ran":7,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"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"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"885da9876401ac0d","entry":"DCT_Compressor_Manager","repo":"tyxqc/SpindleKV","repo_kind":"official","path":"compressor/compressor.py","file_url":"https://github.com/tyxqc/SpindleKV/blob/HEAD/compressor/compressor.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"885da9876401ac0d"}},{"code_sha256_prefix":"379490e311311127","entry":"DctCompressor","repo":"tyxqc/SpindleKV","repo_kind":"official","path":"compressor/compressor.py","file_url":"https://github.com/tyxqc/SpindleKV/blob/HEAD/compressor/compressor.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"379490e311311127"}},{"code_sha256_prefix":"4100920cbd32b463","entry":"PastKey","repo":"tyxqc/SpindleKV","repo_kind":"official","path":"compressor/compressor.py","file_url":"https://github.com/tyxqc/SpindleKV/blob/HEAD/compressor/compressor.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4100920cbd32b463"}},{"code_sha256_prefix":"e17033f46f8c6bad","entry":"PastValue","repo":"tyxqc/SpindleKV","repo_kind":"official","path":"compressor/compressor.py","file_url":"https://github.com/tyxqc/SpindleKV/blob/HEAD/compressor/compressor.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e17033f46f8c6bad"}},{"code_sha256_prefix":"7cb1afdb14211e1e","entry":"Pool","repo":"tyxqc/SpindleKV","repo_kind":"official","path":"compressor/compressor.py","file_url":"https://github.com/tyxqc/SpindleKV/blob/HEAD/compressor/compressor.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"7cb1afdb14211e1e"}},{"code_sha256_prefix":"83bda82a67b5cd7d","entry":"PrePool","repo":"tyxqc/SpindleKV","repo_kind":"official","path":"compressor/compressor.py","file_url":"https://github.com/tyxqc/SpindleKV/blob/HEAD/compressor/compressor.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"83bda82a67b5cd7d"}},{"code_sha256_prefix":"0a813f84fe488d52","entry":"parse_thresholds","repo":"tyxqc/SpindleKV","repo_kind":"official","path":"compressor/compressor.py","file_url":"https://github.com/tyxqc/SpindleKV/blob/HEAD/compressor/compressor.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0a813f84fe488d52"}},{"code_sha256_prefix":"455d8fc04c2ce866","entry":"Compressor","repo":"tyxqc/SpindleKV","repo_kind":"official","path":"compressor/compressor.py","file_url":"https://github.com/tyxqc/SpindleKV/blob/HEAD/compressor/compressor.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"455d8fc04c2ce866"}},{"code_sha256_prefix":"a0b1cfb815e3ea99","entry":"apply_rotary_pos_emb_k","repo":"tyxqc/SpindleKV","repo_kind":"official","path":"compressor/compressor.py","file_url":"https://github.com/tyxqc/SpindleKV/blob/HEAD/compressor/compressor.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a0b1cfb815e3ea99"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}