Skip to content

[BUG] Follow-up on #4151/#4154: MoEConfig(routing=ExpertsRoutingBypass()) still makes AWQ drop every MoE expert gate/up group to RTN fallback #4223

Closed

Description

@Qubitium

Severity: medium (silent AWQ loss on MoE models, with only a warning; with fallback=None, quantization aborts)
Version: 7.11.0 @ 9dad249. 60ac76d fixed only ExpertsRoutingOverride.

Summary

  • _replay_moe_routing_override (looper/awq_processor.py:2548-2589) handles only moe_routing_override.
  • In bypass mode, ForwardExecutor uses MoELifecycleContext, which feeds tokens to every expert.
  • AWQ's reference replay of module2inspect still routes natively, so unrouted experts look "unobserved".
  • The coverage guard (awq_processor.py:~2715) then raises _AWQScaleGroupError, and the whole expert group falls back, including experts that were routed.

Reproduce (the fixture from the new test in tests/test_tiny_moe_quant_smoke.py)

from tests.test_tiny_moe_quant_smoke import _build_tiny_qwen3_moe_fixture, _build_calibration_dataset
from gptqmodel import BACKEND, GPTQModel, QuantizeConfig
from gptqmodel.quantization import FORMAT, METHOD
from gptqmodel.quantization.config import ExpertsRoutingBypass, MoEConfig
cfg, tok = _build_tiny_qwen3_moe_fixture(tmp_path / "m", num_experts=32, num_experts_per_tok=1, moe_intermediate_size=64)
qc = QuantizeConfig(bits=4, group_size=32, desc_act=False, device="cpu", method=METHOD.AWQ, format=FORMAT.GEMM,
                    moe=MoEConfig(routing=ExpertsRoutingBypass()))
m = GPTQModel.load(str(tmp_path / "m"), quantize_config=qc, backend=BACKEND.TORCH)
m.quantize(_build_calibration_dataset(tok), batch_size=1, backend=BACKEND.TORCH, calibration_data_min_length=1)
print(sum(r["loss"] == "not applicable" for r in m.quant_log if "experts" in str(r["module"])))

Actual:

  • The guard raises "AWQ: reference replay did not execute targets [mlp.experts.0.gate_proj, ...]".
  • 64/64 expert gate/up rows are "not applicable", i.e. they fell back.
  • The same script with ExpertsRoutingOverride() gives 0.

Expected: either keep AWQ scaling under bypass (make the replay use the same all-experts lifecycle), or have the guard require only the experts that were natively routed.


Found during an AI-assisted review (Claude Code) of 9dad249; repros were run on RTX 4090/5090 (CUDA 13) and/or Radeon AI PRO R9700 (ROCm) unless marked static/suspected.

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions