From 2465ee39485799cc777b243c51996a7126cf7ef2 Mon Sep 17 00:00:00 2001 From: Bingxu Chen Date: Fri, 11 Sep 2026 14:00:29 +0800 Subject: [PATCH] [AMD] Fix DeepSeek block-FP8 loading on gfx94x (#38446) Signed-off-by: Bingxu Chen --- .../srt/models/deepseek_common/deepseek_weight_loader.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/sglang/srt/models/deepseek_common/deepseek_weight_loader.py b/python/sglang/srt/models/deepseek_common/deepseek_weight_loader.py index b6c830fea..c526df775 100644 --- a/python/sglang/srt/models/deepseek_common/deepseek_weight_loader.py +++ b/python/sglang/srt/models/deepseek_common/deepseek_weight_loader.py @@ -628,7 +628,10 @@ class DeepseekV2WeightLoaderMixin: if hasattr(self_attn.kv_b_proj, "weight_scale") else self_attn.kv_b_proj.weight_scale_inv ) - if _is_fp8_fnuz: + is_ue8m0_uint8 = ( + weight_scale.format_ue8m0 and weight_scale.dtype == torch.uint8 + ) + if _is_fp8_fnuz and not is_ue8m0_uint8: weight, weight_scale, _ = normalize_e4m3fn_to_e4m3fnuz( weight=w, weight_scale=weight_scale, @@ -638,7 +641,7 @@ class DeepseekV2WeightLoaderMixin: weight = w # In multiple weight loading scenarios (e.g. RL), we need to inverse the scale of the weights after the requantization happened at the first loading. - if weight_scale.format_ue8m0 and weight_scale.dtype == torch.uint8: + if is_ue8m0_uint8: weight_scale = (weight_scale.to(torch.int32) << 23).view( torch.float32 )