From 5f10b70d9c5c29e4258a90ec1625ba8ce6b71550 Mon Sep 17 00:00:00 2001 From: strint Date: Mon, 15 Dec 2025 16:39:54 +0800 Subject: [PATCH] enable only when mmap is enabled --- comfy/model_base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/comfy/model_base.py b/comfy/model_base.py index 5e3967449..31ed6adb9 100644 --- a/comfy/model_base.py +++ b/comfy/model_base.py @@ -307,7 +307,8 @@ class BaseModel(torch.nn.Module): to_load = self.model_config.process_unet_state_dict(to_load) # 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) + delay_copy_with_assign = utils.MMAP_TORCH_FILES or not utils.DISABLE_MMAP + m, u = self.diffusion_model.load_state_dict(to_load, strict=False, assign=delay_copy_with_assign) if len(m) > 0: logging.warning("unet missing: {}".format(m))