[hotfix] missing w13_weight_fp8 and w2_weight_fp8 in UE8M0 requantization (#12259)

This commit is contained in:
Cheng Wan
2025-10-28 19:10:38 -07:00
committed by GitHub
parent 334543ff3b
commit 83087247d1
4 changed files with 30 additions and 30 deletions
+20 -4
View File
@@ -3289,8 +3289,8 @@ class DeepseekV2ForCausalLM(nn.Module):
experts = layer.mlp.experts
if isinstance(experts, DeepEPMoE):
for w in [
experts.w13_weight_fp8,
experts.w2_weight_fp8,
(experts.w13_weight, experts.w13_weight_scale_inv),
(experts.w2_weight, experts.w2_weight_scale_inv),
]:
requant_weight_ue8m0_inplace(w[0], w[1], weight_block_size)
else:
@@ -3338,10 +3338,26 @@ class DeepseekV2ForCausalLM(nn.Module):
)
experts = layer.mlp.experts
w13_weight_fp8 = (
experts.w13_weight,
(
experts.w13_weight_scale_inv
if hasattr(experts, "w13_weight_scale_inv")
else experts.w13_weight_scale
),
)
w2_weight_fp8 = (
experts.w2_weight,
(
experts.w2_weight_scale_inv
if hasattr(experts, "w2_weight_scale_inv")
else experts.w2_weight_scale
),
)
if isinstance(experts, DeepEPMoE):
for w in [
experts.w13_weight_fp8,
experts.w2_weight_fp8,
w13_weight_fp8,
w2_weight_fp8,
]:
transform_scale_ue8m0_inplace(w[1], mn=w[0].shape[-2])