XB-BOX - VAE分块编码(原版优化)
Tiled VAE encode for big images and video — with the cleanup switch ComfyUI forgot
- pixels
- vae
- LATENT
Encoding a huge image - or worse, a video clip - through the VAE is where a lot of VRAM plans die. The full tensor needs to sit in memory as pixels, as intermediate features, and as latent, all at once. XB_VAEEncodeTiled is the pack's answer: it's a faithful wrapper around ComfyUI's native VAEEncodeTiled that splits the work into spatial tiles (and temporal chunks for video VAEs) so peak memory stays small, then appends the XB_ToolBox cleanup dropdown. One line from the source says it all - "原版 VAEEncodeTiled 套皮 - 仅注入清理,参数零改动" (a skin over the original, only injecting cleanup, zero parameter changes).
So the tile logic is 100% ComfyUI's. What XB adds is a staged VRAM cleanup that fires before the encode runs, which is the same hook the whole "原版优化" wrapper family uses. On AMD/ROCm especially, a fragmented PyTorch cache is what actually kills big encodes - not raw tensor size - so forcing a clean state first genuinely helps there.
Inputs that matter
- pixels (IMAGE) and vae (VAE) - standard.
- tile_size - spatial tile size, default 512 (range 64–4096). Smaller tiles = less peak VRAM but more seams; 512 is a sensible start.
- overlap - spatial overlap, default 64. The thing that hides tile seams. Seams visible after decode → raise this before shrinking tiles.
- temporal_size - "Only used for video VAEs: Amount of frames to encode at a time" (the author's own tooltip). Default 64. If you're encoding an image batch, leave it alone.
- temporal_overlap - "Only used for video VAEs: Amount of frames to overlap," default 8. More overlap smooths temporal boundaries but costs compute.
- cleanup - the four Chinese levels, default "no cleanup."
Output is a single LATENT.
Where people get burned
Two places, both predictable. First: temporal tiling is for video VAEs like Wan's 3D causal VAE. Set temporal_size on an ordinary SD/SDXL image encode and you've added overhead for no benefit - the node will happily do it, you just won't see a difference. Second: the cleanup default is none, so the "optimized" part only exists when you switch it on. Pick "卸载显存模型" before the big encode in a heavy workflow; don't leave the nuclear option on a node that runs repeatedly.
Install
It's a pack node, not a standalone:
cd ComfyUI/custom_nodes
git clone https://github.com/WJLUOXIAO/XB_ToolBox.git
then restart ComfyUI - or search "XB_ToolBox" in ComfyUI Manager. The wrapper needs no extra pip packages; it calls ComfyUI's own VAEEncodeTiled. There's also a compatibility nicety worth knowing: this family probes the target function's signature and drops arguments an older ComfyUI doesn't recognize, so the old "整合包" installs that still have a pre-temporal VAEEncodeTiled won't crash - they just get spatial tiling.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| pixels | IMAGE | — | |
| vae | VAE | — | |
| tile_size | INT | 51264–4096 | — |
| overlap | INT | 640–4096 | — |
| temporal_size | INT | 648–4096 | Only used for video VAEs: Amount of frames to encode at a time. |
| temporal_overlap | INT | 84–4096 | Only used for video VAEs: Amount of frames to overlap. |
| cleanup | COMBO | 不做任何清理 | 4 options: 不做任何清理, 单次缓存清理, 卸载显存模型, 卸载全量模型 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |