Nodes/ComfyUI-Image-Selector/LatentDuplicator
ComfyUI Node Runs on cloud

LatentDuplicator

Duplicate your latent once, sample it N ways — before the VAE tax

By SLAPaper·Created 3 years ago·Updated about a year ago· 107
LatentDuplicator
  • latent_image
  • LATENT
dup_times2

LatentDuplicator is ImageDuplicator's quieter sibling: same idea, but it works on the compressed latent before the VAE decode, so you can clone one encoded image into a batch of N and run N different sampling passes without paying for N encode/decode round-trips.

That's the whole reason the latent version exists. VAE encode and decode cost time and VRAM, and the community treats every encode/decode cycle as a small quality loss on top. The author's guidance in the README is to keep VAE work out of the duplication path: encode/decode -> duplicator is worse than duplicator -> encode/decode. So the intended flow is: encode your source image once, duplicate the latent, and only then decode whatever comes out of your N sampling passes. One encode, N experiments.

Inputs and outputs

  • latent_image (LATENT) - typically straight from VAEEncode, or from the sampler if you're cloning a sampled latent
  • dup_times (INT, default 2, range 1–16) - copies, total, including the original
  • Output: LATENT with dup_times batch slots

dup_times=1 is a passthrough no-op. Feed in one encoded image with dup_times=3 and you get a 3-latent batch, identical in content - the source just clones the tensor and concatenates along the batch dimension.

A common pattern: encode one reference image, duplicate it, then feed each latent to a separate img2img sampling branch with a different prompt, seed, or denoise strength. Since the copies are pixel-identical, whatever differences come out downstream are yours to create - the node only gives you the scaffolding.

The gotcha it shares with LatentSelector

Like LatentSelector, this node rebuilds the latent dict with only the samples key. Any extra keys - most importantly a noise_mask, which you'll have in inpainting workflows - are silently dropped. If your latent comes from a masked pipeline, check that the mask still applies after this node, or you'll wonder why your inpaint region suddenly isn't masked. It's a quiet one, and it's the kind of thing that makes people blame the sampler before they notice the node.

Install

Part of the same tiny pack, so there's nothing special here - no dependencies, no model downloads. Install once through ComfyUI Manager (search "Image Selector"), or:

cd ComfyUI/custom_nodes
git clone https://github.com/SLAPaper/ComfyUI-Image-Selector

Restart ComfyUI and it's in the latent category with LatentSelector. Given how often "batch this and compare" shows up in real workflows, it's a genuinely handy little utility - just remember it duplicates, it doesn't add variety, and don't expect it to carry a noise mask.

Categorylatent

Inputs (2)

NameTypeDefaultDescription
latent_imageLATENT
dup_timesINT21–16

Outputs (1)

NameTypeDescription
LATENTLATENT