Merge branch 'city96:main' into feat_load_stable_diffusion.cpp
This commit is contained in:
@@ -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 = {}
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user