From 26d89c0133f90e5fb3a28dfec2bd7f0501617eaf Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Tue, 11 Nov 2025 16:15:47 -0500 Subject: [PATCH] safe load non-sparse controlnet Signed-off-by: Vladimir Mandic --- CHANGELOG.md | 1 + modules/control/units/controlnet.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65317c33e..ecccaf1de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ TBD - detailer: using lora in detailer prompt - detailer: fail on unsupported models instead of corrputing results - ui: fix collapsible panels + - control: safe load non-sparse controlnet ## Update for 2025-11-06 diff --git a/modules/control/units/controlnet.py b/modules/control/units/controlnet.py index 0108cbfa4..571491987 100644 --- a/modules/control/units/controlnet.py +++ b/modules/control/units/controlnet.py @@ -353,7 +353,12 @@ class ControlNet(): if self.dtype is not None: self.model.to(self.dtype) if self.device is not None: - self.model.to_empty(device=self.device) # model could be sparse + if (opts.diffusers_offload_mode != 'balanced') and hasattr(self.model, 'to'): + try: + self.model.to(self.device) + except Exception as e: + if 'Cannot copy out of meta tensor' in str(e): + self.model.to_empty(device=self.device) if "Control" in opts.sdnq_quantize_weights: try: log.debug(f'Control {what} model SDNQ quantize: id="{model_id}"')