ComfyUI Node

VAE Mode Choose

Does your VAE sample or play it straight?

By longgui0318·Created 2 years ago·Updated 2 years ago· 82
VAE Mode Choose
  • vae
  • VAE
mode

VAE Mode Choose is the smallest honest node in this pack: it flips one boolean on your VAE and hands it back. "Sample" lets the VAE be stochastic; "mode" forces it deterministic. That's the whole node - but the why is more interesting, and it explains a lot about how this pack was built.

What it takes and gives

  • vae (VAE) - any ComfyUI VAE.
  • mode - sample or mode.

Output: the same VAE, with one thing changed inside it.

Under the hood it finds the VAE's first-stage model and toggles the sample flag on its DiagonalGaussianRegularizer:

vae.first_stage_model.regularization.sample = (mode == "sample")

In sample mode the encoder draws from the latent distribution (adds stochastic noise, more variety, slightly less stable). In mode mode it returns the distribution's mean - deterministic, stable, and exactly what you want when you're comparing two runs and need everything else held fixed.

Why it exists in a Magic Clothing pack

This node was debug plumbing that escaped. In the pack's OMS era, the developer was porting the reference diffusers implementation to ComfyUI and validating it tensor-by-tensor - the same effort that produced InjectTensorHashLog. The clothing latent you VAE-encode is the input to the feature-extraction pass, so whether the encoder samples or returns the mean changes the attention features captured from the garment. Whether that mattered was an open question the author needed to test. So he surfaced the switch as a node: flip it, run both, compare.

That's why it's category "model_patches" and historically sat next to the feature-injection nodes - it patches a VAE's behavior, and it lived where the author was actively experimenting.

Should you use it?

For day-to-day try-on, mostly not. The default VAE behavior is fine, and this node's effect on output quality is subtle at best. It's genuinely useful in exactly two situations: you're reproducing a result and want the encode path locked down, or you're A/B testing how much of your output noise comes from the VAE encode step vs. the sampler. Outside those, it's a historical artifact - the node was removed from the current codebase, and it survives here only because comfy.icu catalogs everything a pack ever shipped.

Install

For completeness, it's the same pack:

cd ComfyUI/custom_nodes
git clone https://github.com/longgui0318/comfyui-oms-diffusion
# restart

One caveat if you load it from an old workflow: it pokes vae.first_stage_model.regularization directly, and ComfyUI has refactored VAE internals a few times - if it errors, the fix isn't worth chasing. Delete it and re-wire the VAE straight through.

Categorymodel_patches

Inputs (2)

NameTypeDefaultDescription
vaeVAE
modeCOMBO2 options: sample, mode

Outputs (1)

NameTypeDescription
VAEVAE