Nodes/MD Nodes/MD: APG Guider
ComfyUI Node

MD: APG Guider

A ComfyUI node in MD_Nodes/Guidance with 19 inputs and 3 outputs.

By MDMAchine·Created about a year ago·Updated 2 months ago· 14
MD: APG Guider
  • model
  • positive
  • negative
  • apg_guider
  • guidance_plot
  • config_summary
disable_apgfalse
apg_scale4.5
cfg_before4.0
cfg_after3.0
norm_threshold2.5
momentum0.75
start_sigma-1.00
end_sigma-1.00
eta0.0
dims-1, -2
predict_imagetrue
mode
yaml_parameters_opt
debug_mode0 - Silent
enable_profilingfalse
verbose_debugfalse
CategoryMD_Nodes/Guidance

Inputs (19)

NameTypeDefaultDescription
modelMODELMODEL INPUT • Purpose: The diffusion model to apply APG guidance to. • Requirement: Any standard diffusion model (SD1.5, SDXL, Flux). • Processing: Wraps model in custom CFGGuider.
positiveCONDITIONINGPOSITIVE COND • Purpose: Your main prompt conditioning (what you want). • Usage: Standard positive prompt input.
negativeCONDITIONINGNEGATIVE COND • Purpose: Negative prompt conditioning (what you avoid). • Trade-off: APG uses this heavily for orthogonal projection math. ⭐ Essential for APG logic.
disable_apgBOOLEANfalseDISABLE APG • Purpose: Bypass APG entirely for A/B testing. • Effect: If True, acts as standard CFGGuider. ⭐ Use to compare results without rewiring.
apg_scaleFLOAT4.50–1000APG SCALE • Purpose: Strength of orthogonal correction (how much to fix the path). • Range: 0.0 (Off) to 20.0 (Extreme). • Trade-offs: Higher values enforce prompt adherence but may 'burn' the image. • Recommended: 3.0 - 6.0. ⭐ Start with 4.5 for balanced results.
cfg_beforeFLOAT4.01–1000CFG (BEFORE) • Purpose: Static CFG applied *during* the APG active phase (High Sigma). • Range: 1.0 to 30.0. • Trade-offs: Lower values allow more creativity; higher values enforce strictness. ⭐ Recommended: 4.0 - 7.0.
cfg_afterFLOAT3.01–1000CFG (AFTER) • Purpose: Static CFG applied *after* APG deactivates (Low Sigma). • Range: 1.0 to 30.0. • Trade-offs: Lower values here improve fine details and texture. ⭐ Recommended: 2.0 - 3.5.
norm_thresholdFLOAT2.50–1000NORM THRESHOLD • Purpose: Cap the guidance vector magnitude to prevent artifacts. • Range: 0.0 (No Cap) to 10.0. • Trade-offs: Lower values prevent burning but reduce guidance strength. ⭐ Recommended: 2.5.
momentumFLOAT0.75-1000–1000MOMENTUM • Purpose: Smooths guidance vectors across steps using a running average. • Range: -1.0 to 1.0. • Effect: Positive values stabilize; negative values oscillate. ⭐ Recommended: 0.5 - 0.75.
start_sigmaFLOAT-1.00-1–10000START SIGMA • Purpose: Noise level where APG activates. • Options: -1.0 (Infinity/Always On) or specific sigma (e.g., 15.0). • Logic: Activates when current sigma <= start_sigma. ⭐ Recommended: -1.0 (or match your scheduler's max sigma).
end_sigmaFLOAT-1.00-1–10000END SIGMA • Purpose: Noise level where APG deactivates (switching to 'cfg_after'). • Options: -1.0 (Never disable) or specific sigma (e.g., 1.0). • Logic: Deactivates when current sigma < end_sigma. ⭐ Recommended: 1.0 to 3.0 (let the model refine details freely).
etaFLOAT0.0-1000–1000ETA (DEPRECATED) • Purpose: Legacy parameter from original APG, no longer used in this fork. • Recommendation: Leave at 0.0.
dimsSTRING-1, -2DIMS • Purpose: Dimensions for normalization and projection. • Format: Comma-separated integers (e.g., '-1, -2'). • Meaning: -1,-2 corresponds to Height/Width spatial dimensions. ⭐ Recommended: '-1, -2'.
predict_imageBOOLEANtruePREDICT IMAGE • Purpose: Defines target domain for guidance. • Options: True (v-prediction/x0), False (epsilon/noise). • Trade-offs: True usually works better for modern models. ⭐ Recommended: True.
modeCOMBOAPG MODE • Purpose: Algorithm variant selection. • Options: - pure_apg: Standard orthogonal projection. - pre_cfg: Applies projection before CFG scaling. - alt1/alt2: Alternative momentum blending strategies. ⭐ Recommended: 'pure_apg'.
yaml_parameters_optoptSTRINGYAML OVERRIDE • Purpose: Define complex multi-stage schedules. • Format: List of dicts with 'start_sigma', 'cfg', 'apg_scale', etc. • Priority: Overrides slider inputs if valid. ⭐ Advanced users only.
debug_modeoptCOMBO0 - SilentLOGGING VERBOSITY • Purpose: Controls console output details. • Options: - 0: Minimal output. - 1: Basic info + Profiler report. - 2: Step-by-step guidance logs. ⭐ Recommended: 0 for production, 1 for tuning.
enable_profilingoptBOOLEANfalseENABLE PROFILING • Purpose: Measure timing of rule building and plotting. • Automatic: Enabled if Debug Mode >= 1. ⭐ Recommended: False.
verbose_debugoptBOOLEANfalseLEGACY VERBOSE • Deprecated. Use 'debug_mode' instead.

Outputs (3)

NameTypeDescription
apg_guiderGUIDER
guidance_plotIMAGE
config_summarySTRING