Nodes/ComfyUI/PerturbedAttentionGuidance
ComfyUI Node Runs on cloud

PerturbedAttentionGuidance

The CFG-style guidance that works when you have no negative prompt

By Comfy-Org·Created 4 years ago·Updated about 8 hours ago· 130,663
PerturbedAttentionGuidance
  • model
  • MODEL
scale3.00

Here's the problem this node exists to solve: the models that took over local generation in 2024 - Flux first, then the whole guidance-distilled family - don't have a negative prompt. Guidance is baked into their weights, so CFG has nothing to push against, and you're stuck with whatever the sampler gives you. PerturbedAttentionGuidance (PAG) is a way to steer these models anyway, without ever needing an unconditional pass.

The mechanism is clever and cheap to describe. During sampling, the node runs the model a second time with one specific corruption: in the middle attention block, self-attention's output is replaced by just the value projection - the query/key matching is discarded, so each token can't look at its neighbors. That degraded forward pass is a stand-in for "what the model thinks when its attention is broken," which turns out to be a useful baseline. The guidance step then adds the difference between the clean prediction and the perturbed one, scaled by scale: cfg_result + (cond_pred - pag) * scale. Raise the scale and the model is pulled harder toward the coherent prediction - which reads as better prompt adherence and cleaner structure, with no negative prompt in sight.

The inputs

  • model - any diffusion model; it's most useful on the ones without CFG.
  • scale (default 3.0) - the strength. At 0 the node is a pure passthrough; 3 is a sane start, and you nudge up from there if the output is wandering.

One MODEL out, wired straight into the sampler like any other model/patch node.

Where it came from and what to expect

PAG landed in April 2024, adapted from pamparamm's sd-perturbed-attention - the comment in ComfyUI's own source calls it a simplified, more update-proof version. It predates the guidance-distilled flood and survived it, which tells you something: it's still the most direct way to add guidance to a model that doesn't support it natively. The cost is real - an extra forward pass per step, so you're roughly doubling sampling time - which is the same price CFG always charged, just without needing a negative.

The main gotcha is over-steering. PAG's scale is not a "more is more" dial; past a point it overcooks textures and adds a plasticky sharpness. Start at 3, and if the image is already good, leave it - this is a rescue tool for weak adherence, not a daily quality booster.

Categorymodel/patch/unet

Inputs (2)

NameTypeDefaultDescription
modelMODEL
scaleFLOAT3.000–100

Outputs (1)

NameTypeDescription
MODELMODEL