Nodes/ComfyUI-AutomaticCFG/Automatic CFG - Excellent attention
ComfyUI Node Runs on cloud

Automatic CFG - Excellent attention

The author's 'just try it' attention patch, defaults included

By Extraltodeus·Created 3 years ago·Updated 17 days ago· 427
Automatic CFG - Excellent attention
  • model
  • attn_mod_for_positive_operation
  • attn_mod_for_negative_operation
  • Model
  • Parameters as string
Auto_CFGtrue
patch_multiplier1
patch_condtrue
patch_uncondtrue
light_patchfalse
mute_self_input_layer_8_condfalse
mute_cross_input_layer_8_condfalse
mute_self_input_layer_8_uncondtrue
mute_cross_input_layer_8_uncondfalse
uncond_sigma_end1.0
bypass_layer_8_instead_of_mutefalse
save_as_presetfalse
preset_name

This is the node the author is least bashful about. The README's instructions are basically "just try it" - it's a self-contained attention experiment with sensible defaults that disables input layer 8 on the UNet and applies a custom modification to cross-attention middle layer 0. The "Excellent attention" preset is the default selection in the Preset Loader, and this node is the standalone, knob-exposed version of the same thing.

If you want one attention experiment that's mostly safe, pre-tuned, and easy to reason about, this is the one to grab. It's not a general-purpose CFG patch like the main node - it's a specific, opinionated modification with a handful of toggles around it.

What it actually does

Two concrete patches, both visible in the source:

  • Input layer 8 mute. Input block 8's self-attention (attn1) can be zeroed out (or bypassed) independently for the cond and uncond passes. Layer 8 is late in the UNet's input stack, close to where structure meets detail, so killing it changes how strongly early feature maps get re-attended. The defaults mute it for the uncond pass but leave cond alone.
  • Cross-attention middle layer 0 modification. Middle layer 0's cross-attention (attn2) gets an expression that amplifies how far attention output deviates from the standard attention: normalize(q + (q - attention_basic(...))) * norm, scaled by patch_multiplier. The author says the multiplier "reinforces prompt-following. But like for real." The light_patch toggle swaps this for a cheap q * multiplier that uses far less VRAM, and the README says it actually works better for this purpose.

The inputs that matter

  • patch_multiplier - strength of the cross-attention middle-layer-0 modification. This is your main quality dial.
  • patch_cond / patch_uncond - whether the modification applies to the positive and/or negative pass.
  • light_patch - the cheap, lower-VRAM variant. The author recommends trying it on.
  • mute_self_input_layer_8_cond / _uncond and mute_cross_input_layer_8_cond / _uncond - which input-layer-8 attentions get zeroed, per pass. Defaults: uncond self-attention muted, everything else off.
  • bypass_layer_8_instead_of_mute - instead of zeroing layer 8, replace it with the identity (q). Gentler.
  • uncond_sigma_end - where the negative-side patches stop (default 1).
  • Auto_CFG - on by default, wrapping everything in the automatic CFG rescaling; off for raw guidance.

Optional attn_mod_for_positive_operation / attn_mod_for_negative_operation let you bolt extra ATTNMOD modifiers onto each pass.

Outputs

A patched MODEL for the KSampler, plus a Parameters as string mirroring everything you set - handy when you want to log or save a configuration.

Notes and a genuine mystery

The README is upfront that "for some reason the Juggernaut model does not work with it and I have no idea why" - so if a specific SDXL checkpoint renders wrong with this node, it's probably the checkpoint, not you. Also note the pack's recurring caveat: Juggernaut aside, most testing was on SDXL, and unknown behavior on SD 1.5 is common across all the attention nodes here.

Install is the pack-wide one-liner (git clone https://github.com/Extraltodeus/ComfyUI-AutomaticCFG into custom_nodes, restart). And because this patch also depends on the pack's global sampler-function hook, "update your ComfyUI" remains the first move when outputs turn black or error. If "just try it" appeals to you more than reading about it - which the author clearly hopes - this is the node to try.

Categorymodel_patches/Automatic_CFG

Inputs (16)

NameTypeDefaultDescription
modelMODEL
Auto_CFGBOOLEANtrue
patch_multiplierFLOAT10–100
patch_condBOOLEANtrue
patch_uncondBOOLEANtrue
light_patchBOOLEANfalse
mute_self_input_layer_8_condBOOLEANfalse
mute_cross_input_layer_8_condBOOLEANfalse
mute_self_input_layer_8_uncondBOOLEANtrue
mute_cross_input_layer_8_uncondBOOLEANfalse
uncond_sigma_endFLOAT1.00–10000
bypass_layer_8_instead_of_muteBOOLEANfalse
save_as_presetBOOLEANfalse
preset_nameSTRING
attn_mod_for_positive_operationoptATTNMOD
attn_mod_for_negative_operationoptATTNMOD

Outputs (2)

NameTypeDescription
ModelMODEL
Parameters as stringSTRING