Adaptive Guidance (Castillo et al. 2023)
Turn CFG off once the prompt has been obeyed
- model
- MODEL
Here's a thought experiment that's basically the paper. Run CFG 7 for fifty steps and you spend the whole run paying for guidance - including the last twenty steps, where the picture is already decided and all CFG can still do is exaggerate contrast. So why not stop?
Adaptive Guidance (Castillo et al., AAAI 2025) does exactly that, with a stopping rule instead of a guess. At each step it measures how similar the conditional and unconditional predictions are. While they disagree, guidance is on. Once they've converged - the cosine between them exceeds a threshold - the node stops guiding and passes the conditional prediction through untouched for the rest of the run. The intuition is that agreement between the two branches means the prompt's information is already in the sample, and there's nothing left to steer.
The one detail that will confuse you
The tooltip on threshold contains the most useful sentence in the node:
SDXL's two noise predictions differ by about 1% of their size, so their cosine starts above 0.9999 and the paper's reading would stop guidance at the first step.
Read that twice. If you compute the cosine in the noise space the way the paper describes, SDXL's two
predictions are already almost identical at step one, the threshold is tripped immediately, and the
node becomes a no-op. That's not a bug in the pack - it's why the node reads the cosine of the
denoised predictions (the default space is denoised (x0)), the same workaround ComfyUI's
community node for this method uses. If you set space to auto out of habit and the image suddenly
stops responding to guidance, this is why.
The default threshold of 0.999 is likewise adjusted rather than copied. Measured over 50 steps it
stops guidance after 18 steps on SDXL at cfg 7 and after 25 on Anima at cfg 4.5. The paper's own
0.991, read on the models it was written for, would stop after 8 and 13 here.
Inputs
- model - from the checkpoint or LoRA loader, before the sampler.
- scale (default -1) -
-1uses the KSampler's cfg for the guided phase. - threshold (default 0.999, range 0.9–1.0) - the cosine at which guidance stops. Lower = stops sooner. It's a narrow-feeling range and the whole useful action is in the last two decimal places of it, which is exactly why the tooltip includes the measured step counts instead of leaving you to bisect blind.
- space - leave on
denoised (x0). See above.
Output is a MODEL.
Install
# ComfyUI Manager: search "CFG Megapack" -> Install -> restart
# or:
comfy node install comfy-cfg-megapack
# or by hand:
cd ComfyUI/custom_nodes && git clone https://github.com/AbstractEyes/comfy-cfg-megapack
No dependencies beyond ComfyUI's torch, nothing to download, ComfyUI ≥ 0.38.
Does it save time?
Sometimes people assume "stops guiding" means "skips the unconditional pass" and therefore halves the
back half of the render. Be careful - that's the behaviour the pack's window nodes advertise
(CFG When: Schedule and Window has a skip_uncond_outside option, and CFG Truncation skips the
unconditional pass after its cutoff). This node is a combine-rule, so the mechanism is that the guided
prediction becomes the conditional one; whether the second forward pass can be skipped depends on
what else is in the plan. If speed is the point, prefer the window-based nodes and check the pack's
own HOWTO.md for the current behaviour rather than assuming.
Where it fits
It writes the combine stage of the pack's seven-stage guidance plan, so a later combine node replaces
it; corrections stack. Mixing it with a schedule is the natural experiment - a window that shapes the
scale early plus this node deciding when to stop - and CFG Plan Readout is the node to check what's
actually installed, since a chained order that looks sensible in the graph can produce a plan you
didn't intend. CFG Measure: Per-Step Probe writes the per-step cosine and scale to
output/cfg_probe/, which for this node is the fastest way to see the stopping rule fire.
And the usual: one CFG-function slot per model, so another pack's CFG node chained last silently wins; and the pack's hook forces the unconditional pass on, which matters on distilled models where cfg 1 was giving you a free speedup.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| scale | FLOAT | -1.0-1–100 | The guidance scale w for this rule. -1 uses the sampler's cfg value. |
| threshold | FLOAT | 0.99900.9–1 | Cosine of the denoised predictions where guidance stops. Measured over 50 steps: 0.999 stops it after 18 steps on SDXL (cfg 7) and 25 on Anima (cfg 4.5); the paper's 0.991 (read on its own models, about half of 20 steps) would stop it after 8 and 13 here. |
| space | COMBO | denoised (x0) | Where the rule is computed. Linear rules give the same image in any space; nonlinear ones do not. 'auto' uses the space the method was published in (noise for most, denoised for APG and the angle rule, velocity for flow models). |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |