From 0f11d60afb75ec7fdea78aa418d7e8aaf8609d6d Mon Sep 17 00:00:00 2001 From: Andrew Kvochko Date: Wed, 1 Jan 2025 21:29:01 +0000 Subject: [PATCH] Fix temporal tiling for decoder, remove redundant tiles. (#6306) This commit fixes the temporal tile size calculation, and removes a redundant tile at the end of the range when its elements are completely covered by the previous tile. Co-authored-by: Andrew Kvochko --- comfy/utils.py | 2 +- nodes.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/comfy/utils.py b/comfy/utils.py index 8e64dbe0b04..ea666ae5b46 100644 --- a/comfy/utils.py +++ b/comfy/utils.py @@ -893,7 +893,7 @@ def mult_list_upscale(a): out = torch.zeros([s.shape[0], out_channels] + mult_list_upscale(s.shape[2:]), device=output_device) out_div = torch.zeros([s.shape[0], out_channels] + mult_list_upscale(s.shape[2:]), device=output_device) - positions = [range(0, s.shape[d+2], tile[d] - overlap[d]) if s.shape[d+2] > tile[d] else [0] for d in range(dims)] + positions = [range(0, s.shape[d+2] - overlap[d], tile[d] - overlap[d]) if s.shape[d+2] > tile[d] else [0] for d in range(dims)] for it in itertools.product(*positions): s_in = s diff --git a/nodes.py b/nodes.py index 45686fc7961..7f9f5aa5f87 100644 --- a/nodes.py +++ b/nodes.py @@ -309,7 +309,7 @@ def decode(self, vae, samples, tile_size, overlap=64, temporal_size=64, temporal temporal_compression = vae.temporal_compression_decode() if temporal_compression is not None: temporal_size = max(2, temporal_size // temporal_compression) - temporal_overlap = min(1, temporal_size // 2, temporal_overlap // temporal_compression) + temporal_overlap = max(1, min(temporal_size // 2, temporal_overlap // temporal_compression)) else: temporal_size = None temporal_overlap = None