{"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/resmoe-space-efficient-compression-of-mixture","title":"ResMoE: Space-efficient Compression of Mixture of Experts LLMs via Residual Restoration","arxiv_id":"2503.06881","date":"2025-03-10","proceeding":null,"authors":["Mengting Ai","Tianxin Wei","Yifan Chen","Zhichen Zeng","Ritchie Zhao","Girish Varatkar","Bita Darvish Rouhani","Xianfeng Tang","Hanghang Tong","Jingrui He"],"abstract":"Mixture-of-Experts (MoE) Transformer, the backbone architecture of multiple phenomenal language models, leverages sparsity by activating only a fraction of model parameters for each input token. The sparse structure, while allowing constant time costs, results in space inefficiency: we still need to load all the model parameters during inference. We introduce ResMoE, an innovative MoE approximation framework that utilizes Wasserstein barycenter to extract a common expert (barycenter expert) and approximate the residuals between this barycenter expert and the original ones. ResMoE enhances the space efficiency for inference of large-scale MoE Transformers in a one-shot and data-agnostic manner without retraining while maintaining minimal accuracy loss, thereby paving the way for broader accessibility to large language models. We demonstrate the effectiveness of ResMoE through extensive experiments on Switch Transformer, Mixtral, and DeepSeekMoE models. The results show that ResMoE can reduce the number of parameters in an expert by up to 75% while maintaining comparable performance. The code is available at https://github.com/iDEA-iSAIL-Lab-UIUC/ResMoE.","url_abs":"https://arxiv.org/abs/2503.06881v1","url_pdf":"https://arxiv.org/pdf/2503.06881v1.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":"resmoe-space-efficient-compression-of-mixture","repo_url":"https://github.com/idea-isail-lab-uiuc/resmoe","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"mixture-of-experts","task_name":"Mixture-of-Experts"}],"methods":[{"method_slug":"absolute-position-encodings","method_name":"Absolute Position Encodings"},{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"label-smoothing","method_name":"Label Smoothing"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"moe","method_name":"MoE"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"position-wise-feed-forward-layer","method_name":"Position-Wise Feed-Forward Layer"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"switch-ffn","method_name":"Switch FFN"},{"method_slug":"switch-transformer","method_name":"Switch Transformer"},{"method_slug":"transformer","method_name":"Transformer"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2503.06881","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2503.06881"}},"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/idea-isail-lab-uiuc/resmoe","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_fixture":1,"ran":2,"ran_draft_wrong":2,"unverified":10},"by_repo_kind":{"official":{"samples":15,"ran":5,"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":"d61c483a3c2b3156","entry":"apply_rotary_pos_emb","repo":"idea-isail-lab-uiuc/resmoe","repo_kind":"official","path":"mixtral/resmoe_mixtral/modeling_mixtral.py","file_url":"https://github.com/idea-isail-lab-uiuc/resmoe/blob/HEAD/mixtral/resmoe_mixtral/modeling_mixtral.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d61c483a3c2b3156"}},{"code_sha256_prefix":"507f475feb734647","entry":"compute_intermediate_size","repo":"idea-isail-lab-uiuc/resmoe","repo_kind":"official","path":"mixtral/resmoe_mixtral/convert_mixtral_weights_to_hf.py","file_url":"https://github.com/idea-isail-lab-uiuc/resmoe/blob/HEAD/mixtral/resmoe_mixtral/convert_mixtral_weights_to_hf.py","link_basis":"harvester_set","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":"507f475feb734647"}},{"code_sha256_prefix":"e566aca3f6f9392e","entry":"load_balancing_loss_func","repo":"idea-isail-lab-uiuc/resmoe","repo_kind":"official","path":"mixtral/resmoe_mixtral/modeling_mixtral.py","file_url":"https://github.com/idea-isail-lab-uiuc/resmoe/blob/HEAD/mixtral/resmoe_mixtral/modeling_mixtral.py","link_basis":"harvester_set","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":"e566aca3f6f9392e"}},{"code_sha256_prefix":"c5bcf01d18bba63d","entry":"read_json","repo":"idea-isail-lab-uiuc/resmoe","repo_kind":"official","path":"mixtral/resmoe_mixtral/convert_mixtral_weights_to_hf.py","file_url":"https://github.com/idea-isail-lab-uiuc/resmoe/blob/HEAD/mixtral/resmoe_mixtral/convert_mixtral_weights_to_hf.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":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c5bcf01d18bba63d"}},{"code_sha256_prefix":"b99eea6376d1e212","entry":"rotate_half","repo":"idea-isail-lab-uiuc/resmoe","repo_kind":"official","path":"mixtral/resmoe_mixtral/modeling_mixtral.py","file_url":"https://github.com/idea-isail-lab-uiuc/resmoe/blob/HEAD/mixtral/resmoe_mixtral/modeling_mixtral.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":"752fa6469bf06517","entry":"batch_get_continuation_logits","repo":"idea-isail-lab-uiuc/resmoe","repo_kind":"official","path":"mixtral/utils.py","file_url":"https://github.com/idea-isail-lab-uiuc/resmoe/blob/HEAD/mixtral/utils.py","link_basis":"harvester_set","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":"752fa6469bf06517"}},{"code_sha256_prefix":"a551df2803656673","entry":"get_continuation_logits","repo":"idea-isail-lab-uiuc/resmoe","repo_kind":"official","path":"mixtral/utils.py","file_url":"https://github.com/idea-isail-lab-uiuc/resmoe/blob/HEAD/mixtral/utils.py","link_basis":"harvester_set","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":"a551df2803656673"}},{"code_sha256_prefix":"085a890f4b2a50fb","entry":"get_expert_weights","repo":"idea-isail-lab-uiuc/resmoe","repo_kind":"official","path":"mixtral/wb.py","file_url":"https://github.com/idea-isail-lab-uiuc/resmoe/blob/HEAD/mixtral/wb.py","link_basis":"harvester_set","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":"085a890f4b2a50fb"}},{"code_sha256_prefix":"fd5e576aabbbdbfb","entry":"get_optimal_permutation","repo":"idea-isail-lab-uiuc/resmoe","repo_kind":"official","path":"mixtral/wb.py","file_url":"https://github.com/idea-isail-lab-uiuc/resmoe/blob/HEAD/mixtral/wb.py","link_basis":"harvester_set","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":"fd5e576aabbbdbfb"}},{"code_sha256_prefix":"1d687bf27ad08f02","entry":"is_diagonal","repo":"idea-isail-lab-uiuc/resmoe","repo_kind":"official","path":"mixtral/wb.py","file_url":"https://github.com/idea-isail-lab-uiuc/resmoe/blob/HEAD/mixtral/wb.py","link_basis":"harvester_set","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":"1d687bf27ad08f02"}},{"code_sha256_prefix":"9478f362a225551d","entry":"router_z_loss_func","repo":"idea-isail-lab-uiuc/resmoe","repo_kind":"official","path":"switch/switch_transformers/modeling_switch_transformers.py","file_url":"https://github.com/idea-isail-lab-uiuc/resmoe/blob/HEAD/switch/switch_transformers/modeling_switch_transformers.py","link_basis":"harvester_set","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":"9478f362a225551d"}},{"code_sha256_prefix":"b4d419e7685a8c6c","entry":"validate","repo":"idea-isail-lab-uiuc/resmoe","repo_kind":"official","path":"mixtral/utils.py","file_url":"https://github.com/idea-isail-lab-uiuc/resmoe/blob/HEAD/mixtral/utils.py","link_basis":"harvester_set","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":"b4d419e7685a8c6c"}},{"code_sha256_prefix":"66ba091cfb16c2e3","entry":"validate_head","repo":"idea-isail-lab-uiuc/resmoe","repo_kind":"official","path":"switch/utils.py","file_url":"https://github.com/idea-isail-lab-uiuc/resmoe/blob/HEAD/switch/utils.py","link_basis":"harvester_set","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":"66ba091cfb16c2e3"}},{"code_sha256_prefix":"8b07d9ff65d1cfbd","entry":"validate_seq2seq","repo":"idea-isail-lab-uiuc/resmoe","repo_kind":"official","path":"switch/utils.py","file_url":"https://github.com/idea-isail-lab-uiuc/resmoe/blob/HEAD/switch/utils.py","link_basis":"harvester_set","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":"8b07d9ff65d1cfbd"}},{"code_sha256_prefix":"ee2001e1c7496dc4","entry":"write_model","repo":"idea-isail-lab-uiuc/resmoe","repo_kind":"official","path":"mixtral/resmoe_mixtral/convert_mixtral_weights_to_hf.py","file_url":"https://github.com/idea-isail-lab-uiuc/resmoe/blob/HEAD/mixtral/resmoe_mixtral/convert_mixtral_weights_to_hf.py","link_basis":"harvester_set","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":"ee2001e1c7496dc4"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}