Nodes/ComfyUi-MpiNodes/Mpi Any Switch
ComfyUI Node

Mpi Any Switch

One of five inputs, picked at runtime — the switch that doesn't care about types

By MadPonyInteractive·Created 11 months ago·Updated 5 days ago· 3
Mpi Any Switch
  • any_1
  • any_2
  • any_3
  • any_4
  • any_5
  • any
  • index
select1

A switch node is how you keep five things in a workflow and only pay for one. Mpi Any Switch takes up to five inputs of any type and routes the one you select to a single output - an INT select widget (1 to 5) picks the winner, and the chosen value comes out the any output. There's also an index output that just echoes your selection, handy for logging or for feeding the number onward.

The reason this pack's switch is worth reaching for over a homegrown pile of if/elses is the type story. Every socket is the wildcard * type, so the five inputs don't have to agree with each other. You can have an IMAGE in slot 1, a LATENT in slot 2, and a MODEL in slot 3, and the node is perfectly happy - it's routing, not comparing. That's the classic A/B-switch shape from the KB's node-plumbing doc: a manual routing valve where you hold the selector.

But the real trick, and the reason it's faster than it looks, is that the inputs are lazy. The node declares each any_N input lazy, and its check_lazy_status only requests the one slot you actually selected. ComfyUI then refuses to execute everything feeding the other four inputs. Wire five LoRA loaders or five model loaders into it and pick slot 2: slots 1, 3, 4, and 5 never load at all. No wasted VRAM, no wasted time - the expensive work behind the unselected inputs is skipped, not computed-and-discarded. That single property is why the node exists, and it's the same laziness Mpi Blocker uses.

Inputs: select (INT, default 1, range 1–5, tooltip "Selection from 1 to 5") plus the five optional wildcard slots any_1 through any_5. Outputs: any (the chosen value) and index (INT, the selection). Unconnected slots are fine - leave them hanging, they're just not selectable. If select points at a slot that isn't wired, the node returns an ExecutionBlocker, so the branch quietly does nothing rather than crashing on a None.

Where people actually use this: model-swap workflows (one checkpoint per slot, flip between them by changing select), prompt A/B testing (drive select from a seed or a random int), and "which pipeline stage runs" routing where each slot holds a different subgraph's output. It's also the natural target for the int output of MpiBoolean, if you want a boolean to pick between two slots.

The one thing to keep in mind is that it's a manual switch - it routes what you point it at. If you want a fallback that picks the first non-empty input automatically, that's a different shape (rgthree's Any Switch is the canonical fallback); Mpi Any Switch always picks by index. Two close cousins ship alongside it: MpiAnySwitch10 for ten inputs, and MpiAnyInvSwitch, the inverted version that fans one input out to five outputs.

Install is pack-standard: ComfyUI Manager → search ComfyUi-MpiNodes → install, or clone it:

cd ComfyUI/custom_nodes
git clone https://github.com/MadPonyInteractive/ComfyUi-MpiNodes

Restart, and it's under MpiNodes/Logic. No requirements file, no model downloads - pure Python on top of ComfyUI, the same pack behind the Cubric Vision app.

CategoryMpiNodes/Logic

Inputs (6)

NameTypeDefaultDescription
selectINT11–5Selection from 1 to 5 Output index is also 1 to 5
any_1opt*
any_2opt*
any_3opt*
any_4opt*
any_5opt*

Outputs (2)

NameTypeDescription
any*
indexINT