From 98ca6030f36eee897a3cea1c958837e7d9385acb Mon Sep 17 00:00:00 2001 From: Rattus Date: Sat, 27 Sep 2025 21:38:40 +1000 Subject: [PATCH] wan: Delete the self attention before cross attention This saves VRAM when the cross attention and FFN are in play as the VRAM peak. --- comfy/ldm/wan/model.py | 1 + 1 file changed, 1 insertion(+) diff --git a/comfy/ldm/wan/model.py b/comfy/ldm/wan/model.py index 2dac5980c..54f61a807 100644 --- a/comfy/ldm/wan/model.py +++ b/comfy/ldm/wan/model.py @@ -237,6 +237,7 @@ class WanAttentionBlock(nn.Module): freqs, transformer_options=transformer_options) x = torch.addcmul(x, y, repeat_e(e[2], x)) + del y # cross-attention & ffn x = x + self.cross_attn(self.norm3(x), context, context_img_len=context_img_len, transformer_options=transformer_options)