Nodes/comfy_Pond_Nodes/🐳WanVideo Resource Cleaner
ComfyUI Node

🐳WanVideo Resource Cleaner

A VRAM reset button you can wire into the middle of a graph

By Pondowner857·Created about a year ago·Updated 21 days ago· 45
🐳WanVideo Resource Cleaner
  • any_input
  • any_output
clear_cachetrue
force_gctrue
unload_modelfalse

WanVideo Resource Cleaner is a pass-through node that grabs a chunk of GPU memory back mid-workflow. If you've ever run a long Wan video job and watched VRAM bleed upward until the next step dies with an OOM, this is the sort of tool that exists to reset that pressure without tearing your graph apart: wire anything through it, it does a cleanup pass, and hands the same data out the other side.

Mechanically it's a wrapper around Comfy's memory-management API, plus a few Wan-specific touches. If your input looks like a Wan model (it checks for .model.diffusion_model), it does three Wan-specific cleanups: moves block-swap parameters back to the offload device, clears any teacache_state and magcache_state caches (the TeaCache/MagCache acceleration caches that can hold stale tensors across runs), and clears the VAE cache. Then, regardless of input type, it runs the general housekeeping, controlled by three booleans:

  • clear_cache (default on) - Comfy's soft_empty_cache() plus torch.cuda.empty_cache() and a synchronize
  • force_gc (default on) - a Python gc.collect() to free unreferenced CPU-side objects
  • unload_model (default off) - the big hammer: unload_all_models() + cleanup_models(), which fully evicts loaded models from VRAM

It also prints the current GPU allocated/reserved numbers to the console, which doubles as a crude monitor. The output is any_output - your input, unchanged - so the node can sit anywhere in the data flow without affecting results.

Where it actually earns its place: between the segments of a multi-pass Wan job, or before a memory-hungry step like a VAE decode or an upscale. The Wan-specific parts are the real value - the TeaCache state cleanup in particular addresses a genuine, recurring Wan gotcha where a cache from a previous run keeps data around and inflates memory. If your graph is a straight single generation, you don't need it.

The honest take, though: this is a pressure valve, not a miracle. If you're trying to run Wan 2.2's 27B MoE on a 12GB card, no cleanup node makes that fit - you need a smaller model, quantization (GGUF), or a genuinely smaller workflow. What this node does reliably is clear the accumulated cruft between steps and unload models when a workflow is done with them. Think of it as "flush the toilet before the next segment," not "double your VRAM."

One more note: unload_model defaulting to off is deliberate - flipping it on mid-graph means the next sampling step re-loads everything from disk, which is slow. Use it only when you're done with a model and the next step is on a different model entirely.

Install

Part of Pond Nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/Pondowner857/comfy_Pond_Nodes
cd comfy_Pond_Nodes
pip install -r requirements.txt

Restart after (or Manager → "comfy_Pond_Nodes"). No model files or optional deps. Pack-wide caveat: console spam if comfyui_HiDream-Sampler is installed alongside.

Category🐳Pond/video

Inputs (4)

NameTypeDefaultDescription
any_input*
clear_cacheBOOLEANtrue
force_gcBOOLEANtrue
unload_modelBOOLEANfalse

Outputs (1)

NameTypeDescription
any_output*