Sub-batching VAE
Stop the decode from eating your VRAM
- model
- VAE
The sampler isn't the only memory hog in a tile pipeline - the VAE is. Encoding or decoding a batch of dozens of tiles at once (or one big 20×20 tiling) can spike VRAM just as hard as the UNet. Sub-batching VAE is the sibling of SubBatchModel: it patches the VAE so encode and decode both run in chunks of subbatch_size, taming that spike. Put it on every latent decode in a content_aware_tiles workflow and you stop guessing whether the last node is going to OOM.
What it does
It makes a shallow copy of your VAE and wraps its encode and decode methods with the same chunked executor the pack uses for the UNet. Batch tensors are split into subbatch_size pieces, each processed, then re-joined - including the special case of merging the VAE's DiagonalGaussianDistribution outputs properly, which is the part that trips up naive chunking. As with the model patch, if the batch doesn't divide evenly it shrinks the chunk size until it does, so no edge-case crashes. The output VAE behaves exactly like the original, just with a controlled memory footprint.
Inputs and outputs
- model (VAE) - your VAE
- subbatch_size (INT, default 8)
Output is a single VAE. Wire it wherever you'd use the original: into VAEDecode, VAEEncode, InpaintModelConditioning, or any of the pack's latent nodes that take a VAE (they only use it for the downscale ratio, so either works).
Installing and notes
Standard pack install: git clone https://github.com/samsartor/content_aware_tiles into ComfyUI/custom_nodes (or ComfyUI Manager → "content_aware_tiles") and restart. No model downloads.
The one caveat worth repeating: outputs should be bit-identical to the unpatched VAE, so if you see a quality change after adding it, look elsewhere. And remember the decode side of the equation - RollingKSampler's double_output tiles the latent 2×2, which is exactly the kind of oversized decode this node exists to rescue. This is research-pack plumbing with zero community discourse, but the patch is ~15 lines and the pattern (clone, wrap, merge) is worth stealing for your own workflows. Pair it with SubBatchModel and the bundled workflow's memory story is complete.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| model | VAE | — | |
| subbatch_size | INT | 8 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| VAE | VAE | — |