Custom CFG Keyframe ππ π
Scheduling your CFG scale to change mid-clip
- prev_custom_cfg
- cfg_extras
- CUSTOM_CFG
Your KSampler's CFG slider sets one value for the whole run. This node lets you schedule CFG to change at specific points during sampling instead - the same keyframe idea ADE_AnimateDiffKeyframe applies to motion strength, applied here to guidance scale. Chain several of these together (each declaring a start_percent and a cfg value) and you get a CFG curve across your clip rather than one flat number.
It's a real technique some AnimateDiff users lean on to fight a specific symptom: burned-in, over-contrasted frames later in a clip when CFG stays high the whole way through. Dropping CFG partway through sampling - rather than fighting it with prompt changes - is one lever for that, though it's worth treating as one tool among several rather than a guaranteed fix.
How it works
Each ADE_CustomCFGKeyframeSimple marks a point in the sampling timeline (start_percent) where a new cfg value takes over, staying in effect until the next keyframe in the chain. You build the chain by feeding one keyframe's output into the next one's prev_custom_cfg input, and the whole assembled chain plugs into Sample Settings' custom_cfg slot - which only takes effect once it's wired through to your loader or Use Evolved Sampling, replacing whatever fixed CFG you'd otherwise set on the KSampler itself.
The inputs and outputs that matter
Required: cfg (default 8 - a normal SD 1.5 CFG value, since this replaces your sampler's own CFG setting once wired in), start_percent (default 0, range 0β1), and guarantee_steps (default 1) - the same protection ADE_AnimateDiffKeyframe has, ensuring this keyframe gets at least this many steps before a nearby one crowds it out.
Optional: prev_custom_cfg (type CUSTOM_CFG) to chain the previous keyframe in, building a multi-point schedule, and cfg_extras (type CFG_EXTRAS) for additional CFG-related modifiers from another node in the pack. Output is CUSTOM_CFG, feeding the next keyframe's prev_custom_cfg or Sample Settings' custom_cfg slot.
How to install it
Standard for the pack - ComfyUI Manager, search AnimateDiff Evolved by Kosinkadink, or:
cd ComfyUI/custom_nodes && git clone https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved
No model download for this node - it's sampling configuration on top of whatever checkpoint and motion setup you already have.
Common issues & troubleshooting
Set this up but your KSampler's own CFG slider still seems to be what's controlling output. Confirm the chain actually reaches Sample Settings' custom_cfg input, and Sample Settings itself is wired into your loader or Use Evolved Sampling. If that connection is missing, your KSampler's own CFG value is still the one in effect - this system only overrides it once fully wired through.
Built a multi-point schedule and the transitions look abrupt. There's no built-in crossfade between one keyframe's cfg and the next - it's a hard switch at start_percent, the same way ADE_AnimateDiffKeyframe behaves for motion. If you want a gentler ramp, add more keyframes with smaller CFG steps between them rather than one big jump.
Not sure this is worth the setup versus just picking one CFG value. For most clips, it isn't - a single well-chosen CFG on your KSampler covers the common case fine. This is worth reaching for specifically when you've identified a concrete problem (late-clip burn-in, a scene that needs looser guidance partway through) that a flat CFG value doesn't solve.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| cfg | FLOAT | 8.00β100 | β |
| start_percent | FLOAT | 0.0000β1 | β |
| guarantee_steps | INT | 10β9007199254740991 | β |
| prev_custom_cfgopt | CUSTOM_CFG | β | |
| cfg_extrasopt | CFG_EXTRAS | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| CUSTOM_CFG | CUSTOM_CFG | β |