From b46c206dd71eee9318a5f13b51b6f6c23c556d8e Mon Sep 17 00:00:00 2001 From: City <125218114+city96@users.noreply.github.com> Date: Thu, 5 Sep 2024 05:32:01 +0200 Subject: [PATCH] double patch issue fix for lowvram Potential fix, lowvram weights are called via `patch_weight_to_device` on each run and it was possible to apply the same patch multiple times on subsequent generations. --- nodes.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nodes.py b/nodes.py index 52e3e92..534c1ba 100644 --- a/nodes.py +++ b/nodes.py @@ -147,7 +147,9 @@ 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) - out_weight.patches.append((calculate_weight, patches, key)) + patch = (calculate_weight, patches, key) + if patch not in out_weight.patches: + out_weight.patches.append(patch) else: inplace_update = self.weight_inplace_update or inplace_update if key not in self.backup: