Nodes/ImagesGrid/LatentCombine
ComfyUI Node

LatentCombine

Merging Latent Batches Before the VAE

By LEv145·Created 3 years ago·Updated 2 years ago· 206
LatentCombine
  • latent_1
  • latent_2
  • LATENT

If you've ever wanted to compare two samplers side by side, you've hit the awkward middle: run them as two separate KSamplers, and each one hands you its own latent batch - and you can't decode them together or grid them in one go. LatentCombine is the pack's answer: it merges latent_1 and latent_2 into a single LATENT batch so one VAEDecode turns both into images, and a grid node shows them all on one canvas. It's the exact pattern the pack's own "XYZ plot" workflow is built on: two samplers, LatentCombine, VAEDecode, ImagesGridByColumns.

How it works

A latent in ComfyUI is a dict with a samples tensor - the compressed representation the diffusion model works in. LatentCombine does torch.cat((latent_1["samples"], latent_2["samples"]), 0): it concatenates the two sample tensors along the batch axis and returns a fresh latent dict. So two samplers each producing one image becomes one latent batch of two, and a single VAEDecode turns the whole thing into an IMAGE batch. That's the entire mechanism, and it's elegant for exactly one reason: you decode once, grid once, and everything stays in lockstep.

There's one detail the source makes plain and the docs never mention: the output latent dict contains only samples. If either input latent carried a noise_mask (from masked inpaint workflows), that mask is silently dropped on the floor. For plain text-to-image comparison runs you'll never notice. For inpaint comparisons you absolutely will.

The inputs

  • latent_1 (LATENT) - first latent batch.
  • latent_2 (LATENT) - second latent batch.

Output is one LATENT - the combined batch - wired into VAEDecode. After decode, the resulting IMAGE batch feeds ImagesGridByColumns or ImagesGridByRows.

Installing the pack

Part of ImagesGrid (LEv145/images-grid-comfy-plugin). ComfyUI Manager: search "ImagesGrid", or:

cd ComfyUI/custom_nodes
git clone https://github.com/LEv145/images-grid-comfy-plugin ImagesGrid

then restart. Torch is already there; no other dependencies, models, or keys.

Where people get burned

The mask drop above is the sneaky one. The other classic trap is resolution: all latents in a batch have to share the same spatial size, so if your two samplers ran at different dimensions, the merged batch is ragged and the VAE decode will fail or produce garbage. Standardize the resolution before combining, not after.

Worth saying straight: this is the same job ComfyUI's core LatentBatch node does, so you don't strictly need this pack for the merge alone. But if ImagesGrid is already installed for the grid viewer - which is the whole reason it exists - LatentCombine saves you pulling in core's version and keeps the workflow in one vocabulary. The community's honest take on the pack applies here in miniature: the individual nodes are fine, but building the big comparison workflows around them means duplicating samplers until the wiring costs more than the comparison. For a two-sampler side-by-side, though, this is a tidy three-node hop.

CategoryImagesGrid

Inputs (2)

NameTypeDefaultDescription
latent_1LATENT
latent_2LATENT

Outputs (1)

NameTypeDescription
LATENTLATENT