{"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/eigen-attention-attention-in-low-rank-space","title":"Eigen Attention: Attention in Low-Rank Space for KV Cache Compression","arxiv_id":"2408.05646","date":"2024-08-10","proceeding":null,"authors":["Utkarsh Saxena","Gobinda Saha","Sakshi Choudhary","Kaushik Roy"],"abstract":"Large language models (LLMs) represent a groundbreaking advancement in the domain of natural language processing due to their impressive reasoning abilities. Recently, there has been considerable interest in increasing the context lengths for these models to enhance their applicability to complex tasks. However, at long context lengths and large batch sizes, the key-value (KV) cache, which stores the attention keys and values, emerges as the new bottleneck in memory usage during inference. To address this, we propose Eigen Attention, which performs the attention operation in a low-rank space, thereby reducing the KV cache memory overhead. Our proposed approach is orthogonal to existing KV cache compression techniques and can be used synergistically with them. Through extensive experiments over OPT, MPT, and Llama model families, we demonstrate that Eigen Attention results in up to 40% reduction in KV cache sizes and up to 60% reduction in attention operation latency with minimal drop in performance. Code is available at https://github.com/UtkarshSaxena1/EigenAttn.","url_abs":"https://arxiv.org/abs/2408.05646v2","url_pdf":"https://arxiv.org/pdf/2408.05646v2.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":"eigen-attention-attention-in-low-rank-space","repo_url":"https://github.com/utkarshsaxena1/eigenattn","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"none","reach":{"status":"ok"}}],"tasks":[],"methods":[{"method_slug":"attention","method_name":"Attention"},{"method_slug":"llama","method_name":"LLaMA"},{"method_slug":"opt","method_name":"OPT"},{"method_slug":"softmax","method_name":"Softmax"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2408.05646","atlas_url":"https://app.syntology.ai/?focus=2408.05646","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2408.05646"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+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/utkarshsaxena1/eigenattn","reach":{"status":"ok"}}],"summary":{"ran":7,"ran_draft_wrong":2,"unverified":4},"by_repo_kind":{"official":{"samples":13,"ran":9,"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":13,"samples":[{"code_sha256_prefix":"c29fea147a883771","entry":"assign_layers_to_gpus","repo":"utkarshsaxena1/eigenattn","repo_kind":"official","path":"parallel_utils.py","file_url":"https://github.com/utkarshsaxena1/eigenattn/blob/HEAD/parallel_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c29fea147a883771"}},{"code_sha256_prefix":"6acdafe16c0d4786","entry":"build_mpt_alibi_tensor","repo":"utkarshsaxena1/eigenattn","repo_kind":"official","path":"models/modelling_mpt_eigen_attn.py","file_url":"https://github.com/utkarshsaxena1/eigenattn/blob/HEAD/models/modelling_mpt_eigen_attn.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6acdafe16c0d4786"}},{"code_sha256_prefix":"904cd61df2fe8fb9","entry":"find_layers","repo":"utkarshsaxena1/eigenattn","repo_kind":"official","path":"models/models_utils.py","file_url":"https://github.com/utkarshsaxena1/eigenattn/blob/HEAD/models/models_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"904cd61df2fe8fb9"}},{"code_sha256_prefix":"50c5bf862a9fd458","entry":"get_kvcache_size_opt","repo":"utkarshsaxena1/eigenattn","repo_kind":"official","path":"main_eigen_attn.py","file_url":"https://github.com/utkarshsaxena1/eigenattn/blob/HEAD/main_eigen_attn.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"50c5bf862a9fd458"}},{"code_sha256_prefix":"fc00410022bf942a","entry":"get_model_size","repo":"utkarshsaxena1/eigenattn","repo_kind":"official","path":"main_eigen_attn.py","file_url":"https://github.com/utkarshsaxena1/eigenattn/blob/HEAD/main_eigen_attn.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"fc00410022bf942a"}},{"code_sha256_prefix":"4df9168e0a0c38eb","entry":"make_disjoint_window","repo":"utkarshsaxena1/eigenattn","repo_kind":"official","path":"models/models_utils.py","file_url":"https://github.com/utkarshsaxena1/eigenattn/blob/HEAD/models/models_utils.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"4df9168e0a0c38eb"}},{"code_sha256_prefix":"400ea4f64ccce5ef","entry":"parse_eval_args","repo":"utkarshsaxena1/eigenattn","repo_kind":"official","path":"evaluate_llm.py","file_url":"https://github.com/utkarshsaxena1/eigenattn/blob/HEAD/evaluate_llm.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"400ea4f64ccce5ef"}},{"code_sha256_prefix":"aaa7723c864e0a5e","entry":"sort_layers_by_params","repo":"utkarshsaxena1/eigenattn","repo_kind":"official","path":"parallel_utils.py","file_url":"https://github.com/utkarshsaxena1/eigenattn/blob/HEAD/parallel_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"aaa7723c864e0a5e"}},{"code_sha256_prefix":"4e53fbbdfa160f7d","entry":"truncate_number","repo":"utkarshsaxena1/eigenattn","repo_kind":"official","path":"models/models_utils.py","file_url":"https://github.com/utkarshsaxena1/eigenattn/blob/HEAD/models/models_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"4e53fbbdfa160f7d"}},{"code_sha256_prefix":"131cf84182a40354","entry":"get_alpaca","repo":"utkarshsaxena1/eigenattn","repo_kind":"official","path":"datautils.py","file_url":"https://github.com/utkarshsaxena1/eigenattn/blob/HEAD/datautils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"131cf84182a40354"}},{"code_sha256_prefix":"3c6439a3c61dd2bb","entry":"get_lowest_occupied_gpu","repo":"utkarshsaxena1/eigenattn","repo_kind":"official","path":"parallel_utils.py","file_url":"https://github.com/utkarshsaxena1/eigenattn/blob/HEAD/parallel_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"3c6439a3c61dd2bb"}},{"code_sha256_prefix":"3b51341ed1a0b73e","entry":"get_pile","repo":"utkarshsaxena1/eigenattn","repo_kind":"official","path":"datautils.py","file_url":"https://github.com/utkarshsaxena1/eigenattn/blob/HEAD/datautils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"3b51341ed1a0b73e"}},{"code_sha256_prefix":"46e078681a1cd741","entry":"get_wikitext2","repo":"utkarshsaxena1/eigenattn","repo_kind":"official","path":"datautils.py","file_url":"https://github.com/utkarshsaxena1/eigenattn/blob/HEAD/datautils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"46e078681a1cd741"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}