Nodes/deforum-comfy-nodes/Lazy Conditional | Deforum
ComfyUI Node

Lazy Conditional | Deforum

The if/elif/else chain your workflow didn't know it needed

By deforum·Created about a year ago·Updated 3 months ago· 29
Lazy Conditional | Deforum
  • value1
  • value2
  • value3
  • value4
  • value5
  • value6
  • value7
  • value8
  • value9
  • value10
  • else
  • *
condition1
condition2
condition3
condition4
condition5
condition6
condition7
condition8
condition9
condition10

Here's the scenario: you've got one workflow that should behave three different ways depending on which frame you're on, or which model you loaded, or whether a setting is toggled. A normal ComfyUI graph can't really branch - it just executes everything you've wired. Lazy Conditional | Deforum is the pack's answer: a ten-branch if/elif/else chain that picks one value and, crucially, only executes the branch that wins.

The inputs are ten valueN / conditionN pairs plus an else. The node walks condition1 through condition10 in order, and the first condition that's true makes it return the matching value. If every condition is false, you get else. That's the whole logic, and it reads exactly like the code it's modeling. Every value socket is the wildcard type (*), so a branch can carry a model, a latent, a conditioning, a string - whatever you're switching between.

The word "lazy" in the name is the part that matters. ComfyUI has a lazy-evaluation mechanism where a node can tell the engine which inputs it actually needs before they're computed. This node's check_lazy_status looks at your conditions, decides which one branch is live, and requests only that input. The upstream nodes behind the other nine branches never run. That's not a performance nicety - it's the difference between a workflow that works and one that's impossible. You can keep nine heavy branches (model loaders, ControlNet stacks, entire upscale subgraphs) in one workflow and switch between them per frame, without paying for the branches you didn't pick. If you've used the "Anything Anywhere" style of type-erasing nodes and felt the community's backlash to them, note this is the disciplined version: it's still wildcard-typed, but the laziness gives you real control instead of just hiding wires.

A couple of practical gotchas. The condition sockets are BOOLEAN with forceInput, meaning they arrive as sockets you have to wire from a boolean source - a compare node, a Value Schedule | Deforum driving an INT→BOOLEAN comparison, or a primitive. You can't just type a value into them. Second, remember it's an ordered chain: condition1 is checked first, so if two conditions are both true, the lowest-numbered one wins. And because it's lazy, an unwired branch that would error (say, a missing model) is fine as long as it never gets selected - that's a feature, not a bug, but it also means a half-built branch won't tell you it's broken until you actually switch to it.

It's part of deforum-comfy-nodes, installed with the whole pack: ComfyUI Manager → search "ComfyUI-Deforum" or deforum-comfy-nodes → install and restart, or git clone https://github.com/deforum-art/deforum-comfy-nodes into ComfyUI/custom_nodes. No models, no extra deps. If you only need a two-way choice, Lazy Switch | Deforum is lighter; this one earns its ten slots when you're routing between many branches based on state.

CategoryDeforum/Logic

Inputs (21)

NameTypeDefaultDescription
value1opt*
condition1optBOOLEAN
value2opt*
condition2optBOOLEAN
value3opt*
condition3optBOOLEAN
value4opt*
condition4optBOOLEAN
value5opt*
condition5optBOOLEAN
value6opt*
condition6optBOOLEAN
value7opt*
condition7optBOOLEAN
value8opt*
condition8optBOOLEAN
value9opt*
condition9optBOOLEAN
value10opt*
condition10optBOOLEAN
elseopt*

Outputs (1)

NameTypeDescription
**