From 9ce912099e16be32b9b82a861aa1d1820bae3ddf Mon Sep 17 00:00:00 2001 From: "Ivan R." Date: Tue, 5 Aug 2025 04:48:13 +0500 Subject: [PATCH] Fix Flux Kontext ReferenceLatent and ControlNet shape mismatch --- comfy/ldm/flux/model.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/comfy/ldm/flux/model.py b/comfy/ldm/flux/model.py index 8f4d99f548f3..c09594862c98 100644 --- a/comfy/ldm/flux/model.py +++ b/comfy/ldm/flux/model.py @@ -157,6 +157,11 @@ def block_wrap(args): if i < len(control_i): add = control_i[i] if add is not None: + if img.shape[1] != add.shape[1]: + padding_size = img.shape[1] - add.shape[1] + if padding_size > 0: + padding = torch.zeros(add.shape[0], padding_size, add.shape[2], device=add.device, dtype=add.dtype) + add = torch.cat([add, padding], dim=1) img += add if img.dtype == torch.float16: