Nodes/ComfyUI-JDCN/JDCN_BatchSaveLatent
ComfyUI Node

JDCN_BatchSaveLatent

VAE-encode once, reuse forever β€” dump your latents to disk

By daxcayΒ·Created 2 years agoΒ·Updated about a year agoΒ· 159
JDCN_BatchSaveLatent
  • Latents
    β—„Directoryβ€”β–Ί
    β—„FilenamePrefixLatentβ–Ί

    JDCN_BatchSaveLatent is the write side of this pack's latent save/load pair: it takes a batch of latents and writes them to disk as numbered .latent files. The pitch, straight from the README: "save VAE encoding time or use later." If you're doing animation or video work where you re-run the same encoded frames under different prompts, this is the node that turns a repeated encode into a one-time cost.

    Why you'd use it

    Every encode-decode round trip costs compute - and in a video pipeline, you're encoding hundreds of frames per run. JDCN_BatchSaveLatent lets you encode once, save, and then iterate on prompts, samplers, and denoise settings against the saved latents instead of re-encoding each time. It's a workflow multiplier if you're the type to tweak a prompt eight times on the same keyframes. The sibling loaders (JDCN_BatchLatentLoadFromDir, JDCN_BatchLatentLoadFromList) bring them back.

    Inputs

    • Latents - the LATENT(s) to save (list-input).
    • Directory - where to write them. Created automatically if missing.
    • FilenamePrefix - the name prefix (default Latent). Files come out as Prefix_0001.latent, Prefix_0002.latent, and so on.

    There are no outputs - this is a terminal/output node. Wire latents in, queue, and files appear on disk. Nothing comes back for further wiring.

    How it behaves

    Two details from the source worth knowing. First, numbering: it counts existing files in the destination folder and continues past them, so saving into a folder that already has 5 files starts at _0006 - good for appending runs, mildly surprising if you expected to overwrite. There's no overwrite control; it always appends onward. Second, the format is this pack's own: comfy.utils.save_torch_file with the latent tensor stored under a latent_tensor key. Use the sibling loaders to read it back - don't expect stock ComfyUI nodes or other tools to understand it.

    Installing it

    Part of ComfyUI-JDCN:

    • ComfyUI Manager β†’ Install Custom Node β†’ search JDCN β†’ install ComfyUI-JDCN β†’ restart.
    • Or:
    cd ComfyUI/custom_nodes
    git clone https://github.com/daxcay/ComfyUI-JDCN.git
    cd ComfyUI-JDCN
    pip install -r requirements.txt
    

    Restart; under πŸ”΅ JDCN πŸ”΅. Only dependency is piexif, no models to download.

    Common issues

    Latent files are not small - a full video sequence's worth can eat disk fast. Budget space before pointing it at a long pipeline. If a save errors (bad directory, permissions, disk full), the node prints to the console and keeps going, so check the log for skipped files. And remember the round-trip rule: the latents only decode correctly against the checkpoint/VAE they came from. If you later load them with a different model and colors look wrong, that's the mismatch - re-encode with the intended model rather than debugging the loader.

    CategoryπŸ”΅ JDCN πŸ”΅

    Inputs (3)

    NameTypeDefaultDescription
    LatentsLATENTβ€”
    DirectorySTRINGβ€”
    FilenamePrefixSTRINGLatentβ€”

    Outputs (0)

    No outputs