[Qwen4] validate FP8 PLE weight scale after loading (#54722)

Signed-off-by: huanghaoyan.hhy <huanghaoyan.hhy@alibaba-inc.com>
This commit is contained in:
Harry Huang
2026-09-02 04:30:58 +00:00
committed by GitHub
parent ee3c00bbf4
commit 1e300895ac
2 changed files with 26 additions and 5 deletions
+7 -1
View File
@@ -106,10 +106,16 @@ class Qwen4ExpPLEFp8EmbeddingMethod(QuantizeMethodBase):
input_size_per_partition,
None,
weight_loader,
scale_dtype=torch.bfloat16,
scale_dtype=torch.float32,
)
layer.register_parameter("weight_scale", weight_scale)
def process_weights_after_loading(self, layer: nn.Module) -> None:
"""Reject FP8 PLE checkpoints without a global scale."""
sentinel = torch.finfo(torch.float32).min
if torch.any(layer.weight_scale == sentinel):
raise ValueError("FP8 PLE checkpoint is missing its global scale")
def apply(
self,
layer: nn.Module,