KSampler with VAE
Sample and decode without a second node
- model
- positive
- negative
- latent_image
- vae
- LATENT
- IMAGE
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_nameandscheduler- 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 likebetaorsimple- 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 theIMAGEoutput. 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.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | The model used for sampling. | |
| seed | INT | The seed for random number generation. | |
| steps | INT | The number of steps for sampling. | |
| cfg | FLOAT | The classifier-free guidance scale. | |
| sampler_name | COMBO | The algorithm used when sampling, this can affect the quality, speed, and style of the generated output. | |
| scheduler | COMBO | The scheduler controls how noise is gradually removed to form the image. | |
| positive | CONDITIONING | The conditioning describing the attributes you want to include in the image. | |
| negative | CONDITIONING | The conditioning describing the attributes you want to exclude from the image. | |
| latent_image | LATENT | The latent image to denoise. | |
| denoise | FLOAT | 1.000–1 | The amount of denoising applied, lower values will maintain the structure of the initial image allowing for image to image sampling. |
| vae | VAE | The VAE model used for decoding the latent. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | The denoised latent. |
| IMAGE | IMAGE | The decoded image. |