flow_stage_index_switch
A gate that only lets the active stage's branch through
- any_input
- any_output
In a staged workflow, sometimes stage 2 shouldn't do the same thing as stage 4. That's the entire reason flow_stage_index_switch exists: it's a per-stage gate. Wire whatever you want routed into any_input, and the node passes it through - but only when the current stage_index equals your open_stage_index. Any other stage gets an execution blocker, which means that whole downstream branch simply doesn't run.
How it works
The clever part is that it's lazy - it doesn't even ask its upstream for the input unless it's about to pass it through. Look at the source: check_lazy_status only requests any_input when stage_index == open_stage_index and the input is still missing. So a blocked branch isn't just muted, it's never computed at all. That's a real saving when the blocked branch would otherwise have been, say, a second sampler or a ControlNet stack sitting idle.
When the gate does open, it returns any_input unchanged. When it's closed, it returns an ExecutionBlocker(None) - the standard ComfyUI idiom for "skip everything downstream of me." It's a switch in the same family as the classic A/B and fallback switches covered in the node-plumbing layer, except the selector isn't a boolean or a priority order, it's the pack's own flow-stage counter.
Inputs
stage_index- the current stage number (wire it from the samestage_indexoutput offlow_stage_begin, or it defaults to 1).open_stage_index- the stage you want to let through.any_input- the wildcard*input; it'll carry a model, a latent, a prompt string, whatever.
The output is any_output, same type, nothing transformed.
Where you'd actually use it
Say you have a 3-stage H3 pipeline where only stage 1 needs a ControlNet pass and stages 2–3 run clean. You put a flow_stage_index_switch with open_stage_index = 1 in front of the control branch, and it drops out of the graph on every other stage. Or invert it - open_stage_index pointing at the final stage lets you run a one-time post-process (a save node, a final upscale) only at the end, instead of on every segment. Because it's lazy, you can build these gates into a workflow without paying for the dead branch on every run.
Install
Part of ComfyUI-Apt_Preset - ComfyUI Manager → "ComfyUI-Apt_Preset", or clone into custom_nodes + install.bat. No models, no deps beyond the pack's own requirements.txt. The only real gotcha is remembering that this gates execution, not data - if you wanted a fallback that picks the first non-empty value, that's a different node (rgthree's Any Switch, or this pack's flow_BooleanSwitch). This one is purely "am I the active stage?"
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| stage_index | INT | 11–10000 | — |
| open_stage_index | INT | 11–10000 | — |
| any_inputopt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| any_output | * | — |