Nodes/cgem156-ComfyUI๐ŸŒ/Reference Latent ๐ŸŒ
ComfyUI Node

Reference Latent ๐ŸŒ

Pull one item out of a batch and re-batch it

By laksjdjfยทCreated 2 years agoยทUpdated about a month agoยท 93
Reference Latent ๐ŸŒ
  • latent
  • LATENT
โ—„index0โ–บ
โ—„batch_size1โ–บ

A small, purely mechanical node: it takes a batch of latents, picks out one specific item from that batch by index, and outputs a fresh batch made entirely of copies of that one item. Nothing generative happens here - no sampling, no conditioning, just batch selection and expansion.

Why you'd want this

If you've run a batch generation (say, from an XY strength sweep, or just a batch of random seeds) and landed on one result you actually like, this is a clean way to pull just that one out and turn it into a fresh batch for a next step - a second pass at higher denoise, a batch of variations seeded from that single latent, or feeding a batch_size-wide operation that expects more than one item even though you only care about one source. Rather than manually splitting the batch with more general-purpose tensor nodes, this does the specific "index in, repeated batch out" operation in one step.

Inputs and outputs that matter

  • latent - your source batch of latents.
  • index (default 0, range 0โ€“256) - which item in the batch to pull out. Index 0 is the first item, same zero-based convention as everywhere else in ComfyUI.
  • batch_size (default 1, range 1โ€“256) - how large a batch to produce from that single selected item. Set it to 1 if you just want the one item isolated; set it higher if you want that same latent repeated to fill a batch for a downstream node that needs one.
  • Output: LATENT - a new batch, batch_size copies of whatever was at index in the input.

Installing it

ComfyUI Manager โ†’ search cgem156-ComfyUI๐ŸŒ โ†’ install โ†’ restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/laksjdjf/cgem156-ComfyUI

then restart ComfyUI. Nothing extra to download for this node.

Common issues & troubleshooting

Index out of range. If your input batch has fewer items than the index you set, you're asking for something that isn't there - keep index inside the actual size of your incoming latent batch, which the slider's 0โ€“256 range doesn't enforce for you (it's just the widget's outer bound, not a guarantee your batch is that large).

Output looks identical across the whole batch - that's expected. Since every item in the output is a copy of the same selected latent, don't expect variation across the new batch on its own. If you want variation from that starting point, you need to add noise or run it through a sampler with a different seed per item afterward - this node itself doesn't introduce any.

Wrong item selected. Double check which item you actually wanted before wiring this up - if the upstream batch order isn't obvious (e.g. it came out of an XY sweep), preview or save the full batch first so you know which index corresponds to the result you liked, rather than guessing.

Using this expecting an image-reference/IP-adapter style effect. This node works purely on latent batch indexing - it has no concept of "reference image conditioning" the way some reference-guided generation techniques do. If that's what you're after, look for a dedicated reference-conditioning or IP-Adapter node instead.

Categorycgem156 ๐ŸŒ/reference

Inputs (3)

NameTypeDefaultDescription
latentLATENTโ€”
indexINT00โ€“256โ€”
batch_sizeINT11โ€“256โ€”

Outputs (1)

NameTypeDescription
LATENTLATENTโ€”