Latent Batch Index
The seed-sharing knob for batches
- samples
- LATENT
Straight up: most people will never need this node, and the author is fine with that. The README says it plainly - normal batch generation already uses different initial noise per image, so without this node every latent in your batch starts from its own random noise. That's usually exactly what you want. Latent Batch Index exists for the one case that matters: when you want the sampler to reuse the same initial noise across some or all of the batch items.
Why would you? Think of it as the batch version of "same seed, different prompt" A/B testing. You're generating a row of concept variations - a red sports car, a blue medieval castle, an alien forest - and you want them to share the same starting composition so the comparison is about the prompt, not the luck of the draw. Same starting noise, different conditioning, different result. That's the trick this node exposes as a dropdown.
How it works
It's thin, and that's the point. ComfyUI's KSampler reads a batch_index key inside the latent dict when it generates noise per item. This node sits between EmptyLatentImage and the sampler's latent_image input and just sets or clears that key:
- different_noise_per_prompt (the default): clears
batch_indexentirely, which restores normal ComfyUI behavior - every latent gets its own noise. This is why you don't need the node for the common case. - same_noise_for_all_prompts: sets the index list to
[0, 0, 0, ...], one per latent. Items sharing an index share initial noise. Same composition across the whole batch. - custom_batch_indices: you type one integer per latent, comma- or whitespace-separated. Items with the same number share noise, so a four-item batch with
0, 0, 1, 1gives you two seed-sharing pairs.
Under the hood it copies the latent dict and only touches that key - your samples tensor passes through untouched, and the node returns a LATENT you feed straight into KSampler. Note "initial noise" is the whole scope: the rest of sampling still does its thing, so two same-index items won't be pixel-identical, just start from the same place.
Inputs, outputs, and the one real trap
Three inputs, all required: samples (LATENT), the mode dropdown with those three choices, and custom_batch_indices - a multiline string whose tooltip is the honest summary: "Used only in custom_batch_indices mode. Enter one integer per latent, separated by commas or whitespace." Output is a single LATENT.
The trap is the custom mode's strictness, right there in the source: it must get exactly one integer per latent item, all zero or positive, or it raises. Four latents and three numbers → error. It won't silently pad or truncate, which is the right behavior - you just have to count. Wire it up as:
EmptyLatentImage -> Latent Batch Index -> KSampler latent_image
Install
Same as the rest of the pack - ComfyUI Manager, search "multi prompt batch", or clone it in:
cd ComfyUI/custom_nodes
git clone https://github.com/JousiaPiha/comfyui-multiprompt-batch
Restart, and it shows up under conditioning/multi prompt batch. No dependencies beyond what ComfyUI already has, no model files. It's a five-minute install for a knob you'll reach for maybe once a week - but when you need the "same noise, different prompt" batch trick, there's nothing simpler in core.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| samples | LATENT | — | |
| mode | COMBO | different_noise_per_prompt | 3 options: different_noise_per_prompt, same_noise_for_all_prompts, custom_batch_indices |
| custom_batch_indices | STRING | Used only in custom_batch_indices mode. Enter one integer per latent, separated by commas or whitespace. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |