DCW(+a)
DCW, CWM, and SMC for when the CFG dial isn't enough
- model
- model
If you've ever cranked CFG up to force the prompt through and instead got burnt, oversaturated garbage, that's not you doing it wrong - that's the tool being blunt. Standard CFG multiplies the whole cond − uncond error by a single scalar, all frequencies, all steps, at once. DCWModelPatch takes that one knob and cracks it open into three training-free corrections, each with its own toggle:
- DCW (Differential Correction in Wavelet domain) fixes the SNR-t bias - the tendency of a model's predicted clean image (
x0_pred) to drift as noise accumulates. - CWM (CFG Wavelet Mixing) applies different guidance strength to low vs high frequencies, and to early vs late denoising steps.
- SMC (Sliding Mode Control CFG) stabilizes the guidance error itself so high-CFG sampling stops oscillating.
No training, no model downloads, no API, no external dependencies. It's a single model_patches node you drop between your checkpoint (or LoRA chain) and KSampler.
How it actually works
Think of it as three hooks at different spots in the sampler:
- DCW lives in
sampler_post_cfg_function- it runs after CFG has combined the conditioned and unconditioned predictions. It decomposesx0_predinto wavelet bands and nudges each band toward or away from the current noisy latent, with timing: low-frequency (composition/color) corrections peak in early steps, high-frequency (edge/texture) corrections peak late. Because it runs after CFG, it's independent of your CFG scale and sampler choice. - CWM replaces the scalar CFG formula inside
sampler_cfg_function. It splits the guidance errore = cond − uncondinto wavelet bands and scales each one separately - "follow the prompt's composition hard early, leave the texture alone late," impossible with one CFG value. - SMC runs inside the same hook, before CWM. It's straight control theory: a sliding surface built from the current and previous guidance error, corrected by a normalized switching term so the correction energy stays bounded. Net effect: the guidance trajectory stops wobbling at high CFG. Set
smc_presettoAutoand it reads the model class name and applies paper-tested (λ, k) values for your model family.
Honest caveat: the author cites the DCW SNR-t bias paper and the CFG-Ctrl (SMC) CVPR work, but this is a new, niche pack with a thin community footprint. The README's numbers are the author's own tuning tables, not crowdsourced gospel - treat them as starting points and A/B test (right-click → Bypass does that for free).
The inputs that matter
Nine knobs sounds like a lot, but defaults are sane and you'll realistically touch three:
lambda_l/lambda_h- DCW's low- and high-frequency correction strength. Start0.05 / 0.010for SD/SDXL-class models, roughly double for flow models. Set both to0to disable DCW.alpha_l/alpha_h- CWM's per-band CFG boost, expressed relative to your base CFG scale.0means identical to standard CFG, which is a nice safety property. Start0.1–0.3low-freq and0.1–0.2high-freq.smc_preset-Off(default),Auto(recommended), named presets per model family (SDXL, Flux, SD3/SD3.5, Qwen-Image, Cosmos/Wan…), orCustom, which unlocks thesmc_lambdaandsmc_ksliders. Leave those alone untilAutodisappoints you.
dcw_enabled and cwm_enabled are your A/B toggles. The single output is model (MODEL), which wires straight into KSampler's model port.
Installing it
Through ComfyUI Manager, search "ComfyUI-DCW". Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/namemechan/ComfyUI-DCW
Then restart ComfyUI. That's the whole install - no requirements.txt, no model files, pure PyTorch. Zero-dependency installs are rare in this ecosystem; enjoy it.
Where people get burned
The hook conflict, first and foremost. CWM and SMC take over sampler_cfg_function. If another node upstream has already registered that hook - some CFG-refiner and guidance-modifier nodes do - CWM and SMC are silently skipped with only a console warning. DCW uses a different hook (sampler_post_cfg_function) and always chains safely. If CWM/SMC appear to do nothing, check the console, then move this node earlier or disable the conflicting hook.
A few built-in guards worth knowing: odd-resolution latents are reflect-padded, corrected, and cropped back; fp8 tensors get upcast to bf16 for the math and restored; SMC runs in fp32 specifically to dodge the NaN/black-image failure you can hit when combining fp16 patches like SageAttention with this kind of math.
Flow models are the special case. Flux, Cosmos/Anima, and Wan cap their σ scale around 0.5, so corrections land at half strength - double your lambda/alpha values there. Also know the effect is strongest at low step counts (10–20 steps); at 30+ it gets subtle. And one quiet detail: with CWM or SMC active, the node forces ComfyUI to compute the unconditional pass even at CFG 1 - it needs that prediction to steer with, so your "CFG 1 = free speed" trick won't apply while it's on. If you're already happy with your sampler and CFG, this is strictly optional; if you're fighting oversaturation, blur, or prompt drift, it's worth an afternoon of A/B before you go shopping for a new sampler.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| lambda_l | FLOAT | 0.050-0.5–0.5 | [DCW] Low-frequency correction strength (x0_pred). Positive: push x0_pred toward x_t (more signal). Negative: push away from x_t (less signal). Active mainly in EARLY denoising steps. Start: 0.04–0.07 for DDPM/EDM; ~2× for Flux/Flow. Set 0.0 to disable DCW low-freq correction. |
| lambda_h | FLOAT | 0.010-0.3–0.3 | [DCW] High-frequency correction strength (x0_pred). Positive: push x0_pred toward x_t (more detail). Negative: push away from x_t (less detail). Active mainly in LATE denoising steps. Start: 0.008–0.015 for DDPM/EDM; ~2× for Flux/Flow. Set 0.0 to disable DCW high-freq correction. |
| dcw_enabled | BOOLEAN | true | [DCW] Toggle SNR-t bias correction on/off. |
| alpha_l | FLOAT | 0.00-1–2 | [CWM] Low-frequency CFG boost strength. Scales the LL guidance band relative to base CFG scale. Positive: amplify coarse structure/composition guidance in early steps. Negative: suppress low-freq guidance. 0.0 = standard CFG for this band. Suggested start: 0.1–0.3. Flow models (Flux): try 0.2–0.5. |
| alpha_h | FLOAT | 0.00-1–2 | [CWM] High-frequency CFG boost strength. Scales the HH guidance band relative to base CFG scale. Positive: amplify edge/texture/detail guidance in late steps. Negative: suppress high-freq guidance. 0.0 = standard CFG for this band. Suggested start: 0.1–0.2. Excessive values cause over-sharpening. |
| cwm_enabled | BOOLEAN | true | [CWM] Toggle CFG Wavelet Mixing on/off. |
| smc_preset | COMBO | Off | [SMC] Sliding Mode Control CFG preset. 'Off' — SMC disabled entirely. 'Auto' — auto-detect model family, apply paper defaults. Named presets — paper-verified (λ, k) per model family. 'Custom' — use smc_lambda / smc_k sliders below. SMC runs inside the CWM hook (sampler_cfg_function). It corrects guidance error quality BEFORE CWM distributes it across frequency bands. If cwm_enabled=False, SMC still activates the cfg hook and runs without wavelet overhead (pure SMC-CFG mode). |
| smc_lambda | FLOAT | 6.00.5–30 | [SMC] Shape parameter λ of the sliding mode surface. Only used when smc_preset = Custom. Paper recommends 2–8. Extreme values distort the manifold. |
| smc_k | FLOAT | 0.100–5 | [SMC] Switching gain k. Only used when smc_preset = Custom. Low k → better realism, weaker text alignment. High k → stronger text alignment, risk of chattering. |
| rdc_tau | FLOAT | 0.000–0.5 | [RDC] Band-wise EMA drift compensation — on/off AND time- constant in one value. 0.0 = RDC fully OFF (default; identical to not having RDC). > 0.0 = RDC ON. Value = memory span in sigma_norm units ([0,1) range, scheduler/step-count independent): after the sampler has moved this far in sigma_norm, the EMA's memory of older steps has decayed to ~37%. Smaller (e.g. 0.05–0.1) → reacts fast, short memory. Larger (e.g. 0.2–0.3) → reacts slowly, long memory, smoother. Corrects cross-step trajectory drift (pose/face/composition slowly wandering over steps) — different from DCW, which only compares each step to itself, not the trajectory. Reuses DCW's existing wavelet decomposition (no extra cost). |
| rdc_alpha_ll | FLOAT | 0.0300–0.3 | [RDC] Structure-band (LL) drift correction strength. Pulls the low-frequency band back toward its running EMA each step, damping slow composition/pose drift. Has no effect while rdc_tau = 0.0 (RDC off). Suggested start: 0.02–0.05. Too high → composition gets 'stuck', resists intended change. |
| rdc_alpha_hh | FLOAT | 0.0000–0.1 | [RDC] Texture-band (HH) drift correction strength. HH is expected to regenerate every step (grain/detail); correcting it pulls detail toward a blurred running average. 0.0 (default) = off — recommended unless you see texture flicker you specifically want to dampen. Suggested ceiling if used: ~0.01. Higher values blur detail. Has no effect while rdc_tau = 0.0 (RDC off). |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| model | MODEL | — |