From f3410b3bb16b1b0f33468a65f260148565c9948c Mon Sep 17 00:00:00 2001 From: Willow Lopez <100782273+Oxygen56@users.noreply.github.com> Date: Tue, 23 Jun 2026 23:46:23 +0800 Subject: [PATCH] fix(moe_wna16): access tp_size via moe_config for RoutedExperts compatibility (#45404) Signed-off-by: Oxygen <1391083091@qq.com> Signed-off-by: Willow Lopez <100782273+Oxygen56@users.noreply.github.com> --- vllm/model_executor/layers/quantization/moe_wna16.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vllm/model_executor/layers/quantization/moe_wna16.py b/vllm/model_executor/layers/quantization/moe_wna16.py index 3f332c86e8..23e175fd62 100644 --- a/vllm/model_executor/layers/quantization/moe_wna16.py +++ b/vllm/model_executor/layers/quantization/moe_wna16.py @@ -426,7 +426,6 @@ class MoeWNA16Method(FusedMoEMethodBase): device = get_tp_group().device tp_rank = get_tensor_model_parallel_rank() - tp_size = layer.moe_config.moe_parallel_config.tp_size loaded_weight = loaded_weight.to(device) shard_size = layer.intermediate_size_per_partition @@ -465,7 +464,9 @@ class MoeWNA16Method(FusedMoEMethodBase): ) if "w13_qzeros" in weight_name: - tensor = loaded_weight.view(tp_size, -1, loaded_weight.size(1))[tp_rank] + tensor = loaded_weight.view( + layer.moe_config.tp_size, -1, loaded_weight.size(1) + )[tp_rank] if shard_id == "w1": param.data[expert_id, : shard_size // 2] = tensor else: @@ -473,7 +474,7 @@ class MoeWNA16Method(FusedMoEMethodBase): return True if return_success else None elif "w2_qzeros" in weight_name: param.data[expert_id] = loaded_weight.view( - loaded_weight.size(0), tp_size, -1 + loaded_weight.size(0), layer.moe_config.tp_size, -1 )[:, tp_rank] return True if return_success else None else: