Nodes/ComfyUI-ChunkedSampling/VAE Decode Batch Chunked
ComfyUI Node

VAE Decode Batch Chunked

Decode a whole latent batch without the VRAM cliff

By xmarre·Created 5 months ago·Updated 5 months ago· 0
VAE Decode Batch Chunked
  • samples
  • vae
  • images
chunk_size8
clear_cache_between_chunksfalse

This is the "cleanup" half of the batch-chunking story. VAE Decode Batch Chunked is the stock VAEDecode node, but it decodes a latent batch in slices and stitches the frames back together, so a big batch doesn't all hit the decoder at once and blow your VRAM.

If your sampler produced a stack of latents, the stock VAEDecode will happily try to decode the entire thing in one call. That's fine for one image and dicey for a few dozen. This node splits the work: decode chunk_size latents at a time (default 8), concatenate the resulting images, hand you one clean IMAGE batch.

Inputs and output

Three inputs, and you already know two of them:

  • samples (LATENT) - what comes out of a sampler's output port, e.g. SamplerCustomAdvancedChunked.
  • vae (VAE) - the same VAE you encoded with.
  • chunk_size (INT, default 8) - how many latents to decode per pass. Lower it if you still hit OOM; raise it if you have headroom.
  • clear_cache_between_chunks (BOOLEAN, default off) - empty the VRAM cache between slices. On when memory creeps, off when you want max speed.

The single output, images (IMAGE), is the full decoded batch in frame order - wire it straight into a Preview, a Save, or whatever's next in your pipeline.

One detail worth knowing: the decoder handles the case where a VAE returns 5D output from a decode call and reshapes it back to the standard 4D image tensor before concatenating. So the batch you get out is clean even if your VAE is one of the quirky ones.

Where it fits

This node is one link in the pack's canonical non-temporal chain:

IMAGE batch -> VAE Encode Batch Chunked -> SamplerCustomAdvanced Chunked -> VAE Decode Batch Chunked

You don't strictly need all three. If you got your latents some other way and only the decode step is the one OOMing, this node alone fixes that. It's a dumb, honest wrapper: loop, decode, cat.

Installing it

It ships in the xmarre/ComfyUI-ChunkedSampling pack, so installing the pack gives you this node. ComfyUI Manager: search "ComfyUI-ChunkedSampling". Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/xmarre/ComfyUI-ChunkedSampling

Then restart ComfyUI. No requirements.txt, no model files, no extra pip installs - it only calls the VAE API ComfyUI already provides.

Gotchas

The honest caveat: chunked decode doesn't change the total work, just the peak memory, so a big batch will still take as long overall. And this is a niche pack with a small install base, so don't expect a huge ecosystem of shared workflows around it. What it does, though, it does by delegating to ComfyUI's own decoder - low risk, easy to reason about, and easy to remove if you don't need it.

Categorylatent

Inputs (4)

NameTypeDefaultDescription
samplesLATENT
vaeVAE
chunk_sizeINT81–4096
clear_cache_between_chunksBOOLEANfalse

Outputs (1)

NameTypeDescription
imagesIMAGE