Nodes/ComfyUI-TkNodes/Repeat Latent Batch (Optional)
ComfyUI Node

Repeat Latent Batch (Optional)

Batching a latent that turns nothing into nothing, not an error

By TensorKaze·Created about a year ago·Updated about a year ago· 0
Repeat Latent Batch (Optional)
  • samples
  • LATENT
amount1

This one does exactly what ComfyUI's stock RepeatLatentBatch does - take one latent and repeat it into a batch of N, so a single sampler call produces N results at once instead of you running the sampler N separate times - with one difference that only matters in a specific situation: if the latent you feed it is None, it returns None instead of erroring.

Why "None" instead of an error

That's a small thing, but it's the thread running through several nodes in this pack. If you're building a workflow with an optional img2img branch - say, chained after something like this pack's VAEEncodeOptional, which itself returns None when there's no source image - you want the whole optional branch to stay None-safe all the way down, not just the first node in it. RepeatLatentBatchOptional exists so that a batching step can sit in that chain without becoming the thing that breaks it when the branch is inactive. Feed it a real latent, it batches normally; feed it nothing, it passes nothing along.

Same caveat as everywhere else this pattern shows up: None only stays harmless as long as everything downstream is built to expect it. A stock KSampler still needs an actual latent - it doesn't know what to do with None any more than it would with a missing VAEEncode output. This node is for keeping an optional branch consistently optional, not for making a required latent input suddenly forgiving.

What batching actually buys you

When it does have a real latent, repeating it amount times and sampling the batch in one KSampler call isn't the same as getting amount identical images. Each item in a batch gets its own noise during sampling, so one graph pass with a batch of 4 typically gives you 4 different results from the same starting latent and seed - which is faster than queuing four separate runs and rewiring a seed each time, if what you're after is a handful of variations to pick from.

What matters

  • samples (LATENT, required) - the latent to repeat. If this is None, the node returns None and does nothing else.
  • amount (INT, default 1, range 1–64) - how many copies to batch. At the default of 1 this node is a no-op either way.

One output: LATENT - the batched latent, or None.

Installing it

Search ComfyUI-TkNodes in ComfyUI Manager, or:

cd ComfyUI/custom_nodes
git clone https://github.com/TensorKaze/ComfyUI-TkNodes
cd ComfyUI-TkNodes
pip install -r requirements.txt

Restart ComfyUI. Nothing heavy - this is a small logic node with no model or download dependencies of its own.

Common issues

Batch is bigger than my VRAM likes. amount goes up to 64 in the schema, but that's the node's ceiling, not a recommendation - a batch of 64 full-resolution latents through a large diffusion model will exhaust VRAM on most consumer cards long before 64. Push it up gradually and watch your usage.

Downstream node errors on None. Expected if whatever's next isn't built to tolerate an empty latent - a plain KSampler will still error on None exactly as it would on a missing input from any other node. This node only helps if the rest of the chain after it is also None-aware.

Not actually getting variety in the batch. If every image in the batch looks identical, double-check you're not forcing the exact same noise per batch item somewhere upstream (a fixed per-item seed override, for instance) - the variety comes from ComfyUI's normal per-batch-item noise generation, and something overriding that will flatten it back out.

Small, no-frills node from a small, no-frills pack - no community reputation to speak of, just a quietly useful bit of plumbing if you already lean on this pack's optional-branch pattern elsewhere in your graph.

Categorylatent/batch

Inputs (2)

NameTypeDefaultDescription
samplesLATENTThe latent to repeat. If None, returns None.
amountINT11–64Number of times to repeat the latent.

Outputs (1)

NameTypeDescription
LATENTLATENT