Nodes/ComfyUI/Video Triangle CFG Guidance
ComfyUI Node Runs on cloud

Video Triangle CFG Guidance

Dial guidance down at the ends of your video so the middle doesn't melt

By Comfy-Org·Created 4 years ago·Updated about 4 hours ago· 129,874
Video Triangle CFG Guidance
  • model
  • MODEL
min_cfg1.0

VideoTriangleCFGGuidance patches a video model so its guidance scale follows a triangle wave across the clip: low at the first frame, climbing to your full CFG in the middle, then easing back down at the end. It's a model patch in the model/sampling/guiders family, so its job is to reshape how guidance is applied over time - not to set the guidance value itself. Same MODEL in, same MODEL out, but the model it returns behaves differently frame by frame.

How it works

The node clones your model and replaces its CFG function with one that, for each frame in the batch, computes a per-frame scale: 2 * |value/period - floor(value/period + 0.5)| - literally the triangle wave formula - over the frame axis, with a period of 1.0, so you get exactly one full triangle across the video. The per-frame scale runs from min_cfg up to your actual cond_scale (the CFG you set on the sampler) and back down, and the output is uncond + scale * (cond - uncond).

One input:

  • min_cfg (default 1.0, 0-100) - the floor at the two ends of the clip. At 1.0, the first and last frames still follow the prompt, just weakly; at 0, guidance basically turns off at the ends.

There's a sibling, VideoLinearCFGGuidance, that ramps the same way but monotonically - low at frame one, full CFG by the end. Triangle is the version that relaxes both ends, which is what you want when the first and last frames come out oversaturated or drifting while the middle is fine.

Why you'd reach for it

Video samplers apply one CFG to every frame, and that's often wrong. Strong guidance on the opening frames can pin the start of the clip to a "stuck" composition, and the end frames can drift or blow out as the model fights for coherence. By easing guidance in and out, you get a steadier first frame (which matters - it's the thumbnail) and a calmer ending. It's a small quality knob, and it's built-in, so Wan and LTX workflow authors reach for it when their clips have "melted" ends.

Where people get burned

  • Wire the patched model into your sampler. The output MODEL is a clone with the new CFG behavior. Keep using the original input model and nothing changes - silently.
  • It reshapes, it doesn't set. Your sampler's CFG is still the ceiling; min_cfg only sets the floor. Expecting this node to lower overall guidance won't work - set the CFG where you want the middle to be.
  • It's video-only in practice. The math scales along the frame axis; on a single-frame image batch there's no triangle to draw.
  • Watch it with distilled video models. They bake guidance into the training and want very low CFG anyway; a triangle peaking at that already-low value is usually fine, but don't stack it expecting magic.

Ships with ComfyUI core, no install. It won't rescue a bad prompt, but if your video's ends look overcooked, this is the built-in fix.

Categorymodel/sampling/guiders

Inputs (2)

NameTypeDefaultDescription
modelMODEL
min_cfgFLOAT1.00–100

Outputs (1)

NameTypeDescription
MODELMODEL