(deforum) Load Cached Latent
How Deforum hands a latent to the next frame
- LATENT
You can't draw a wire that goes backwards. ComfyUI's graph is a DAG, and animation is inherently a loop - frame N's latent has to come back around and become frame N+1's starting point. The whole "(deforum) Cache Latent" / "(deforum) Load Cached Latent" pair exists to fake that loop: one node stashes a latent in a slot, the other one pulls it back out on the next pass.
This node is the reader half of that pair. Its sibling, DeforumCacheLatentNode ("(deforum) Cache Latent"), writes; this one reads. Internally the pack keeps a small in-memory dictionary of latents keyed by an index, so you can hold several independent latent streams in the same graph without them stomping on each other. It's a genuinely simple mechanism - the interesting part is knowing when to reach for it.
What it's for
Anywhere a Deforum pipeline needs "the previous frame's latent" - which is most places. In the pack's base example workflow (examples/deforum_base.json), the cache/load pair carries the sampled latent from the KSampler output back into the next iteration's input. That's how an animation keeps evolving from its own output instead of restarting from noise every frame.
The inputs and outputs that matter
There's exactly one input and one output, and that's the whole charm.
- cache_index (INT, 0–16, default 0) - which slot to read from. Keep it in sync with the
cache_indexon the matchingCache Latentnode. If you're running two animations in one graph, give each its own index so they don't cross-talk.
Output:
- LATENT - the stashed latent, ready to wire into a sampler's latent input, a VAE decode, or a frame-warp node. If the slot is empty it returns
None, which is intentional and is how the loop resets.
One quirk worth knowing: when the pipeline signals a reset (the Iterator's reset_latent, or the global reset flag), this node returns None rather than the old value. That's not a bug - it's how the animation forgets its history and starts over cleanly, which is exactly what you want at frame 0 or when you change animation_mode.
Installing this pack
This node ships in Deforum Nodes by XmYx - one repo, one install, the whole "(deforum)" family comes with it. ComfyUI Manager: search for Deforum Nodes. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/XmYx/deforum-comfy-nodes
Restart ComfyUI. First install is the heavy part: there's no requirements.txt - the pack's install.py pulls the deforum-studio backend straight from GitHub, plus a long list of scientific packages with numpy pinned below 2.0. The README says Python 3.10 or nothing. The installer also tries stable-fast and warns (harmlessly) when that fails.
Common issues
- "None" flowing out of the node on the first run. Expected. Slot 0 starts empty; the load node returns
Noneuntil aCache Latentnode has written to it. Structure the graph so the cache node runs before the load node reads, or accept theNoneon frame 0. - Stale latents across restarts. The cache is in-memory only - close ComfyUI and it's gone. Restarting a long animation mid-way means starting from frame 0 again, which is why the reset flow exists.
- Wrong slot. Two different latent streams sharing
cache_index0 will clobber each other. Bump one of them to index 1.
If you want the same trick for images or text, the pack has identical Cache Image / Cache String nodes with the same slot system - same mental model, different data type.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| cache_index | INT | 00–16 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |