Nodes/ComfyUI_experiments/TonemapNoiseWithRescaleCFG
ComfyUI Node

TonemapNoiseWithRescaleCFG

Tonemap the noise and rescale the CFG

By comfyanonymous·Created 3 years ago·Updated 2 years ago· 202
TonemapNoiseWithRescaleCFG
  • model
  • MODEL
tonemap_multiplier1.00
rescale_multiplier1.00

Two nodes from this pack attack the same enemy - high CFG making images burn - in two different ways. ModelSamplerTonemapNoiseTest compresses the noise prediction's magnitude with a Reinhard curve. RescaleClassifierFreeGuidanceTest rescales the CFG output's dispersion to match the conditional prediction. This node is the "both, please" option: one patch that does the tonemapping and the rescaling in a single pass, with two dials instead of one.

If you've hit the wall where either fix alone isn't enough - CFG so high that the tonemap flattens the steering while the rescale still can't hold the color together - this is the node you were looking for. It's also just convenient: one model patch, one place to look, instead of chaining two experiment nodes that were never designed to be stacked.

How it works

Open the source and you'll recognize both halves stacked in sequence. First, the tonemap half: it takes cond - uncond, computes each sample's vector magnitude, and compresses it with the Reinhard curve x / (x + 1), scaled by tonemap_multiplier which sets the curve's "top" (the mean plus three standard deviations of the magnitude). Then it builds the CFG result from the tonemapped noise and runs the rescale half on top: measure the standard deviation of the conditional (ro_pos) and of the CFG output (ro_cfg), rescale by ro_pos / ro_cfg, and blend with rescale_multiplier.

The two dials split the work cleanly:

  • tonemap_multiplier - FLOAT, 0 to 100, default 1.0. Lower it to compress the noise extremes harder, buying headroom for very high CFG.
  • rescale_multiplier - FLOAT, 0 to 1, default 1.0. The blend between fully-rescaled CFG and plain CFG.

Inputs and output

  • model - your checkpoint's MODEL.
  • The two multipliers above.

Output is a single MODEL, wired between checkpoint and KSampler like any model patch. Same placement rule as its siblings: checkpoint → this node → KSampler.model.

When it's worth it - and when it isn't

Reach for it when you're genuinely pushing CFG hard (double digits on SD 1.5/SDXL) and the image still fights you - one technique flattens, the other doesn't fully fix, and you want to tune both against each other. The two knobs interact, which is the real skill here: they're not independent sliders, they're two ways of clipping the same amplification, so you'll feel them pull against each other as you raise CFG.

Don't reach for it if you're at normal CFG (5–9 on SD 1.5/SDXL). At ordinary values both effects are mild and this node mostly adds dials you'll forget about. It's a rescue tool for the CFG-pushing edge case, and for understanding what CFG blowout actually is.

Installing it

ComfyUI Manager → search ComfyUI_experiments, or:

cd ComfyUI/custom_nodes
git clone https://github.com/comfyanonymous/ComfyUI_experiments

Restart ComfyUI. No dependencies, no model downloads; it sits under custom_node_experiments.

Troubleshooting

  • Everything looks flat - both effects at default 1.0 is the most aggressive setting, and it's easy to overdo. Lower CFG a bit, or back tonemap_multiplier up toward 2–3 to lighten the compression.
  • Two dials, no idea which one to turn - start with the tonemap multiplier, since color/contrast blowout is mostly a magnitude problem; use the rescale multiplier to dial back the remaining dispersion.
  • On v-pred checkpoints it can misbehave - like the rescale sibling, this experiment doesn't handle v-prediction space; use core ComfyUI's RescaleCFG for those models.

It's the most niche node in a pack of experiments, but if you've ever spent an evening trying to rescue a CFG-14 image, you'll appreciate that someone bundled the two best rescue tools into one patch.

Categorycustom_node_experiments

Inputs (3)

NameTypeDefaultDescription
modelMODEL
tonemap_multiplierFLOAT1.000–100
rescale_multiplierFLOAT1.000–1

Outputs (1)

NameTypeDescription
MODELMODEL