From ea9d6fab23fd9445b71b92cb4025e8ed3bd0ecd5 Mon Sep 17 00:00:00 2001 From: Rattus Date: Fri, 23 Jan 2026 12:10:44 +1000 Subject: [PATCH] wan-vae: implement zero pad fast path The WAN VAE is also QWEN where it is used single-image. These convolutions are however zero padded 3d convolutions, which means the VAE is actually just 2D down the last element of the conv weight in the temporal dimension. Fast path this, to avoid adding zeros that then just evaporate in convoluton math but cost computation. --- comfy/ldm/wan/vae.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/comfy/ldm/wan/vae.py b/comfy/ldm/wan/vae.py index 812725412..40e767213 100644 --- a/comfy/ldm/wan/vae.py +++ b/comfy/ldm/wan/vae.py @@ -28,6 +28,11 @@ class CausalConv3d(ops.Conv3d): cache_x = cache_list[cache_idx] cache_list[cache_idx] = None + if cache_x is None and x.shape[2] == 1: + #Fast path - the op will pad for use by truncating the weight + #and save math on a pile of zeros. + return super().forward(x, autopad="causal_zero") + if self._padding > 0: padding_needed = self._padding if cache_x is not None: