Nodes/ComfyUI_experiments/ModelSamplerTonemapNoiseTest
ComfyUI Node

ModelSamplerTonemapNoiseTest

Tonemap the noise

By comfyanonymous·Created 3 years ago·Updated 2 years ago· 202
ModelSamplerTonemapNoiseTest
  • model
  • MODEL
multiplier1.00

Higher CFG obeys your prompt better, until the image catches fire - oversaturated colors, blown-out highlights, that baked-in look. The usual fix is to just lower CFG and lose the prompt adherence. This node tries to give you both, by tonemapping the noise prediction the way HDR photos get tonemapped. It's the "Test" ancestor of a trick that ComfyUI would later absorb into core.

The idea is simple to state: CFG amplifies the difference between your prompt and the unconditional prediction, and it amplifies the extremes of that difference most. Those extremes are what burn out. Tonemapping compresses them - the direction of the steering stays, the crazy magnitude gets clipped. You can then push CFG much higher than usual before the image falls apart.

How it works

The source is short and readable. It patches the sampler's CFG function (via set_model_sampler_cfg_function), so it runs on every denoising step after both predictions exist. It takes the noise prediction cond - uncond, computes each sample's magnitude, and compresses that magnitude with a Reinhard curve x / (x + 1) - the classic photographic tonemapper - before re-applying it. The one input, multiplier, scales the "top" of the curve (the mean plus three standard deviations of the magnitude).

The README gives you the whole tuning guide in one sentence: to use higher CFG, lower the multiplier value. At multiplier 1.0 you get a modest compression; drop toward 0.3–0.5 and the curve gets aggressive enough that CFG 15+ stops looking like a neutron star. The Test suffix in the name is a real tell: it's a blunt instrument, no per-step scheduling, no special handling for v-prediction models.

Inputs and output

Just two things matter:

  • model - your checkpoint's MODEL.
  • multiplier - FLOAT, 0 to 100, default 1.0. Lower = stronger tonemapping = more headroom for high CFG.

Output is a single MODEL. Drop it in front of a KSampler like any model patch node - model → this node → KSampler.model. It composes with the sampler's CFG setting, so you set the CFG on the KSampler as usual and let this node buy back the headroom.

Why you'd reach for it

The honest case is narrow but real: a checkpoint whose sweet spot sits at awkwardly high CFG, or a prompt that needs a strong CFG push on SD 1.5/SDXL where the "CFG ~1, distilled, just use it" advice from the distilled-model era doesn't apply. It's also a great way to understand what CFG blowout actually is - set CFG to 14, watch the burn, then hear the node flatten it. (If you want the modern, maintained version of this idea, look at what core ComfyUI does with tonemapping today - but this is where it started.)

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 appears under custom_node_experiments.

Troubleshooting

  • Output goes flat and washed - multiplier too low. The compression is eating too much of the steering. Back it up toward 1.0 and raise CFG in smaller steps.
  • No visible change - you wired the node after the sampler or into the wrong slot; it must sit between the checkpoint and the KSampler's model input.
  • Worse on some checkpoints - expected. It's tuned for standard (epsilon-prediction) models. v-prediction checkpoints behave differently under this kind of patching; for those, reach for the rescale-CFG approach instead.

It's an experiment, it says so in the name, and it's still genuinely useful for the one job it does. If you live at CFG 9+ on SD 1.5 or SDXL, give it a spin.

Categorycustom_node_experiments

Inputs (2)

NameTypeDefaultDescription
modelMODEL
multiplierFLOAT1.000–100

Outputs (1)

NameTypeDescription
MODELMODEL