Nodes/Tojioo Passthrough/Any Latent Batch Switch
ComfyUI Node

Any Latent Batch Switch

Stack latents into a batch without touching the batch size

By Tojioo·Created 11 months ago·Updated 7 months ago· 13
Any Latent Batch Switch
  • latent_1
  • latents

Any Latent Batch Switch combines several LATENT inputs into a single latent batch and hands the result to the latents output. One latent in, and it passes through unchanged; several in, and their sample tensors get stacked along the batch axis. If you've been fighting ComfyUI's "one latent, one batch size" layout - where sampling a few images means a fresh empty latent with a batch size typed in - this is the node that lets you assemble the batch from whatever latents you actually have.

It's the batch-merge sibling of the pack's Any Latent Switch (which selects one latent). This one merges, and it fits a real gap: core ComfyUI will happily batch empty latents, but batching latents you already encoded or carried from another pass is something you usually hacked around.

How it works

The node starts with latent_1 and grows a slot per additional latent source. With a single connected input it returns that latent unchanged. With several, the latent samples are unsqueezed as needed and concatenated along the batch dimension - again, only within the largest group of matching shapes, so mismatched resolutions mean the odd ones out are silently dropped. One subtlety worth knowing: when merging, the node builds a fresh latent from the concatenated samples and drops the per-entry batch_index bookkeeping, so downstream sampler nodes treat the result as one clean batch rather than fragments of others.

Where you'd use it

  • Batch generation. Assemble several pre-encoded latents into one sampler pass instead of retyping batch size.
  • Multiple passes. Carry latents from separate branches and combine them before the final sample.
  • Single-latent passthrough. One input wired = behaves like a plain passthrough.

Install

ComfyUI Manager → search "Tojioo Passthrough" → install, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Tojioo/tojioo_passthrough.git

Restart ComfyUI. No models or pip dependencies - the pack is lean Python plus a bundled frontend, on the Comfy Registry under publisher tojioo.

Common issues

Same shape-mismatch trap as the other batch switches, with an extra latent-specific wrinkle. Different resolutions don't error; the node batches the largest matching group and drops the rest, and since latents don't show you their shape at a glance, that's easier to miss than with images. And because a merged latent is rebuilt fresh (with batch_index dropped), don't expect per-entry noise/seed bookkeeping to survive the merge - if your downstream relies on noise_mask per entry, this node isn't preserving it. Keep one input wired or the node errors.

CategoryTojioo Passthrough/Dynamic Nodes/Batch Switch Nodes

Inputs (1)

NameTypeDefaultDescription
latent_1optLATENT

Outputs (1)

NameTypeDescription
latentsLATENT