@inproceedings{jin-etal-2025-align,
title = "Align Attention Heads Before Merging Them: An Effective Way for Converting {MHA} to {GQA}",
author = "Jin, Qingyun and
Song, Xiaohui and
Zhou, Feng and
Qin, Zengchang",
editor = "Christodoulopoulos, Christos and
Chakraborty, Tanmoy and
Rose, Carolyn and
Peng, Violet",
booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2025",
month = nov,
year = "2025",
address = "Suzhou, China",
publisher = "Association for Computational Linguistics",
url = "https://preview.aclanthology.org/author-page-yu-wang-polytechnic/2025.findings-emnlp.467/",
doi = "10.18653/v1/2025.findings-emnlp.467",
pages = "8804--8816",
ISBN = "979-8-89176-335-7",
abstract = "Large language models (LLMs) have demonstrated exceptional performance across diverse natural language processing tasks. However, as the model size and the input sequence{'}s length increase, the linearly increasing key-value (KV) cache significantly degrades inference throughput. Therefore, grouped-query attention (GQA), as an alternative to multi-head attention (MHA), has been widely introduced into LLMs. In this work, we propose a cost-effective method for converting MHA into GQA with any compression ratio of KV heads. The key point of our method lies in the application of Procrustes analysis to the attention heads, which enhances the similarity among attention heads while preserving computational invariance, thereby improving the model{'}s post-training performance. Subsequently, we employ $\mathit{L_0}$ regularization to prune redundant parameters. The model after pruning can be adapted to the standard GQA framework. Experimental results show that our strategy can compress up to 87.5{\%} KV heads of LLaMA2-7B model and 75{\%} KV heads of Sheared-LLaMA-1.3B with acceptable performance degradation. Our code is released at https://github.com/fpcsong/mha2gqa."
}Markdown (Informal)
[Align Attention Heads Before Merging Them: An Effective Way for Converting MHA to GQA](https://preview.aclanthology.org/author-page-yu-wang-polytechnic/2025.findings-emnlp.467/) (Jin et al., Findings 2025)
ACL