{"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/xkv-cross-layer-svd-for-kv-cache-compression","title":"xKV: Cross-Layer SVD for KV-Cache Compression","arxiv_id":"2503.18893","date":"2025-03-24","proceeding":null,"authors":["Chi-Chih Chang","Chien-Yu Lin","Yash Akhauri","Wei-Cheng Lin","Kai-Chiang Wu","Luis Ceze","Mohamed S. Abdelfattah"],"abstract":"Large Language Models (LLMs) with long context windows enable powerful applications but come at the cost of high memory consumption to store the Key and Value states (KV-Cache). Recent studies attempted to merge KV-cache from multiple layers into shared representations, yet these approaches either require expensive pretraining or rely on assumptions of high per-token cosine similarity across layers which generally does not hold in practice. We find that the dominant singular vectors are remarkably well-aligned across multiple layers of the KV-Cache. Exploiting this insight, we propose xKV, a simple post-training method that applies Singular Value Decomposition (SVD) on the KV-Cache of grouped layers. xKV consolidates the KV-Cache of multiple layers into a shared low-rank subspace, significantly reducing KV-Cache sizes. Through extensive evaluations on the RULER long-context benchmark with widely-used LLMs (e.g., Llama-3.1 and Qwen2.5), xKV achieves up to 6.8x higher compression rates than state-of-the-art inter-layer technique while improving accuracy by 2.7%. Moreover, xKV is compatible with the emerging Multi-Head Latent Attention (MLA) (e.g., DeepSeek-Coder-V2), yielding a notable 3x compression rates on coding tasks without performance degradation. These results highlight xKV's strong capability and versatility in addressing memory bottlenecks for long-context LLM inference. Our code is publicly available at: https://github.com/abdelfattah-lab/xKV.","url_abs":"https://arxiv.org/abs/2503.18893v1","url_pdf":"https://arxiv.org/pdf/2503.18893v1.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":"xkv-cross-layer-svd-for-kv-cache-compression","repo_url":"https://github.com/abdelfattah-lab/xkv","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[],"methods":[{"method_slug":"attention","method_name":"Attention"},{"method_slug":"softmax","method_name":"Softmax"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2503.18893","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2503.18893"}},"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":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/abdelfattah-lab/xkv","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran":1,"unverified":5},"by_repo_kind":{"official":{"samples":6,"ran":1,"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":"51bd109470f0db84","entry":"fast_svd","repo":"abdelfattah-lab/xkv","repo_kind":"official","path":"xKV_SR/models/kv_cache_xkv.py","file_url":"https://github.com/abdelfattah-lab/xkv/blob/HEAD/xKV_SR/models/kv_cache_xkv.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"51bd109470f0db84"}},{"code_sha256_prefix":"8658f6659fc4ba42","entry":"LayerGroup","repo":"abdelfattah-lab/xkv","repo_kind":"official","path":"xKV_SR/models/kv_cache_xkv.py","file_url":"https://github.com/abdelfattah-lab/xkv/blob/HEAD/xKV_SR/models/kv_cache_xkv.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"8658f6659fc4ba42"}},{"code_sha256_prefix":"ddc6ae03f3bd5097","entry":"ShadowKVCache_xKV_CPU","repo":"abdelfattah-lab/xkv","repo_kind":"official","path":"xKV_SR/models/kv_cache_xkv.py","file_url":"https://github.com/abdelfattah-lab/xkv/blob/HEAD/xKV_SR/models/kv_cache_xkv.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"ddc6ae03f3bd5097"}},{"code_sha256_prefix":"4748877f5f1ef59a","entry":"apply_rotary_pos_emb_cuda_push_cache","repo":"abdelfattah-lab/xkv","repo_kind":"official","path":"xKV_SR/models/kv_cache_xkv.py","file_url":"https://github.com/abdelfattah-lab/xkv/blob/HEAD/xKV_SR/models/kv_cache_xkv.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"4748877f5f1ef59a"}},{"code_sha256_prefix":"3120b7261cb08430","entry":"batch_gather_gemm_rotary_pos_emb_cuda","repo":"abdelfattah-lab/xkv","repo_kind":"official","path":"xKV_SR/models/kv_cache_xkv.py","file_url":"https://github.com/abdelfattah-lab/xkv/blob/HEAD/xKV_SR/models/kv_cache_xkv.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"3120b7261cb08430"}},{"code_sha256_prefix":"42ad4c72c72f161a","entry":"xKVConfig","repo":"abdelfattah-lab/xkv","repo_kind":"official","path":"xKV_SR/models/kv_cache_xkv.py","file_url":"https://github.com/abdelfattah-lab/xkv/blob/HEAD/xKV_SR/models/kv_cache_xkv.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"42ad4c72c72f161a"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}