ComfyUI Node

LatentCompose

Slerp two latents together without ever leaving latent space

By Apache0ne·Created about a year ago·Updated about a year ago· 1
LatentCompose
  • latent1
  • latent2
  • LATENT
ratio0.55

The name is a small lie in the best way. LatentCompose calls no API, needs no key, and doesn't even require you to understand the math hiding behind it. You feed it two LATENT tensors and a ratio, it hands back one latent that sits somewhere between them, and you keep right on sampling. The entire point is that you never decode to pixels in between.

Why you'd reach for it

Most "blend two images" workflows happen in pixel space: generate A and B, paste them together in an editor, feed the composite through a VAE Encode, and img2img from there. That round trip costs you. Encode-decode is lossy, and the paste job usually leaves seams the model then has to reinterpret. LatentCompose skips the trip - both inputs are already latents (from a VAE Encode, a sampler, or an unsampler), so the blend happens in the space the model actually works in.

The README tells you where this shines: "use with unsample nodes for best effects." That's the unsample → interpolate → resample family of tricks: unsample two images partway back toward noise, slerp their latents together, then sample forward again. It's how people mix two images' composition and content at a controllable depth, and it's also the base technique for adding detail back in an unsample/resample refinement pass.

How it works

This is proper spherical linear interpolation, not the lazy lerp a lot of "interpolate" nodes do. Each latent is flattened into one giant vector, and the node measures the angle between the two. Instead of walking the straight chord between them (which dips through a low-magnitude valley mid-way - that's the blurry middle you get with plain lerp), it walks the arc, weighting each endpoint by sin factors. The result stays closer to a real latent distribution at every ratio.

ratio does what you'd expect: 0.0 gives you latent1, 1.0 gives you latent2, and the default 0.55 is already slightly past center. The code falls back to linear interpolation automatically when the two latents are nearly parallel, so you won't hit a divide-by-zero surprise with two near-identical inputs.

The inputs and output

Three inputs, and only one needs your attention:

  • latent1, latent2 - the two LATENT tensors to blend
  • ratio - the blend point, 0 to 1, default 0.55

The single LATENT output wires straight into a KSampler's latent input to keep sampling, or into a VAE Decode if you just want to look at the blend. You can also chain it - pipe the output back into one of the inputs for a second-level blend.

Installing it

This pack is ComfyUI-LantentCompose (yes, "Lantent" - the whole pack is a tribute to spellchecker martyrdom). Easiest route: ComfyUI Manager, search "LantentCompose", install, restart. Or clone by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/Apache0ne/ComfyUI-LantentCompose

Then restart ComfyUI. The README's "Dependencies: None" is honest here - no pip install, no model downloads, nothing to fetch. The only imports are ComfyUI's own comfy.* modules, so this is one of the rare packs that just works after a clone.

Common issues

  • The latents must be the same shape. Same resolution, same channel count, same batch size. The classic failure is mixing an SD 1.5/SDXL latent (4 channels) with a Flux latent (16 channels) and getting something like The size of tensor a (4) must match the size of tensor b (16) - the same mismatch that trips people in LatentComposite workflows everywhere.
  • Same latent space, not just same shape. Two checkpoints with different VAEs will happily slerp and produce visual garbage, because "latent" isn't a universal currency. A shared VAE means a shared latent space; without that, don't blend.
  • The middle looks mushy. A 50/50 slerp of two scenes is still two scenes fighting for the frame. That's expected - nudge the ratio hard to one side or start from unsampled latents closer to noise.

LatentCompose is a niche tool, and it's usually not doing anything impressive on its own. Pair it with an unsampler and it becomes the hinge of a genuinely useful mixing workflow.

CategoryLatent/Advanced

Inputs (3)

NameTypeDefaultDescription
latent1LATENT
latent2LATENT
ratioFLOAT0.550–1

Outputs (1)

NameTypeDescription
LATENTLATENT