Nodes/ComfyUI-nodes-hnmr/VAEEncodeBatched
ComfyUI Node

VAEEncodeBatched

Chunk your image batch through the VAE

By CYBERLOOM-INC·Created 3 years ago·Updated 2 years ago· 11
VAEEncodeBatched
  • pixels
  • vae
  • LATENT
batch_size1

If you've ever fed a big batch of images into ComfyUI's built-in VAE Encode and watched it die with an out-of-memory error, VAEEncodeBatched is the fix. It does the same job - IMAGE in, LATENT out - but it encodes the batch in slices of a size you choose, so your GPU never has to hold the whole batch in memory at once.

The inputs are pixels (your IMAGE), vae, and batch_size, a simple INT from 1 to 32 that defaults to 1. Set it to something like 4 or 8 and the node loops through the images in chunks, encoding each slice and concatenating the resulting latents back into one tensor. The output LATENT wires straight into a KSampler's latent input or an image-to-image workflow, just like the built-in node.

Two small bits of behavior worth knowing. It silently crops images to a multiple of 64 in each dimension - that's a necessary step because the VAE's latent is 1/8 the resolution, and non-multiple sizes would produce ragged latents. It also drops the alpha channel, keeping only RGB. Fine for almost everything; just don't expect an RGBA pass-through.

This is one of the pack's quiet utility gems, and it earns its keep the moment you start generating batches (which is exactly what the pack's own KSamplerXYZ encourages - a 60-image grid sweep). It also plays nice with VAEIter: if you're comparing VAEs on the same images, the encode path routes through the iterated VAE list.

Install through ComfyUI Manager - search "ComfyUI-nodes-hnmr" - or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/CYBERLOOM-INC/ComfyUI-nodes-hnmr

Restart ComfyUI. There are no model files to grab and no requirements.txt - everything it needs is already in ComfyUI's environment.

Troubleshooting is mostly about expectations. A batch_size of 1 is the most memory-frugal but slowest, and for typical single images it's pointless overhead over the built-in node - you want this when a batch is involved. If you're still OOMing at batch 1 on a very high-resolution image, the bottleneck is a single image's latent, not the batch, and chunking won't save you. And because this is the maintained fork of the pack, remember the usual rule: if a workflow references these nodes but ComfyUI can't find them, install this repo, not the abandoned original.

Categorylatent

Inputs (3)

NameTypeDefaultDescription
pixelsIMAGE
vaeVAE
batch_sizeINT11–32

Outputs (1)

NameTypeDescription
LATENTLATENT