Nodes/ComfyUI-VideoHelperSuite/VAE Encode Batched πŸŽ₯πŸ…₯πŸ…—πŸ…’
ComfyUI Node Runs on cloud

VAE Encode Batched πŸŽ₯πŸ…₯πŸ…—πŸ…’

Encode images to latents in controlled batch sizes

By KosinkadinkΒ·Created 3 years agoΒ·Updated 3 months agoΒ· 1,727
VAE Encode Batched πŸŽ₯πŸ…₯πŸ…—πŸ…’
  • pixels
  • vae
  • LATENT
β—„per_batch16β–Ί

This is a targeted fix for one specific problem: VRAM spikes when you VAE-encode a big pile of images at once. The native VAE Encode tries to process the whole batch in one shot, and on a long video that can OOM your GPU. VAE Encode Batched does the same encode but lets you cap how many images go through the VAE at a time, trading a little speed for staying under your VRAM ceiling. It's one of the "batched nodes" in Kosinkadink's VideoHelperSuite.

Be honest with yourself about whether you need it. The node's own docs say it plainly: unless you've actually hit VRAM issues encoding or decoding large batches, it's simpler to use the native VAE Encode or to encode directly from a Load Video node (by handing that loader a VAE). This is a workaround, not a default. Reach for it when you see out-of-memory errors on the encode step, not before.

How it works

Instead of encoding all your images in a single forward pass through the VAE, it slices them into chunks of per_batch and encodes each chunk, then assembles the results into one latent batch. The peak VRAM is set by the chunk size, not the total frame count - so a 500-frame sequence encodes at the memory cost of per_batch frames.

The inputs and outputs that matter

  • pixels - the images to encode.
  • vae - the VAE to encode with (same one you'd use anywhere else).
  • per_batch (default 16) - the max images per encode chunk. This is the dial: lower it if you're still OOMing, raise it (toward the native behavior) if you have VRAM to spare and want speed.

The single output is LATENT, ready for a sampler or any latent-space node.

How to install it

ComfyUI Manager: search ComfyUI-VideoHelperSuite, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite

then restart. No model downloads (you supply the VAE like any other workflow).

Common issues & troubleshooting

Still running out of VRAM. Drop per_batch further - 8, 4, even 1. Smaller chunks, lower peak memory. If it OOMs at per_batch of 1, the problem is elsewhere (resolution, another node holding VRAM), not the encode.

It's slower than plain VAE Encode. Expected. More, smaller passes have more overhead. That's the trade you're making to fit in memory - if you're not memory-constrained, use the native encode instead.

Do I even need this? If you loaded your video with a VAE already attached to the Load Video node, your frames are latents from the start and you don't need a separate encode at all. This node is specifically for the case where you have images in hand and the one-shot encode won't fit.

CategoryVideo Helper Suite πŸŽ₯πŸ…₯πŸ…—πŸ…’/batched nodes

Inputs (3)

NameTypeDefaultDescription
pixelsIMAGEβ€”
vaeVAEβ€”
per_batchINT16β€”

Outputs (1)

NameTypeDescription
LATENTLATENTβ€”