Fix dummy weight init for tensor subclasses (#29229)
This commit is contained in:
@@ -1469,7 +1469,10 @@ def initialize_dummy_weights(
|
||||
if torch.is_floating_point(param):
|
||||
generator = torch.Generator(device=param.data.device)
|
||||
generator.manual_seed(seed)
|
||||
if torch.finfo(param.data.dtype).bits < 16:
|
||||
# Tensor subclasses such as MXFP8 wrappers expose a low-bit raw
|
||||
# storage dtype through `.data`, but their wrapper `uniform_` also
|
||||
# updates side tensors such as block scales.
|
||||
if torch.finfo(param.dtype).bits < 16:
|
||||
# uniform_ doesn't support < 16-bit datatypes (FP8)
|
||||
dtype = param.data.dtype
|
||||
tmp_param = param.data.to(torch.float16)
|
||||
|
||||
Reference in New Issue
Block a user