Nodes/Yaser-nodes for ComfyUI/๐Ÿ“ฆ Tiled VAE Encode - Yaser
ComfyUI Node

๐Ÿ“ฆ Tiled VAE Encode - Yaser

Encode a giant image into a latent without the OOM โ€” the encoder twin

By YaserJaradehยทCreated about a year agoยทUpdated 11 months agoยท 8
๐Ÿ“ฆ Tiled VAE Encode - Yaser
  • pixels
  • vae
  • LATENT
โ—„tile_size512โ–บ
โ—„fasttrueโ–บ
โ—„color_fixtrueโ–บ

The encoder twin of the tiled VAE story. Where Tiled VAE Decode gets a giant latent out of the VAE, Tiled VAE Encode - Yaser gets a giant image in: you hand it a big IMAGE - a 4K render, a stitched panorama, a huge reference - and it produces a latent without your GPU keeling over. Same lineage, same "wild hack" pedigree, opposite direction.

If you've only ever worked at 1024ร—1024, you might wonder why you'd need this. The answer is img2img at scale. Want to re-run a huge image through a sampler at full resolution, or feed a big reference into an inpainting or ControlNet pass? The stock VAE encode can eat your VRAM in one bite. Tiled encode splits the job into chunks so the memory footprint stays flat no matter how big the input is.

How it works

It's the same machinery as the decoder port: split the image into tiles, pad each (32 pixels in the encoder), encode them separately via a VAEHook wrapped around the encoder's forward pass, then stitch the latent tiles back together. GroupNorm is the usual complication - the encoder's stats need to represent the whole image, not just one tile - and again there are two strategies:

  • fast = true (default): downsample the full image, record its GroupNorm mean/var, apply those to every tile. Cheap and good enough for generation work.
  • fast = false: the slow, careful path that accumulates GroupNorm stats across tiles.
  • color_fix = true (also default): a "semi-fast" encoder mode that estimates GroupNorm from a downsampled pass before encoding - it's the fix that keeps colors from drifting between tiles. Keep it on.

The merged latent comes out seamless, same as the decoder's stitched image.

The inputs you'll set

  • pixels - the IMAGE to encode. vae - your VAE.
  • tile_size - 256 to 4096, step 16, default 512. This one's minimum is lower than the decoder's (256 vs 384) because encoding is generally less memory-hungry; drop it if you still OOM.
  • fast and color_fix - both default true. Leave them unless you're chasing a specific artifact and know what you're doing.

Output: LATENT, ready for a sampler, a VAE Decode, or a latent edit node.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/YaserJaradeh/comfyui-yaser-nodes.git

restart ComfyUI, or ComfyUI Manager โ†’ "Yaser-nodes". No models to fetch.

Gotchas worth knowing

The same family of caveats as the decoder: no gradients through the VAE (the hook breaks autograd - fine for generation, wrong for training), and the fp16/NaN-at-huge-sizes issue applies here too. If encoding a truly enormous image gives you garbage latents, relaunch ComfyUI with --no-half-vae and retry.

And the same honest note: ComfyUI core now has native tiled VAE encode, well maintained and likely to be more future-proof than this _for_testing port, which patches into VAE internals. Try core's VAEEncodeTiled first if you just need the capability; reach for this one when you want the fast/color_fix knobs or you're already building on this pack's tiled-diffusion workflow, where the matching seams between encode and the tiled sampler matter.

Category_for_testing

Inputs (5)

NameTypeDefaultDescription
pixelsIMAGEโ€”
vaeVAEโ€”
tile_sizeINT512256โ€“4096โ€”
fastBOOLEANtrueโ€”
color_fixBOOLEANtrueโ€”

Outputs (1)

NameTypeDescription
LATENTLATENTโ€”