Skip to content

Add ImageBatchListCombineWithOverlap - new Node to allow for more RAM efficient Video Generation - #691

Open
Nihongasuki wants to merge 1 commit into
kijai:mainfrom
Nihongasuki:image-batch-list
Open

Add ImageBatchListCombineWithOverlap - new Node to allow for more RAM efficient Video Generation#691
Nihongasuki wants to merge 1 commit into
kijai:mainfrom
Nihongasuki:image-batch-list

Conversation

@Nihongasuki

Copy link
Copy Markdown

Problem

When generating videos in multiple sampler steps (e.g. WAN SVI workflows), each step generates a rather large image tensor. With each application of the Image Batch Extend With Overlap Node, this image tensor needs to be cached as port of that nodes outputs. This causes unneccesary RAM bloat and can lead to cache busting if enough steps are performed.

For example in this case, the image tensor from the first step is copied 3 times (and thus uses 3 times as much RAM as is required.
image

This is especially problematic since the increase is not linear - each added step adds the weight of itself + all previous steps to RAM.

Fix

Introduce a new Node, that takes a list of image batches instead of only two at a time. I chose a list input over dynamic inputs because this allows cleaner workflows or workflows with dynamic generation steps (the workflow I am building uses Loop Nodes to theoretically extend the video forever). Also, it is pretty easy to create a list from a fixed number of Inputs.

For example here, the image tensor is only copied once. Rebatch Latents creates a list of batches with one latent each (one WAN latent = x frames). This is turned into a list of image batches of size x by VAE Decode, and this list is then combined in a single step via the new node.
image

This setup still copies Latents more then required, but since those are way smaller the impact is negligable. A complete solution would be a Node that also included the VAE Decode step, however that was too complicated and specialized for my tastes.

The code in the Node is basically identical to the existing Node, it just loops within the node and not within the workflow. In fact, the actual execution code could easily be shared between the two nodes, however I was unsure if you want your nodes to always be completely independent from each other.

In my workflow, this Node reduces RAM usage for 4 WAN 2.2 segments of 81 frames @ 0.7 MP each from multiple GB to under 1. (After models are unloaded)

@Viper442

Viper442 commented Jul 5, 2026

Copy link
Copy Markdown

I have run into this memory issue as well with SVI in a loop with the ImageBatchExtendWithOverlap node. The memory bloat increases every iteration non-linearly and gets out of hand fast. Was not sure what was causing it inside the node. Hope this fixes it.

@altoiddealer altoiddealer mentioned this pull request Jul 24, 2026
@altoiddealer

Copy link
Copy Markdown

I've implemented a more robust version of this in my little repo, which does the same except there is another node which can also merge audio at the same time - compatible with all the existing blending methods.

https://github.com/altoiddealer/comfyui_essential-er

Screenshot 2026-08-08 232456

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants