Nodes/ComfyUI-AutoGuidance/AutoGuidance CFG Guider (good+bad)
ComfyUI Node

AutoGuidance CFG Guider (good+bad)

Guide the sampler with a bad version of itself

By xmarre·Created 7 months ago·Updated 3 months ago· 8
AutoGuidance CFG Guider (good+bad)
  • good_model
  • bad_model
  • positive
  • negative
  • GUIDER
cfg5.0
w_autoguide2.00
swap_modeshared_safe_low_vram
ag_combine_modesequential_delta
ag_delta_modebad_conditional
ag_max_ratio0.35
ag_allow_negativetrue
ag_ramp_modeflat
ag_ramp_power2.0
ag_ramp_floor0.15
ag_post_cfg_modekeep
safe_force_clean_swaptrue
uuid_only_noopfalse
debug_swaptrue
debug_metricstrue
debug_metrics_allfalse

CFG already makes your model predict twice every step - once with your prompt, once without - and amplifies the difference. This node makes it predict a third time, against a deliberately worse copy of the same model, and steers relative to that. It's the ComfyUI implementation of "Guiding a Diffusion Model with a Bad Version of Itself" (Karras et al., 2024, arXiv 2406.02507), and the name is literal, not a gimmick: you point it at a second checkpoint you loaded. No API, no key, no downloads.

Why bother? Classic CFG pushes the image toward your prompt, and the failure mode is pushing too hard - oversaturation, that deep-fried look, faces falling apart. AutoGuidance adds a separate axis: "good minus bad." If your bad model is the same model, just trained less, then that difference points at what the extra training actually bought, and you can lean on it without cranking CFG into burn territory. The README's own recipe runs it at cfg 1.1 with a distilled DMD2/LCM stack - the regime where normal CFG is basically off - and gets its guidance from AutoGuidance instead. That's the sweet spot for this thing: a guidance axis that doesn't re-apply doubled CFG on a model that was trained to run without it.

What it is

It's a guider node, the same abstraction as the built-in CFGGuider. Feed it good_model, bad_model, positive, negative, and connect its GUIDER output to the guider input on SamplerCustomAdvanced. That's the whole swap: your normal sampler setup, with the guidance replaced.

The inputs that matter

  • cfg - your normal CFG value (default 5). The good model's prediction is combined with this exactly like the stock guider.
  • w_autoguide - how hard to push the good-minus-bad direction. 1.0 is off, 2.0 is the default and moderate, 3.0 is strong.
  • swap_mode - the input that decides your VRAM budget. shared_safe_low_vram (default) keeps one model loaded and swaps state between good and bad: slowest, least VRAM. shared_fast_extra_vram trades a little VRAM for faster swapping. dual_models_2x_vram loads both models and is the only fast mode - but it needs two genuinely distinct model instances. More on that below.

The rest you'll actually touch: ag_max_ratio caps the AutoGuidance push relative to the CFG update (the source comment says it plainly - if the effect is too subtle, raise the default 0.35 toward 0.75 first); ag_ramp_mode picks where in the denoise the effect bites (flat, detail_late, compose_early, mid_peak); ag_combine_mode switches between the default sequential_delta and multi_guidance_paper, which reimplements the paper's parameterization (cfg = total g, w_autoguide = 1+α) but ignores the ramping and ratio controls.

Install

Painless - one clone, no pip dependencies, no model files:

cd ComfyUI/custom_nodes
git clone https://github.com/xmarre/ComfyUI-AutoGuidance

then restart ComfyUI. ComfyUI Manager finds it if you search "AutoGuidance." The checkpoints themselves you bring - you need a good one and a weak one.

Where people get burned

  • dual_models_2x_vram with both loaders pointing at the same file path. ComfyUI dedupes the load into one shared instance and you get washed-out or identical output. Copy the safetensors under a new name (SDXL_base_BADCOPY.safetensors) and load that as bad_model. In shared modes, if output still looks wrong, safe_force_clean_swap (on by default) is the author's named fix.
  • Shared swap modes are not just slower. The author reports the sampling pass can run an order of magnitude slower while juggling LoRA state between good and bad. Budget for it.
  • Scope. It's SDXL/SD 1.5 territory (Z-Image support landed after release); modern DiT models are untested and the author expects them to crash.
  • The bad model has to be a degraded version of the same model, not a random different one. The paper assumes aligned error patterns - fewer training steps, a weaker LoRA, reduced capacity. Grab something off-distribution and "good minus bad" stops pointing at quality and starts pointing at artifacts. The author's own recipe uses an early-epoch LoRA on the bad path at 4x weight.

One honest caveat: the release thread's most substantive reply argues two full models is a heavy hardware ask for a gain that's hard to see in quick tests. The method is real, but do what the author asks - fixed seed, A/B against plain CFG, several images per setting - before you commit the VRAM.

Categorysampling/guiders

Inputs (20)

NameTypeDefaultDescription
good_modelMODEL
bad_modelMODEL
positiveCONDITIONING
negativeCONDITIONING
cfgFLOAT5.00–50
w_autoguideFLOAT2.001–5
swap_modeCOMBOshared_safe_low_vram3 options: shared_safe_low_vram, shared_fast_extra_vram, dual_models_2x_vram
ag_combine_modeoptCOMBOsequential_delta2 options: sequential_delta, multi_guidance_paper
ag_delta_modeoptCOMBObad_conditional4 options: bad_conditional, raw_delta, project_cfg, reject_cfg
ag_max_ratiooptFLOAT0.350–5
ag_allow_negativeoptBOOLEANtrue
ag_ramp_modeoptCOMBOflat4 options: flat, detail_late, compose_early, mid_peak
ag_ramp_poweroptFLOAT2.00.5–8
ag_ramp_flooroptFLOAT0.150–1
ag_post_cfg_modeoptCOMBOkeep3 options: keep, apply_after, skip
safe_force_clean_swapoptBOOLEANtrue
uuid_only_noopoptBOOLEANfalse
debug_swapoptBOOLEANtrue
debug_metricsoptBOOLEANtrue
debug_metrics_alloptBOOLEANfalse

Outputs (1)

NameTypeDescription
GUIDERGUIDER