From 2c01c141b38ee7dea231a00ee2a34900b07cd6d1 Mon Sep 17 00:00:00 2001 From: drozbay <17261091+drozbay@users.noreply.github.com> Date: Fri, 3 Jul 2026 20:30:52 -0600 Subject: [PATCH] Remove unused grid_sizes assignment in CameraWanModel, WanModel_S2V, HumoWanModel, and AnimateWanModel; simplify patch size initialization in WanUni3CControlnet; refine sigmas check in WanUni3CCnetPatch. --- comfy/ldm/wan/model.py | 3 --- comfy/ldm/wan/model_animate.py | 1 - comfy/ldm/wan/uni3c.py | 14 ++------------ comfy_extras/nodes_model_patch.py | 2 +- 4 files changed, 3 insertions(+), 17 deletions(-) diff --git a/comfy/ldm/wan/model.py b/comfy/ldm/wan/model.py index d90600c81..b7ec6f7d2 100644 --- a/comfy/ldm/wan/model.py +++ b/comfy/ldm/wan/model.py @@ -908,7 +908,6 @@ class CameraWanModel(WanModel): if self.control_adapter is not None and camera_conditions is not None: x = x + self.control_adapter(camera_conditions).to(x.dtype) grid_sizes = x.shape[2:] - transformer_options["grid_sizes"] = grid_sizes x = x.flatten(2).transpose(1, 2) # time embeddings @@ -1368,7 +1367,6 @@ class WanModel_S2V(WanModel): t = t.unsqueeze(1).repeat(1, x.shape[2]) grid_sizes = x.shape[2:] - transformer_options["grid_sizes"] = grid_sizes x = x.flatten(2).transpose(1, 2) seq_len = x.size(1) @@ -1635,7 +1633,6 @@ class HumoWanModel(WanModel): x_input = x x = self.patch_embedding(x.float()).to(x.dtype) grid_sizes = x.shape[2:] - transformer_options["grid_sizes"] = grid_sizes x = x.flatten(2).transpose(1, 2) # time embeddings diff --git a/comfy/ldm/wan/model_animate.py b/comfy/ldm/wan/model_animate.py index 411f2ab17..9ebe5694b 100644 --- a/comfy/ldm/wan/model_animate.py +++ b/comfy/ldm/wan/model_animate.py @@ -497,7 +497,6 @@ class AnimateWanModel(WanModel): x = self.patch_embedding(x.float()).to(x.dtype) x, motion_vec = self.after_patch_embedding(x, pose_latents, face_pixel_values) grid_sizes = x.shape[2:] - transformer_options["grid_sizes"] = grid_sizes x = x.flatten(2).transpose(1, 2) # time embeddings diff --git a/comfy/ldm/wan/uni3c.py b/comfy/ldm/wan/uni3c.py index b42c212d3..850cb1b39 100644 --- a/comfy/ldm/wan/uni3c.py +++ b/comfy/ldm/wan/uni3c.py @@ -97,13 +97,11 @@ class WanUni3CControlnet(nn.Module): device=None, dtype=None, operations=None ): super().__init__() - self.dtype = dtype - self.patch_size = (1, 2, 2) - self.in_channels = in_channels + patch_size = (1, 2, 2) self.num_layers = num_layers self.controlnet_patch_embedding = operations.Conv3d( - in_channels, conv_out_dim, kernel_size=self.patch_size, stride=self.patch_size, device=device, dtype=torch.float32) + in_channels, conv_out_dim, kernel_size=patch_size, stride=patch_size, device=device, dtype=torch.float32) self.controlnet_mask_embedding = MaskCamEmbed(add_channels, mid_channels, conv_out_dim, device=device, dtype=dtype, operations=operations) if conv_out_dim != dim: @@ -152,11 +150,3 @@ class WanUni3CControlnet(nn.Module): hidden = self.controlnet_blocks[block_index](hidden, temb, freqs, transformer_options=transformer_options) residual = self.proj_out[block_index](hidden) return hidden, residual - - def forward(self, control_input, temb, render_mask=None, camera_embedding=None, transformer_options={}): - hidden, freqs = self.process_input(control_input, render_mask=render_mask, camera_embedding=camera_embedding) - controlnet_states = [] - for i in range(self.num_layers): - hidden, residual = self.forward_block(i, hidden, temb, freqs, transformer_options=transformer_options) - controlnet_states.append(residual) - return controlnet_states diff --git a/comfy_extras/nodes_model_patch.py b/comfy_extras/nodes_model_patch.py index 5b55b1ffd..575cb3377 100644 --- a/comfy_extras/nodes_model_patch.py +++ b/comfy_extras/nodes_model_patch.py @@ -572,7 +572,7 @@ class WanUni3CCnetPatch: self.temp_data = None active = True sigmas = transformer_options.get("sigmas", None) - if sigmas is not None and sigmas.numel() > 0: + if sigmas is not None: sigma = sigmas[0].item() if sigma > self.sigma_start or sigma < self.sigma_end: active = False