Nodes/ComfyUI-TJ_NODE/Multi Switch (TJ)
ComfyUI Node

Multi Switch (TJ)

A switch that actually stops the losing branch from running

By designloves2·Created 3 months ago·Updated 5 days ago· 13
Multi Switch (TJ)
    • output_1
    • output_2
    • output_3
    • output_4
    • output_5
    • output_6
    • output_7
    • output_8
    • output_9
    • output_10
    • output_11
    • output_12
    toggle_mode
    global_switchtrue
    num_groups1

    Most "switches" in ComfyUI are lying to you. An ordinary A/B switch picks one input's value, sure, but everything upstream of both sides still runs - your two checkpoint loaders both load, both LoRA chains both apply, and you pay for a branch you never look at. Multi Switch (TJ) is the one that isn't lying: it cuts the losing branch out of the queued prompt entirely, so the model on the side you didn't pick never loads at all.

    That's the whole point, and it's a real feature, not marketing. It works because the pruning happens in the frontend: a queue hook intercepts graphToPrompt() right before submit and deletes the unselected branch from the prompt JSON. No selected branch, no execution, no VRAM. If you're A/B-testing two checkpoints, or you want one workflow that switches between a heavy ControlNet pipeline and a plain generation, this is the node for it.

    It's also a group switch, not a one-shot. A "group" is an A_n/B_n input pair plus one output_n, and you get up to 12 of them, so one node can switch an entire pipeline of related signals at once - model, latent, conditioning - all in lockstep. Add/remove groups with the [+ Group]/[- Group] buttons or right-click → Delete Group.

    The inputs that actually matter:

    • toggle_mode - Global (one switch drives all groups) or Per-Group (each group gets its own A/B toggle). Global is what you want 90% of the time.
    • global_switch - the toggle itself: ON = A, OFF = B.
    • num_groups - how many group pairs are active (1–12).

    Outputs are output_1 through output_12, and every socket is the wildcard type, so it routes IMAGE, LATENT, MODEL, whatever you hang off it. Connect a wire and the group's type locks in.

    The one trap: pruning runs in the frontend queue path. If you submit via the /prompt API directly - automation, another tool driving ComfyUI - the hook can't intervene, and the node falls back to a plain pass-through where both sides do execute. Also, if the selected side of a group is unconnected, that group just passes through silently rather than erroring. And note the distinction from rgthree's Any Switch: that's a first-non-null fallback that picks whichever input is live. This is a manual A/B valve that physically removes the dead branch. Different tools.

    Install

    It ships in the ComfyUI-TJ_NODE pack. Easiest path is ComfyUI Manager - search "ComfyUI-TJ_NODE" and install. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/designloves2/ComfyUI-TJ_NODE
    

    Then restart ComfyUI. The pack is a big all-in-one (LLM nodes, LoRA analyzers, prompt databases), but the switch itself has no dependencies beyond the pack's own frontend JS - nothing heavy pulls in for this node.

    Troubleshooting

    • Both branches ran anyway - you're calling the API directly, or the pack is out of date (subgraph pruning was fixed in v2.11.1). Update the pack.
    • DependencyCycleError when a switch is inside a subgraph - this was the pre-2.11.1 bug: the hook only scanned top-level nodes and skipped pruning entirely, so both branches queued and cycled. Update.
    • Switch doesn't exist in your palette - the pack is huge; if Manager skipped it, clone manually and restart.
    Category ✨ TJ_Node/Wireless

    Inputs (3)

    NameTypeDefaultDescription
    toggle_modeCOMBO2 options: Global, Per-Group
    global_switchBOOLEANtrue
    num_groupsINT11–12

    Outputs (12)

    NameTypeDescription
    output_1*
    output_2*
    output_3*
    output_4*
    output_5*
    output_6*
    output_7*
    output_8*
    output_9*
    output_10*
    output_11*
    output_12*