Nodes/raylight/CFGNorm (Ray)
ComfyUI Node

CFGNorm (Ray)

Stop your CFG output from looking radioactive

By komikndr·Created about a year ago·Updated 2 days ago· 409
CFGNorm (Ray)
  • ray_actors
  • ray_actors
strength1.00
pre_cfgfalse

Crank CFG too high and you get the classic failure: oversaturated colors, blown-out contrast, a result that looks like someone ran it through a badly-tuned filter. The textbook fix is CFG rescaling, and RayCFGNorm is that fix running on the Ray cluster - the distributed version of ComfyUI's built-in CFGNorm feature. If your Raylight generations are washed out or overcooked at higher guidance, this is the node you were looking for.

How it works. CFG produces a combined prediction - negative prediction plus scale times the difference between positive and negative. When that scale is high, the combined prediction can drift off in magnitude, and that's where the radioactive look comes from. RayCFGNorm rescales the combined prediction so its norm matches the conditional prediction's norm. The mechanism in the source is straightforward: compute the norm of the conditionally-denoised output, compute the norm of the combined output, and scale the latter to the former. strength then blends between the fully-rescaled result and the raw combined output, so at strength 0 you're back to no normalization and at 1 you're fully normalized.

The inputs that matter. Three, all required:

  • ray_actors - the initializer chain.
  • strength - the blend amount, default 1.0 (full normalization), range 0–100. Yes, it goes above 1, which means "over-normalize" - almost nobody needs that, but it's there. Start at 1.0 and dial back if the result looks flat.
  • pre_cfg - boolean, default false. This is the interesting knob. false (default) applies the norm rescaling after the CFG combination, which is the classic approach. true applies it before - it normalizes the conditional and unconditional terms first, then does CFG. For certain models, pre-CFG normalization interacts differently with the guidance math and can recover more contrast than the post-CFG form. Worth flipping if post-CFG looks mushy.

Output. ray_actors, passed through. That's the tell that this is a patch node: it takes the worker chain in, patches the model on every worker, and hands the chain onward. You wire it in series between the initializer and the sampler, like a filter in a pipe - RayInitializerRayCFGNorm → sampler.

Where it fits. This belongs in the guidance toolchain for models that use real CFG - SDXL, SD1.5, Chroma, Qwen Image. For CFG=1 models (Flux, Wan, Hunyuan) there's nothing to normalize, so it does nothing; don't add it to those graphs. The strength/pre_cfg pair is also a genuinely useful knob when CFG-parallel splitting changes how the branches interact - a side effect of running cond/uncond on separate GPUs that single-GPU users never see.

Install. Part of the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/komikndr/raylight
cd raylight
pip install -r requirements.txt

or ComfyUI Manager → search "raylight" → Install, restart. xfuser is the heavy dependency, FlashAttention is optional, Windows means WSL2.

If the output is oversaturated, this is a better first move than lowering CFG - it keeps your guidance strength while fixing the magnitude drift. If the output just looks flat, your CFG is probably too low, and no normalization node fixes that.

CategoryRaylight/extra/guidance

Inputs (3)

NameTypeDefaultDescription
ray_actorsRAY_ACTORS
strengthFLOAT1.000–100
pre_cfgBOOLEANfalse

Outputs (1)

NameTypeDescription
ray_actorsRAY_ACTORS