Nodes/CFG Megapack/CFGNorm: per-pixel norm matching (Qwen-Image)
ComfyUI Node

CFGNorm: per-pixel norm matching (Qwen-Image)

The norm fix that Qwen-Image ships with, as a node

By AbstractEyes·Created 5 days ago·Updated 5 days ago· 3
CFGNorm: per-pixel norm matching (Qwen-Image)
  • model
  • MODEL
◄scale-1.0►
◄strength1.00►
◄modematch►
◄spaceauto (the method's own)►

Not every guidance trick comes from a paper. CFGNorm comes from a pipeline: it's the normalization step inside the official Qwen-Image sampling code, and ComfyUI has its own CFGNorm node implementing a related variant. This node gives you both forms with a switch, and it's the lowest-risk correction in the pack - it can't change the direction guidance pushes, only how hard.

That makes it a good first experiment if you've ever stared at a CFG 10 SDXL render that's correct in composition and radioactive in color.

What it does

Plain CFG gives you a guided prediction. CFGNorm then walks the latent pixel by pixel, treats each pixel's channel vector as one little arrow, and fixes its length to match the corresponding arrow in the conditional prediction.

Two flavours:

  • match - the Qwen-Image form. Every pixel's vector is rescaled to the conditional prediction's length, up or down. Shorter pushes get lengthened too.
  • attenuate - the ComfyUI CFGNorm form. Pixels are only ever shortened, never stretched. If a pixel's vector was already shorter than the conditional one, it's left alone.

Because the rescale is per-pixel rather than per-image, it acts locally: a blown-out sky gets pulled back without dragging the shadows down with it. That's the practical difference between CFGNorm and the older per-image rescalers like Guidance Rescale, which match a single standard deviation across the whole image. If your high-CFG damage is concentrated - a glowing window, a hot rim light - per-pixel is the more surgical choice.

Inputs

  • model - the usual wire from the checkpoint or LoRA loader.
  • scale (default -1) - -1 means the KSampler's cfg is the scale. This node is a rescale on top of CFG, so the scale still decides how far you go; CFGNorm decides the shapes after that.
  • strength (default 1) - blend between the plain CFG result (0) and the fully rescaled one (1). This is your dial for "a little of this, please" and it's the reason the node is safe to leave in a workflow: at 0.3 it's a nudge, at 1 it's the full Qwen treatment.
  • mode - match (Qwen-Image) or attenuate (ComfyUI CFGNorm). Start on match if you're porting a Qwen-Image workflow; start on attenuate if your complaint is only over-saturation.
  • space - auto picks the method's published space (noise prediction). The rule is nonlinear, so switching the space is a real change, not a formality.

The output is a MODEL; it plugs into KSampler, KSamplerAdvanced, or SamplerCustomAdvanced's model input like any patch node.

Installing

# ComfyUI Manager: search "CFG Megapack" -> Install -> restart
# or:
comfy node install comfy-cfg-megapack
# or by hand:
cd ComfyUI/custom_nodes && git clone https://github.com/AbstractEyes/comfy-cfg-megapack

The pack brings no dependencies and no model files - torch plus the standard library, which is already there. It wants ComfyUI 0.38+ and uses comfy_api.latest, so old installs won't load it at all.

Things that will confuse you

It fights with other CFG nodes. ComfyUI stores one CFG function per model. RescaleCFG, Mahiro, RenormCFG and this pack all write to the same slot; the last one chained is the only one that runs. If CFGNorm seems inert, that's the first thing to check.

At the sampler's default scale, match can look like it did nothing. On a well-behaved prompt at CFG 7 the guided vector lengths aren't far off the conditional ones, so there's little to correct - the node earns its keep as you climb the scale.

Pack-level gotcha for flow models: the pack supports Anima (Cosmos-Predict2, the Qwen3-0.6B text encoder, Qwen-Image VAE) alongside SDXL and SD1.5, and the space labels follow the model. If you force denoised (x0) on an Anima workflow instead of leaving auto, you're computing the rule somewhere the model never was. Leave it on auto unless you're deliberately experimenting.

CategoryCFG Megapack/papers/combining the two predictions

Inputs (5)

NameTypeDefaultDescription
modelMODEL—
scaleFLOAT-1.0-1–100The guidance scale w for this rule. -1 uses the sampler's cfg value.
strengthFLOAT1.000–2Blend of the rescaled and the plain result.
modeCOMBOmatchmatch (Qwen-Image) or attenuate (ComfyUI CFGNorm).
spaceCOMBOauto (the method's own)Where the rule is computed. Linear rules give the same image in any space; nonlinear ones do not. 'auto' uses the space the method was published in (noise for most, denoised for APG and the angle rule, velocity for flow models).

Outputs (1)

NameTypeDescription
MODELMODEL—