Skip to content

Commit 1b3cb5f

Browse files
authored
Merge PR #163 from Kosinkadink/develop - SparseCtrl lowvram fix for newest ComfyUI
Make SparseCtrl work with newest ComfyUI updates
2 parents 85d4970 + d98cd8d commit 1b3cb5f

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

adv_control/control_sparsectrl.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,13 @@ def __init__(self, *args, **kwargs):
114114
self.model: SparseControlNet
115115
super().__init__(*args, **kwargs)
116116

117-
def patch_model_lowvram(self, device_to=None, *args, **kwargs):
118-
patched_model = super().patch_model_lowvram(device_to, *args, **kwargs)
117+
def load(self, device_to=None, lowvram_model_memory=0, *args, **kwargs):
118+
to_return = super().load(device_to=device_to, lowvram_model_memory=lowvram_model_memory, *args, **kwargs)
119+
if lowvram_model_memory > 0:
120+
self._patch_lowvram_extras(device_to=device_to)
121+
return to_return
119122

123+
def _patch_lowvram_extras(self, device_to=None):
120124
if self.model.motion_wrapper is not None:
121125
# figure out the tensors (likely pe's) that should be cast to device besides just the named_modules
122126
remaining_tensors = list(self.model.motion_wrapper.state_dict().keys())
@@ -134,6 +138,10 @@ def patch_model_lowvram(self, device_to=None, *args, **kwargs):
134138
if device_to is not None:
135139
comfy.utils.set_attr(self.model.motion_wrapper, key, comfy.utils.get_attr(self.model.motion_wrapper, key).to(device_to))
136140

141+
# NOTE: no longer called by ComfyUI, but here for backwards compatibility
142+
def patch_model_lowvram(self, device_to=None, *args, **kwargs):
143+
patched_model = super().patch_model_lowvram(device_to, *args, **kwargs)
144+
self._patch_lowvram_extras(device_to=device_to)
137145
return patched_model
138146

139147
def clone(self):

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "comfyui-advanced-controlnet"
33
description = "Nodes for scheduling ControlNet strength across timesteps and batched latents, as well as applying custom weights and attention masks."
4-
version = "1.2.0"
4+
version = "1.2.1"
55
license = { file = "LICENSE" }
66
dependencies = []
77

0 commit comments

Comments
 (0)