Nodes/raylight/Tangential Damping CFG (Ray)
ComfyUI Node

Tangential Damping CFG (Ray)

The Set-and-Forget Quality Bump

By komikndr·Created about a year ago·Updated 2 days ago· 409
Tangential Damping CFG (Ray)
  • ray_actors
  • ray_actors

Here's a rare one: a guidance patch with zero inputs. RayTCFG (Tangential Damping CFG) takes ray_actors in, applies a model patch, and hands the stream back. No sliders, no tuning, no way to screw it up. That alone makes it my favorite kind of node.

What it does is subtle and worth understanding. CFG extrapolates between the conditional and unconditional predictions, but that extrapolation isn't only a matter of how far you go - it's also what direction. Part of the CFG push is "on-target" (moves toward your prompt) and part is "tangential" (spins off sideways, contributing artifacts without helping adherence). Tangential damping identifies that off-target component in the unconditional prediction and damps it before the CFG calculation runs, so the extrapolation is cleaner.

Concretely, the patch hooks the pre-CFG stage: it takes the unconditional prediction, computes the component that's perpendicular to the correct denoising direction (x - uncond vs x - cond), and replaces the unconditional prediction with a damped version. The CFG then extrapolates against a cleaner baseline. The visible result: fewer of those CFG-induced artifacts - the noise-correlated smearing and the "AI look" - at the same CFG value. It's essentially a free quality tweak on any workflow that uses real CFG (greater than 1 with a negative prompt).

It only engages when there's an actual conditional and unconditional pass to work with - the source code bails out if len(conds_out) <= 1 or a cond is None. So on a distilled model at CFG 1, it's inert. That's not a bug; there's nothing to damp.

Where it fits

Any Raylight workflow running SD 1.5/SDXL through CFG parallelism, or any un-distilled model with a real CFG pass. Chain it anywhere after Ray Init Actor. It composes with RescaleCFG nicely - TCFG cleans the direction, RescaleCFG fixes the magnitude, and between them high-CFG workflows lose most of their jank. It's a port of the community TCFG node, so any tuning lore you've read about that applies here; the pack just made it worker-aware.

Install

Part of raylight:

cd ComfyUI/custom_nodes
git clone https://github.com/komikndr/raylight
cd raylight
pip install -r requirements.txt

Restart, or install "raylight" via ComfyUI Manager.

Gotchas

Because it's a pre-CFG patch, it only matters when the sampler actually runs an unconditional pass. At CFG 1 (the default for every guidance-distilled model of the last couple years) this node does nothing - which is fine, it just means it's not the tool for that workflow. Don't be tempted to raise CFG just to make the node "work"; you'll reintroduce the artifacts it's there to remove.

CategoryRaylight/extra/guidance

Inputs (1)

NameTypeDefaultDescription
ray_actorsRAY_ACTORS

Outputs (1)

NameTypeDescription
ray_actorsRAY_ACTORS