Nodes/ComfyUI-nodes-hnmr/VAEDecodeBatched
ComfyUI Node

VAEDecodeBatched

Decode a whole latent batch without blowing up your VRAM

By CYBERLOOM-INC·Created 3 years ago·Updated 2 years ago· 11
VAEDecodeBatched
  • samples
  • vae
  • IMAGE
batch_size1

VAEDecodeBatched is the decode-side twin of VAEEncodeBatched, and it's the node you'll reach for constantly if you use this pack's KSamplerXYZ. An XYZ sweep can return a batch of 30, 60, or 100 latents at once, and trying to decode all of them in a single VAE Decode call is a fast way to run out of VRAM. This node slices the batch into chunks you control, decodes each chunk, and stitches the images back together.

Inputs are samples (LATENT), vae, and batch_size (an INT from 1 to 32, default 1). Set batch_size to 4 or 8 - whatever your GPU can chew through comfortably - and the loop decodes that many latents per step. Output is a single IMAGE tensor, which you can then hand to SaveImage, PreviewImage, or GridImage to arrange the results.

There's a second trick hiding in here that makes it more than a memory helper. It works with VAEIter-iterated VAEs: when the VAE connected to this node carries an iterated list (built with VAEIter), the decoder runs each chunk through all the VAEs in the list and splits the results per VAE. That's how you decode one batch of latents with two different VAEs side by side for comparison, in a single pass.

Mechanically it's a straightforward chunked loop over vae.decode() with torch.cat at the end - no magic, which is exactly what you want from a node whose only job is "don't OOM."

Install via ComfyUI Manager (search "ComfyUI-nodes-hnmr") or:

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

Restart ComfyUI. No downloads, no extra dependencies - it runs on ComfyUI's own torch/tqdm stack.

Practical notes. Start with batch_size 1 to see if the whole batch even fits chunked; then raise it until you're near your memory ceiling but not past it. On a single image it's pointless overhead - use the plain VAE Decode. The other gotcha is ordering: because decoding happens in chunks, a crash mid-decode loses the whole batch's output, so if you're doing a huge sweep it's worth decoding in smaller pieces yourself anyway. And the usual fork rule applies: this is the maintained fork of hnmr293's pack, so install CYBERLOOM-INC/ComfyUI-nodes-hnmr, not the abandoned original.

Categorylatent

Inputs (3)

NameTypeDefaultDescription
samplesLATENT
vaeVAE
batch_sizeINT11–32

Outputs (1)

NameTypeDescription
IMAGEIMAGE