Automatic CFG - Custom attentions
Replace the model's cond and uncond with attention-rewritten ones
- model
- attn_mod_for_positive_operation
- attn_mod_for_negative_operation
- Model
CFG is just uncond + (cond - uncond) * scale - the difference between a conditioned and an unconditioned prediction, amplified. This node attacks the inputs rather than the scale: it recomputes cond and/or uncond with your attention patches applied, then feeds those rewritten predictions into the guidance math. If you can imagine what an image would look like when some attention layer is muted or perturbed, this is the node that turns that alternate reality into a usable negative or positive.
It's the most experimental node in an experimental family, and the least "give me a nice picture" of the bunch - you're expected to bring an attention modifier built in the Attention modifiers node and a theory about what it should do.
How it works
Under the hood it configures the Advanced engine's cond_exp / uncond_exp machinery to one of the attention-modifier methods. When the mode is replace_by_custom, the model reruns the relevant pass with your ATTNMOD patches installed and uses the result as the new cond or uncond prediction. The other two modes keep the normal prediction and add a scaled difference: normal + (normal - custom) * multiplier. That diff form is the interesting one - with a positive multiplier you push toward the custom-rewritten prediction, with a negative one you push away from it, which is how you'd steer against an artifact a normal negative prompt can't name.
The inputs that matter
- cond_mode / uncond_mode - each takes one of the three behaviors above, independently for the positive and negative passes.
replace_by_customis the raw swap; thenormal+(normal-custom_cond)*multipliervariants are the steerable mixing modes. - cond_diff_multiplier / uncond_diff_multiplier - the strength of that mixing, -100 to 100. Negative flips the direction. This is your actual creative dial.
- Auto_CFG - on by default, wraps the whole thing in the automatic CFG rescaling. Off and you get raw per-step guidance with just the custom predictions.
- uncond_sigma_end - where the custom negative stops applying, default 1 (i.e. effectively all the way through).
- save_as_preset / preset_name - export your setup so the Preset Loader can reproduce it.
Optional attn_mod_for_positive_operation and attn_mod_for_negative_operation take the ATTNMOD chains that define the "custom" prediction for each side.
Outputs
Just a patched MODEL, straight into your KSampler. No text output here - if you want to inspect what the node is doing, the Advanced node (which this one configures internally) is the place to look.
Practical notes
- This is not a beginner node and it's not a speed hack - depending on the modifier, recomputing a pass with patched attention costs real VRAM and time. Think of it as building a custom guidance signal.
- Start with
normal+(normal-custom_uncond)*multiplierat a small multiplier on the uncond side; that's the least likely to nuke composition. Thereplace_by_custommodes are the "trust my attention theory" option. - Same eval/trust caveat as the rest of the pack: the modifiers you feed in are eval'd, and the pack's global sampler patch means update ComfyUI first if you hit weird errors. And as with all these attention experiments, SDXL is the ground most of them were validated on.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| Auto_CFG | BOOLEAN | true | — |
| cond_mode | COMBO | 3 options: replace_by_custom, normal+(normal-custom_cond)*multiplier, normal+(normal-custom_uncond)*multiplier | |
| uncond_mode | COMBO | 3 options: replace_by_custom, normal+(normal-custom_cond)*multiplier, normal+(normal-custom_uncond)*multiplier | |
| cond_diff_multiplier | FLOAT | 1.0-100–100 | — |
| uncond_diff_multiplier | FLOAT | 1.0-100–100 | — |
| uncond_sigma_end | FLOAT | 1.00–10000 | — |
| save_as_preset | BOOLEAN | false | — |
| preset_name | STRING | — | |
| attn_mod_for_positive_operationopt | ATTNMOD | — | |
| attn_mod_for_negative_operationopt | ATTNMOD | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Model | MODEL | — |