ComfyUI Node

Pre CFG sharpening

Unsharp-mask your noise predictions — sharper images, less saturation

By Extraltodeus·Created 2 years ago·Updated about a year ago· 66
Pre CFG sharpening
  • model
  • MODEL
do_onboth
scale0.75
start_at_sigma15.00
end_at_sigma1.00

This one is exactly what it sounds like: it sharpens during generation by stealing from the past. "Pre CFG sharpening" takes the noise prediction from the current step and subtracts a bit of the previous step's prediction from it, before CFG ever merges anything. The author describes it plainly - "subtract from the current step something from the previous step" - and notes it tends to make images sharper and less saturated.

Why does that work? In a sampler, consecutive steps' predictions are close. If you remove the part of the current prediction that the previous one already "knew" - the overlap - what's left is the new, high-frequency information this step is adding. Amplify that and you've got an unsharp-mask applied in prediction space instead of pixel space: edges and detail get a lift, and because the subtraction trims the shared low-frequency content, colors end up less muddy/saturated. The implementation does this carefully, normalizing both tensors and removing only the component of the previous prediction that's orthogonal to the current one, scaled by your scale. Negative scale values are allowed and just invert the effect.

The inputs that matter:

  • scale - strength, default 0.75 (range −10 to 10). Start here; 0.75 is a light-to-moderate lift. A negative value will de-emphasize detail instead.
  • do_on - both / cond / uncond. Default both; you can sharpen only the positive or only the negative prediction if you want half the effect.
  • start_at_sigma / end_at_sigma - sigma window, defaults 15 down to 1, which spans SDXL's whole sampling range. If you only want the late, detail-heavy steps sharpened, drop start_at_sigma to something like 3 so the early high-sigma steps are skipped. The defaults are the sane starting point.
  • model - patched MODEL in/out, wired after your loader.

This is marked experimental in the README, so treat it as a seasoning node, not a fix-it button. The "less saturated" side effect is real and worth planning around: if your image comes back slightly washed, that's the mechanism doing its thing, and a touch of saturation in post (or a LoRA) compensates. You might also want to run it only on part of the denoising - many people find sharpening in the later steps is enough and cheaper, since the node tracks the previous step only within its active sigma window.

Cost-wise this is the cheap one: no second forward pass, just a tensor subtraction per step. That's the appeal - sharpness you can feel without paying the render-time tax that PAG charges.

Installation, same as the whole pack:

cd ComfyUI/custom_nodes && git clone https://github.com/Extraltodeus/pre_cfg_comfy_nodes_for_ComfyUI

or ComfyUI Manager → search pre_cfg_comfy_nodes_for_ComfyUI → restart. No dependencies, no model files. And the usual pack caveat: on CFG-1 / guidance-distilled workflows there's no negative prediction to sharpen, and at start_at_sigma 15 / end_at_sigma 1 the window still expects SDXL's sigma range - the author tested on SDXL. Start at scale 0.75, look at edges and text, then nudge.

Categorymodel_patches/Pre CFG

Inputs (5)

NameTypeDefaultDescription
modelMODEL
do_onCOMBOboth3 options: both, cond, uncond
scaleFLOAT0.75-10–10
start_at_sigmaFLOAT15.000–100
end_at_sigmaFLOAT1.000–100

Outputs (1)

NameTypeDescription
MODELMODEL