Save Latent Batch ๐
Skip the PNG, cache raw latents to disk instead
- latents
Most save nodes in ComfyUI expect you to VAEDecode first - turn the latent back into pixels, then write a PNG. Save Latent Batch skips that step entirely and writes the raw latent tensor to disk instead. It's a small node with an obvious niche: building a dataset that's already in latent space, so a downstream training script (or a later ComfyUI run) doesn't have to re-encode the same images through the VAE every time it needs them.
What it does
latents is your batch, folder is where to write them, extension picks the file format (npy by default - a plain NumPy array, loadable in any Python script with numpy.load, no ComfyUI required to read it back), and seed most likely feeds into the output filenames so you can trace which generation produced which saved file. This node has no outputs - it's a terminal, is_output_node: true - it exists purely to write files as a side effect, same shape as SaveImage but for latents instead of pixels.
The README doesn't spell out the exact folder-path convention (relative to ComfyUI's output directory, or an absolute path), so the safe first move is testing with a simple relative folder name and checking where the files actually land before building a bigger pipeline around it.
Why you'd want this
Latent caching is a real, recurring pattern in LoRA and fine-tune training pipelines: encoding the same dataset through a VAE on every training epoch is wasted compute if the images and encoder aren't changing between runs. Precomputing and saving the latents once, then loading them directly, is a standard efficiency move - this node is a lightweight way to produce exactly that cache from inside a ComfyUI graph rather than needing a separate script.
Installing it
Via ComfyUI Manager: search cgem156-ComfyUI, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/laksjdjf/cgem156-ComfyUI
Restart afterward. No model downloads, no extra dependencies for the node itself.
Common issues & troubleshooting
No image preview after running the node. That's expected - this node doesn't decode or display anything, it only writes raw tensor files. If you want to see the images too, run a parallel VAEDecode + SaveImage off the same latents; this node doesn't replace that, it's for a different purpose entirely.
Files aren't where you expected. Check whether folder resolved relative to ComfyUI's output directory or as a literal path - this isn't documented in the README, so confirm it once with a throwaway test run before relying on the location for a real pipeline.
Downstream training script can't read the saved files. Raw latents aren't pixel images - don't try to open a .npy latent file in an image viewer, and make sure whatever's consuming these expects the same latent shape and scaling convention ComfyUI itself uses. A mismatch here is a data-format problem, not a bug in this node.
You're not sure this is what you need. If your goal is just saving generated images normally, this is the wrong node - reach for the standard SaveImage after a VAEDecode. This one is specifically for people who know they want a latent-space cache, most commonly for training prep.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| latents | LATENT | โ | |
| folder | STRING | โ | |
| extension | COMBO | npy | 2 options: npy, npz |
| seed | INT | 00โ18446744073709550000 | โ |
Outputs (0)
No outputs