ComfyUI Node

Save Universal Latent

Save the latent, decode in a clean room

By XxcomfyTestxX·Created 3 months ago·Updated 3 months ago· 2
Save Universal Latent
  • latent

    The classic ComfyUI death spiral on a video model: you generate, the sampler finishes, and then the VAE encode or decode blows up because the model is still parked in VRAM. The community fix, straight from r/comfyui, is almost embarrassingly simple - save the latent instead of decoding it, end the workflow, unload everything, and decode in a separate lean workflow with room to breathe. SaveUniversalLatent is the "save the latent" half of that trick, and it does it better than Comfy's own node for video latents.

    What it does

    It takes the LATENT you feed it, moves every tensor to CPU (the same recursive "universal" walk its conditioning sibling uses - it handles whatever dict shape the latent is, from a 512×512 SDXL sample to an LTX video tensor), and writes it with torch.save() to ComfyUI/input/ as Latent_00001_.latent - auto-incremented as you save more. It's an output node with no sockets: a terminal, like Save Image.

    Two details separate it from Comfy's native SaveLatent:

    • It saves the whole latent dict, not just the samples tensor. Comfy's core node serializes only samples via safetensors, which is exactly why video latents - which carry extra keys like frame counts, batch metadata, and audio - don't round-trip through it. This pack pickles everything, untouched.
    • It writes to input/, the folder every ComfyUI loader reads from, so other tools can grab what you saved.

    The one input that matters

    • latent - wire the LATENT out of a KSampler (or an EmptyLatentImage if you're pre-staging a canvas) into this. Nothing else to set.

    Why you'd reach for it

    The VAE OOM dodge above is the headline use, and it's a real one on mid-range cards: generate and save, then decode in a workflow that never loads the big model. Beyond that it's the tool for video workflows - save a generated latent, feed it into an img2vid or video-extension pass later without regenerating, or batch a bunch of prompt variations, save all their latents, and decode them in one pass to keep memory flat. If you're spending more time fighting memory pressure than generating, this node quietly changes the shape of your workflow.

    Install

    No dependencies, no model downloads - just ComfyUI itself, which already ships torch, folder_paths, and comfy.cli_args that this pack imports.

    • ComfyUI Manager → install from Git URL → https://github.com/XxcomfyTestxX/ComfyUI-SaveLoadUniversalConditioningLatent, then restart; or
    • cd ComfyUI/custom_nodes && git clone https://github.com/XxcomfyTestxX/ComfyUI-SaveLoadUniversalConditioningLatent and restart.

    Know what you're installing: a one-commit fork of endman100's ComfyUI-SaveAndLoadPromptCondition from a small, unmaintained-looking account. Fine for your own automation, not the backbone of a shared pipeline.

    Where people get burned

    The files are pickle (torch.save), not safetensors - so the .latent files Comfy's own nodes write to output/ will never show up in this pack's loader, and vice versa. Don't mix them up. And "universal" cuts both ways: it saves any latent, but a latent is only meaningful to the model family that produced it, so keep your Latent_*.latent files organized or you'll be decoding LTX samples through an SDXL VAE and wondering what happened.

    CategoryUniversalIO

    Inputs (1)

    NameTypeDefaultDescription
    latentLATENT

    Outputs (0)

    No outputs