From 5a8f8730bd768e878d7b2ade4c8d022fbf238c8e Mon Sep 17 00:00:00 2001 From: kijai <40791699+kijai@users.noreply.github.com> Date: Tue, 19 Aug 2025 13:31:56 +0300 Subject: [PATCH 1/2] Fix for using additional scaled model and merging loras --- utils.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/utils.py b/utils.py index 95430f7..d824fec 100644 --- a/utils.py +++ b/utils.py @@ -208,6 +208,17 @@ def apply_lora(model, device_to, transformer_load_device, params_to_keep=None, d continue m.comfy_patched_weights = True pbar.update(1) + + # After LoRA patching, scale weights that have scale_weight but are NOT LoRA patched + if len(scale_weights) > 0: + for name, param in model.model.diffusion_model.named_parameters(): + scale_key = name.replace("weight", "scale_weight").replace("diffusion_model.", "") if "weight" in name else None + full_param_name = f"diffusion_model.{name}" + if scale_key and scale_key in scale_weights and full_param_name not in model.patches: + scale = scale_weights[scale_key] + param_fp32 = param.to(torch.float32) + param_fp32.mul_(scale.to(param.device, torch.float32)) + param.copy_(param_fp32.to(param.dtype)) model.current_weight_patches_uuid = model.patches_uuid if low_mem_load: From 4f9ef5b7a96729545ffb828b16e01b954c20c597 Mon Sep 17 00:00:00 2001 From: kijai <40791699+kijai@users.noreply.github.com> Date: Tue, 19 Aug 2025 13:34:56 +0300 Subject: [PATCH 2/2] Update nodes.py --- nodes.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nodes.py b/nodes.py index 7a65367..2cd0dad 100644 --- a/nodes.py +++ b/nodes.py @@ -3005,6 +3005,8 @@ class WanVideoSampler: frame_num = clip_length = image_embeds.get("num_frames", 81) vae = image_embeds.get("vae", None) clip_embeds = image_embeds.get("clip_context", None) + if clip_embeds is not None: + clip_embeds = clip_embeds.to(dtype) colormatch = image_embeds.get("colormatch", "disabled") motion_frame = image_embeds.get("motion_frame", 25) target_w = image_embeds.get("target_w", None) @@ -3196,7 +3198,7 @@ class WanVideoSampler: cfg[idx], text_embeds["prompt_embeds"], text_embeds["negative_prompt_embeds"], - timestep, idx, y.squeeze(0), clip_embeds.to(dtype), control_latents, vace_data, unianim_data, audio_proj, control_camera_latents, add_cond, + timestep, idx, y.squeeze(0), clip_embeds, control_latents, vace_data, unianim_data, audio_proj, control_camera_latents, add_cond, cache_state=self.cache_state, multitalk_audio_embeds=audio_embs) if callback is not None: