Generic Attention Guidance
One node, twelve ways to poke at attention — PAG included
- model
- MODEL
Perturbed Attention Guidance (PAG) has a reputation problem. When it lands, it's the trick that "cleaned up compositions" and made people rave back in 2024; when it misses, it deep-fries your image - oversaturated, overcooked, like someone turned CFG up to eleven. GenericAttentionGuidance from Comfy Latent Tools is a single model-patch node that hands you PAG plus eleven other ways to perturb attention, wrapped in rescaling methods built specifically to stop the deep-frying.
It sits in the model_patches/unet category. You feed it a MODEL, it clones and patches the sampler, and the patched MODEL goes into your KSampler in place of the original. Output is a single MODEL; nothing else changes in your workflow.
How it works
Classifier-free guidance normally extrapolates the conditioned prediction away from the unconditioned one. Attention guidance adds a third term: a perturbed forward pass of the UNet, computed with a damaged attention function in one chosen block, and the final output is steered by the difference between that perturbed prediction and the normal one, scaled by guidance_weight (default 1.5).
Which damage you apply is the guidance_type dropdown - all twelve are in the schema: ValueRescale, Scramble, RandomRotation, Fuzzy, AAT, SEG, PAG, Permute, RandomDrop, RandomSubspace, SVD, Phase. The classic one is PAG, which simply ignores the attention matrix and passes the values straight through (the "identity attention" idea from the PAG paper - real thing, still 140+ threads on Reddit since 2024). RandomDrop (the default) randomly drops tokens before attention. The others range from scrambling to phase-shifting in FFT space.
Here's the part that fixes PAG's bad reputation. A raw PAG guidance term pushes dynamic range off a cliff, which is the oversaturation. The rescaling_method dropdown (VSpaceRescale default, PredSpaceRescale, SNF, Softmax, Normalize, OrthogonalComponent) rebalances the combined prediction so you keep the fidelity gain without the saturation, and rescaling_fraction (default 0.7) blends between rescaled and unscaled. The pack author's own note for the PAG variant: start with weight around half your CFG and a post-rescale close to 1.0.
The inputs that actually matter
guidance_type- which perturbation;PAGandRandomDropare the sane starts.guidance_weight- strength of the extra guidance term.param1/param2/param3- per-type tuning knobs. They mean different things per type and the node won't tell you; e.g.AATwantsparam2near −100,RandomRotationwantsparam2in 0–1. Check the pack source if you go deep.rescaling_method+rescaling_fraction- the anti-deep-fry controls.unet_block(input/middle/output) andunet_block_id- which block's attention gets perturbed;middle/0 is the default.unet_block_listis an optional string if you want several blocks at once.guidance_start_sigma(7) /guidance_end_sigma(0) - the noise window where the guidance actually runs. Abovestart_sigma, early chaotic steps, the node stands aside and lets plain sampling happen.
One honest cost: every PAG-style method adds a second UNet forward pass per step, so sampling time roughly doubles. The author claims samplers converge faster with it on, so you can sometimes shave steps to compensate - but budget for the slowdown first.
Install and gotchas
ComfyUI Manager, search Comfy Latent Tools, install, restart. Or the manual way:
cd ComfyUI/custom_nodes
git clone https://github.com/JTriggerFish/ComfyLatentTools
Then restart ComfyUI. No model files to download, and the only dependencies are torch, torchvision, pillow and numpy - nothing exotic.
Where people get burned: this pack is openly experimental - the README literally says "MANY MISSING NODES HERE - WILL BE UPDATED" - and the guidance types need real tuning; the defaults are starting points, not answers. If you see oversaturation creeping back, rescaling_fraction isn't catching it - raise it toward 1.0. Start with PAG + VSpaceRescale, weight about half your CFG, and change one thing at a time. That's the workflow, not a bug.
Inputs (15)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| guidance_type | COMBO | RandomDrop | 12 options: ValueRescale, Scramble, RandomRotation, Fuzzy, AAT, SEG, +6 |
| guidance_weight | FLOAT | 1.50–100 | — |
| param1 | FLOAT | 1.00-1–1 | — |
| param2 | FLOAT | 0.00-1–1 | — |
| param3 | FLOAT | 0.00-1–1 | — |
| apply_rescaling_to_alternate_guidance | BOOLEAN | false | — |
| rescaling_method | COMBO | VSpaceRescale | 7 options: None, PredSpaceRescale, VSpaceRescale, SNF, Softmax, Normalize, +1 |
| rescaling_fraction | FLOAT | 0.700–1 | — |
| unet_block | COMBO | middle | 3 options: input, middle, output |
| unet_block_id | INT | 0 | — |
| guidance_start_sigma | FLOAT | 7.000–15 | — |
| guidance_end_sigma | FLOAT | 0.000–15 | — |
| time_perturbation_std | FLOAT | 0.000–1 | — |
| unet_block_listopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |