VideoLinearCFGGuidance (Ray)
VideoLinearCFGGuidance (Ray)
- ray_actors
- ray_actors
Flat CFG is a blunt instrument for video. A single guidance scale that's right for frame 20 is often too aggressive for frame 1 and too weak by frame 60 - which is exactly why video generations drift into over-saturated, over-contrasty territory the longer they get. VideoLinearCFGGuidance (Ray) replaces that flat scale with a ramp, and it's Raylight's take on a trick that's quietly become standard in good video workflows.
Raylight is Komikndr's multi-GPU pack for ComfyUI - one model, several GPUs, work split by USP sequence parallelism and weights split by FSDP. This node sits under Raylight/extra/guidance, which means it's a patch: it doesn't sample anything itself, it modifies the model held by your RAY_ACTORS chain so the sampler behaves differently.
How it works
It installs a custom CFG function on the model. Each denoising step, instead of applying your single cfg value to every item in the batch, it computes a linear ramp from min_cfg up to your sampler's CFG across the batch dimension:
scale = linspace(min_cfg, cond_scale, batch_size)
output = uncond + scale * (cond - uncond)
In video the batch dimension is effectively the frames, so what you get is guidance starting low and climbing to full strength. Low guidance on the early frames keeps them stable and stops the clip from overcooking at the start; full guidance by the end is where the prompt adherence lives. Set min_cfg to 1 and the start of your clip is essentially unguided - a good default for Wan, where CFG 1 is the natural resting state.
The inputs
Two, and one matters:
- ray_actors - the model chain. In, then out, into your sampler.
- min_cfg (default 1.0) - the guidance scale applied to the first frame(s). Raise it if your opening frames look flat or detached from the prompt; lower it (toward 0) if your clips still open too hot. It's a feel-it-out dial.
Install
It's part of the raylight pack, so:
cd ComfyUI/custom_nodes
git clone https://github.com/komikndr/raylight
cd raylight
<your_python> -m pip install -r requirements.txt
or find raylight in ComfyUI Manager and let it handle it. Same dependencies as everything else here: ray, xfuser, kernels, huggingface_hub, hf_transfer. No FlashAttention needed on modern setups.
Where people get burned
The ramp only shows up if the node is actually in the chain - it has to sit between your Load Diffusion Model (Ray) and the sampler, because it patches the model object that flows through. And a subtle one: this node overrides the sampler's own CFG handling, so if you also chain the triangle variant into the same model, the last patch wins. Pick one guidance patch per chain, or you'll chase phantom behavior changes.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| ray_actors | RAY_ACTORS | — | |
| min_cfg | FLOAT | 1.00–100 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| ray_actors | RAY_ACTORS | — |