Nodes/ComfyUI-AutomaticCFG/Automatic CFG - Advanced
ComfyUI Node Runs on cloud

Automatic CFG - Advanced

The kitchen-sink patch node for people who like to break things

By Extraltodeus·Created 3 years ago·Updated about a month ago· 429
Automatic CFG - Advanced
  • model
  • attention_modifiers_positive
  • attention_modifiers_negative
  • attention_modifiers_fake_negative
  • attention_modifiers_global
  • MODEL
  • STRING
automatic_cfghard
skip_uncondtrue
fake_uncond_startfalse
uncond_sigma_start1000.0
uncond_sigma_end1.0
lerp_uncondfalse
lerp_uncond_strength2.0
lerp_uncond_sigma_start1000.0
lerp_uncond_sigma_end1.0
subtract_latent_meanfalse
subtract_latent_mean_sigma_start1000.0
subtract_latent_mean_sigma_end1.0
latent_intensity_rescalefalse
latent_intensity_rescale_methodhard
latent_intensity_rescale_cfg8.0
latent_intensity_rescale_sigma_start1000.0
latent_intensity_rescale_sigma_end3.0
cond_expfalse
cond_exp_normalizefalse
cond_exp_sigma_start1000.0
cond_exp_sigma_end1.0
cond_exp_method
cond_exp_value2.0
uncond_expfalse
uncond_exp_normalizefalse
uncond_exp_sigma_start1000.0
uncond_exp_sigma_end1.0
uncond_exp_method
uncond_exp_value2.0
fake_uncond_expfalse
fake_uncond_exp_normalizefalse
fake_uncond_exp_method
fake_uncond_exp_value2.0
fake_uncond_multiplier1
fake_uncond_sigma_start1000.0
fake_uncond_sigma_end1.0
auto_cfg_topk0.25
auto_cfg_ref8.0
attention_modifiers_global_enabledfalse
disable_condfalse
disable_cond_sigma_start1000.0
disable_cond_sigma_end0.0
save_as_presetfalse
preset_name
eval_string_cond
eval_string_uncond
eval_string_fake
args_filter

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; hard is 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>.json so 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 eval experiment 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_attention works), 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.

Categorymodel_patches/Automatic_CFG

Inputs (53)

NameTypeDefaultDescription
modelMODEL
automatic_cfgCOMBOhard5 options: None, soft, hard, hard_squared, range
skip_uncondBOOLEANtrue
fake_uncond_startBOOLEANfalse
uncond_sigma_startFLOAT1000.00–10000
uncond_sigma_endFLOAT1.00–10000
lerp_uncondBOOLEANfalse
lerp_uncond_strengthFLOAT2.00–10
lerp_uncond_sigma_startFLOAT1000.00–10000
lerp_uncond_sigma_endFLOAT1.00–10000
subtract_latent_meanBOOLEANfalse
subtract_latent_mean_sigma_startFLOAT1000.00–10000
subtract_latent_mean_sigma_endFLOAT1.00–10000
latent_intensity_rescaleBOOLEANfalse
latent_intensity_rescale_methodCOMBOhard3 options: soft, hard, range
latent_intensity_rescale_cfgFLOAT8.00–100
latent_intensity_rescale_sigma_startFLOAT1000.00–10000
latent_intensity_rescale_sigma_endFLOAT3.00–10000
cond_expBOOLEANfalse
cond_exp_normalizeBOOLEANfalse
cond_exp_sigma_startFLOAT1000.00–10000
cond_exp_sigma_endFLOAT1.00–10000
cond_exp_methodCOMBO24 options: amplify, root, power, erf, erf_amplify, exp_erf, +18
cond_exp_valueFLOAT2.00–100
uncond_expBOOLEANfalse
uncond_exp_normalizeBOOLEANfalse
uncond_exp_sigma_startFLOAT1000.00–10000
uncond_exp_sigma_endFLOAT1.00–10000
uncond_exp_methodCOMBO22 options: amplify, root, power, erf, erf_amplify, exp_erf, +16
uncond_exp_valueFLOAT2.00–100
fake_uncond_expBOOLEANfalse
fake_uncond_exp_normalizeBOOLEANfalse
fake_uncond_exp_methodCOMBO25 options: cond_pred, previous_average, amplify, root, power, erf, +19
fake_uncond_exp_valueFLOAT2.00–1000
fake_uncond_multiplierINT1-1–1
fake_uncond_sigma_startFLOAT1000.00–10000
fake_uncond_sigma_endFLOAT1.00–10000
auto_cfg_topkFLOAT0.250–0.5
auto_cfg_refFLOAT8.00–100
attention_modifiers_global_enabledBOOLEANfalse
disable_condBOOLEANfalse
disable_cond_sigma_startFLOAT1000.00–10000
disable_cond_sigma_endFLOAT0.00–10000
save_as_presetBOOLEANfalse
preset_nameSTRING
eval_string_condoptSTRING
eval_string_uncondoptSTRING
eval_string_fakeoptSTRING
args_filteroptSTRING
attention_modifiers_positiveoptATTNMOD
attention_modifiers_negativeoptATTNMOD
attention_modifiers_fake_negativeoptATTNMOD
attention_modifiers_globaloptATTNMOD

Outputs (2)

NameTypeDescription
MODELMODEL
STRINGSTRING