Nodes/ComfyUi-MzMaXaM/KSampler with VAE
ComfyUI Node

KSampler with VAE

Sample and decode without a second node

By MzMaXaM·Created 2 years ago·Updated about a year ago· 14
KSampler with VAE
  • model
  • positive
  • negative
  • latent_image
  • vae
  • LATENT
  • IMAGE
seed
steps
cfg
sampler_name
scheduler
denoise1.00

Almost every ComfyUI graph ends the same way: a KSampler, then a VAE Decode wired right after it, every single time. This node fuses that pair into one. You get the denoised latent and the decoded image out of a single box, which saves you a node and a wire on every graph you build - small, but it adds up over dozens of workflows.

How it works

It's the standard reverse-diffusion loop: starting from your latent_image, it denoises step by step, steered by your positive and negative conditioning, using whichever sampler and scheduler you pick. Once denoising finishes, it immediately runs the result through the VAE you supplied and hands you back both the raw latent (for chaining a second pass) and the decoded image (ready to preview or save) - in one step.

Inputs and outputs that matter

The full set mirrors ComfyUI's stock KSampler plus a VAE input bolted on, so if you've used KSampler before, nothing here is new - it's just consolidated:

  • model, positive, negative, latent_image - the usual suspects.
  • seed, steps - reproducibility and how many denoising steps to run.
  • cfg - how hard the model is steered toward your prompt. The right value is architecture-dependent, not a universal number: roughly 5–9 on SD 1.5/SDXL, 4–6 on Pony and Illustrious, and close to 1 on anything distilled (Turbo/Lightning-style checkpoints).
  • sampler_name and scheduler - the algorithm and noise curve. This pairing matters more than it looks: DDPM-style models (SD 1.5, SDXL, and their finetunes like Pony and Illustrious) want the classic combos like DPM++ 2M with a Karras schedule. Flow-matching models (Flux, Z-Image, and similar) want Euler-family samplers on a gentler schedule like beta or simple - Karras and exponential schedules are a real, outright failure on that architecture family, not just a worse choice.
  • denoise (default 1, range 0–1) - how much of the input latent survives. At 1.0 you're generating from scratch. Lower values (0.3–0.5 is the common range) preserve more of the input's structure - this is what you want for img2img or a second hi-res pass, not a fresh generation.
  • vae - the decoder used for the IMAGE output. Match it to the checkpoint family.

Two outputs: LATENT (the denoised latent, useful for feeding into another sampling pass or a latent upscaler) and IMAGE (the decoded picture, ready to save or preview).

Installing it

ComfyUI Manager: search mzmaxam in Custom Nodes Manager, install, restart. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/MzMaXaM/ComfyUi-MzMaXaM

No models to fetch, no extra dependencies - this pack is pure node logic, so a clone and a restart is the whole install.

Where people get tripped up

The sampler/scheduler pairing is the one that bites hardest, and it isn't cosmetic: run a Karras schedule on a flow-matching model and you don't get a slightly worse image, you get a genuinely broken one, because that model's trajectory doesn't tolerate an aggressively reshaped noise curve. Match your pair to your model's architecture family, not to whatever combo you're used to from a different checkpoint. Second, CFG that's fine on one family looks burnt or oversaturated on another - a distilled checkpoint run at CFG 7 instead of ~1 is a common source of that. Third, this node always decodes, every single run - so if you only wanted the latent to chain into a second pass, you're still paying for a VAE Decode's memory and time cost on every step. That's the trade-off for the convenience: fine for most graphs, worth knowing if you're chaining several passes and want to skip decoding until the last one. And, as always, a mismatched VAE (wrong family for the checkpoint) shows up as muddy colors or noise in the IMAGE output - nothing to do with the sampling itself.

CategoryMzMaXaM

Inputs (11)

NameTypeDefaultDescription
modelMODELThe model used for sampling.
seedINTThe seed for random number generation.
stepsINTThe number of steps for sampling.
cfgFLOATThe classifier-free guidance scale.
sampler_nameCOMBOThe algorithm used when sampling, this can affect the quality, speed, and style of the generated output.
schedulerCOMBOThe scheduler controls how noise is gradually removed to form the image.
positiveCONDITIONINGThe conditioning describing the attributes you want to include in the image.
negativeCONDITIONINGThe conditioning describing the attributes you want to exclude from the image.
latent_imageLATENTThe latent image to denoise.
denoiseFLOAT1.000–1The amount of denoising applied, lower values will maintain the structure of the initial image allowing for image to image sampling.
vaeVAEThe VAE model used for decoding the latent.

Outputs (2)

NameTypeDescription
LATENTLATENTThe denoised latent.
IMAGEIMAGEThe decoded image.