From 71b536c47f9ff3e184fc6b6b54dc207f27f99f5a Mon Sep 17 00:00:00 2001 From: Jedrzej Kosinski Date: Thu, 4 Jun 2026 14:26:17 -0700 Subject: [PATCH] Fix dtype mismatch for SparseCtrl and SVD-ControlNet models load_sparsectrl and load_svdcontrolnet never set controlnet_config["dtype"], so the control model was built with dtype=None (float32) while the UNet runs in fp16. This caused "mat1 and mat2 must have the same dtype, but got Half and Float" at sampling time (notably for .pth/.ckpt SparseCtrl models). Set controlnet_config["dtype"] = unet_dtype before building the model, matching the existing ControlNet++ and CtrLoRA loaders and ComfyUI's own controlnet loader. Fixes #574 Amp-Thread-ID: https://ampcode.com/threads/T-019e947a-9fd3-76df-a847-5eb68d7f18de Co-authored-by: Amp --- adv_control/control.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/adv_control/control.py b/adv_control/control.py index eb71b0f..9ddb701 100644 --- a/adv_control/control.py +++ b/adv_control/control.py @@ -811,6 +811,7 @@ def load_sparsectrl(ckpt_path: str, controlnet_data: dict[str, Tensor]=None, tim controlnet_config["operations"] = manual_cast_clean_groupnorm else: controlnet_config["operations"] = disable_weight_init_clean_groupnorm + controlnet_config["dtype"] = unet_dtype controlnet_config.pop("out_channels") # get proper hint channels if use_simplified_conditioning_embedding: @@ -944,6 +945,7 @@ def load_svdcontrolnet(ckpt_path: str, controlnet_data: dict[str, Tensor]=None, manual_cast_dtype = comfy.model_management.unet_manual_cast(unet_dtype, load_device) if manual_cast_dtype is not None: controlnet_config["operations"] = comfy.ops.manual_cast + controlnet_config["dtype"] = unet_dtype controlnet_config.pop("out_channels") controlnet_config["hint_channels"] = controlnet_data["{}input_hint_block.0.weight".format(prefix)].shape[1] control_model = SVDControlNet(**controlnet_config)