Skip to content

fix(awq): keep AWQ for covered MoE experts when one is starved (#4675) - #4720

Merged
Qubitium merged 1 commit into
mainfrom
fix/awq-moe-starved-group-4675
Nov 17, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/awq-moe-starved-group-4675

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Fixes #4675.

Problem

AWQ builds one scaling group per MoE block's routed-expert gate_proj/up_proj pair and treated it as all-or-nothing. One expert below Fallback.threshold, one expert native routing never selects, or one dynamic-excluded expert moved every expert in the layer to RTN. On Qwen3-30B-A3B that silently RTNs all 256 routed gate/up projections per layer with only a per-layer warning. GPTQ handles this per module.

The search reads one captured MoE-root input per group, and a member's own rows only reach the objective through the replayed block, so a starved member contributes nothing to the scale search — yet the norm it reads is still divided by the folded scale.

Fix

Tests

tests/test_awq_moe_starved_expert_group_4675.py:

  • unit contract: search sees the covered members, apply_scale sees all, only the starved member is plain-quantized;
  • whole group falls back only when every member is starved;
  • tiny Qwen3-MoE (8 experts, top-2) with a router bias making expert 3 unreachable: the other 7 experts keep AWQ in quant_log, only expert 3 is "not applicable", no whole-group fallback.

Red on the parent commit (assert 'not applicable' != 'not applicable' for mlp.experts.0.gate_proj); green with the fix.

Verified: PYTHONPATH=/root/work-4675 python -m pytest over the new file + test_awq_scale_search_safety, test_awq_weight_mean, test_awq_moe_router_scaling, test_awq_per_module_bits, test_awq_empty_groups, test_awq_clip_empty_feature_4679, test_awq_clip_consistency, test_awq_gptq_lifecycle, test_bloom_awq_replay, test_tiny_moe_quant_smoke → 277 passed, 90 skipped. ruff check gptqmodel tests clean.

Residual: CPU-only validation here (GB10 GPU present but no large MoE checkpoint); the changed math is device-agnostic. A dynamic-excluded expert stays dense but now receives the folded scale (required for norm/weight equivalence).

AWQ builds one scaling group per MoE block's routed-expert `gate_proj`/`up_proj`
pair and treated it as all-or-nothing. One expert below `Fallback.threshold`,
one expert that native routing never selects, or one `dynamic`-excluded expert
moved every expert in the layer to RTN. On Qwen3-30B-A3B that silently RTNs all
256 routed gate/up projections per layer and only logs a per-layer warning.

The search reads one captured MoE-root input per group, and a member's own rows
only reach the objective through the replayed block, so a starved member
contributes nothing to the scale search while the norm it reads is still
divided by the folded scale.

- Split the group verdict: `_starved_group_members` classifies members per
  module; `_should_fallback_group` keeps the whole-group predicate for dense
  groups (#4063).
- Routed-expert gate/up groups (search input is not a group member) drop only
  the starved members from the search, fold the scale into every member, and
  plain-quantize the starved ones after the fold. The group falls back wholesale
  only when no member has data and the group's routed tokens miss the threshold.
- The replay-coverage guard now requires only the members native routing
  executed, and only for routed-expert groups; a dense group still fails closed.
- `apply_scale` skips the input-feature division for a member that captured no
  rows instead of broadcasting a `(0,)` tensor against the scale.

Tests: `tests/test_awq_moe_starved_expert_group_4675.py` adds a unit contract
(search sees the covered members, the fold sees all of them, only the starved
member is plain-quantized) and a tiny Qwen3-MoE end-to-end case whose router
bias makes expert 3 unreachable: the other 7 experts' gate/up keep AWQ and only
expert 3 is "not applicable". Both fail on the parent commit.
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