XLatentLoad
Pick up where you left off — latent included
- latent_input
- latent
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:
latent_inputport - if you connect a LATENT from another node, that wins. No file involved.latent_filedropdown - if no input is connected, this loads from disk. The dropdown auto-scans your ComfyUI output directory (recursively) for.latentfiles, 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
.latentfiles 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.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| latent_file | COMBO | Latent file to load from ComfyUI output directory | |
| latent_inputopt | LATENT | Input latent from another node (higher priority than file loading) |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| latent | LATENT | Loaded latent tensor |