ComfyUI Node

XLatentLoad

Pick up where you left off — latent included

By Xz3r0-M·Created 8 months ago·Updated about 6 hours ago· 13
XLatentLoad
  • latent_input
  • latent
latent_file

Most of what ComfyUI saves is finished pixels. But sometimes you want to stop a generation partway - right after the VAE encode, before the sampler, or mid-diffusion - and come back to it later. That's what latents are for, and XLatentLoad is the load half of the story: it grabs a .latent file from your ComfyUI output directory and hands you back the tensor as a proper LATENT. If you're doing multi-session img2img, debugging a sampler chain, or just want reproducible intermediate states, this is the node that makes "save now, resume Tuesday" work.

How it works

Two sources, with a clear priority order that the source code spells out:

  1. latent_input port - if you connect a LATENT from another node, that wins. No file involved.
  2. latent_file dropdown - if no input is connected, this loads from disk. The dropdown auto-scans your ComfyUI output directory (recursively) for .latent files, so new saves show up without you typing paths.

If neither is available, it raises "No latent provided via input port or file selection" instead of returning garbage. Under the hood it uses safetensors to read the file, validates the content, and detects the latent format version so older and newer saves both load. What you get out is a standard latent dict - the compressed representation, 8x smaller per side than the image it encodes, which is why it round-trips so cleanly.

The one thing to understand

A latent is not an image, and it's not model-agnostic. When you load a latent you're loading a tensor in a specific latent space - the space defined by the VAE that encoded it. Feed a Flux latent into an SDXL pipeline and you get noise or flat garbage, not "slightly wrong." The KB's writeup on latent spaces is the right mental model: a latent only means something in the space of the VAE that produced it. So XLatentLoad and XLatentSave are best used as a pair, saving and resuming within the same model family, or deliberately across models that share a VAE/latent space.

Inputs and outputs

  • latent_file - the dropdown of available .latent files in the output dir.
  • latent_input - optional LATENT input that overrides file loading.
  • latent - the loaded latent, ready for the sampler.

Installing it

Part of ComfyUI-Xz3r0-Nodes. ComfyUI Manager: search ComfyUI-Xz3r0-Nodes, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Xz3r0-M/ComfyUI-Xz3r0-Nodes.git
cd ComfyUI-Xz3r0-Nodes
pip install -r requirements.txt

Restart ComfyUI. safetensors is already part of any ComfyUI install, so no extra dependency here.

Gotchas

The mismatch trap is the big one - save with one model family, load into another, wonder why the output is mush. Keep a note of which checkpoint/VAE produced a latent if you're storing many. Second, the dropdown only lists files in the output directory by default; if you save latents elsewhere, point your workflow accordingly. And be aware that a latent file is usually bigger than the PNG it would decode to, so it's a working-state format, not an archival one - save the PNG for sharing, save the latent for resuming.

Category♾️ Xz3r0/File-Processing

Inputs (2)

NameTypeDefaultDescription
latent_fileCOMBOLatent file to load from ComfyUI output directory
latent_inputoptLATENTInput latent from another node (higher priority than file loading)

Outputs (1)

NameTypeDescription
latentLATENTLoaded latent tensor