Skip to content

fix(awq): search the MoE root feature for shared-expert gate/up groups (#4760) - #4790

Merged
Qubitium merged 2 commits into
mainfrom
fix/issue-4760
Nov 17, 2026
Merged

Qubitium merged 2 commits into
mainfrom
fix/issue-4760

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

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:

shared_search_input = cfg.get("_input_feature_name") not in layer_names

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 root mlp (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_root bookkeeping in awq_get_modules_for_scaling. Ling declares a dense mlp block next to mlp:moe, and the router mlp.gate moves last_module_root to mlp before the experts block, so module2inspect stays 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 the last_module_root bookkeeping. 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):

  • unit: real BailingMoeQModel / Qwen2MoeQModel / DeepSeekV2QModel definitions on fake MoE layers — the merged group's _input_feature_name is mlp, the split searches 2·N members minus the starved pair, covered + shared keep AWQ, only the starved expert falls back;
  • e2e (slow): tiny sparse bailing_hybrid with a router bias starving one expert — asserts keeps 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 no keeps AWQ for line.

Verification

  • new file: 7 passed; with test_awq_moe_starved_expert_group_4675.py: 10 passed
  • tests/test_awq_scaling_groups.py: 152 passed, 9 skipped
  • tests/module_tree/test_registered_module_plans.py: 419 passed
  • ruff check gptqmodel tests: clean

Closes #4760

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant