never double patch

#98
Instead of adding/removing patches, sync with `self.patches[key]` - old patch should be GC'd. Most likely no legitimate reasons for double patching. Can simplify logic in ops.py if no issues.
This commit is contained in:
City
2024-09-06 18:10:02 +02:00
parent b46c206dd7
commit 0342f0a183
+2 -3
View File
@@ -147,9 +147,8 @@ class GGUFModelPatcher(comfy.model_patcher.ModelPatcher):
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)
patch = (calculate_weight, patches, key)
if patch not in out_weight.patches:
out_weight.patches.append(patch)
# TODO: do we ever have legitimate duplicate patches? (i.e. patch on top of patched weight)
out_weight.patches = [(calculate_weight, patches, key)]
else:
inplace_update = self.weight_inplace_update or inplace_update
if key not in self.backup: