ComfyUI Node

Stack_latent

One Node for Empty Latents, Encoded Images, and Inpaint Masks

By cardenluo·Created 2 years ago·Updated 17 days ago· 309
Stack_latent
  • latent
  • pixels
  • mask
  • latent_stack
diff_difusiontrue
smoothness0
ratio_selectedNone
batch_size1
width512
height512

Stock ComfyUI makes you pick your latent-source node before you even start building: Empty Latent Image if you're doing txt2img, VAE Encode if you're doing img2img, VAE Encode (for Inpainting) if you're painting over part of an existing image. Stack_latent skips that decision entirely - it's one node that figures out which job you're doing based on what you plugged in, and outputs a latent_stack any Apt_Preset sampler downstream can consume.

The mechanism, straight from the pack author's own notes: latent, pixels, and ratio_selected are mutually exclusive - pick exactly one path. Feed it an existing latent and it just passes that through. Feed it a pixels image (optionally with a mask) and it VAE-encodes it for you, running an inpaint-style encode when a mask is present. Leave both empty and pick something from ratio_selected and it builds an empty latent at that resolution instead. It's the same "one node picks the right internal path" pattern you'll see across a lot of this pack - fewer nodes on the canvas, at the cost of a little magic you have to learn once.

What you'll actually touch. ratio_selected is a big preset list of common resolutions tagged with their aspect ratio - things like [768x1024]3:4 or [576x1024]9:16 - plus a customer_WxH entry that switches control over to the plain width/height fields (8 to 16384 px each) if none of the presets fit your model's native resolution. batch_size does the obvious thing, up to 300 latents at once if your VRAM can take it. diff_difusion toggles Differential Diffusion - ComfyUI's technique for blending inpaint edits more gradually across denoise steps using your mask as a strength map rather than a hard cutout - and it defaults to on, which is the right default for anyone doing masked edits without thinking too hard about it. smoothness feathers that mask's edges (0-500) so the inpainted region doesn't have a visible hard line where it meets the rest of the image.

Output: latent_stack, of a custom LATENT_STACK type - this isn't a raw ComfyUI LATENT, it's a bundle meant for the pack's own sampler nodes, so don't expect to wire it straight into a stock KSampler.

Installing it. This node ships with the base pack, no extra downloads needed: git clone https://github.com/cardenluo/ComfyUI-Apt_Preset into custom_nodes and restart, or grab it through ComfyUI Manager by searching the pack title. Run install.bat on Windows to be safe - several nodes elsewhere in this pack pull in extra Python dependencies that Manager's own resolver sometimes misses.

Where this bites people. The most common confusion is plugging in both latent and pixels at once and expecting some kind of blend - you won't get one; the node picks a priority and one input silently wins. If your inpaint edit isn't blending cleanly at the mask boundary, check smoothness before you assume the model's fighting you - a smoothness of 0 with a hard-edged mask is a classic cause of visible seams. And if diff_difusion is producing softer, less committed edits than you expected inside the masked region, that's it working as designed - Differential Diffusion trades a bit of edit strength for a much more natural blend, so turn it off if you specifically want a hard, fully-committed replacement inside the mask rather than a graduated one.

CategoryApt_Preset/stack/😺backup

Inputs (9)

NameTypeDefaultDescription
latentoptLATENT
pixelsoptIMAGE
maskoptMASK
diff_difusionoptBOOLEANtrue
smoothnessoptINT00–500
ratio_selectedoptCOMBONone32 options: None, customer_WxH, [384x512]AD, [512x384]AD, [512x512]1:1, [512x768]2:3, +26
batch_sizeoptINT11–300
widthoptINT5128–16384
heightoptINT5128–16384

Outputs (1)

NameTypeDescription
latent_stackLATENT_STACK