Merge branch 'city96:main' into feat_load_stable_diffusion.cpp

This commit is contained in:
blepping
2024-09-01 02:47:16 -06:00
committed by GitHub
2 changed files with 8 additions and 1 deletions
+5 -1
View File
@@ -145,7 +145,7 @@ class GGUFModelPatcher(comfy.model_patcher.ModelPatcher):
if device_to is not None:
out_weight = weight.to(device_to, copy=True)
else:
out_weight = weight.clone()
out_weight = weight.to(weight.device, copy=True) # make sure patches are copied
if self.patch_on_device:
patches = move_patch_to_cuda(patches, self.load_device)
@@ -165,6 +165,10 @@ class GGUFModelPatcher(comfy.model_patcher.ModelPatcher):
else:
comfy.utils.set_attr_param(self.model, key, out_weight)
def load(self, *args, force_patch_weights=False, **kwargs):
# always call `patch_weight_to_device` even for lowvram
return super().load(*args, force_patch_weights=True, **kwargs)
def clone(self, *args, **kwargs):
n = GGUFModelPatcher(self.model, self.load_device, self.offload_device, self.size, weight_inplace_update=self.weight_inplace_update)
n.patches = {}
+3
View File
@@ -109,6 +109,9 @@ def handle_tensors(args, writer, state_dict):
if data.dtype == torch.bfloat16:
data = data.to(torch.float32).numpy()
# this is so we don't break torch 2.0.X
elif data.dtype in [getattr(torch, "float8_e4m3fn", "_invalid"), getattr(torch, "float8_e5m2", "_invalid")]:
data = data.to(torch.float16).numpy()
else:
data = data.numpy()