A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 15, 12:15 UTC
[Bugfix] Fix moe weight losing all extra attrs after `process_weights_after_loading`. (#16854)
Signed-off-by: charlifu <charlifu@amd.com>
Charlie Fu committed
Apr 28, 2025 at 16:05 UTC
ed2462030f2ccc84be13d8bb2c7476c84930fb71
2 files changed
+6
-11
vllm/model_executor/layers/fused_moe/layer.py
+5
-10
@@ -113,12 +113,9 @@ class UnquantizedFusedMoEMethod(FusedMoEMethodBase, CustomOp):
113
def process_weights_after_loading(self, layer: torch.nn.Module) -> None:
114
super().process_weights_after_loading(layer)
115
116
- layer.w13_weight = torch.nn.Parameter(self._maybe_pad_weight(
117
- layer.w13_weight.data),
118
- requires_grad=False)
119
- layer.w2_weight = torch.nn.Parameter(self._maybe_pad_weight(
120
- layer.w2_weight.data),
121
- requires_grad=False)
116
+ # Padding the weight for better performance on ROCm
117
+ layer.w13_weight.data = self._maybe_pad_weight(layer.w13_weight.data)
118
+ layer.w2_weight.data = self._maybe_pad_weight(layer.w2_weight.data)
119
# Lazy import to avoid importing triton.
120
from vllm.model_executor.layers.fused_moe.rocm_aiter_fused_moe import (
121
is_rocm_aiter_moe_enabled, shuffle_weights)
@@ -127,10 +124,8 @@ class UnquantizedFusedMoEMethod(FusedMoEMethodBase, CustomOp):
124
shuffled_w13, shuffled_w2 = shuffle_weights(
125
layer.w13_weight.data, layer.w2_weight.data)
126
130
- layer.w13_weight = torch.nn.Parameter(shuffled_w13,
131
- requires_grad=False)
132
- layer.w2_weight = torch.nn.Parameter(shuffled_w2,
133
- requires_grad=False)
127
+ layer.w13_weight.data = shuffled_w13
128
+ layer.w2_weight.data = shuffled_w2
129
130
if current_platform.is_cpu():
131
if current_platform.get_cpu_architecture() == CpuArchEnum.X86:
vllm/model_executor/layers/quantization/utils/w8a8_utils.py
+1
-1
@@ -156,7 +156,7 @@ def rocm_per_tensor_w8a8_scaled_mm(*, qinput: torch.Tensor,
156
input_2d: torch.Tensor,
157
output_shape: List) -> torch.Tensor:
158
from vllm.platforms.rocm import on_mi250_mi300
159
- if envs.VLLM_ROCM_USE_SKINNY_GEMM and not on_mi250_mi300(
159
+ if envs.VLLM_ROCM_USE_SKINNY_GEMM and on_mi250_mi300(
160
) and qinput.shape[0] == 1 and qinput.shape[1] % 16 == 0:
161
output = ops.wvSplitKQ(weight.t(), qinput, out_dtype, scale_a, scale_b,
162
current_platform.get_cu_count())