Files
ComfyUI-CFG-CTRL/nodes.py
Ethanfel a0d6bf39f7 Fix chattering: boundary layer SMC instead of hard sign()
The hard sign(s) creates a random +/-1 pattern in regions where the
guidance error is near zero. When amplified by cond_scale (e.g. 12),
this produces severe high-frequency noise artifacts, especially on
SDXL which has smaller guidance magnitudes than SD3/FLUX.

Replace sign(s) with sat(s/phi) — the standard boundary layer approach
in practical sliding mode control. phi adapts to the guidance error
std so the switching threshold is meaningful across different models.

- |s| >> phi: correction = +/-K (same as paper)
- |s| << phi: correction = K*s/phi (smooth, proportional)
- Near-zero guidance regions get near-zero correction (no noise)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 18:00:57 +01:00

4.9 KiB