Nodes/ComfyUI-Prediction/Characteristic Guidance Prediction
ComfyUI Node

Characteristic Guidance Prediction

Characteristic guidance with Anderson acceleration

By redhottensors·Created 3 years ago·Updated 2 years ago· 15
Characteristic Guidance Prediction
  • cond
  • uncond
  • fallback
  • prediction
guidance_scale6.0
history2
log_step_size-3.0
log_tolerance-4.0
keep_tolerance1
reuse_scale0.0000
max_steps20
precondition_gradientstrue

This is the node in the pack that makes people stop and go "whoa." Characteristic Guidance Prediction implements the Characteristic Guidance paper - a mathematically fancier replacement for CFG - with Anderson acceleration bolted on to make it converge faster. It is also brutally expensive, and the author doesn't pretend otherwise. This is a research-grade curiosity rather than a daily driver, but if you're chasing the last bit of prompt adherence on an SDXL-lineage model, it's the most interesting thing here.

What it does, roughly

Plain CFG extrapolates between a conditioned and an unconditioned prediction, and that extrapolation has a known bias: the result drifts off the true "characteristic" of the target distribution. Characteristic guidance fixes the bias by solving for a correction - and it does it with an actual optimizer, not a closed-form formula. At each sampling step this node iterates, nudging a correction term until it converges. Anderson acceleration is the trick that remembers recent optimizer states to skip ahead, which is where history comes in.

The README is blunt about the cost: four full model evaluations plus two more for each optimizer step. The first optimizer step re-uses the initial cond/uncond pass (hence four), and every step after that is two evals. With max_steps at its default of 20, one CHG step can be tens of model evals - an entire sampling run, per step. That's why the author's advice is to never run it everywhere: "use Switch Predictions to skip CHG on the first timestep as convergence is unlikely and to disable it towards the end."

Inputs that matter

  • cond (PREDICTION) and uncond (PREDICTION) - your desired conditioned/positive prediction and your unconditioned/negative one. Wire Conditioned Prediction outputs here.
  • fallback (PREDICTION, optional) - what to use for samples that don't converge. Leave it unconnected and the node silently falls back to vanilla CFG (cond * (scale+1) - uncond * scale) for the stubborn samples, which is honestly a fine default.
  • guidance_scale (default 6) - the CFG-like strength of the conditioned prediction.
  • history (default 2) - Anderson acceleration memory. Set to 1 to disable acceleration entirely; the README warns you'll then need a larger max_steps and smaller log_step_size to converge.
  • log_step_size (default −3) and log_tolerance (default −4) - log₁₀ learning rate and convergence tolerance. Higher step size = faster but flakier; higher tolerance = faster but more artifacts.
  • keep_tolerance (default 1) - relaxes the tolerance on the final step so it returns a mostly-converged result instead of falling back.
  • reuse_scale (default 0) - reuses part of the previous correction across samples. The README says "use with caution": can improve consistency, can destabilize.
  • max_steps (default 20), precondition_gradients (default true, strongly recommended).

Working with it

Feed it a cond prediction and an uncond prediction, connect the output to your prediction chain, and wrap it in Switch Predictions or Early/Middle/Late Prediction so it only runs in the middle of denoising. Keep an eye on the console - the node prints "CHG sample N: X/Y samples did not converge" and its own progress bar. That message isn't an error; it's the fallback doing its job.

If you're on a guidance-distilled model that runs CFG 1 by design, this whole pack - and definitely this node - is the wrong tool. Characteristic guidance is an SD-lineage CFG replacement; it assumes the negative/empty pass is meaningful.

Installing it

Ships in the ComfyUI-Prediction pack by @RedHotTensors (Project RedRocket). ComfyUI Manager → search "ComfyUI-Prediction", or:

cd ComfyUI/custom_nodes
git clone https://github.com/redhottensors/ComfyUI-Prediction

Restart ComfyUI. No extra pip deps or model files. Node is under Add Node > sampling > prediction.

Common issues

  • It's slow. That's the feature. If one step visibly hangs, reduce max_steps or use it only mid-schedule.
  • Non-convergence spam. Tune log_step_size/log_tolerance, or accept the fallback.
  • ControlNet unsupported, like the rest of the pack.
Categorysampling/prediction

Inputs (11)

NameTypeDefaultDescription
condPREDICTION
uncondPREDICTION
guidance_scaleFLOAT6.01–100
historyINT2
log_step_sizeFLOAT-3.0-6–0
log_toleranceFLOAT-4.0-6–-2
keep_toleranceFLOAT11–1000
reuse_scaleFLOAT0.00000–1
max_stepsINT205–1000
precondition_gradientsBOOLEANtrue
fallbackoptPREDICTION

Outputs (1)

NameTypeDescription
predictionPREDICTION