Nodes/KJNodes for ComfyUI/Scheduled CFG Guidance
ComfyUI Node Runs on cloud

Scheduled CFG Guidance

Apply CFG only over the steps that need it

By kijai·Created 3 years ago·Updated about 21 hours ago· 2,930
Scheduled CFG Guidance
  • model
  • positive
  • negative
  • GUIDER
cfg6.00
start_percent0.00
end_percent1.00

Classifier-free guidance is what makes a model actually follow your prompt, but it isn't free - with CFG on, the model runs twice per step, so it roughly doubles render time. This node lets you apply CFG only during the slice of sampling where it matters and turn it off for the rest, buying back some of that time. It's a GUIDER, so it plugs into the custom-sampler path rather than a plain KSampler.

The idea

Guidance does most of its useful work early. The first chunk of steps is where composition and prompt adherence get locked in; the later steps are mostly refining detail, where cranking guidance buys little and can even over-sharpen. So instead of paying for the double forward pass on every single step, you schedule CFG to run over, say, the first 60% and then drop to unguided for the tail. Structure comes out where you wanted it, and the back half runs at single-pass speed.

This dovetails with the modern distillation story. A guidance-distilled model already has guidance baked in and runs at CFG 1 - no double pass, nothing to schedule. This node is for the case where you're running real CFG above 1 and want to be surgical about when you spend it. It's filed experimental, and it's the kind of tuning you reach for when you're optimizing a workflow you run a lot, not a first-draft graph.

The inputs and output

  • model - the model to guide.
  • positive / negative - your conditioning. Because this produces a guider, the prompts go into it rather than into a separate sampler node.
  • cfg (default 6) - the guidance strength while it's active. Same meaning as the CFG you know.
  • start_percent (default 0) / end_percent (default 1) - the fraction of the sampling schedule over which CFG is applied. 0-1 means the whole run (equivalent to normal CFG); set end_percent to 0.6 and CFG runs for the first 60% then guidance switches off for the rest.

The output is a GUIDER, which you feed into a SamplerCustomAdvanced setup (alongside your sampler, sigmas, and noise) rather than a basic KSampler. If you're not already on the custom-sampler nodes, that's the one adjustment to make.

How to install it

It's in kijai's KJNodes pack.

  • ComfyUI Manager - search KJNodes for ComfyUI, install, restart.
  • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, then pip install -r ComfyUI-KJNodes/requirements.txt, restart.

No models or dependencies.

Common issues & troubleshooting

Prompt adherence dropped after you narrowed the window. You cut CFG off too early - if end_percent is too low, the model loses guidance before composition is settled and drifts from the prompt. Push end_percent back up until adherence returns; the savings aren't worth a gen that ignores you.

No speedup. If you're already at CFG 1 (a distilled model), there's no second pass to skip and this node has nothing to save - it's only meaningful when CFG is above 1. And if your window is still effectively 0-1, you're paying full CFG the whole time.

It won't connect to my KSampler. Right - a GUIDER doesn't go into a standard KSampler. Switch to SamplerCustomAdvanced (or the BasicGuider-style custom path) and wire the guider there.

Detail looks different in the back half. Expected - the tail is running unguided once CFG switches off. If you liked the guided look throughout, that's the trade you opted into; widen the window or accept the softer, faster finish.

CategoryKJNodes/experimental

Inputs (6)

NameTypeDefaultDescription
modelMODEL
positiveCONDITIONING
negativeCONDITIONING
cfgFLOAT6.000–100
start_percentFLOAT0.000–1
end_percentFLOAT1.000–1

Outputs (1)

NameTypeDescription
GUIDERGUIDER