[Bugfix][CPU][MoE] Fix out-of-bounds write and segfault when router weights are fp32 (#56168)
Signed-off-by: Farzad Abdolhosseini <farzad@elastix.ai> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Li, Jiang <jiang1.li@intel.com>
This commit is contained in:
co-authored by
Claude
Li, Jiang <jiang1.li@intel.com>
parent
7f1a5398e9
commit
8b06a343ec
@@ -513,7 +513,10 @@ def dispatch_cpu_unquantized_gemm(
|
||||
)
|
||||
)
|
||||
if remove_weight:
|
||||
layer.weight = torch.nn.Parameter(torch.empty(0), requires_grad=False)
|
||||
layer.weight = torch.nn.Parameter(
|
||||
torch.empty(0, dtype=dtype, device=layer.weight.device),
|
||||
requires_grad=False,
|
||||
)
|
||||
logger.debug_once(
|
||||
"CPU unquantized GEMM dispatch: using zentorch_linear_unary (prepacked=%s)",
|
||||
is_prepacked,
|
||||
@@ -539,7 +542,10 @@ def dispatch_cpu_unquantized_gemm(
|
||||
bias,
|
||||
)
|
||||
if remove_weight:
|
||||
layer.weight = torch.nn.Parameter(torch.empty(0), requires_grad=False)
|
||||
layer.weight = torch.nn.Parameter(
|
||||
torch.empty(0, dtype=dtype, device=layer.weight.device),
|
||||
requires_grad=False,
|
||||
)
|
||||
logger.debug_once(
|
||||
"CPU unquantized GEMM dispatch: using sgl-kernel weight_packed_linear"
|
||||
)
|
||||
@@ -554,7 +560,10 @@ def dispatch_cpu_unquantized_gemm(
|
||||
handler = ops.create_onednn_mm(origin_weight.t(), 32)
|
||||
layer.cpu_linear = lambda x, weight, bias: ops.onednn_mm(handler, x, bias)
|
||||
if remove_weight:
|
||||
layer.weight = torch.nn.Parameter(torch.empty(0), requires_grad=False)
|
||||
layer.weight = torch.nn.Parameter(
|
||||
torch.empty(0, dtype=dtype, device=layer.weight.device),
|
||||
requires_grad=False,
|
||||
)
|
||||
logger.debug_once("CPU unquantized GEMM dispatch: using oneDNN onednn_mm")
|
||||
return
|
||||
except RuntimeError as e:
|
||||
|
||||
Reference in New Issue
Block a user