IF Branch
The lazy A/B switch that skips the branch you didn't pick
- true_value
- false_value
- result
IF Branch from the PM Nodes pack is the ComfyUI version of an if/else, and the "if" part is the whole point. You feed it a boolean, it passes through one of two inputs. Boring, until you realize the clever bit: it only loads the branch you actually chose. Flip the condition and the other branch's nodes don't execute at all. That's the difference between this and a dumb routing valve, and it's why you'd install a pack for what sounds like the simplest node imaginable.
What it is
An A/B switch with a selector - exactly the shape the KB's node-plumbing doc calls out as one of the two switch families. Where rgthree's Any Switch is a fallback (passes the first non-null input, no selector), this one is driven: condition (boolean, default true) decides between true_value and false_value, and result comes out. All three values are * (any type), so you can route models, conditioning, latents, prompts, numbers - whatever the graph is carrying at that point.
How the lazy part works
ComfyUI normally executes a node as soon as anything feeding it is ready. IF Branch declares both values as lazy optional inputs, which means it gets to tell the engine which one it actually needs. Its check_lazy_status looks at condition and only requests the active branch's input. The dead branch - and every node upstream of it - never runs. Feed it two model loaders or two sampler paths and the loser is skipped entirely, not just ignored. That's real VRAM and time saved on every run, not a nicety.
There's a sentinel value in the source that distinguishes "this input isn't connected" from "connected but the value is None," and that's what powers the validation: if condition is true and true_value is unconnected, you get a clear error telling you the true branch must be wired. Same for the false side. Annoying when it happens, but it's better than silently routing a missing value.
The inputs that matter:
condition(boolean) - the selector. Wire it from a primitive, or convert a widget elsewhere in the graph to an input and drive it from here.true_value(any, optional) - what passes whenconditionis true.false_value(any, optional) - what passes when it's false.result(any) - whichever branch won. Wire this into the downstream node; it adopts whatever type that node expects.
When to reach for it
Classic use is keeping two configurations in one workflow and flipping between them: two checkpoints, two prompts for A/B testing, an SDXL path and a Flux path, a "fast draft" sampler vs a "final quality" sampler. Because the unused branch genuinely doesn't run, you can leave both branches fully built and still pay for only one per run. Wire condition to a boolean on a control panel or even to another node's output and the choice becomes automatic.
Install
ComfyUI Manager → search "PM Nodes" → install. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/pixel-magician/ComfyUI-PM-Nodes.git
Restart after cloning. No pip dependencies beyond what ComfyUI 1.0+ already ships, and no models to download - this pack is pure logic.
Gotchas
- You must connect whichever branch the condition currently points at, or you'll get an error until you do. It's explicit about which one, at least.
resultis typed*, so it only becomes a model (or a latent, or whatever) once you connect it to something. That's normal any-type behavior, not a bug.- The pack is new and small (v0.0.9, one author, barely any community footprint yet). The lazy-loading here is the real differentiator; the rest is what it says on the tin.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| condition | BOOLEAN | true | — |
| true_valueopt | * | — | |
| false_valueopt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result | * | — |