BD Cache Latent
Cache the latent, not the pixels
- latent
- latent
- status
Here's a subtle one, and it's the reason you want a latent cache rather than an image cache for certain workflows. BD Cache Image freezes a finished picture. BD Cache Latent freezes the picture before it's a picture - the compressed tensor that comes out of the VAE encode. That's the right level to cache when the expensive part you're trying to skip is everything upstream of the encode, and the part you're still actively tweaking is downstream of it.
The classic case: image-to-image workflows where you run a big first pass (Hunyuan, a Qwen edit, a long ControlNet-guided generation), then iterate on the latent with different sampler settings, denoise strengths, or refiner passes. Encode once, cache the latent, and every sampler tweak reruns without paying for the encode - or worse, without re-running the whole upstream generation because the image branch got skipped too. Cache the latent and you keep the denoise iterations cheap.
The mechanism is the same lazy-evaluation family as the other BD caches: on a cache hit, check_lazy_status tells ComfyUI it doesn't need its inputs, so the entire upstream branch is skipped and the cached tensor is loaded instead. What's different is the file format. Latents save as safetensors, not PNG - which is exactly right, because a latent is a float tensor and PNG would destroy it. No precision loss round-tripping.
The inputs
- latent - the LATENT tensor to cache. Comes from a VAE Encode or anywhere else latents appear.
- cache_name - label for the entry (default
cached_latent). - seed - the invalidation key. The filename is hashed from it, so a new seed = a new cache file = a fresh encode. Change the seed when the upstream image actually changed and you want it re-encoded.
- force_refresh - True to overwrite the cached file and rerun upstream anyway.
- name_prefix - optional path prefix for organizing under
output/BrainDead_Cache/.
Outputs: latent (the tensor, loaded or fresh) and status ("Cache HIT"/"SAVED"). It behaves like a passthrough - wire latent into your KSampler exactly as you would from the VAE Encode directly.
A workflow worth stealing
[VAE Encode] → [BD Cache Latent] → [KSampler] → [VAE Decode]
cache_name: "pose_base"
seed: 42
First run encodes and caches. Now you can spend an afternoon cycling CFG, sampler, and seed on the KSampler and the encode runs exactly once. When you finally land on a base image you love, this is also how you keep it: bump the cache seed, let it regenerate once, and the old latent stays safe under its old hash.
Installing it
From BizaNator/ComfyUI-BrainDead (BrainDeadGuild): ComfyUI Manager → search "BrainDead" → install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/BizaNator/ComfyUI-BrainDead
cd ComfyUI-BrainDead
pip install -r requirements.txt
Restart and it appears under 🧠BrainDead/Cache. No extra dependencies for this one - the pack's heavier requirements are only for the Pixal3D nodes.
Gotchas
The usual seed trap applies double here: the cache is keyed on seed, so changing the VAE Encode's inputs without changing the cache seed will silently serve you the stale latent. And remember latents are resolution- and model-specific - a cached latent from an SDXL encode is only a cache hit for that same setup. If you change the latent size upstream, force a refresh. There's no version check; the cache doesn't know your sampler changed its mind, it just knows the seed.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| latent | LATENT | — | |
| cache_name | STRING | cached_latent | — |
| seed | INT | 00–18446744073709550000 | — |
| force_refresh | BOOLEAN | false | — |
| name_prefixopt | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| latent | LATENT | — |
| status | STRING | — |