From 977f4a5c3a4cf838c4314baf05dd47c6ec2af615 Mon Sep 17 00:00:00 2001 From: kijai <40791699+kijai@users.noreply.github.com> Date: Tue, 4 Nov 2025 11:31:08 +0200 Subject: [PATCH] Update model.py --- wanvideo/modules/model.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/wanvideo/modules/model.py b/wanvideo/modules/model.py index 80a5699..765509d 100644 --- a/wanvideo/modules/model.py +++ b/wanvideo/modules/model.py @@ -1338,7 +1338,6 @@ class WanAttentionBlock(nn.Module): x_mot_ref = x_mot_ref.to(input_dtype) # MultiTalk if multitalk_audio_embedding is not None and not isinstance(self, VaceWanAttentionBlock): - x_audio = self.audio_cross_attn(self.norm_x(x.to(self.norm_x.weight.dtype)).to(input_dtype), encoder_hidden_states=multitalk_audio_embedding, x_audio = self.audio_cross_attn(self.norm_x(x.to(self.norm_x.weight.dtype)).to(input_dtype), encoder_hidden_states=multitalk_audio_embedding, shape=grid_sizes[0], x_ref_attn_map=x_ref_attn_map, human_num=human_num) x = x.add(x_audio, alpha=audio_scale) @@ -2664,13 +2663,20 @@ class WanModel(torch.nn.Module): e = e.to(self.offload_device, non_blocking=self.use_non_blocking) # clip vision embedding - clip_embed = None + clip_embed = clip_embed_mot_ref = None if clip_fea is not None and hasattr(self, "img_emb"): clip_fea = clip_fea.to(self.main_device) if self.offload_img_emb: self.img_emb.to(self.main_device) clip_embed = self.img_emb(clip_fea) # bs x 257 x dim - #context = torch.concat([context_clip, context], dim=1) + if self.offload_img_emb: + self.img_emb.to(self.offload_device, non_blocking=self.use_non_blocking) + + if mot_ref_clip_embeds is not None: + mot_ref_clip_embeds = mot_ref_clip_embeds.to(self.main_device) + if self.offload_img_emb: + self.img_emb.to(self.main_device) + clip_embed_mot_ref = self.img_emb_mot_ref(mot_ref_clip_embeds) # bs x 257 x dim if self.offload_img_emb: self.img_emb.to(self.offload_device, non_blocking=self.use_non_blocking)