Nodes/was-node-suite-comfyui/VAEEncode (Bundle Latent)
ComfyUI Node Runs on cloud

VAEEncode (Bundle Latent)

The workflow that carries its own starting image

By WASasquatch·Created 4 years ago·Updated a day ago· 1,864
VAEEncode (Bundle Latent)
  • vae
  • image
  • latent
◄tiledfalse►
◄tile_size512►
◄store_or_load_latenttrue►
◄remove_latent_on_loadtrue►
◄delete_workflow_latentfalse►

Every shared ComfyUI workflow has the same hole in it. You post a graph, someone loads it, and the Load Image node is red because the PNG was on your drive and not theirs. Prompts travel fine, seeds travel fine, the picture you actually fed the sampler does not.

VAEEncode (Bundle Latent) is the pack's answer to that. It encodes an image to a latent like the core VAE Encode does, and then - if you leave it on - packs that latent into the workflow file itself, base64 and zlib'd, stored in the workflow document. Send the .json to someone and the starting point goes with it. No image file, no "which one did you use?".

How the bundle actually works

Two things are worth knowing, because they explain every weird moment you'll have with this node.

The latent isn't written to disk anywhere. It lives in the workflow's own extra dictionary, which the node gets at via extra_pnginfo - the same hidden metadata that ends up inside your saved PNG. So it only exists as long as the workflow does, and it travels exactly as far as the workflow travels.

The node also keeps a hash of the last image it encoded, per node id, for the life of the ComfyUI process. That's the staleness rule, and it's slightly counterintuitive: a latent bundled earlier in this same session is treated as stale the moment you connect an image, and the image wins. Only a bundle that arrived with the workflow file gets loaded in preference to encoding. So if you're staring at your image and wondering why it re-encoded, that's correct behaviour, not a bug.

The settings that matter

store_or_load_latent defaults to on and is the whole feature: with it on, the node reads a latent already in the workflow rather than encoding, and writes the one it encodes back for next save. Turn it off and this is a plain, quiet VAE encode.

remove_latent_on_load (on by default) uses the bundle once and takes it back out of the file, which keeps the thing you hand over clean. If you want the latent to keep riding along through every save, turn it off.

delete_workflow_latent is the ejector seat. Flip it on for one run and whatever bundle is sitting in the workflow is thrown away and the image encoded fresh. That's your move when a shared workflow arrived carrying a starting latent you didn't want, or when the bundle no longer matches the picture.

vae is required whenever the node has to encode - use the VAE belonging to the checkpoint that will sample the latent; a mismatched VAE produces noise, not a subtly wrong image, because the channel counts differ between architectures. image is optional on purpose: leave it unconnected and the node simply hands back the bundled latent. That's how a workflow runs without the picture it was built around.

tiled plus tile_size exist for big inputs: encode a tile at a time and VRAM use drops hard, at the cost of speed and faint seams where tiles meet. 512 is the safe starting point, 1024+ if your card has room. The overlap is fixed at 64px, the same value ComfyUI's own tiled encode uses, so a tiled result here matches that node at its defaults.

One output: latent, which goes where any VAE Encode's output goes - the sampler's latent input, or VAE Decode.

Installing it

Part of WAS Node Suite v3, so you install the pack, not the node. ComfyUI Manager, search WAS Node Suite v3, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui.git

That's the whole install. The pack installs nothing, downloads nothing and never runs pip, and it needs ComfyUI 0.14.0+ with Python 3.10+. It sits in the extras feature group, which is on out of the box. The first start after install (and after each update) takes a moment longer while it writes its config.yaml and compiles bytecode under <ComfyUI user dir>/was-node-suite/.

Where people get burned

Leaving an image wired in and expecting the bundle to be used. It won't be - a connected image replaces a same-session bundle, by design.

Waiting for a bundle that never appears: if you're queueing through the API, there's no workflow document, so the node logs that it can neither read nor write one and just encodes. Same if you somehow run it outside a prompt.

Bundles are big. A 1024×1024 latent is 128×128×4 floats carried as compressed base64 text inside your workflow JSON, so don't be surprised when a file that used to be 40 KB gets fat. A few of these in one graph and the workflow becomes genuinely slow to save and open.

And the loudest-of-all error - "has no image on its image input, and no latent bundled in the workflow to read instead" - means exactly what it says: no picture, no bundle. Connect something, or turn on delete_workflow_latent for a run to clear a corrupt bundle and start over.

CategoryWAS Suite/Latent

Inputs (7)

NameTypeDefaultDescription
vaeVAEThe VAE that turns the image into a latent. Use the one belonging to the checkpoint that will sample it.
tiledBOOLEANfalseWhether 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_sizeINT512320–4096Edge 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_latentBOOLEANtrueWhether 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_loadBOOLEANtrueWhether 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_latentBOOLEANfalseTurn 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.
imageoptIMAGEThe 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)

NameTypeDescription
latentLATENTThe encoded latent, or the one that was bundled in the workflow when there was one to read.