Nodes/ComfyUI-RvTools_v2/Latent Multi-Switch v2
ComfyUI Node

Latent Multi-Switch v2

First live latent wins, plus a VRAM reset

By r-vage·Created about a year ago·Updated 5 months ago· 23
Latent Multi-Switch v2
  • input1
  • input2
  • input3
  • input4
  • input5
  • latent
Purge_VRAMfalse

Latent Multi-Switch v2 is the v1 multi-switch with one addition bolted on: a Purge_VRAM toggle. Everything else is identical - up to five latent inputs, and the first one that isn't empty gets passed through, no selector to flip. If all five are empty it errors out with "Missing Input" rather than silently handing you garbage, which is a feature in disguise.

So first, the core mechanic, because it's the part people misuse. This node is built for bypass-driven switching: connect several latent-producing branches, then bypass the ones you don't want this run. A bypassed node outputs nothing, the switch skips the empty slots, and the first live branch wins. No wire editing, no widgets, just Ctrl+B on the losers. The trap is slot order - an always-enabled node sitting in slot 1 will never be None, so it shadows everything after it. The author's README advice: put the source you can't bypass (like a checkpoint loader's always-on output) in the last slot, and put bypassable options first. Slot order is the entire logic of this node.

The v2 difference is where it gets interesting for people running tight on VRAM. When Purge_VRAM is on, the node runs a full cleanup at the start of every execution: Python garbage collection, CUDA cache empty, IPC collect, then unload_all_models() and a soft cache empty from ComfyUI's model management. The scenario it's for: your multi-switch is selecting between latent branches that each drag in their own model set - a video model branch, an image branch - and switching branches leaves the old models parked in VRAM until the new ones OOM. Flipping Purge_VRAM on at the switch forces a clean slate before the winner's branch loads.

Inputs and outputs

  • input1 through input5 (LATENT, all optional) - in priority order; first non-empty wins.
  • Output latent (LATENT) - the winner.
  • Purge_VRAM (BOOLEAN, default false) - the v2 addition, as described.

Installing it

Part of ComfyUI-RvTools_v2:

cd ComfyUI/custom_nodes
git clone https://github.com/r-vage/ComfyUI-RvTools_v2

Restart ComfyUI or install via ComfyUI Manager (search "RvTools"). No model downloads; dependencies are torch/numpy/Pillow plus opencv-python, pilgram, pynvml, piexif.

Gotchas

README says the pack is no longer maintained, superseded by ComfyUI_Eclipse (same author). v2 still works fine.

The Purge_VRAM caveat from the 2-way latent switch applies double here: it's blunt force. It unloads every model, runs on every execution while toggled, and if another branch was mid-flight with something you wanted cached, it's gone. Keep it off until you actually hit the OOM wall - that's what it's for.

Category🫦 RvTools II/ Multi-Switches

Inputs (6)

NameTypeDefaultDescription
Purge_VRAMBOOLEANfalse
input1optLATENT
input2optLATENT
input3optLATENT
input4optLATENT
input5optLATENT

Outputs (1)

NameTypeDescription
latentLATENT