A ComfyUI custom node implementing AutoGuidance from the paper:
Guiding a Diffusion Model with a Bad Version of Itself (Karras et al., 2024)
https://arxiv.org/abs/2406.02507
Repository: https://github.com/xmarre/ComfyUI-AutoGuidance
Reddit Thread with more info on usage: https://www.reddit.com/r/StableDiffusion/comments/1r2a7qo/release_comfyuiautoguidance_guide_the_model_with/
Classic CFG steers generation by contrasting conditional and unconditional predictions.
AutoGuidance adds a second model path (“bad model”) and guides relative to that weaker reference.
In practice, this gives you another control axis for balancing:
- quality/faithfulness,
- collapse/overcooking risk,
- structure vs detail emphasis (via ramping).
This extension registers two nodes:
- AutoGuidance CFG Guider (good+bad) (
AutoGuidanceCFGGuider)
Produces aGUIDERfor use withSamplerCustomAdvanced. - AutoGuidance Detailer Hook (Impact Pack) (
AutoGuidanceImpactDetailerHookProvider)
Produces aDETAILER_HOOKfor Impact Pack detailer workflows (including FaceDetailer).
Clone into your ComfyUI custom nodes directory and restart ComfyUI:
git clone https://github.com/xmarre/ComfyUI-AutoGuidanceNo extra dependencies.
- Load two models:
good_modelbad_model
- Build conditioning normally:
positivenegative
- Add AutoGuidance CFG Guider (good+bad).
- Connect its
GUIDERoutput to SamplerCustomAdvancedguiderinput.
Use AutoGuidance Detailer Hook (Impact Pack) when your detailer nodes accept a DETAILER_HOOK.
This injects AutoGuidance into detailer sampling passes without editing Impact Pack source files.
If you use:
swap_mode = dual_models_2x_vram
then ensure ComfyUI does not dedupe the two model loads into one shared instance.
Make a real file copy of your checkpoint (same bytes, different filename), for example:
SDXL_base.safetensorsSDXL_base_BADCOPY.safetensors
Then:
- Loader A (file 1) →
good_model - Loader B (file 2) →
bad_model
If both loaders point to the exact same path, ComfyUI may share/collapse model state and dual-mode behavior/performance can be incorrect.
cfgw_autoguide(effect is effectively off at1.0; stronger above1.0)swap_modeshared_safe_low_vram(safest/slowest)shared_fast_extra_vram(faster shared swap, extra VRAM)dual_models_2x_vram(fastest, highest VRAM, requires distinct instances)
ag_combine_modesequential_delta(default; current behavior: CFG result + AG delta)multi_guidance_paper(paper-style multi-guide extrapolation using good-cond, good-uncond, bad-cond)- In
multi_guidance_paper,ag_delta_mode,ag_max_ratio, ramping, and project/reject controls are not used.
ag_delta_modebad_conditional(default, common starting point)raw_deltaproject_cfgreject_cfg
ag_max_ratio(caps AutoGuidance push relative to CFG update magnitude)ag_allow_negativeag_ramp_modeflatdetail_latecompose_earlymid_peak
ag_ramp_powerag_ramp_floorag_post_cfg_modekeepapply_afterskip
safe_force_clean_swapuuid_only_noopdebug_swapdebug_metrics
This is one practical baseline, not a rule.
- Good side:
- Base checkpoint + more fully-trained/specialized stack (e.g., 40-epoch character LoRA + DMD2/LCM, etc.)
- Bad side options:
- Base checkpoint + earlier/weaker checkpoint/LoRA (e.g., 10-epoch) with intentionally poor weighting
- Base checkpoint + fewer adaptation modules
- Base checkpoint only
Core idea: bad side should be meaningfully weaker/less specialized than good side.
cfg: 1.1w_autoguide: 3.00- note: in
multi_guidance_paper, values above2.0clamp toα=1.0(pure AG share).
- note: in
swap_mode: dual_models_2x_vramag_delta_mode: reject_cfgag_max_ratio: 0.75ag_allow_negative: trueag_ramp_mode: compose_earlyag_ramp_power: 2.0ag_ramp_floor: 0.00ag_post_cfg_mode: skipsafe_force_clean_swap: trueuuid_only_noop: falsedebug_swap: truedebug_metrics: true
- In non-paper modes, increase
w_autoguideabove1.0to strengthen effect. - In
multi_guidance_papermode, weights are interpreted as:α = clamp(w_autoguide - 1, 0, 1)w_total = max(cfg - 1, 0)w_cfg = (1 - α) * w_totalw_ag = α * w_total- CFG leg uses
cfg_scale = 1 + w_cfg(including sampler CFG hooks). - final output =
CFG(good, cfg_scale) + w_ag * (C - B)whereC= good conditional andB= bad conditional.
- To set paper interpolation directly (total
g, mixα):cfg = gw_autoguide = 1 + αag_combine_mode = multi_guidance_paper
- In
multi_guidance_paper,ag_post_cfg_modestill works:keep/skip: AG is mixed before post-CFG hooks.apply_after: run post-CFG hooks on CFG-only output, then add AG delta.
- In
multi_guidance_paper,ag_delta_mode,ag_max_ratio,ag_ramp_mode,ag_ramp_power, andag_ramp_floorare currently ignored. compose_earlytends to affect composition/structure earlier in denoise.- Try
detail_latefor a more late-step/detail-leaning influence.
AutoGuidance adds extra forward work versus plain CFG.
dual_models_2x_vram: fastest but highest VRAM and strict dual-instance requirement.- Shared modes: lower VRAM, slower due to swapping.
At fixed seed/steps, compare:
- CFG-only vs CFG + AutoGuidance
- different
ag_ramp_mode - different
ag_max_ratiocaps - different
ag_delta_mode
Useful community feedback includes:
- what “bad model” definitions work best in real SD pipelines,
- parameter combos that outperform standard CFG or NAG,
- reproducible A/B examples with fixed seed + settings.
If this node helps, share workflows and side-by-side comparisons in issues/discussions.