Nodes/Vantage-Nodes/Switch Latent (By Index)
ComfyUI Node

Switch Latent (By Index)

Choose one latent batch from four with a number — the latent router

By vantagewithai·Created 8 months ago·Updated about a month ago· 25
Switch Latent (By Index)
  • latent_1
  • latent_2
  • latent_3
  • latent_4
  • latent
index0

Same job as SwitchImageByIndex, but for LATENT tensors instead of images: up to four optional latent inputs, one integer, and the node passes through whichever slot the integer picks. Zero-based, so 0 → latent_1, 1 → latent_2, and so on. Nothing is blended or modified - you get exactly the latent batch you pointed at.

Latents are the representation before the VAE decode, so this is the switch you reach for when you're routing between different encoded candidates early in the pipeline - a few VAE-encoded reference frames, alternative latents from different conditioning, a batch you want to send down one of several sampling paths. It's the same "make the choice a data input instead of a rewiring chore" philosophy as the image switch, and it composes the same way: drive the index from a scheduler or random node and you get runtime routing.

What it needs

  • index - zero-based, defaults to 0. Any int works; out-of-range values return None rather than erroring.
  • latent_1 … latent_4 - the candidate batches, all optional. Only wire the slots you need.

One output: latent. If the index points at an unwired slot (or out of range), you get None out. That's the failure mode to remember: a router that silently passes None is indistinguishable from a broken wire until you check the index.

The useful trick

Because the node accepts a LATENT in any slot and does no processing, you can chain these to make wider switches - a "switch of switches" if you're routing more than four candidates. It also pairs naturally with a batch count or a counter node, so an iteration-driven workflow can cycle through latent candidates across runs.

One thing it won't do: validate that the selected latent has the same shape as the others. The router doesn't care - shape checks are the join nodes' job. If a downstream node then trips on a shape mismatch, you've routed latents of different resolutions into one consumer, which is on the workflow, not the switch.

Install

Part of Vantage-Nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/vantagewithai/Vantage-Nodes.git
pip install -r requirements.txt

or ComfyUI Manager → search "Vantage-Nodes" → Install → restart.

Common issues

  • Empty output - index points at an unwired slot or is out of range; you get None. Double-check the number maps to a wired slot.
  • Off-by-one - zero-based again. The second slot is index 1.
  • Shape mismatch downstream - the switch passes whatever you gave it; if your candidates differ in resolution, the sampler will complain later.
CategoryVantage/Latent

Inputs (5)

NameTypeDefaultDescription
indexINT0
latent_1optLATENT
latent_2optLATENT
latent_3optLATENT
latent_4optLATENT

Outputs (1)

NameTypeDescription
latentLATENT