You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Regression from #5019 (fix of #4891): AWQ with ExpertsRoutingBypass crashes on every MoE block ('SparseMoeBlock.forward() got an unexpected keyword argument position_ids'): the bypass wrapper's **kwargs makes _forward_accepts_var_kwargs pass all layer kwargs #5095
For bypass routing, AWQ replaces the MoE block's forward with an instance-level wrapper all_experts_forward(hidden_states, **kwargs) (awq_processor.py:3313-3348).
inspect.signature(moe_block.forward) now sees the wrapper's **kwargs. So the MoE block gets the whole decoder-layer kwargs (position_ids, attention_mask, position_embeddings, ...), and the wrapper forwards them to the original SparseMoeBlock.forward(hidden_states), which raises.
Before #5019, the name filter used the wrapper's signature too, but it kept only hidden_states, so nothing extra was forwarded.
Repro
olmoe2 = OLMoE-1B-7B-0924 with num_hidden_layers=2 (config copy, same weights). Qwen1.5-MoE-A2.7B (2 layers) fails the same way.
TypeError: OlmoeSparseMoeBlock.forward() got an unexpected keyword argument 'position_ids'
GPTQConfig with the same bypass routing, and AWQ with native routing, both quantize fine on main.
Suggested fix
Have the wrapper keep the block's real signature (functools.wraps(original_forward) sets __wrapped__, which inspect.signature follows) and call original_forward(hidden_states, **kwargs) only with the keys the original accepts.
Or let _forward_accepts_var_kwargs ignore the processor's own instance-level patch (look at type(module).forward instead of the bound instance attribute).
Test that should have caught it
tests/test_awq_moe_bypass_4223.py / tests/test_moe_bypass_batch_size.py should run the bypass path through _sanitize_kwargs with real layer kwargs (position_ids, attention_mask), for example on the tiny Qwen3-MoE fixture used by tests/test_dp_subset_early_stop_4904.py. The #5019 tests only cover Hymba's **kwargs block.
Severity
High for AWQ MoE users who use bypass routing (the documented way to give every expert calibration data): it is a hard crash on every standard MoE family since #5019. Native routing is unaffected.
Additional data from the full-suite triage on main @ 7b8f127.
The existing test tests/test_awq_moe_bypass_4223.py::test_awq_bypass_replay_scales_every_expert already catches this regression. It is red on main on CPU-only, on RTX 4090 and on ROCm (R9700):
E TypeError: LinearQwen3MoeSparseMoeBlock.forward() got an unexpected keyword argument 'position_ids'
I bisected it with the HEAD test on CPU over 3867c82af..7b8f12785. The first bad commit is 7744cb898 (#5019), which matches the root cause above. It passed at the previous full triage (3867c82af). (tests/test_moe_bypass_batch_size.py stays green, but it only covers config validation and never runs the bypass replay.)
Agent claim:agent-root-5095-awq-bypass is working on this issue now.
Started 2026-11-18T05:37:24Z. The claim expires 4.0h after this comment was last edited (heartbeat). Other agents: do not start this issue while the claim is live.
claiming: fix the ExpertsRoutingBypass **kwargs detection so the bypass wrapper no longer forwards position_ids to SparseMoeBlock.forward
Agent claim released:agent-root-5095-awq-bypass finished this issue.
Pull request: #5142
Fixed the #5019 regression by decorating AWQ's instance-level bypass replay wrapper with functools.wraps(original_forward), so inspect.signature reports the MoE block's real forward(hidden_states) instead of the wrapper's **kwargs; the wrapper now also forwards only keywords the original block declares. Hymba's genuine **kwargs block keeps the #4891 behavior. On the issue's 2-layer OLMoE-1B-7B-0924 + C4 repro, e2f9676 raises the reported TypeError and the PR quantizes 392 modules / 1,817,856 expert rows (pre-#5019 baseline). Added two regression tests and the mechanism diagrams in docs/moe-routing-override.md section 8.
Activity
Qubitium commentedon Nov 18, 2026
Additional data from the full-suite triage on
main@ 7b8f127.The existing test
tests/test_awq_moe_bypass_4223.py::test_awq_bypass_replay_scales_every_expertalready catches this regression. It is red onmainon CPU-only, on RTX 4090 and on ROCm (R9700):I bisected it with the HEAD test on CPU over
3867c82af..7b8f12785. The first bad commit is7744cb898(#5019), which matches the root cause above. It passed at the previous full triage (3867c82af). (tests/test_moe_bypass_batch_size.pystays green, but it only covers config validation and never runs the bypass replay.)🤖 Generated with Claude Code
Qubitium commentedon Nov 18, 2026
Agent claim:
agent-root-5095-awq-bypassis working on this issue now.Started 2026-11-18T05:37:24Z. The claim expires 4.0h after this comment was last edited (heartbeat). Other agents: do not start this issue while the claim is live.
claiming: fix the ExpertsRoutingBypass **kwargs detection so the bypass wrapper no longer forwards position_ids to SparseMoeBlock.forward
Qubitium commentedon Nov 18, 2026
Agent claim released:
agent-root-5095-awq-bypassfinished this issue.Pull request: #5142
Fixed the #5019 regression by decorating AWQ's instance-level bypass replay wrapper with
functools.wraps(original_forward), soinspect.signaturereports the MoE block's realforward(hidden_states)instead of the wrapper's**kwargs; the wrapper now also forwards only keywords the original block declares. Hymba's genuine**kwargsblock keeps the #4891 behavior. On the issue's 2-layer OLMoE-1B-7B-0924 + C4 repro, e2f9676 raises the reported TypeError and the PR quantizes 392 modules / 1,817,856 expert rows (pre-#5019 baseline). Added two regression tests and the mechanism diagrams in docs/moe-routing-override.md section 8.fix(awq): keep the block signature visible in bypass replay (#5095) (#…