Conversation
leejet
left a comment
There was a problem hiding this comment.
The CFG simplification is valid, but skipping these branches also skips work required by other features:
-
Preserve APG behavior
With APG momentum enabled, removing the unconditional prediction at scale 1 makesAdaptiveProjectedGuidance::forward()return before updating its momentum buffer. Subsequent guided steps therefore produce different results. Removinguncondin three-condition APG also changes the output formula after projection/clipping. Please restrict this optimization to plain CFG until these cases are handled. -
Keep the ControlNet computation needed by
img_uncond
Whentext_cfg == img_cfg != 1, skipping theuncondbranch also skips computing negative-prompt controls. The remainingimg_uncondpass then receives the positive-prompt controls instead. Its required ControlNet computation must remain even when the unconditional diffusion pass is skipped. -
Invalidate caches for skipped conditions
With a schedule such as2 → 1 → 2, the positive cache can be refreshed while the negative cache remains unchanged. When guidance resumes, EasyCache/UCache can reuse the older negative residual based on the newer positive cache state. Please invalidate the skipped condition’s cache or force a refresh when it becomes active again.
7bcbaf8 to
75e1c85
Compare
|
Like this? |
Summary
Avoid running unnecessary diffusion model forward passes when using guidance schedule with scale == 1 (or rather scale == img_cfg)
Related Issue / Discussion
Additional Information
Checklist