[Bugfix] Size and iterate w13 by shard count for non-gated MoE (#51125)

Signed-off-by: aoshen02 <aoshen@inferact.ai>
Co-authored-by: Matej Sirovatka <matej.sirovatka@gmail.com>
Co-authored-by: Rishi Puri <riship@nvidia.com>
Co-authored-by: Hsiao-Yuan Chen <littlecircle0730@users.noreply.github.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
aoshen02
2026-08-05 17:24:47 -07:00
committed by GitHub
co-authored by Matej Sirovatka Rishi Puri Hsiao-Yuan Chen Claude Opus 5
parent 811622c410
commit 7c77868cdf
16 changed files with 104 additions and 80 deletions
+1
View File
@@ -65,6 +65,7 @@ def test_auto_gptq_moe_creates_zero_initialized_expert_biases():
method.quant_config = AutoGPTQConfig(4, 128, False, True, False, {}, {})
method.input_dtype = None
method.experts_cls = None
method.moe = SimpleNamespace(w13_num_shards=2)
layer = torch.nn.Module()
method.create_weights(
+4 -2
View File
@@ -8,6 +8,7 @@ Validating the configuration and printing results for manual checking.
Run `pytest tests/quantization/test_auto_round.py`.
"""
from types import SimpleNamespace
from typing import Any, cast
import pytest
@@ -694,7 +695,8 @@ def test_inc_mxfp4_moe_method_registers_weights_and_builds_kernel(
INCMxfp4MoEMethod,
)
method = INCMxfp4MoEMethod(moe=cast(Any, "moe-config"))
expected_moe_config = SimpleNamespace(w13_num_shards=2)
method = INCMxfp4MoEMethod(moe=cast(Any, expected_moe_config))
layer = torch.nn.Module()
layer._expert_routing_tables = lambda: "routing-tables"
@@ -723,7 +725,7 @@ def test_inc_mxfp4_moe_method_registers_weights_and_builds_kernel(
assert captured["quant_config_kwargs"]["w1_scale"] is layer.w13_weight_scale
assert captured["quant_config_kwargs"]["w2_scale"] is layer.w2_weight_scale
assert captured["kernel_kwargs"]["moe_quant_config"] is expected_quant_config
assert captured["kernel_kwargs"]["moe_config"] == "moe-config"
assert captured["kernel_kwargs"]["moe_config"] is expected_moe_config
assert captured["kernel_kwargs"]["experts_cls"] is expected_experts_cls
assert captured["kernel_kwargs"]["routing_tables"] == "routing-tables"
assert method.moe_kernel is expected_kernel