Nodes/ComfyUI-Fluxtapoz/Apply Flux PAG Attention
ComfyUI Node Runs on cloud

Apply Flux PAG Attention

More detail without a single extra checkpoint

By logtd·Created 2 years ago·Updated 2 years ago· 1,392
Apply Flux PAG Attention
  • model
  • attn_override
  • MODEL
scale3.00
rescale0.00

PAGAttention implements Perturbed Attention Guidance for Flux: it removes the self-attention between image patches inside one of Flux's transformer blocks, runs a second forward pass with that "perturbed" attention, and uses the difference to guide generation toward more detail and structure. It's a training-free enhancement - no LoRA, no ControlNet, no extra model - and it's one of two such nodes in this pack (the other being SEGAttention). The README's comparison row is worth taking literally: vanilla Flux, then PAG, then SEG, each a notch sharper than the last.

How it works

The core idea of PAG is to give the sampler a "worse" version of itself to contrast against. In the first single-stream block, the node replaces image-to-image self-attention with a mask that forces each image patch to attend only to itself (the diagonal), so image tokens stop exchanging information. The model's prediction with this broken attention is compared against its normal prediction, and the difference is added to the output scaled by scale (default 3.0). It's CFG-like, but the "negative" is structural perturbation rather than a negative prompt - which matters because CFG-style negative prompts are useless on Flux.

Inputs:

  • model (MODEL) - the Flux model (ConfigureModifiedFlux-patched, per pack convention).
  • scale (FLOAT, default 3.0) - how hard the perturbation pushes. Zero disables the effect entirely.
  • attn_override (ATTN_OVERRIDE, optional) - from FluxAttnOverride, to choose which block gets perturbed (default: single block 0).
  • rescale (FLOAT, default 0.0) - a secondary scaling term that renormalizes the guided output. Leave at 0 to start; if results get over-bright or harsh, this is the safety valve.

Output:

  • MODEL - a patched model that plugs straight into your guider and sampler like normal.

Installation

The pack's standard install: ComfyUI Manager → search "ComfyUI-Fluxtapoz" → install → restart, or git clone https://github.com/logtd/ComfyUI-Fluxtapoz into custom_nodes. Only einshape, no models to download.

Common issues

  • Over-sharpening / artifacts at high scale - drop scale, or use attn_override to perturb fewer blocks. Scale is the first dial; rescale is the second.
  • "It did nothing." Scale of 0 disables the effect by design, and if you wired an empty attn_override in, no blocks are perturbed either. Also confirm the model output is the patched one.
  • PAG vs SEG: they're different mechanisms (perturbed attention vs energy guidance on smoothed queries). PAG is the cheaper, more general default; SEG has more knobs (blur, inf_blur) and can push further, at the cost of tuning. Try PAG first.

It's a free detail boost on Flux that costs one extra forward pass - if you're already paying for a 12B model, that's a rounding error.

Categoryfluxtapoz/attn

Inputs (4)

NameTypeDefaultDescription
modelMODEL
scaleFLOAT3.000–100
attn_overrideoptATTN_OVERRIDE
rescaleoptFLOAT0.000–100

Outputs (1)

NameTypeDescription
MODELMODEL