[weight loader] add dtype equality validation between parameter and weight (#51792)

Signed-off-by: Andy Xie <andy.xning@gmail.com>
This commit is contained in:
Ning Xie
2026-10-01 03:07:31 +00:00
committed by GitHub
parent bfbcde26d5
commit a37c402f32
+8
View File
@@ -321,6 +321,14 @@ class AutoWeightsLoader:
f"into a single parameter {base_prefix!r}"
)
if param.dtype != weight_data.dtype:
logger.warning(
"Attempted to load weight %s with dtype %s into "
"parameter with dtype %s",
weight_qualname,
weight_data.dtype,
param.dtype,
)
weight_loader = getattr(param, "weight_loader", default_weight_loader)
weight_loader(param, weight_data)