Automatic CFG - Advanced
The kitchen-sink patch node for people who like to break things
- model
- attention_modifiers_positive
- attention_modifiers_negative
- attention_modifiers_fake_negative
- attention_modifiers_global
- MODEL
- STRING
Every other node in this pack is a thin wrapper around this one. The plain Automatic CFG node is Advanced with two knobs pre-set; the Preset Loader is Advanced with the parameters read from JSON; Warp Drive, Negative, Custom attentions and Excellent attention all just call its patch() with different arguments. So if you've used any of those, you've used this - you just didn't see all the switches. The author's own note is the best summary: "I leave the advanced node for those who are interested. It will not be beneficial to those who do not feel like experimenting."
Don't start here. Start with the one-dial node or a preset, learn what the rescaling feels like, and come to Advanced when you have a specific experiment in mind - or want to save your tinkering as a preset.
What's actually in here
It's the same per-step rescaling engine: the model predicts cond and uncond, the node measures each channel's denoised range (top-k mean, auto_cfg_topk default 0.25) and rescales toward a target intensity set by auto_cfg_ref (default 8 - your sampler CFG becomes a dial around it). On top of that you get:
- automatic_cfg -
None,soft,hard,hard_squared,range. How the per-step rescaling is computed;hardis the default and the most commonly useful. - skip_uncond with uncond_sigma_start/end - the "boost" idea in raw form: turn the negative pass off outside a sigma window. Start 1000 → end 1 is the standard "no negative in the tail" recipe.
- lerp_uncond with lerp_uncond_strength and sigma bounds - blends cond toward uncond each step (norm-preserving). This is the mechanism behind the "Negative" node, and it's how you get negative-weight-style behavior without burning.
- latent_intensity_rescale with latent_intensity_rescale_cfg and sigma bounds - a post-CFG rescale that clamps overall intensity; the "post rescale only" node is just this piece.
- cond_exp / uncond_exp / fake_uncond_exp - the experimental function zoo (amplify, root, power, erf, sine, sign, zero, previous_average, eval, and a couple of attention-modifier methods). These transform the cond or uncond prediction each step. Genuinely a place to play, not a place to tune "correctly."
- fake_uncond_* - build a stand-in uncond from the previous cond prediction instead of running the real negative pass. The Warp Drive node's engine.
- disable_cond - the flip side of skip_uncond: skip the positive pass in a sigma window.
- save_as_preset + preset_name - write your current settings to
presets/<name>.jsonso the Preset Loader picks them up. Turn the toggle back off after saving or every run overwrites it (the console even warns you).
The optional inputs let you pipe in eval_string_cond / eval_string_uncond / eval_string_fake (arbitrary Python via eval() - the same trust warning as presets) and up to four ATTNMOD chains for positive, negative, fake-negative, and global attention patching.
Outputs
Two: the patched MODEL for your KSampler, and a STRING of the current parameters as text - useful for logging an experiment or feeding back into a preset.
The two things that will bite you
- eval is everywhere. The
evalexperiment methods and eval strings run arbitrary code during sampling. Only paste expressions you wrote or trust. Presets you save from here get the same treatment when loaded. - You can save yourself into a hole. With ~40 fields and sigma windows everywhere, it's easy to build a config that does nothing or does something awful. Keep a known-good preset (the shipped
Excellent_attentionworks), and change one thing at a time on a fixed seed - the CFG-panel rule about single-variable A/B tests applies harder here than anywhere.
Install
Same pack, same one-liner:
cd ComfyUI/custom_nodes
git clone https://github.com/Extraltodeus/ComfyUI-AutomaticCFG
Restart ComfyUI. And if anything misbehaves, the pack's global sampling-function patch means "update your ComfyUI" is the first fix to try. Advanced is a lab bench, not a daily driver - treat it that way and you'll learn more about how CFG actually behaves per step than any slider will teach you.
Inputs (53)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| automatic_cfg | COMBO | hard | 5 options: None, soft, hard, hard_squared, range |
| skip_uncond | BOOLEAN | true | — |
| fake_uncond_start | BOOLEAN | false | — |
| uncond_sigma_start | FLOAT | 1000.00–10000 | — |
| uncond_sigma_end | FLOAT | 1.00–10000 | — |
| lerp_uncond | BOOLEAN | false | — |
| lerp_uncond_strength | FLOAT | 2.00–10 | — |
| lerp_uncond_sigma_start | FLOAT | 1000.00–10000 | — |
| lerp_uncond_sigma_end | FLOAT | 1.00–10000 | — |
| subtract_latent_mean | BOOLEAN | false | — |
| subtract_latent_mean_sigma_start | FLOAT | 1000.00–10000 | — |
| subtract_latent_mean_sigma_end | FLOAT | 1.00–10000 | — |
| latent_intensity_rescale | BOOLEAN | false | — |
| latent_intensity_rescale_method | COMBO | hard | 3 options: soft, hard, range |
| latent_intensity_rescale_cfg | FLOAT | 8.00–100 | — |
| latent_intensity_rescale_sigma_start | FLOAT | 1000.00–10000 | — |
| latent_intensity_rescale_sigma_end | FLOAT | 3.00–10000 | — |
| cond_exp | BOOLEAN | false | — |
| cond_exp_normalize | BOOLEAN | false | — |
| cond_exp_sigma_start | FLOAT | 1000.00–10000 | — |
| cond_exp_sigma_end | FLOAT | 1.00–10000 | — |
| cond_exp_method | COMBO | 24 options: amplify, root, power, erf, erf_amplify, exp_erf, +18 | |
| cond_exp_value | FLOAT | 2.00–100 | — |
| uncond_exp | BOOLEAN | false | — |
| uncond_exp_normalize | BOOLEAN | false | — |
| uncond_exp_sigma_start | FLOAT | 1000.00–10000 | — |
| uncond_exp_sigma_end | FLOAT | 1.00–10000 | — |
| uncond_exp_method | COMBO | 22 options: amplify, root, power, erf, erf_amplify, exp_erf, +16 | |
| uncond_exp_value | FLOAT | 2.00–100 | — |
| fake_uncond_exp | BOOLEAN | false | — |
| fake_uncond_exp_normalize | BOOLEAN | false | — |
| fake_uncond_exp_method | COMBO | 25 options: cond_pred, previous_average, amplify, root, power, erf, +19 | |
| fake_uncond_exp_value | FLOAT | 2.00–1000 | — |
| fake_uncond_multiplier | INT | 1-1–1 | — |
| fake_uncond_sigma_start | FLOAT | 1000.00–10000 | — |
| fake_uncond_sigma_end | FLOAT | 1.00–10000 | — |
| auto_cfg_topk | FLOAT | 0.250–0.5 | — |
| auto_cfg_ref | FLOAT | 8.00–100 | — |
| attention_modifiers_global_enabled | BOOLEAN | false | — |
| disable_cond | BOOLEAN | false | — |
| disable_cond_sigma_start | FLOAT | 1000.00–10000 | — |
| disable_cond_sigma_end | FLOAT | 0.00–10000 | — |
| save_as_preset | BOOLEAN | false | — |
| preset_name | STRING | — | |
| eval_string_condopt | STRING | — | |
| eval_string_uncondopt | STRING | — | |
| eval_string_fakeopt | STRING | — | |
| args_filteropt | STRING | — | |
| attention_modifiers_positiveopt | ATTNMOD | — | |
| attention_modifiers_negativeopt | ATTNMOD | — | |
| attention_modifiers_fake_negativeopt | ATTNMOD | — | |
| attention_modifiers_globalopt | ATTNMOD | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |
| STRING | STRING | — |