Nodes/ComfyUI_MiraSubPack/VAE Decode (Mira SubPack)
ComfyUI Node

VAE Decode (Mira SubPack)

The other half of the VRAM fix — decode tiled latents one at a time

By mirabarukaso·Created 8 months ago·Updated 2 months ago· 0
VAE Decode (Mira SubPack)
  • samples
  • vae
  • image

Mirror image of the pack's VAEEncode_MiraSubPack, and it fixes the same failure on the way out: VAE Decode (Mira SubPack) decodes a batch of latents one at a time instead of all at once, so your tiled sampler's 16-tile output doesn't blow up VRAM at the final decode step. If you've ever watched a workflow get through the entire sampling run and then die at the VAE decode, this is the node that rescues you.

In the tiled-upscale loop this pack is built around - ImageCropTiles → VAEEncode → ImageTiledKSamplerWithTaggerVAEDecode_MiraSubPackOverlappedImageMerge - this is the step that turns the sampled latents back into the pixels the merge node stitches together.

How it works

Same strategy as the encode twin, from the source: single latent → standard vae.decode(). Multiple latents → loop, decode latent[i:i+1] individually, move each result to CPU immediately (single_image.cpu()) so GPU memory is freed before the next one, then concatenate back into one image batch. It also handles two edge cases the stock node can stumble on: nested latents (via unbind()), and 5D tensors that some VAE paths return for batched input, which it reshapes back to [N, H, W, C].

The CPU offload is the clever bit - decoded images go to system RAM while the loop continues, so peak VRAM stays at roughly one latent's decode instead of the whole batch's.

Inputs and output

  • samples - the LATENT batch to decode.
  • vae - the same VAE you encoded with (SDXL, FLUX, Qwen Image - the interface is uniform).

One output: image (IMAGE), ready for the merge node or a preview/save.

Install

Same pack, same routine:

cd ComfyUI/custom_nodes
git clone https://github.com/mirabarukaso/ComfyUI_MiraSubPack

or search "MiraSubPack" in ComfyUI Manager and restart. No extra dependencies - pure PyTorch.

Notes

The single-image path is identical to the stock VAEDecode, so there's no quality cost to using this everywhere in a tiled graph; the loop overhead only appears when the batch is actually big. One thing worth knowing: if your VAE is one of the newer ones that returns 5D tensors for batched input, this node normalizes that for you - a small compatibility win you don't appreciate until a workflow breaks without it.

For beginners: connect samples and vae, wire image into the merge or preview node, and let the pack's batch strategy do its thing. If you're decoding a genuinely giant batch, this is also the version that lets you keep working on an 8GB card where the stock node gives up.

CategoryMira/SubPack/Utils

Inputs (2)

NameTypeDefaultDescription
samplesLATENT
vaeVAE

Outputs (1)

NameTypeDescription
imageIMAGE