Nodes/ComfyUI_Eclipse/Any Multi-Switch Lazy Purge
ComfyUI Node

Any Multi-Switch Lazy Purge

The fallback switch that skips losers and sweeps VRAM before it wins

By r-vage·Created 10 months ago·Updated a day ago· 31
Any Multi-Switch Lazy Purge
  • any_1
  • any_2
  • *
inputcount2
Purge_VRAMfalse

Any Multi-Switch Lazy Purge is the top of the Eclipse switch food chain: lazy evaluation and a VRAM purge, in one node. It does the first-non-empty fallback routing of Any Multi-Switch, only executes the winning branch's upstream graph like Any Multi-Switch Lazy, and adds a Purge_VRAM checkbox that unloads all ComfyUI-managed models and clears the accelerator caches before the winner's data flows on. If you're running a tight-VRAM setup with several heavy alternative branches, this is the "I want only one branch to run, and I want it to start clean" node.

How the pieces fit

  • Lazy: the node inspects the actual prompt graph, requests connected slots one at a time in priority order, and stops at the first slot that resolves to a value. The losing branches never execute - no wasted sampling, no stray model loads.
  • Purge: if the Purge_VRAM flag is on (default False), it calls Eclipse's memory barrier before returning: every ComfyUI-managed model is unloaded, unused accelerator caches are cleared, and there's a sync before garbage collection so native CUDA finalizers don't trip. The purge runs before the switch returns, i.e. before anything downstream loads the winner's weights.

The combination covers both failure modes of a plain switch on a small card: the losers aren't loaded in the first place (lazy), and the winner doesn't have to fight whatever was resident (purge).

Inputs and behavior

  • inputcount - number of sockets (1–64, default 2), auto-updating as you change it.
  • Purge_VRAM - the checkbox.
  • any_1any_N - branches, highest priority first; empty/None slots are skipped.
  • Output - the first non-empty value, or None if everything is empty.

Is this overkill?

Honestly, sometimes. If your branches are lightweight - strings, latents, small images - the purge is pure overhead and the plain Lazy version is the right call. The purge earns its keep in the specific case where the winning branch loads something enormous and the previous run left the card full. If you can't tell whether you need the purge, you probably don't yet; start with Any Multi-Switch Lazy and add this one the day you see an OOM on a branch switch.

Installing it

Part of ComfyUI_Eclipse, installed once:

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

Restart ComfyUI (or ComfyUI Manager → search "ComfyUI Eclipse"). No extra dependencies beyond what ComfyUI already ships.

Gotchas

Pack-wide, the usual: ComfyUI_Eclipse was formerly RvTools, and v4.0.0 removed all legacy nodes - old workflows need the Workflow Migration Tool node (or python tools/migrate_workflow.py <workflow.json>) to rewrite old IDs with a backup. Two behavior notes: with lazy evaluation, losing branches never run (including their side effects - usually what you want), and a purged run is slower on the reload, which is the price of the clean slate, not a bug.

Category🌒 Eclipse/ Router

Inputs (4)

NameTypeDefaultDescription
inputcountINT21–64Number of ANY inputs to expose. Inputs update automatically.
Purge_VRAMBOOLEANfalseIf enabled, purges VRAM before switching.
any_1optCOMFY_MATCHTYPE_V3Any input #1 (highest priority). Only this branch executes if connected.
any_2optCOMFY_MATCHTYPE_V3Any input #2 (used if #1 is empty or not connected).

Outputs (1)

NameTypeDescription
*COMFY_MATCHTYPE_V3The selected output.