Compare commits

...

2 Commits

Author SHA1 Message Date
Xiaoyu Xu
2c2646193d
Merge afe05d68ee into da2bfb5b0a 2025-12-13 07:31:59 +00:00
strint
afe05d68ee load diffusion model from state dict with assign 2025-12-12 17:06:06 +08:00

View File

@ -305,7 +305,9 @@ class BaseModel(torch.nn.Module):
to_load[k[len(unet_prefix):]] = sd.pop(k)
to_load = self.model_config.process_unet_state_dict(to_load)
m, u = self.diffusion_model.load_state_dict(to_load, strict=False)
# assign=True will reuse the tensor storage in state dict, this will avoid copy and saving CPU memory
# when loading large models with mmap.
m, u = self.diffusion_model.load_state_dict(to_load, strict=False, assign=True)
if len(m) > 0:
logging.warning("unet missing: {}".format(m))