ComfyUI Node

Mpi If Else

The node that actually skips the branch you don't take

By MadPonyInteractive·Created 11 months ago·Updated 5 days ago· 3
Mpi If Else
  • true
  • false
  • output
booleantrue

The whole promise of "smart" ComfyUI workflows is that they don't do useless work - and the node that delivers on it is MpiIfElse. Give it a boolean and two possible values, and it hands back one of them. Sounds like every switch you've ever seen. The difference is lazy evaluation: the branch you don't take is never computed at all, which means everything feeding it is skipped too. That's not a nicety, that's the feature.

How it works

Three inputs: boolean (the condition, a widget you can flip or wire), true (the value to output when the condition is true), and false (the value when false). Both value inputs are * - any type - so it can route a model, an image, a string, a latent, whatever your branches produce. The single output is the winner, unchanged.

The lazy part lives in check_lazy_status: when the condition is true, only the true input is requested from upstream; the false input and its entire upstream chain never run. ComfyUI's executor is built around this, so it's not a performance hint - the skipped branch's nodes genuinely don't execute. That's how a workflow can check "is this image small?" and, when it isn't, avoid paying for an upscale pass it doesn't need.

The inputs that matter

  • boolean - the gate. Wire it from MpiCompare, MpiHasOptions, MpiHasAudio, any boolean source.
  • true / false - the two candidate values. Wire them from different loader/config paths and the node becomes a router.

Where people get burned

The trap is thinking lazy is the default everywhere. It is here - but only because the author wired it up. A generic switch node in another pack may compute both inputs, which silently defeats the whole point and can double your VRAM usage. If you've got a workflow where the "other" branch is expensive and you're not sure it's being skipped, check which node you used.

Also: both true and false are required sockets even though one is always unused. You can't leave one dangling and expect the other to fill in - the node needs a value on each side of the fork. If you only have one real path, feed the other a pass-through value like MpiFloat or a cheap constant.

Install

From the MadPonyInteractive/ComfyUi-MpiNodes pack. ComfyUI Manager → search ComfyUi-MpiNodes (publisher mad-pony-interactive), install, restart. Or:

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

then restart. No dependencies, no models. The pack is AGPL-3.0 (≤ 1.2.6 MIT) and is the node library behind the author's Cubric Vision app.

The pattern worth stealing

The canonical combo is MpiCompare (or MpiHasOptions) feeding the boolean, with an expensive branch on one side and a cheap pass-through on the other. Conditionals like "only run the face-detail pass if the batch isn't empty" or "only upscale if the image exceeds 1MP" become one boolean and zero wasted generations. If you're building branching workflows at all, this is the node you reach for first - and its inverted sibling MpiIfElseInverted is what you use when one input needs to fan out to two possible destinations instead.

CategoryMpiNodes/Logic

Inputs (3)

NameTypeDefaultDescription
booleanBOOLEANtrue
true*
false*

Outputs (1)

NameTypeDescription
output*