Repository navigation
Description
Found on main @ 12c1273, AMD R9700 (ROCm 10.1).
What is wrong
For every MoE definition without moe_lifecycle_hooks, AWQ silently drops the routed-expert gate/up scaling group. Nothing is logged, not even the fallback quant warning: the experts' gate/up projections are just quantized without an AWQ scale.
Mechanism:
BaseQModel.awq_input_feature_aggregation(models/base.py:5244-5273) returnscapture_root: Truefor every MoE root, soAWQProcessor._build_input_featuresadds the root (mlp/block_sparse_moe) as a feature task (looper/awq_processor.py:2060-2065).- The root activation is only recorded by
register_moe_root_capture_hook.stage_subset.py:995-1017registers that hook only whenlooper.gptq_model.moe_lifecycle_hooksreturns an MoE block (hooks.get_moe_block_for_subset(...)). With no lifecycle hooks, the root is never hooked, and its feature staysmode: "empty", a(0,)tensor. awq_get_modules_for_scalingprefers the root feature for an MoE gate/up block (models/base.py,is_moe_gate_up_blockbranch). It picks the empty root input and drops the block, so nopost_attention_layernorm -> experts.*.gate/upgroup is emitted.
These 15 registered model types have an MoE root but moe_lifecycle_hooks is None:
dbrx_converted, diffusion_gemma, ernie4_5_moe, ernie4_5_moe_vl, ernie4_5_vl_moe, gemma4, gemma4_text, gpt_oss, granitemoe, granitemoehybrid, kimi_k3, kimi_linear (K3 runner), nemotron_h, nemotron_h_puzzle, nemotronh_nano_omni_reasoning_v3.
Evidence
Groups emitted by awq_get_modules_for_scaling during a real quantize() (tiny random models, AWQConfig(bits=4, group_size=32), 32 pre-tokenized rows, bs=4), with the root feature shape seen by the builder:
| model_type | lifecycle hooks | root feature | expert gate/up group |
|---|---|---|---|
granitemoe |
none | block_sparse_moe: (0,) |
none |
gpt_oss |
none | mlp: (0,) |
none |
ernie4_5_moe |
none | mlp: (0,) |
none |
qwen3_moe (control) |
GateUpDownMoELifecycleHooks |
mlp: (1, 64, 32) |
post_attention_layernorm -> 8 experts |
mixtral (control) |
GateUpDownMoELifecycleHooks |
mlp: (1, 256, 32) |
post_attention_layernorm -> 8 experts |
granitemoe + hooks injected |
GateUpDownMoELifecycleHooks |
block_sparse_moe: (1, 256, 32) |
post_attention_layernorm -> 8 experts |
gpt_oss + hooks injected |
GateUpDownMoELifecycleHooks |
mlp: (1, 256, 32) |
post_attention_layernorm -> 8 experts |
Real checkpoint: gpt-oss-20b-BF16 truncated to 2 layers (real weights), AWQConfig(bits=4, group_size=128), 32 C4 rows. The applied scales, from a hook on apply_scale:
main: APPLY input_layernorm ['self_attn.q_proj','self_attn.k_proj','self_attn.v_proj'] # only group per layer
AWQProcessor: layer 0 sanitized 1 scaling groups
hooks injected: GROUP post_attention_layernorm ['mlp.experts.0.gate_proj', ...] 64 ['mlp.router']
APPLY post_attention_layernorm ['mlp.experts.0.gate_proj', ...] scale min/max 0.214/4.688
AWQProcessor: layer 0 sanitized 2 scaling groups
Reloaded 4-bit model vs bf16 native, on the prompt's logits: top-1 agreement 0.789 on main vs 0.947 with the expert group restored (rel logit err 0.055 / 0.058).
Suggested fix
Register the AWQ MoE-root capture from the module plan (plan.moe_roots()), not from the optional routing-lifecycle object. The root input is just a pre-forward hook on the declared MoE root and needs no routing control. If a root feature ends up empty, the builder should fall back to the expert features or warn, instead of dropping the group silently. Alternatively, give each of the 15 definitions the matching lifecycle hooks class, but then the next MoE definition without hooks breaks the same way.
Test that should have caught it
A per-family AWQ test asserting that every MoE layer emits (or deliberately skips, with a log line) a norm -> experts gate/up group during a real quantize. tests/test_awq_scaling_groups.py calls awq_get_modules_for_scaling with hand-built features and no root key, so it always sees the group.
Severity
Medium (silent quality loss). Confirmed at runtime on gpt-oss, Granite-MoE and ERNIE-4.5-MoE: all routed-expert gate/up projections (most of the model's parameters) are quantized without AWQ scaling, and no log line says so. The other definitions listed above have the same missing hook and were not run individually.
🤖 Generated with Claude Code
Activity
ZX-ModelCloud commentedon Nov 17, 2026
Claimed. I'm working on this issue and will submit a fix PR. Please avoid duplicate work in the meantime.
fix(awq): capture declared MoE roots without lifecycle hooks (#4697)
ZX-ModelCloud commentedon Nov 17, 2026
Fixed in #4723. AWQ now resolves the declared MoE roots from the module plan and registers the root capture hook without requiring
moe_lifecycle_hooks; an empty root feature now warns instead of silently dropping the routed-expert gate/up group.fix(awq): capture declared MoE roots without lifecycle hooks (#4697) (#…
Qubitium commentedon Nov 17, 2026
Agent claim:
agent-root-4697is working on this issue now.Qubitium commentedon Nov 17, 2026
Agent release:
agent-root-4697verified this issue and closed it. It was already fixed onmainby #4723 (d08de50c3, "fix(awq): capture declared MoE roots without lifecycle hooks"), so no new PR is needed here.Verification on current
main(a62bed008):tests/test_awq_moe_root_capture_4697.py(added by fix(awq): capture declared MoE roots without lifecycle hooks (#4697) #4723): 3 passed — the plan-derived root hook is registered and an empty declared root warns instead of silently dropping the group.tests/test_awq_hybrid_moe_root_4903.py::test_moe_layer_keeps_awq_without_lifecycle_hooks): a tinyernie4_5_moe(one of the 15 definitions listed here, nomoe_lifecycle_hooks) keeps AWQ for its routed-expert gate/up group and for the shared expert; only the genuinely unrouted experts fall back. Passes on unmodifiedmain.2 failed) when the module-plan root registration is disabled (simulating pre-fix(awq): capture declared MoE roots without lifecycle hooks (#4697) #4723), which is the regression guard this issue asked for: without the plan-derived capture the group anchors on the shared expert, the router's boundary check rejects it, and the shared expert plus every starved expert goes to plain quantization.The remaining related bug from the same mechanism — the dense prefix of a hybrid MoE losing its own
post_attention_layernorm -> gate/upgroup because the seeded root feature is empty — is #4903, fixed in PR #5000.Closing as fixed by #4723, with the end-to-end coverage above.
fix(awq): keep the dense-prefix norm group when the MoE root is empty (…
refactor(awq): build scaling groups from fold declarations; the tree …