Nodes/ComfyUI/LatentApplyOperationCFG
ComfyUI Node Runs on cloud

LatentApplyOperationCFG

Inject a latent filter into every sampling step

By Comfy-Org·Created 4 years ago·Updated about 4 hours ago· 129,964
LatentApplyOperationCFG
  • model
  • operation
  • MODEL

LatentApplyOperationCFG is the "during sampling" sibling of LatentApplyOperation: instead of transforming a latent once up front, it patches the model so the operation runs inside every denoising step. It takes a MODEL and a LATENT_OPERATION, and returns a patched MODEL you feed to the sampler instead of the original. The operation (sharpen is the one that ships today) then applies per step, on the guidance direction itself.

The two inputs: model (a MODEL, typically off the checkpoint loader) and operation (a LATENT_OPERATION, e.g. from LatentOperationSharpen). Output is a MODEL - wire it into the KSampler where you'd normally put the loader's model. That's the whole interface.

What "on the guidance direction" actually means

This is the part worth understanding, because it's the difference between the two apply nodes. When the sampler runs with CFG, each step computes a conditional and an unconditional prediction and steers along their difference - the "direction" of the edit. LatentApplyOperationCFG hooks into that: it takes the difference, runs the operation on it, and adds it back. So sharpening here isn't sharpening the image once; it's sharpening the gradient of change every step, compounding the effect across the whole denoise. That's dramatically stronger than a one-shot pre-filter, and it's why you'd reach for this node when LatentApplyOperation felt too weak.

For sharpen specifically, this produces a crisper end result than filtering the input latent, because the detail signal is reinforced throughout generation rather than applied once at the start. Think of it as a persistent guidance-shaping filter versus a one-time input filter.

The honest warnings

This node is experimental, and it's the more dangerous of the pair for two reasons. First, its behavior depends on CFG being active: the operation works on cond - uncond, so on a guidance-distilled model running at CFG 1 (where there's no unconditional pass to subtract) the hook degrades to applying the operation to the plain prediction - which is not what its tuning was designed for. Second, because the effect compounds every step, small parameter changes on the operation node produce large output changes, and there's no way to preview the operation in isolation. Start with very mild parameters and work up; don't port your LatentApplyOperation settings over verbatim and expect the same look.

It ships with ComfyUI core - no install, no model files. If you only remember one thing: this node changes how the model generates, not what you feed it. Filter once → LatentApplyOperation. Filter every step → this one, carefully.

Categorymodel/latent/advanced/operations

Inputs (2)

NameTypeDefaultDescription
modelMODEL
operationLATENT_OPERATION

Outputs (1)

NameTypeDescription
MODELMODEL