Nodes/ComfyUI-IterSwitch/Iter_ModelSwitch
ComfyUI Node

Iter_ModelSwitch

Iter_ModelSwitch makes the model a variable

By younger15·Created 5 months ago·Updated 5 months ago· 0
Iter_ModelSwitch
    • MODEL
    output_index0
    input_count2
    use_last_inputtrue

    Here's the workflow move everyone does at least once a week: load checkpoint A, queue, swap to checkpoint B, queue, swap back to A with a tweak, queue. It's the most boring manual labor in ComfyUI, and Iter_ModelSwitch exists to automate exactly that. It's a model switcher - you wire several checkpoints into it, and it hands one MODEL out based on an index you control.

    What it does

    Wire up to 64 MODEL inputs (from two or more checkpoint loaders), set an index, and the node passes the matching model through to the sampler. Drive that index from a counter node, and suddenly one queue run tests every checkpoint against the same prompt, seed, and sampler settings. You stop being the swap monkey and start reading results.

    It's a member of ComfyUI-IterSwitch, the pack's family of typed switches. The family trait matters here: unlike the anything-anywhere style routers that pass any type down any wire and make graphs genuinely hard to debug, this node only ever carries MODEL. One type, visible sockets, no surprises. The graph stays legible, which is exactly what the ecosystem's legibility crowd keeps asking for.

    How it works

    Three widgets - output_index, input_count, use_last_input - plus dynamically generated model_0, model_1, … sockets. input_count drives the socket count via a small web extension: raise it and new model_N inputs appear, lower it and the extras get trimmed without disturbing connections you've made.

    At run time the node computes target = output_index % input_count, so indexes past the count wrap around. Then, with use_last_input on (its default here), it walks backward from your target toward model_0 and returns the nearest connected model. Checkpoint B disconnected? You still get a valid model instead of a dead run.

    Wiring it up

    • input_count - set this first; it's how many sockets exist.
    • output_index - which socket wins. Wire it to a counter or seed to loop through models.
    • use_last_input - defaults on; the backward-fallback behavior described above.

    The MODEL output plugs straight into a KSampler's model input. Typical shape: two checkpoint loaders → Iter_ModelSwitch → KSampler, with the same prompt and seed feeding both branches. Add a second Iter_ModelSwitch (or a conditioning switch from the same pack) and you're A/B testing prompt and model in one sweep.

    Installing the pack

    ComfyUI-IterSwitch has no Python dependencies beyond what ComfyUI already ships - no requirements.txt, no model files to fetch. The whole install is a clone:

    cd ComfyUI/custom_nodes
    git clone https://github.com/younger15/ComfyUI-IterSwitch.git
    

    Then restart ComfyUI. Via Manager: search "ComfyUI-IterSwitch," and if it's not in the registry (small pack, it may not be), use Manager's install-by-Git-URL with the same repo link.

    Common issues

    • Fallback only looks backward. use_last_input searches from your target index down to model_0. If the only connected slot is above your target, you'll get None out and the sampler will choke. Keep the lower-index slots wired, or keep indexes pointing at real connections.
    • Sockets missing after install. The dynamic inputs are JavaScript, so a backend-only restart won't create them. Fully restart ComfyUI or refresh the browser page.
    • Index wraps silently. output_index 4 with three inputs gives you model_1, not an error. Great for looping, easy to forget when you bump a counter.

    This is the pack's most-likely-to-get-used node, which is faint praise for an undiscovered pack - none of these nodes have any community footprint yet. If the fallback behavior bites you, check the repo's issues and consider filing; you're on the leading edge.

    CategoryCustomNodes/Iterators

    Inputs (3)

    NameTypeDefaultDescription
    output_indexINT00–18446744073709550000
    input_countINT21–64
    use_last_inputBOOLEANtrue

    Outputs (1)

    NameTypeDescription
    MODELMODEL