VAEEncode (Bundle Latent)
A VAE encode that ships its output inside the workflow file
- vae
- image
- latent
Normal VAE encode, plus one trick: it can stash the resulting latent directly inside the workflow's own embedded metadata. That means if you share the workflow file (or a PNG with the workflow baked in), the "starting latent" travels with it - no separate .latent file to lose, no "here's the image, now go re-encode it yourself" step for whoever you send it to.
How it works
Point it at an image and a VAE and it encodes like any VAE Encode node. The difference is store_or_load_latent: with it on, the node writes the encoded latent into the workflow's metadata the first time it runs, and on later runs (or when someone else opens the same workflow file) it can load that stored latent back out instead of re-encoding from the image. That's the whole pitch - a "starting latent" that's portable inside the workflow itself, which matters most for the case in the README: sharing a workflow that depends on a specific starting latent, without also having to ship a loose file alongside it.
There's tiled encoding too, same idea as any tiled VAE encode: split a large image into tiles to keep VRAM down, at some cost to speed.
The inputs and outputs that matter
vae(VAE) - required, the VAE to encode with.image(IMAGE, optional) - the image to encode. It's optional because if you're loading a previously-stored latent from the workflow metadata, you don't need a fresh image at all.store_or_load_latent(default true) - the core toggle. On: store the latent into the workflow metadata if it's not there yet, or load it back out if it is.tiled(default false) /tile_size(default 512, 320–4096) - standard tiled-encode knobs for large images on tight VRAM.remove_latent_on_load(default true) - after loading a stored latent, delete it from the workflow so it doesn't sit there bloating the file on every subsequent save.delete_workflow_latent(default false) - force-clear any stored latent before this run, if you want to guarantee a fresh encode regardless of what's cached.
Single output: latent (LATENT), same as any encode node - feed it to your sampler as usual.
How to install it
Via ComfyUI Manager: search "WAS_Extras", install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/WAS_Extras
Restart ComfyUI. No extra dependencies for this node - it's plain torch/VAE work, same as core ComfyUI's own encode node.
Common issues & troubleshooting
A shared workflow keeps returning a stale latent instead of encoding your new image. That's store_or_load_latent doing exactly what it's for - once a latent is stored, the node prefers loading it over re-encoding. If you want a fresh encode from a new image, set delete_workflow_latent to true for that run, or turn store_or_load_latent off entirely.
Workflow file size keeps creeping up. A stored latent is real data sitting in your workflow's JSON. Leave remove_latent_on_load on unless you specifically need the latent to persist across many runs - otherwise every save keeps carrying that payload around.
Tiled encode looks seamy at tile boundaries or is unexpectedly slow. That's the standard trade-off with any tiled VAE encode, not specific to this node - smaller tile_size saves more VRAM but risks visible seams and costs more time; only turn tiled on when you're actually VRAM-constrained on a large image.
You just wanted a normal VAE encode. This node is a strict superset of that - leave store_or_load_latent off and it behaves like a plain encode with no metadata side effects.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| vae | VAE | The VAE that turns the image into a latent. Use the one belonging to the checkpoint that will sample it. | |
| tiled | BOOLEAN | false | Whether the image is encoded a tile at a time instead of all at once. Tiling holds far less in VRAM, which is what makes a very large image encodable on a small card, at the cost of being slower and of faint seams where tiles meet. |
| tile_size | INT | 512320–4096 | Edge of one tile in pixels, read only when tiled is on. Smaller tiles use less VRAM and take longer: 512 is a safe starting point, and 1024 or more is worth trying if the card has room. |
| store_or_load_latent | BOOLEAN | true | Whether the workflow is used as the latent's home. On, the node reads a latent already bundled in the workflow rather than encoding, and writes the one it encodes back into it so the next save carries it. Off, the node is an ordinary VAE encode and touches nothing. |
| remove_latent_on_load | BOOLEAN | true | Whether a bundled latent is taken out of the workflow once it has been read. On, it is used once and the saved file is left clean, which suits carrying a starting point into a run. Off, it stays in the workflow and every later save keeps carrying it. |
| delete_workflow_latent | BOOLEAN | false | Turn on for one run to throw away whatever this node has bundled and encode the image again. That is the way out when the stored latent no longer matches the image, or when a shared workflow arrived with one that is not wanted. |
| imageopt | IMAGE | The image to encode. It can be left unconnected when the workflow already carries a bundled latent, which is what lets a workflow be reopened and run without the picture it started from. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| latent | LATENT | The encoded latent, or the one that was bundled in the workflow when there was one to read. |