LatentToBatch
Replace or insert a latent inside an existing batch
- latent_batch
- latent
- latent
ComfyUI is happiest when every image in a batch is processed the same way, and miserable when you want to swap one item in a batch and leave the rest alone. That's the gap this node fills: it takes an existing LATENT batch, plus a single latent (or sub-batch), and replaces or inserts it at a chosen batch index. Nothing exotic, but it's the kind of glue that unblocks workflows like "generate a grid, then rerun one slot with a different seed/prompt and re-insert it."
The operation is deliberately simple. You give it the existing latent_batch, the latent to place, an index, and a mode:
mode: replace(default) - overwrites the item(s) atindex. Batch size stays the same. The index must point at an existing item.mode: insert- shifts existing items right and places the new latent atindex. You can also useindexequal to the current batch size to append. Batch grows.
The one non-obvious thing to know: this node is metadata-aware. If both inputs carry a noise_mask, they get spliced together properly (singleton masks are expanded to match the sample count), and existing batch_index metadata is preserved and spliced when present. So if you're re-inserting a latent that came out of a masked/inpaint pipeline, you don't lose the mask bookkeeping - a surprisingly common thing to break in hand-rolled batch surgery.
The constraints that bite
Because it's splicing tensors, the latent you place must match the batch's shape after the batch dimension - same spatial size, channels, dtype, and device. Trying to drop a 1024×1024 latent into a batch of 512×512 latents is a hard error, not a silent corruption. That's worth knowing up front: this is a batch surgery node, not a resize node. Resize/encode first, then splice.
Installing and using it
Part of the Skoogeer-Noise pack. ComfyUI Manager → search "Skoogeer-Noise", or:
cd ComfyUI/custom_nodes
git clone https://github.com/ttulttul/Skoogeer-Noise
Restart ComfyUI. No models or keys; deps are torch, numpy, einops, pyyaml.
A natural workflow: run a KSampler with batch_size 4, take one latent out of the grid, perturb it (this pack is full of perturb nodes - mesh drag, swirl, channel transforms), then LatentToBatch it back in at the same index and decode the whole grid in one shot. The mode choice matters more than it looks: reach for replace when you want to keep grid size constant and insert when you're progressively building a batch. And if you're in a list-iteration workflow, note the pack also ships Models List for model fan-out and ListSlice/Reorder List for list surgery - the batch and list utilities are meant to be used together.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| latent_batch | LATENT | Existing latent batch to modify. | |
| latent | LATENT | Latent or latent batch to place at the requested index. | |
| index | INT | 00–4096 | Batch index where the latent is placed. |
| mode | COMBO | replace | replace overwrites existing item(s); insert shifts existing items right. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| latent | LATENT | — |