Nodes/ComfyUI VAE Reflection/Add Reflection to VAE
ComfyUI Node

Add Reflection to VAE

That ugly dark border on your EQ-VAE images? One node flips the padding and it's gone.

By Jelosus2·Created about a year ago·Updated 10 months ago· 14
Add Reflection to VAE
  • vae
  • VAE

If you've swapped in one of the newer EQ-style VAEs - the latent-equalized ones that promise better detail and color - and noticed a faint dark or discolored band hugging the edges of every image, this is the fix. The "Add Reflection to VAE" node from the ComfyUI VAE Reflection pack walks every convolution in your VAE, flips its padding from zero to reflect mode, and hands you back a VAE that doesn't smear its borders anymore. That's the whole job, and it does it well.

Why the border is there

VAE conv layers pad their inputs before convolving. The default padding mode in PyTorch - and in almost every stock VAE - is zeros: a ring of black outside the image edges. That's fine as long as the VAE was trained with zero padding, because inference matches training. But a growing crop of fine-tuned VAEs (the pack's author explicitly targets the EQ VAE family, tested against Anzhc's MS-LC-EQ-D-VR_VAE, which builds on the EQ-VAE paper) were trained with reflect padding, which mirrors the edge pixels instead of padding with zeros. When ComfyUI decodes with those VAEs using zero padding, the conv layers "see" edges that don't match what they learned, and you get that telltale artifact - usually most visible in corners when you zoom in.

So the node is essentially an inference/training mismatch patch. Reflect padding isn't "better," it's what that VAE expects. That's the one-line caveat the README hammers on: if your VAE wasn't trained with reflect padding, forcing it on can cause edge artifacts. This isn't a universal VAE enhancer - it's a compatibility switch for a specific family.

How it works

The mechanism is delightfully small. It takes your VAE and, if it has a first_stage_model, makes a shallow copy of the VAE and a deep copy of the model itself, moves it to the same device and dtype, then iterates every module and sets padding_mode = "reflect" on each Conv2d layer that actually has padding greater than zero.

That deep copy is the quietly important part. ComfyUI caches VAEs in memory, so if the node mutated your loaded VAE in place, the change would silently leak into every other workflow that loads that same VAE - including ones you never asked to change. Instead it hands you a modified clone, leaving the cached original untouched. Non-destructive, exactly what you want.

Inputs and outputs

Refreshingly simple - there's one input and one output:

  • vae (required, VAE): the VAE model to apply reflection to. Just your normal VAE from a Load VAE / VAE Loader node.
  • VAE (output, VAE): the same VAE with reflection applied. Plug it anywhere a VAE goes - typically into the vae input of a VAE Decode node, or directly into the VAE slot on the sampler.

It's a passthrough swap: load VAE → Add Reflection to VAE → decode. Two wires and you're done.

Installing it

The README ships it on the ComfyUI Registry, so the lazy path is the best one:

  1. In ComfyUI Manager, search for ComfyUI VAE Reflection and install.
  2. Restart ComfyUI.

Or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/Jelosus2/comfyui-vae-reflection

Then restart. There are no pip dependencies worth mentioning - the pack pulls in nothing beyond torch, which ComfyUI already has - and no model files to download. The node itself is pure Python. (Side note: the same repo doubles as a SwarmUI extension, so if you're a SwarmUI person you can enable "Enable VAE Reflection" in the parameters there instead.)

Troubleshooting

  • You get new edge artifacts after adding it. That VAE wasn't trained with reflect padding - delete the node and your artifacts likely vanish. This is the README's explicit warning, and it's the number one misuse.
  • Nothing changed at all. Either your VAE already defaults to reflect mode (rare with stock VAEs), or the border you're seeing isn't a padding issue. A border that shifts depending on upscale factor is usually a resolution-not-multiple-of-8 problem, and washed-out gray images mean a wrong/mismatched VAE - neither is this node's job. See the ComfyUI troubleshooting basics for those.
  • It does nothing to a VAE with no first_stage_model - the node short-circuits and returns the VAE unchanged, which is also what you want.

If you run an EQ VAE and see the border, this is the one-node fix. For everything else, skip it - it's a scalpel, not a hammer.

Categoryutils

Inputs (1)

NameTypeDefaultDescription
vaeVAEThe VAE model to apply reflection to.

Outputs (1)

NameTypeDescription
VAEVAEThe VAE with reflection applied.