Remove old workaround

This commit is contained in:
City
2025-05-07 04:42:20 +02:00
parent 3d673c5c09
commit 03842fab0a
2 changed files with 9 additions and 11 deletions
+4 -7
View File
@@ -5,6 +5,8 @@ import collections
import nodes
import comfy.sd
import comfy.lora
import comfy.float
import comfy.utils
import comfy.model_patcher
import comfy.model_management
@@ -37,17 +39,12 @@ class GGUFModelPatcher(comfy.model_patcher.ModelPatcher):
return
weight = comfy.utils.get_attr(self.model, key)
try:
from comfy.lora import calculate_weight
except Exception:
calculate_weight = self.calculate_weight
patches = self.patches[key]
if is_quantized(weight):
out_weight = weight.to(device_to)
patches = move_patch_to_device(patches, self.load_device if self.patch_on_device else self.offload_device)
# TODO: do we ever have legitimate duplicate patches? (i.e. patch on top of patched weight)
out_weight.patches = [(calculate_weight, patches, key)]
out_weight.patches = [(patches, key)]
else:
inplace_update = self.weight_inplace_update or inplace_update
if key not in self.backup:
@@ -60,7 +57,7 @@ class GGUFModelPatcher(comfy.model_patcher.ModelPatcher):
else:
temp_weight = weight.to(torch.float32, copy=True)
out_weight = calculate_weight(patches, temp_weight, key)
out_weight = comfy.lora.calculate_weight(patches, temp_weight, key)
out_weight = comfy.float.stochastic_rounding(out_weight, weight.dtype)
if inplace_update:
+5 -4
View File
@@ -4,6 +4,7 @@ import torch
import logging
import comfy.ops
import comfy.lora
import comfy.model_management
from .dequant import dequantize_tensor, is_quantized
@@ -169,7 +170,7 @@ class GGMLLayer(torch.nn.Module):
# consolidate and load patches to GPU in async
patch_list = []
device = tensor.device
for function, patches, key in getattr(tensor, "patches", []):
for patches, key in getattr(tensor, "patches", []):
patch_list += move_patch_to_device(patches, device)
# dequantize tensor while patches load
@@ -180,13 +181,13 @@ class GGMLLayer(torch.nn.Module):
weight = torch.Tensor(weight)
# apply patches
if patch_list:
if len(patch_list) > 0:
if self.patch_dtype is None:
weight = function(patch_list, weight, key)
weight = comfy.lora.calculate_weight(patch_list, weight, key)
else:
# for testing, may degrade image quality
patch_dtype = dtype if self.patch_dtype == "target" else self.patch_dtype
weight = function(patch_list, weight, key, patch_dtype)
weight = comfy.lora.calculate_weight(patch_list, weight, key, patch_dtype)
return weight
@torch_compiler_disable()