Repository navigation
fix(awq): search the MoE root feature for shared-expert gate/up groups (#4760) - #4790
Merged
Merged
Conversation
This was referenced Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
#4720 keeps AWQ for the covered experts of a routed-expert gate/up group, but only when the group's search input is not one of its own members:
On Ling 2.0 (
bailing_moe) the 514-member gate/up group got_input_feature_name = "mlp.shared_experts.gate_proj"— a member — instead of the MoE rootmlp(what Qwen1.5-MoE gets). One starved routed expert therefore still sent all 514 gate/up projections to RTN in every MoE layer: the exact #4675 behaviour #4720 was meant to fix.Root cause: the
root != last_module_rootbookkeeping inawq_get_modules_for_scaling. Ling declares a densemlpblock next tomlp:moe, and the routermlp.gatemoveslast_module_roottomlpbefore the experts block, somodule2inspectstays unset and the group is anchored on the shared-expert projection.Fix
gptqmodel/models/base.py: a MoE gate/up block now uses the MoE root capture (mlp) as its search feature whenever that capture exists, independent of thelast_module_rootbookkeeping. The MoE-root resolution is extracted into_block_moe_root()and reused by_moe_block_consumers.Tests
New
tests/test_awq_moe_shared_expert_group_4760.py(7 tests):BailingMoeQModel/Qwen2MoeQModel/DeepSeekV2QModeldefinitions on fake MoE layers — the merged group's_input_feature_nameismlp, the split searches 2·N members minus the starved pair, covered + shared keep AWQ, only the starved expert falls back;bailing_hybridwith a router bias starving one expert — assertskeeps AWQ for 8 of 10 members,fallback quant 3 modules, no whole-layer fallback.Red on parent (source stashed): 3 failed, 4 passed —
assert 'mlp.shared_experts.gate_proj' == 'mlp'and nokeeps AWQ forline.Verification
test_awq_moe_starved_expert_group_4675.py: 10 passedtests/test_awq_scaling_groups.py: 152 passed, 9 skippedtests/module_tree/test_registered_module_plans.py: 419 passedruff check gptqmodel tests: cleanCloses #4760