Skip to content

Commit 6516ab3

Browse files
authored
wan-vae: Switch off feature cache for single frame (#12090)
The code throughout is None safe to just skip the feature cache saving step if none. Set it none in single frame use so qwen doesn't burn VRAM on the unused cache.
1 parent ad53e78 commit 6516ab3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

comfy/ldm/wan/vae.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,12 @@ def __init__(self,
479479

480480
def encode(self, x):
481481
conv_idx = [0]
482-
feat_map = [None] * count_conv3d(self.decoder)
483482
## cache
484483
t = x.shape[2]
485484
iter_ = 1 + (t - 1) // 4
485+
feat_map = None
486+
if iter_ > 1:
487+
feat_map = [None] * count_conv3d(self.decoder)
486488
## 对encode输入的x,按时间拆分为1、4、4、4....
487489
for i in range(iter_):
488490
conv_idx = [0]
@@ -502,10 +504,11 @@ def encode(self, x):
502504

503505
def decode(self, z):
504506
conv_idx = [0]
505-
feat_map = [None] * count_conv3d(self.decoder)
506507
# z: [b,c,t,h,w]
507-
508508
iter_ = z.shape[2]
509+
feat_map = None
510+
if iter_ > 1:
511+
feat_map = [None] * count_conv3d(self.decoder)
509512
x = self.conv2(z)
510513
for i in range(iter_):
511514
conv_idx = [0]

0 commit comments

Comments
 (0)