{"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/transformer-tricks-removing-weights-for","title":"Transformer tricks: Removing weights for skipless transformers","arxiv_id":"2404.12362","date":"2024-04-18","proceeding":null,"authors":["Nils Graef"],"abstract":"He and Hofmann (arXiv:2311.01906) detailed a skipless transformer without the V and P (post-attention projection) linear layers, which reduces the total number of weights. However, this scheme is only applicable to MHA (multi-head attention), but not for MQA (multi-query attention) and GQA (grouped-query attention). The latter schemes are used by many popular LLMs such as Llama 2, Mistral, Mixtral, PaLM, and Gemma. Therefore, this micro-paper proposes mathematically equivalent versions that are suitable for MQA and GQA. For example, removing Q and P from a skipless version of Mistral-7B would remove 15% of its weights (and thus reduce its compute and memory complexity). See arXiv:2402.13388 and https://github.com/OpenMachine-ai/transformer-tricks for code and more transformer tricks.","url_abs":"https://arxiv.org/abs/2404.12362v1","url_pdf":"https://arxiv.org/pdf/2404.12362v1.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":"transformer-tricks-removing-weights-for","repo_url":"https://github.com/openmachine-ai/transformer-tricks","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[],"methods":[{"method_slug":"llama","method_name":"LLaMA"},{"method_slug":"palm","method_name":"PaLM"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2404.12362","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2404.12362"}},"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/openmachine-ai/transformer-tricks","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_fixture":1,"ran_draft_wrong":2,"ran":6,"unverified":3},"by_repo_kind":{"official":{"samples":12,"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":0,"samples":[{"code_sha256_prefix":"30d7eec482ebf6b1","entry":"repeat_kv","repo":"openmachine-ai/transformer-tricks","repo_kind":"official","path":"flashNorm_modeling_llama.py","file_url":"https://github.com/openmachine-ai/transformer-tricks/blob/HEAD/flashNorm_modeling_llama.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":2,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"30d7eec482ebf6b1"}},{"code_sha256_prefix":"bac65c3dafaec040","entry":"apply_rotary_pos_emb","repo":"openmachine-ai/transformer-tricks","repo_kind":"official","path":"flashNorm_modeling_llama.py","file_url":"https://github.com/openmachine-ai/transformer-tricks/blob/HEAD/flashNorm_modeling_llama.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"bac65c3dafaec040"}},{"code_sha256_prefix":"20e22b8f41ddbad5","entry":"decoder_layers","repo":"openmachine-ai/transformer-tricks","repo_kind":"official","path":"flashNorm_cancel.py","file_url":"https://github.com/openmachine-ai/transformer-tricks/blob/HEAD/flashNorm_cancel.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":"20e22b8f41ddbad5"}},{"code_sha256_prefix":"0a7f153062fd147d","entry":"detect_gain_convention","repo":"openmachine-ai/transformer-tricks","repo_kind":"official","path":"flashNorm_cancel.py","file_url":"https://github.com/openmachine-ai/transformer-tricks/blob/HEAD/flashNorm_cancel.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":"0a7f153062fd147d"}},{"code_sha256_prefix":"dda207bbc6473767","entry":"fold_norm_into_projs","repo":"openmachine-ai/transformer-tricks","repo_kind":"official","path":"flashNorm_cancel.py","file_url":"https://github.com/openmachine-ai/transformer-tricks/blob/HEAD/flashNorm_cancel.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":"dda207bbc6473767"}},{"code_sha256_prefix":"2dd827044e01478c","entry":"ops","repo":"openmachine-ai/transformer-tricks","repo_kind":"official","path":"slimAttn_paper.py","file_url":"https://github.com/openmachine-ai/transformer-tricks/blob/HEAD/slimAttn_paper.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":"2dd827044e01478c"}},{"code_sha256_prefix":"b99eea6376d1e212","entry":"rotate_half","repo":"openmachine-ai/transformer-tricks","repo_kind":"official","path":"flashNorm_modeling_llama.py","file_url":"https://github.com/openmachine-ai/transformer-tricks/blob/HEAD/flashNorm_modeling_llama.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b99eea6376d1e212"}},{"code_sha256_prefix":"f99579ed1c453457","entry":"softmax","repo":"openmachine-ai/transformer-tricks","repo_kind":"official","path":"slimAttn_paper.py","file_url":"https://github.com/openmachine-ai/transformer-tricks/blob/HEAD/slimAttn_paper.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f99579ed1c453457"}},{"code_sha256_prefix":"52f30ea4cb620aab","entry":"weight","repo":"openmachine-ai/transformer-tricks","repo_kind":"official","path":"transformer_tricks.py","file_url":"https://github.com/openmachine-ai/transformer-tricks/blob/HEAD/transformer_tricks.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":"52f30ea4cb620aab"}},{"code_sha256_prefix":"aae2e9803ea68042","entry":"get_param","repo":"openmachine-ai/transformer-tricks","repo_kind":"official","path":"transformer_tricks.py","file_url":"https://github.com/openmachine-ai/transformer-tricks/blob/HEAD/transformer_tricks.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":"aae2e9803ea68042"}},{"code_sha256_prefix":"7ea152390b9c400a","entry":"head_residual","repo":"openmachine-ai/transformer-tricks","repo_kind":"official","path":"slimAttn_whisper.py","file_url":"https://github.com/openmachine-ai/transformer-tricks/blob/HEAD/slimAttn_whisper.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":"7ea152390b9c400a"}},{"code_sha256_prefix":"46e983bb70feefd9","entry":"perplexity","repo":"openmachine-ai/transformer-tricks","repo_kind":"official","path":"transformer_tricks.py","file_url":"https://github.com/openmachine-ai/transformer-tricks/blob/HEAD/transformer_tricks.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":"46e983bb70feefd9"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}