Nodes/ComfyUI-Latent-Modifiers/Latent Diffusion Mega Modifier
ComfyUI Node

Latent Diffusion Mega Modifier

The one node that fixes CFG burn, sharpens detail, and stacks every latent trick ComfyUI won't let you stack

By Clybius·Created 3 years ago·Updated 2 years ago· 87
Latent Diffusion Mega Modifier
  • model
  • MODEL
sharpness_multiplier0.0
sharpness_method
tonemap_multiplier0.00
tonemap_method
tonemap_percentile100.000
contrast_multiplier0.0
combat_method
combat_cfg_drift0.00
rescale_cfg_phi0.00
extra_noise_type
extra_noise_method
extra_noise_multiplier0.0
extra_noise_lowpass100
divisive_norm_size127
divisive_norm_multiplier0.00
spectral_mod_mode
spectral_mod_percentile5.00
spectral_mod_multiplier0.00
affect_uncond
dyn_cfg_augmentation
seed

You know the failure. You nudge CFG from 7 to 11 chasing prompt adherence, and the image comes back deep-fried - oversaturated, burned, face melting at the edges. ComfyUI has a whole drawer of fixes for this - dynamic thresholding, CFG rescaling, sharpening - but they're scattered across different packs and they fight each other, because ComfyUI only lets one of these hooks live on a model at a time. That's the problem the Latent Diffusion Mega Modifier from Clybius' ComfyUI-Latent-Modifiers pack exists to solve. It bundles nine separate latent-modification techniques into one node, so you can stack them without them clobbering each other.

Think of it as a post-processing bay for the sampler's internals rather than for your image. You patch it onto your checkpoint model, and at every denoising step it intercepts the conditioning and rescues it before the sampler commits.

How it actually works

Under the hood it's one big set_model_sampler_cfg_function hijack - the README is refreshingly honest that this is a workaround, because ComfyUI's single CFG-function slot means you normally get exactly one trick per model. The author chose to fuse everything into one function rather than ask you to chain hooks.

At each step the node grabs the conditioned and unconditioned predictions and runs them through a fixed pipeline: add extra noise to conditioning → sharpen → convert to a noise prediction → tonemap → spectral modification → adjust contrast → rescale CFG → divisive normalization → center out CFG drift. Every stage is a no-op at its default, so the node is a blank wire until you actually turn something on.

The two biggest draws are the tonemapping and the sharpening. Tonemapping clamps the noise prediction so you can push CFG well past a checkpoint's sweet spot without the burn - pick from seven methods, from Reinhard (borrowed from comfyanonymous' experiments) through quantile, gated, and a CFG-mimic mode that fakes a different CFG entirely. Sharpening comes straight from Fooocus' sampling code, giving you the same perceptual-detail boost that made that UI famous, with four methods (anisotropic, joint-anisotropic, gaussian, cas) to pick from.

The dials that matter

The info panel lists ~20 inputs, which looks terrifying until you notice almost everything defaults to 0 (off). You'll realistically touch five:

  • sharpness_multiplier and sharpness_method - the detail boost. Start around 2–4 with anisotropic and compare.
  • tonemap_multiplier and tonemap_method - the anti-burn clamp. The README's own starting points: arctan at 5/90, quantile at 1/99.
  • tonemap_percentile - how aggressively the clamp bites; closer to 100 is stronger.
  • contrast_multiplier - a secondary CFG slider that adds "pop" without moving subject pose. Negative values invert the operation.
  • rescale_cfg_phi - dynamically scales CFG back by comparing noise standard deviations, the old rescale-CFG trick.

There's also an optional seed input that seeds the extra-noise generator, so your noise-based effects stay reproducible.

The output is a single MODEL, which you wire straight into your existing KSampler. Placement matters: it needs to sit between your checkpoint loader and the sampler, and because it patches the model, it won't stack with other nodes that also hijack the CFG function.

Installing it

No dependencies, no model downloads, no torch extras beyond what ComfyUI already ships - the pack is one Python file. Install it with the Manager (search "ComfyUI-Latent-Modifiers") or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/Clybius/ComfyUI-Latent-Modifiers

Then restart ComfyUI. The node shows up as "Latent Diffusion Mega Modifier" under the clybNodes category. It's a small pack - this is the only node in it - and it's by Clybius, the same person behind the Chroma-GGUF and fp8 quantizations people run for Chroma checkpoints.

Gotchas

The README's warnings are worth heeding. Spectral modification has a dragon zone: percentiles above 15 and multipliers above 5 can make the latent "noise out" into nonsense, especially early in sampling. Combat CFG drift, which recenters the latent to fight the mean drifting off zero at high CFG, can also discolor output. And since every dial defaults off, a common "it's not working" report is just… nothing having been turned on. Set one thing at a time, fixed seed, and compare a handful of generations - the usual CFG-tuning discipline. It's an SD-lineage tool, so reach for it on SDXL/Pony/Illustrious, not on guidance-distilled models where CFG shouldn't be cranked at all.

CategoryclybNodes

Inputs (22)

NameTypeDefaultDescription
modelMODEL
sharpness_multiplierFLOAT0.0-100–100
sharpness_methodCOMBO4 options: anisotropic, joint-anisotropic, gaussian, cas
tonemap_multiplierFLOAT0.000–100
tonemap_methodCOMBO7 options: reinhard, reinhard_perchannel, arctan, quantile, gated, cfg-mimic, +1
tonemap_percentileFLOAT100.0000–100
contrast_multiplierFLOAT0.0-100–100
combat_methodCOMBO4 options: subtract, subtract_channels, subtract_median, sharpen
combat_cfg_driftFLOAT0.00-10–10
rescale_cfg_phiFLOAT0.00-10–10
extra_noise_typeCOMBO6 options: gaussian, uniform, perlin, pink, green, pyramid
extra_noise_methodCOMBO7 options: add, add_scaled, speckle, cads, cads_rescaled, cads_speckle, +1
extra_noise_multiplierFLOAT0.00–100
extra_noise_lowpassINT1000–1000
divisive_norm_sizeINT1271–255
divisive_norm_multiplierFLOAT0.000–1
spectral_mod_modeCOMBO2 options: hard_clamp, soft_clamp
spectral_mod_percentileFLOAT5.000–50
spectral_mod_multiplierFLOAT0.00-15–15
affect_uncondCOMBO2 options: None, Sharpness
dyn_cfg_augmentationCOMBO3 options: None, dyncfg-halfcosine, dyncfg-halfcosine-mimic
seedoptINT0–18446744073709550000

Outputs (1)

NameTypeDescription
MODELMODEL