{"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/gqa-training-generalized-multi-query","title":"GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints","arxiv_id":"2305.13245","date":"2023-05-22","proceeding":null,"authors":["Joshua Ainslie","James Lee-Thorp","Michiel de Jong","Yury Zemlyanskiy","Federico Lebrón","Sumit Sanghai"],"abstract":"Multi-query attention (MQA), which only uses a single key-value head, drastically speeds up decoder inference. However, MQA can lead to quality degradation, and moreover it may not be desirable to train a separate model just for faster inference. We (1) propose a recipe for uptraining existing multi-head language model checkpoints into models with MQA using 5% of original pre-training compute, and (2) introduce grouped-query attention (GQA), a generalization of multi-query attention which uses an intermediate (more than one, less than number of query heads) number of key-value heads. We show that uptrained GQA achieves quality close to multi-head attention with comparable speed to MQA.","url_abs":"https://arxiv.org/abs/2305.13245v3","url_pdf":"https://arxiv.org/pdf/2305.13245v3.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":"gqa-training-generalized-multi-query","repo_url":"https://github.com/alansun17904/circuit-stability","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"gqa-training-generalized-multi-query","repo_url":"https://github.com/fkodom/grouped-query-attention-pytorch","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"gqa-training-generalized-multi-query","repo_url":"https://github.com/facebookresearch/llama/blob/6c7fe276574e78057f917549435a2554000a876d/llama/model.py","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":null},{"paper_slug":"gqa-training-generalized-multi-query","repo_url":"https://github.com/knotgrass/attention/blob/main/attn/attention.py","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"decoder","task_name":"Decoder"},{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"}],"methods":[{"method_slug":"attention","method_name":"Attention"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"feedforward-network","method_name":"Feedforward Network"},{"method_slug":"grouped-query-attention","method_name":"Grouped-query attention"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"multi-query-attention","method_name":"Multi-Query Attention"},{"method_slug":"speed","method_name":"SPEED"},{"method_slug":"softmax","method_name":"Softmax"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2305.13245","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2305.13245"}},"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/alansun17904/circuit-stability","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/knotgrass/attention/blob/main/attn/attention.py","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/fkodom/grouped-query-attention-pytorch","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/facebookresearch/llama/blob/6c7fe276574e78057f917549435a2554000a876d/llama/model.py","reach":null}],"summary":{"ran":3,"ran_fixture":1,"unverified":1},"by_repo_kind":{"listed":{"samples":5,"ran":4,"repositories":2}},"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":3,"samples":[{"code_sha256_prefix":"7bd4605898291f6a","entry":"Attention","repo":"knotgrass/attention","repo_kind":"listed","path":"attn/attention.py","file_url":"https://github.com/knotgrass/attention/blob/HEAD/attn/attention.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7bd4605898291f6a"}},{"code_sha256_prefix":"959111f20c6f8476","entry":"GroupedQueryAttention","repo":"knotgrass/attention","repo_kind":"listed","path":"attn/attention.py","file_url":"https://github.com/knotgrass/attention/blob/HEAD/attn/attention.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":"959111f20c6f8476"}},{"code_sha256_prefix":"edf29ee77f89d029","entry":"MultiQueryAttention","repo":"knotgrass/attention","repo_kind":"listed","path":"attn/attention.py","file_url":"https://github.com/knotgrass/attention/blob/HEAD/attn/attention.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"edf29ee77f89d029"}},{"code_sha256_prefix":"aa68f534d467d1bd","entry":"scaled_dot_product_gqa","repo":"fkodom/grouped-query-attention-pytorch","repo_kind":"listed","path":"grouped_query_attention_pytorch/attention.py","file_url":"https://github.com/fkodom/grouped-query-attention-pytorch/blob/HEAD/grouped_query_attention_pytorch/attention.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"aa68f534d467d1bd"}},{"code_sha256_prefix":"5cb9f0bfab83e93d","entry":"MultiheadGQA","repo":"fkodom/grouped-query-attention-pytorch","repo_kind":"listed","path":"grouped_query_attention_pytorch/attention.py","file_url":"https://github.com/fkodom/grouped-query-attention-pytorch/blob/HEAD/grouped_query_attention_pytorch/attention.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":"5cb9f0bfab83e93d"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}