From dd7e29e5c2e9c8630b00e5199bfa378e7b27bdc4 Mon Sep 17 00:00:00 2001 From: Jedrzej Kosinski Date: Tue, 20 Aug 2024 05:09:30 -0500 Subject: [PATCH 1/2] Make SparseCtrl work with new ComfyUI ModelPatcher updates --- adv_control/control_sparsectrl.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/adv_control/control_sparsectrl.py b/adv_control/control_sparsectrl.py index 1a1163f..1267942 100644 --- a/adv_control/control_sparsectrl.py +++ b/adv_control/control_sparsectrl.py @@ -114,9 +114,13 @@ def __init__(self, *args, **kwargs): self.model: SparseControlNet super().__init__(*args, **kwargs) - def patch_model_lowvram(self, device_to=None, *args, **kwargs): - patched_model = super().patch_model_lowvram(device_to, *args, **kwargs) + def load(self, device_to=None, lowvram_model_memory=0, *args, **kwargs): + to_return = super().load(device_to=device_to, lowvram_model_memory=lowvram_model_memory, *args, **kwargs) + if lowvram_model_memory > 0: + self._patch_lowvram_extras(device_to=device_to) + return to_return + def _patch_lowvram_extras(self, device_to=None): if self.model.motion_wrapper is not None: # figure out the tensors (likely pe's) that should be cast to device besides just the named_modules remaining_tensors = list(self.model.motion_wrapper.state_dict().keys()) @@ -134,6 +138,10 @@ def patch_model_lowvram(self, device_to=None, *args, **kwargs): if device_to is not None: comfy.utils.set_attr(self.model.motion_wrapper, key, comfy.utils.get_attr(self.model.motion_wrapper, key).to(device_to)) + # NOTE: no longer called by ComfyUI, but here for backwards compatibility + def patch_model_lowvram(self, device_to=None, *args, **kwargs): + patched_model = super().patch_model_lowvram(device_to, *args, **kwargs) + self._patch_lowvram_extras(device_to=device_to) return patched_model def clone(self): From d98cd8d38f7a74d5b5f9f8280538775e831a4367 Mon Sep 17 00:00:00 2001 From: Jedrzej Kosinski Date: Tue, 20 Aug 2024 05:11:22 -0500 Subject: [PATCH 2/2] version bump --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c9dfe25..9d1085a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-advanced-controlnet" description = "Nodes for scheduling ControlNet strength across timesteps and batched latents, as well as applying custom weights and attention masks." -version = "1.2.0" +version = "1.2.1" license = { file = "LICENSE" } dependencies = []