Nodes/CFG Megapack/SMC-CFG: sliding-mode control CFG (Wang et al. 2026)
ComfyUI Node

SMC-CFG: sliding-mode control CFG (Wang et al. 2026)

Treat guidance as a control loop (and leave the k on auto)

By AbstractEyes·Created 5 days ago·Updated 5 days ago· 3
SMC-CFG: sliding-mode control CFG (Wang et al. 2026)
  • model
  • MODEL
◄scale-1.0►
◄lam5.0►
◄k-1.000►
◄switchingsign►
◄spaceauto (the method's own)►

Engineers have a name for systems that oscillate around a target: you bolt a feedback controller on. SMC-CFG (Wang et al., CVPR 2026) does exactly that to guidance. Instead of trusting a fixed scale for the whole run, it watches how the guidance difference changes between steps and adds a small bounded correction to push it back on track.

It's the most "engineering" node in the pack, and it comes with the most explicit warning label in the docs - which is genuinely useful, because the paper's own constant will wreck your SDXL images.

The mechanism

Per step, with e = c - u the guidance difference and e_prev the corrected difference from the previous step:

s = (e - e_prev) + lam * e_prev          the sliding surface
correction = -k * sign(s)                or -k * s / ||s|| in the 'unit' form
e_hat = e + correction
out   = u + w * e_hat

lam is the slope of the surface (how much the controller cares about the accumulated offset versus the step-to-step change), k is how big each correction can be. The correction is bounded by construction - it's a fixed-size nudge, not a multiple of the error - which is what a sliding-mode controller buys you: it pushes hard when it's off and then stops pushing.

The paper's settings are lam 6 and k 0.1 on SD3.5/Qwen, 0.7 on Flux; the pack's official README uses lam 5 and k 0.2.

The problem the pack's author found and documented: on a noise-prediction model like SDXL, that correction moves the denoised estimate by sigma × w × k per element, and SDXL's sigma starts at 14.6. So the paper's k = 0.2 produces garbage. Hence the default.

Inputs and output

  • model - between the loader and the sampler.
  • scale - the w for this rule, -1 = the sampler's cfg.
  • lam - default 5, "sliding-surface slope". Higher means the controller leans more on accumulated error.
  • k - default -1, which is auto: the pack picks the paper's 0.2 on flow-matching models and 0.01 on noise-prediction models like SDXL. You can set it explicitly, but there's a reason the default exists. k = 0 is plain CFG.
  • switching - sign (the paper) or unit vector (the node's own longer form). Both bound the correction; sign is a hard yes/no per element, unit is smoother.
  • space - auto (the method's own).

Output: MODEL, no extra forward pass, one small buffer of state. It resets when a new run starts, so successive queues don't bleed into each other.

Who this is for

Flow-matching models. On Anima, Flux and the like the paper's value applies as written, and this is one of the few methods that's actively better on a 2026 architecture than on SDXL. On SDXL it works with the auto value but the effect is close to a mild stabilizer.

If you're on an SDXL family checkpoint and want something visibly transformative, this isn't the node - go to skimming, rescale or APG. If you're on Anima and want to stop late-step texture from going strange, this is a legitimately underrated one.

Install

Manager → search CFG Megapack → install → restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/AbstractEyes/comfy-cfg-megapack

No dependencies and no model downloads - the pack is torch and the stdlib, and it deliberately ships without a requirements.txt. The flip side: it's written against comfy_api.latest and the README reports testing on ComfyUI 0.38.0, so a stale install won't import the pack at all. If you're on Anima, the repo's tools/get_anima.py fetches and checksum-verifies its files (read the licence on the model page first - it's non-commercial).

Where people get burned

Setting k to the paper's 0.2 on SDXL. This is the documented failure mode, not a mystery. The value is documented as wrecking the image at 1024×1024 with both dpmpp_2m and euler. Values around 0.005–0.01 work. Just leave it at -1.

Expecting a visible change from lam alone. With k near zero, lam has nothing to scale. lam shapes when the correction bites, k decides whether it matters.

Assuming it replaces a schedule. It corrects the difference between steps; it doesn't ramp your scale up or down over the run. Pair it with CFG When or a schedule node if that's what you're after.

Slot conflicts. Another pack's RescaleCFG / Mahiro / RenormCFG chained after this node takes ComfyUI's single CFG-function slot and SMC-CFG does nothing. The pack's CFG Plan Readout exists to catch exactly that; CFG Measure: Per-Step Probe will show you the per-step scale and push if you want the numbers.

CategoryCFG Megapack/papers/combining the two predictions

Inputs (6)

NameTypeDefaultDescription
modelMODEL—
scaleFLOAT-1.0-1–100The guidance scale w for this rule. -1 uses the sampler's cfg value.
lamFLOAT5.00–20Sliding-surface slope.
kFLOAT-1.000-1–2Correction size per element (0 = plain CFG; -1 = auto: the paper's 0.2 on flow models, 0.01 on noise-prediction models such as SDXL, where the paper's value wrecks the image).
switchingCOMBOsignsign (paper) or unit vector (the ComfyUI node's form).
spaceCOMBOauto (the method's own)Where the rule is computed. Linear rules give the same image in any space; nonlinear ones do not. 'auto' uses the space the method was published in (noise for most, denoised for APG and the angle rule, velocity for flow models).

Outputs (1)

NameTypeDescription
MODELMODEL—