Nodes/ComfyUI-RefUNet/REF] Prep Sampling Latents
ComfyUI Node

REF] Prep Sampling Latents

The most honest node in the pack does nothing on purpose

By logtd·Created 2 years ago·Updated 2 years ago· 46
REF] Prep Sampling Latents
  • src_latents
  • ref_latents
  • LATENT

PrepareRefLatents is the rare node whose README-description would be: "a trick." Look at the code and it takes two LATENTs - src_latents and ref_latents - then returns src_latents unchanged. It doesn't mix them, it doesn't denoise anything, it just passes your source latent straight through. So why does it exist?

Execution ordering. ComfyUI runs a graph lazily, based on what wires into what. In a reference-UNet workflow you have two sampling passes running on two different models: the write pass encodes the reference image, and the read pass actually animates. The read pass needs to be sure the write pass has finished - otherwise its sampler tries to read a ref_bank that's still empty. By threading the reference latent (and everything upstream of it) through this node and into the read pass's latent_image slot, you create a hard dependency: the read sampler literally can't run until the reference has been encoded and written.

So the ref_latents input is mostly a delivery mechanism for ordering, and src_latents is the payload that gets handed onward. In the example workflow you'll see exactly that: the write-pass sampler's output feeds ref_latents, your actual source-image VAE encode feeds src_latents, and the output goes into the animation pass's SamplerCustom. Same graph would probably work without the node in some ComfyUI versions, but the author built it in to make the dependency explicit and deterministic - and if you're cargo-culting a working FYE workflow, you keep it.

There's nothing to configure, no models to download, and it costs you basically nothing. It's not a fix for anything on its own; it's plumbing. The thing to get right is the wiring: make sure the reference latent chain (not your video latents) lands on ref_latents, because that's what actually forces the ordering you want.

Install is shared with the whole pack - ComfyUI Manager → search "ComfyUI-RefUNet", or git clone https://github.com/logtd/ComfyUI-RefUNet into custom_nodes/ and restart. No Python requirements, per the README. If you're debugging a workflow where the animation pass clearly runs before the reference is ready (flickering, washed-out frames that never match the source), this node is the intended guard rail - double-check it's actually sitting between the write pass and the read sampler.

Categoryreference

Inputs (2)

NameTypeDefaultDescription
src_latentsLATENT
ref_latentsLATENT

Outputs (1)

NameTypeDescription
LATENTLATENT