ComfyUI Node

ND Any Switch

One output, sixty-four inputs, and only one of them actually runs

By neural-dreamer·Created 23 days ago·Updated a day ago· 5
ND Any Switch
  • in_1
  • in_2
  • in_3
  • in_4
  • in_5
  • in_6
  • in_7
  • in_8
  • in_9
  • in_10
  • in_11
  • in_12
  • in_13
  • in_14
  • in_15
  • in_16
  • in_17
  • in_18
  • in_19
  • in_20
  • in_21
  • in_22
  • in_23
  • in_24
  • in_25
  • in_26
  • in_27
  • in_28
  • in_29
  • in_30
  • in_31
  • in_32
  • in_33
  • in_34
  • in_35
  • in_36
  • in_37
  • in_38
  • in_39
  • in_40
  • in_41
  • in_42
  • in_43
  • in_44
  • in_45
  • in_46
  • in_47
  • in_48
  • in_49
  • in_50
  • in_51
  • in_52
  • in_53
  • in_54
  • in_55
  • in_56
  • in_57
  • in_58
  • in_59
  • in_60
  • in_61
  • in_62
  • in_63
  • in_64
  • out
◄index1►

You've got three checkpoints loaded in one workflow and you want a single dial to pick which one renders. Or a branch that either sends the latent straight to the decoder or through a detailer first. That's the job: pick one wire out of many, by number, cheaply.

What it is

ND Any Switch takes up to 64 inputs of any type and passes one of them through, chosen by an integer. The output type is whatever you plugged into the picked pin, so you can feed it a MODEL, a LATENT, a prompt string, or a mix of all three on different pins - that's the point.

The important half of the sentence is what happens to the inputs you didn't pick: nothing. The unselected pins aren't evaluated, so the model loader sitting on in_3 doesn't load anything when your index points at in_1. Not "loads and gets discarded" - never runs. In a build where each branch loads 12 GB of weights, that's the whole reason to use this instead of a merge node.

It's a different animal from rgthree's Any Switch, which most people meet first. rgthree's walks its inputs and passes the first non-null one, no selector at all - the graph decides. This one is an A/B(/C/D) valve: you decide, by number. If you find yourself wishing you could flip branches with one widget instead of rewiring, you want this one.

The inputs that matter

Only one field is required, and it's the interesting one:

  • index (INT, default 1, range 1–64) - which pin gets passed on. 1 is the top pin. The author's tooltip is the whole manual: "Which input is passed on: 1 is the first pin, 2 the second, and so on."
  • in_1 … in_64 (type *, all optional) - the candidates. You'll only ever see the ones in use; the node starts with one pin plus a free + and grows a new one the moment you connect the last. A connected pin gets labelled N: <source name> so you can tell your three loaders apart at a glance.

The single output is named out, type * - wire it into anything, including a converted widget input.

How the empty case behaves

This is where the node earns its keep versus a naive switch. If index points at a pin with nothing connected, out is empty and nothing raises. If whatever is downstream treats that input as required, ComfyUI reports it as a missing input, same as any unconnected wire - the node doesn't try to be clever and substitute a zero or an empty tensor.

There's also a nice piece of frontend magic worth knowing because it explains cache behaviour. When index is set in the node itself (or comes from a Primitive Int), the browser strips the switch out of the prompt it sends: downstream nodes get wired straight to the picked source, or lose the wire entirely. So flipping the index is a real prompt change - you get a fresh run of exactly the branch you picked, and nothing else. When index comes from a computed value - some expression, some other node's output - the switch stays in the prompt and returns an empty value for "nothing" instead.

Install

It ships in Neural Dreamer's pack, which is the pack a Russian-language ComfyUI tutorial channel (YouTube, Boosty, Civitai) publishes alongside its workflows. Version 1.1.0, MIT, and dependency-free - the pyproject.toml declares dependencies = [], there's no requirements.txt, no models to fetch.

ComfyUI Manager → search "Neural Dreamer Nodes" → install → restart. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/neural-dreamer/ComfyUI-NeuralDreamer-Nodes.git

Then reload the browser tab, not just the queue. Some of this pack's behaviour is frontend code; a stale tab will show the old node.

Common issues

The pin count doesn't grow. You have to connect the last pin for a new one to appear. Two connected pins out of six visible is normal, and unrelated - the display trims to what's wired.

Index points past your pins. Easy to do once you've deleted a branch. You get an empty output and the downstream node complains about a missing required input, which reads like a bug and isn't. Count the pins, not the labels.

A branch you're not using still seems slow. Check that index is a widget value or a Primitive, not the output of some computed node. Computed index means the switch runs inside the prompt - and the browser-side pruning, which is what keeps the dead branch from executing, doesn't happen.

Nothing connects to out. The output pin takes its type from the picked input, so with nothing picked it's an untyped wildcard. Connect a source first, then wire out onward.

CategoryNeural Dreamer/Logic

Inputs (65)

NameTypeDefaultDescription
indexINT11–64Which input is passed on: 1 is the first pin, 2 the second, and so on.
in_1opt*—
in_2opt*—
in_3opt*—
in_4opt*—
in_5opt*—
in_6opt*—
in_7opt*—
in_8opt*—
in_9opt*—
in_10opt*—
in_11opt*—
in_12opt*—
in_13opt*—
in_14opt*—
in_15opt*—
in_16opt*—
in_17opt*—
in_18opt*—
in_19opt*—
in_20opt*—
in_21opt*—
in_22opt*—
in_23opt*—
in_24opt*—
in_25opt*—
in_26opt*—
in_27opt*—
in_28opt*—
in_29opt*—
in_30opt*—
in_31opt*—
in_32opt*—
in_33opt*—
in_34opt*—
in_35opt*—
in_36opt*—
in_37opt*—
in_38opt*—
in_39opt*—
in_40opt*—
in_41opt*—
in_42opt*—
in_43opt*—
in_44opt*—
in_45opt*—
in_46opt*—
in_47opt*—
in_48opt*—
in_49opt*—
in_50opt*—
in_51opt*—
in_52opt*—
in_53opt*—
in_54opt*—
in_55opt*—
in_56opt*—
in_57opt*—
in_58opt*—
in_59opt*—
in_60opt*—
in_61opt*—
in_62opt*—
in_63opt*—
in_64opt*—

Outputs (1)

NameTypeDescription
out*—