Skip to content

[QUALITY] AWQ silently drops the routed-expert gate/up scaling group for 15 MoE definitions without moe_lifecycle_hooks (gpt-oss, Granite-MoE, ERNIE-4.5-MoE, Gemma-4, Nemotron-H...): MoE-root capture is never registered #4697

Closed

Description

@Qubitium

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:

  1. BaseQModel.awq_input_feature_aggregation (models/base.py:5244-5273) returns capture_root: True for every MoE root, so AWQProcessor._build_input_features adds the root (mlp / block_sparse_moe) as a feature task (looper/awq_processor.py:2060-2065).
  2. The root activation is only recorded by register_moe_root_capture_hook. stage_subset.py:995-1017 registers that hook only when looper.gptq_model.moe_lifecycle_hooks returns an MoE block (hooks.get_moe_block_for_subset(...)). With no lifecycle hooks, the root is never hooked, and its feature stays mode: "empty", a (0,) tensor.
  3. awq_get_modules_for_scaling prefers the root feature for an MoE gate/up block (models/base.py, is_moe_gate_up_block branch). It picks the empty root input and drops the block, so no post_attention_layernorm -> experts.*.gate/up group 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

  1. ZX-ModelCloud commented on Nov 17, 2026

    @ZX-ModelCloud
    Collaborator

    Claimed. I'm working on this issue and will submit a fix PR. Please avoid duplicate work in the meantime.

  2. ZX-ModelCloud commented on Nov 17, 2026

    @ZX-ModelCloud
    Collaborator

    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.

  3. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

    Agent claim: agent-root-4697 is working on this issue now.

  4. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

    Agent release: agent-root-4697 verified this issue and closed it. It was already fixed on main by #4723 (d08de50c3, "fix(awq): capture declared MoE roots without lifecycle hooks"), so no new PR is needed here.

    Verification on current main (a62bed008):

    The remaining related bug from the same mechanism — the dense prefix of a hybrid MoE losing its own post_attention_layernorm -> gate/up group 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.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions