ComfyUI Node

SaveLatent_AS

Save a latent to disk — and here's exactly where it lands

By flyingshutter·Created 3 years ago·Updated about a year ago· 8
SaveLatent_AS
  • latent_in
  • LATENT

SaveLatent_AS writes a LATENT to disk as a .pt file, then passes the same latent through so you can keep using it in your graph. It's the save half of a latent-persistence pair with LoadLatent_AS in the same pack - save a latent in one workflow, pick it up in another, skip the decode/encode round trip entirely.

There's a catch you need to know up front: the filename is hardcoded to latent.pt, and it's saved to ComfyUI's current working directory - the folder you launched ComfyUI from, not your models or output folder. There's no file picker, no name field, no options. That's not a bug in your setup; that's just what this node is.

How it works

The mechanism is a single torch.save(latent_in, 'latent.pt'). A latent is a Python dictionary - the samples tensor plus its metadata - and torch.save serializes it to disk with PyTorch's own format. The node returns the input latent unchanged, so you can insert it into a pipeline as a "save a copy here" side branch without interrupting the flow.

The inputs

  • latent_in - the LATENT to save. Output: the same LATENT (passthrough).

That's it. The file always lands at latent.pt in the working directory.

Where you'd use it

The intended use case is checkpointing mid-pipeline: run the expensive part of a workflow up to a latent, save it, then experiment with different samplers or denoise settings on the same latent without re-running the early stages each time. Since the latent is already in latent space, loading it back with LoadLatent_AS avoids a VAE decode/re-encode cycle - and as the KB's notes on shared latent spaces point out, each decode/encode round trip is lossy, so skipping it preserves quality.

It's also the pack's answer to persistent latents for people who want the simplest possible version. If you need named files, a picker, or organized storage, this isn't it - core ComfyUI and several packs do proper latent save/load with file selection.

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/flyingshutter/As_ComfyUI_CustomNodes

Restart ComfyUI and it's under ASNodes (or ComfyUI Manager → "As_ComfyUI_CustomNodes"). No extra dependencies.

Common issues

  • "Where did my file go?" It's in the working directory - where you started ComfyUI. If you launch from a shortcut or a script, that's the folder to look in. The source even carries a commented example pointing at e:/portables/ComfyUI_windows_portable/latent.pt, confirming it's a working-dir file, not a managed one.
  • Silent overwrite. Because the name never changes, every save clobbers the previous latent.pt. If you need multiple saved latents, this node can't do it - save copies externally or use a proper tool.
  • Loading from a different directory. LoadLatent_AS uses the same relative path, so if you relaunch ComfyUI from another folder, the save and load no longer see each other. Keep the working directory consistent.

It's a two-line node with a hardcoded filename. For quick latent checkpoints in one environment it works fine; for anything more organized, you'll want a real latent saver.

CategoryASNodes

Inputs (1)

NameTypeDefaultDescription
latent_inLATENT

Outputs (1)

NameTypeDescription
LATENTLATENT