Nodes/ComfyCollectorNodes/Latent Clamp (CCN)
ComfyUI Node

Latent Clamp (CCN)

Stop extreme latent values from burning your image

By valkymaera·Created 4 months ago·Updated 10 days ago· 1
Latent Clamp (CCN)
  • latent
  • latent
min_value-4.0
max_value4.0
debugfalse

Latent Clamp is the answer to a specific, annoying failure: an image that comes out blown out, blocked up, or with white-hot edges because some values in the latent went way out of bounds. It's a one-operation node - clamp every value in the latent to a min_value/max_value range - but it targets a real mechanism rather than a symptom.

Here's the grounding from the concepts knowledge base: a latent isn't pixels, it's the compressed representation the diffusion model works in, and its values live on a roughly bounded scale. When a workflow - heavy guidance, aggressive resampling, tinkering nodes further up the chain - pushes values past where they belong, the VAE decode can blow them out into burned highlights or crushed shadows. Clamping before decode cuts the extreme values off so the rest of the distribution stays usable. The source's own docstring calls it "useful for reducing 'burn' artifacts from extreme values," and that's the honest job description.

The inputs that matter

  • latent - the LATENT you're trying to tame. In, clamped, out.
  • min_value (default −4) and max_value (default 4) - the clamp bounds. The defaults bracket the normal latent range for most models; the input limits let you go down to −20 / up to 20, but honestly if your latents are routinely beyond ±4 you've got a bigger problem and clamping is just triage.

There's a debug toggle that prints the pre- and post-clamp min/max to the console - genuinely handy the first time, because it tells you whether clamping even did anything or whether your values were already in range.

What it does well, and the one trap

Because it clones the latent dict properly (copying the samples tensor and carrying extra keys like noise_mask along), it plays nicely with inpainting and other masked workflows - a surprising number of latent-tinkering nodes drop those keys and silently break your mask. Latent Clamp doesn't. That attention to detail is the reason to prefer it over writing your own clamp.

The trap is expecting a silver bullet. Clamping is a lossy operation: you're deleting information, and if the extreme values were carrying real content (like a genuinely bright light source), clamping it can produce flat, lifeless highlights instead of burned ones. Use it as a rescue tool or a deliberate stylistic choice, not as a permanent fixture in every workflow. If you want something gentler and more flexible, the pack's Latent Normalize offers a whole menu of methods including soft clamp variants (clamp_1, clamp_1.5, clamp_2…) with a strength knob - start there for tuning, reach for Latent Clamp when you want a hard floor and ceiling.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/valkymaera/ComfyCollectorNodes

restart, or ComfyUI Manager → ComfyCollectorNodes. No models, no extra dependencies - pure torch, one clamp call. It's under ComfyCollectorNodes/Latent with the rest of the pack's latent fiddlers.

CategoryComfyCollectorNodes/Latent

Inputs (4)

NameTypeDefaultDescription
latentLATENT
min_valueFLOAT-4.0-20–0
max_valueFLOAT4.00–20
debugoptBOOLEANfalse

Outputs (1)

NameTypeDescription
latentLATENT