XB-BOX - VAE编码(原版优化)
Stock VAE encode, with a VRAM cleanup knob you can actually see
- pixels
- vae
- LATENT
If you've used ComfyUI for more than an hour, you've met the default VAEEncode: image in, latent out, no drama. XB_VAEEncode is that node wearing a pack-branded coat. The class literally deep-copies the official VAEEncode's input definitions and appends one extra dropdown, then forwards every argument through unchanged. So the honest summary is: same pixels, same VAE, same latent - plus a cleanup switch that runs before encoding.
That sounds anticlimactic, and it is, but that's the point of the whole "原版优化" (original-vanilla optimized) family in XB_ToolBox. The pack's real business is squeezing 14B–22B video models onto consumer GPUs, and its author found that fragmented VRAM caches were OOMing people at the encode step - right before the heavy work started. These wrappers give you a controlled way to clear that cache and unload models at exactly the right moment in the graph, without rewriting any sampling math.
Why you might swap it in
Honestly? Most people don't need to. If your plain VAEEncode works, keep it. This node earns its place in two situations:
- You're in a big Wan or LTX video workflow that keeps dying at the latent-construction stage, and you want an explicit "clean the deck" step before the VAE runs.
- You're on AMD/ROCm, where PyTorch's cache fragmentation bites harder and a
torch.cuda.empty_cache()before encode measurably reduces failures.
The inputs
- pixels (IMAGE) and vae (VAE) - identical to the stock node.
- cleanup - the only addition. Chinese options: "不做任何清理" (no cleanup, default), "单次缓存清理" (cache empty), "卸载显存模型" (unload VRAM models), "卸载全量模型" (unload everything plus a deep
gc.collect()). The code path is shared across the wrapper family, so the behavior is identical whichever "原版优化" node you put it on.
Output is a single LATENT, wired into whatever sampler or latent manipulation you already use.
The honest gotcha
Because it's a passthrough, there's zero quality or speed benefit on its own. Set cleanup to "卸载全量模型" on a node that runs every frame of a video loop and you'll pay a reload tax every single execution - that's the one way this friendly wrapper turns hostile. Keep the default for normal image work; use "卸载显存模型" as a deliberate step before your first big encode of a run.
Install and dependencies
It's part of XB_ToolBox, so it isn't a standalone install:
cd ComfyUI/custom_nodes
git clone https://github.com/WJLUOXIAO/XB_ToolBox.git
Then restart ComfyUI (or use ComfyUI Manager and search "XB_ToolBox"). The vanilla wrappers have no extra pip dependencies - they call ComfyUI's own nodes.VAEEncode - so if a workflow tells you this node is missing, you're missing the whole pack, not a pip package. One thing to watch: because these are wrappers, if a future ComfyUI changes VAEEncode's signature, the wrapper's **kwargs passthrough is designed to follow it automatically. That's the design intent, and it's also why the code comments say "parameter names never go stale."
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| pixels | IMAGE | — | |
| vae | VAE | — | |
| cleanup | COMBO | 不做任何清理 | 4 options: 不做任何清理, 单次缓存清理, 卸载显存模型, 卸载全量模型 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |