Nodes/ComfyUI_agilly1989_motorway/PerturbedAttentionGuidance_motorway_edition
ComfyUI Node

PerturbedAttentionGuidance_motorway_edition

PAG on the bus — structure without a prompt, now key-driven

By agilly1989·Created 2 years ago·Updated about a year ago· 7
PerturbedAttentionGuidance_motorway_edition
  • MOTORWAY 🚌💨
  • MOTORWAY 🚌💨
INPUT_model_keymodel
scale3.00
OUTPUT_MODEL_keyMODEL

Perturbed Attention Guidance (PAG) is one of those tricks that sounds like a joke and then quietly saves a batch of images. It doesn't use your prompt, your negative, or any text at all. It works by taking one attention layer's map mid-denoise, replacing it with something slightly "wrong" (usually its mean), running the step, and using the difference between the perturbed and unperturbed predictions as an extra guidance direction. Scale that difference with the scale widget (default 3) and you get better structure, shape, and coherence - no conditioning required.

That's why PAG got famous in the CFG-1 era. On guidance-distilled models like Flux and the Turbo/Lightning family, CFG 1 means no unconditional pass is even computed, which also means a negative prompt is effectively dead weight. PAG doesn't care - it perturbs attention directly, so it gives you a real steering signal where the normal dials went quiet. It's also handy with unCLIP models and anywhere a text prompt is doing a weak job of holding the image together.

The motorway-ed wrapper

This _motorway_edition is the stock PAG model patch rewired for the MOTORWAY 🚌💨 bus. You don't drag a wire from the model loader; you park the model on the bus under a key and point the node at it:

  • INPUT_model_key (default model) - which bus key holds the checkpoint.
  • scale - the PAG strength, default 3. Start at 3; crank toward 5–7 if structure is still mushy, back off if things get painterly or over-worked.
  • OUTPUT_MODEL_key (default MODEL) - where the patched model is written back onto the bus.

The only return is the bus itself. The actual data lives inside it under MODEL, so whatever sampler comes next reads that key instead of model. Keys are case-sensitive and shared by name across the whole workflow - rename with care.

One nice property of PAG: because it perturbs a single layer, it's cheap. It's not a free lunch, but the overhead is small next to the guidance it buys on models where CFG does nothing.

Install

Same as every node in this pack - pure Python, no pip requirements, no model files to chase down:

cd ComfyUI/custom_nodes
git clone https://github.com/agilly1989/ComfyUI_agilly1989_motorway

Or ComfyUI Manager → search ComfyUI_agilly1989_motorway → install → restart.

The honest caveats

Two things worth knowing before you build on this. The pack is a self-described beta - "IF THINGS BREAK ITS BECAUSE I BROKE IT," per the README - and the _motorway_edition clones were auto-generated by a cloner that the 1.1.7 build disabled. Fresh installs may not show PerturbedAttentionGuidance_motorway_edition at all; you'd get the bus nodes but not the cloned core nodes. If you want PAG and just want it to work, the stock PerturbedAttentionGuidance node does the same job without the bus.

And the usual bus gotcha: KeyError: 'hash_...' doesn't exist in motorway means the key you referenced was never stored upstream. Verify your ramp nodes put model on the bus under exactly that name. There's no community lore to lean on here - this pack barely registers in the wild - so when in doubt, test the stock node first.

Categoryagilly1989 Nodes/Motorway-ed/model_patches/unet

Inputs (4)

NameTypeDefaultDescription
MOTORWAY 🚌💨MOTORWAY 🚌💨
INPUT_model_keySTRINGmodel
scaleFLOAT3.000–100
OUTPUT_MODEL_keySTRINGMODEL

Outputs (1)

NameTypeDescription
MOTORWAY 🚌💨MOTORWAY 🚌💨