Nodes/ComfyUI LatentSaver/A1 Save Latent
ComfyUI Node

A1 Save Latent

Save your latent before Decode OOM eats an hour of video sampling

By A1-multiply·Created 7 months ago·Updated 2 months ago· 7
A1 Save Latent
  • samples
    filename_prefixlatent
    folder_nameSaved_Latent

    This node exists for one situation, and that situation is why the whole pack was built: your video sampler runs for an hour, finishes clean, and then VAE Decode blows up with a VRAM OOM. ComfyUI dies, and the run - the hour, the seed, all of it - is gone. The fix is absurdly simple in hindsight: save the latent right after sampling, before you ever hit Decode.

    A1 Save Latent is the write half of ComfyUI LatentSaver. It takes the LATENT that comes out of your KSampler or video sampler and dumps it to disk as a .pt file inside ComfyUI's output folder. Later - after a restart, on another machine, tomorrow - you load that file back with the pack's A1 Load Latent node and connect it straight to Decode, skipping the entire diffusion run. It's a checkpoint for your sampling work, not for the model.

    How it works

    What you're saving is the compressed latent-space representation - the VAE's "image, but smaller" that the diffusion model actually denoises. That's why reusing it is so cheap: the expensive part (sampling) is done, and decoding a latent is fast by comparison. One honest caveat: a latent is only meaningful to a VAE with the same channel layout, so you can't decode an SD 1.5 latent with a Flux VAE and expect anything but noise. Same model family, fine. Mixing VAE families, don't.

    Mechanically the node is simple and, importantly, safe. It calls torch.save on the whole samples dict, but first it moves every tensor to CPU - so it frees GPU memory as it saves, which is the opposite of making your OOM problem worse. It writes to output/<folder_name>/<filename_prefix>.pt, and it refuses to write anywhere else: absolute paths get stripped back to defaults, and there's a realpath containment check that raises if a path escapes the output folder. If a file with your name already exists it appends _01, _02, and so on, so you never silently overwrite a latent you cared about. There are zero dependencies - no requirements file, no model downloads. It's torch + ComfyUI's folder utilities.

    The inputs that matter

    Three inputs, all simple:

    • samples (LATENT) - wire this from your sampler. Nothing else takes the place of this.
    • filename_prefix (default latent) - the file name; the .pt extension is added for you, and if you type it anyway the node strips the duplicate.
    • folder_name (default Saved_Latent) - the subfolder under output it goes into. Use a descriptive folder per project; it's how you'll keep this from becoming a junk drawer.

    It's an output node with no outputs - it just does its job and reports the path to the console.

    Installing

    Either ComfyUI Manager (search ComfyUI LatentSaver) or the usual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/A1-multiply/ComfyUI-LatentSaver
    

    Restart ComfyUI. That's it - no models, no pip install, nothing else.

    Where people get burned

    The file lands in ComfyUI/output/Saved_Latent/latent.pt, not input - that trips people up if they go looking with a file browser. And remember the file list on the Load side is built when the page loads, so after you save, refresh the browser (F5) before hunting for it in the dropdown. The author has said the built-in core Save Latent node annoyed him enough to write this, and a few commenters on his announcement post correctly pointed out that ComfyUI ships its own. Fair - but the built-in one is pickier about paths, and this one's recursive auto-scan on the load side plus free subfolder naming is genuinely easier for the "keep a library of good samples" workflow.

    CategoryA1_latent_saver

    Inputs (3)

    NameTypeDefaultDescription
    samplesLATENT
    filename_prefixSTRINGlatentFile name for the saved latent (extension is added automatically).
    folder_nameSTRINGSaved_LatentSubfolder to create inside the ComfyUI output directory. Saving outside the output directory is not allowed.

    Outputs (0)

    No outputs