Nodes/SpectrumKSampler/DiT CFG-FSG/DCW Patch
ComfyUI Node

DiT CFG-FSG/DCW Patch

Anima's correction stack, without switching samplers

By sorryhyun·Created 4 months ago·Updated 22 days ago· 25
DiT CFG-FSG/DCW Patch
  • model
  • clip
  • positive
  • MODEL
enabledtrue
dcw_modeoff
dcw_lambda0.010
dcw_band_maskLL
dcw_calibrator
smc_cfgfalse
adaptive_smc_alpha0.10
smc_cfg_lambda5.0
cfgppfalse
cfgpp_lambda0.0
fsgfalse
fsg_band_lo0.59
fsg_band_hi0.75
fsg_k3
fsg_d_sigma0.10
fsg_gamma0.0
replace_existing_cfgfalse
steps30
cfg4.0
sampler_name
scheduler
denoise1.00

If you don't want to switch off your stock KSampler but you do want Anima's quality corrections, this is the node. It's a MODEL → MODEL patcher that groups four independent correction features - DCW, SMC-CFG, CFG++, and FSG - behind toggles, so you can wire it in front of any sampler graph, including a plain KSampler, KSampler Advanced, or a Custom Sampler chain, and skip the Spectrum caching entirely if you don't want it. The recommended chain from the pack's own docs puts this node before the caching patch: model → Anima Mod Guidance → DiT CFG-FSG/DCW Patch → DiT Spectrum Patch Advanced → sampler.

The four features, briefly

  • DCW (dcw_mode) is a post-step correction for a known SNR-timestep bias in flow-matching DiTs - it nudges each step's output toward or away from the post-CFG prediction, by default restricted to the Haar low-frequency subband (dcw_band_mask = LL), which testing found strictly better than a full-spectrum correction. manual mode uses dcw_lambda directly; auto predicts it per-prompt via a small auto-downloaded fusion head (needs the optional clip + positive inputs).
  • SMC-CFG (smc_cfg + adaptive_smc_alpha) swaps the plain CFG combine for an α-adaptive sliding-mode controller - it tends to recover fine detail (fingers, eyes, small text) at the cost of a slightly darker image.
  • CFG++ (cfgpp + cfgpp_lambda) replaces the constant-weight CFG combine with a σ-scheduled one - the substrate FSG is built on top of.
  • FSG (fsg + its band/iteration knobs) is the expensive one: pre-step latent calibration via forward-backward fixed-point iterations toward a "golden path," at roughly three extra DiT forwards per iteration per in-band step.

Needed extra inputs only show up in the optional slots when you actually need them: clip/positive for DCW's auto mode, and steps/cfg/sampler_name/scheduler/denoise - matching your downstream sampler's own settings - for CFG++ or FSG.

Landmines worth knowing before you flip switches

smc_cfg and cfgpp are mutually exclusive - both replace the same sampler_cfg_function hook, and the node includes a replace_existing_cfg guard specifically to stop this patch from silently clobbering a CFG function something upstream already set. Leave it false unless you're sure you want this patch to win. FSG can't run with SMC-CFG either - pair FSG with CFG++ (or, experimentally, plain CFG), never with SMC. FSG needs cfg != 1, so it's a no-op on any Anima Turbo-style low-CFG setup. And if you're chaining this before the Spectrum caching patch for FSG's cache veto to actually work, ordering matters: this node has to come before DiT Spectrum Patch Advanced in your graph, not after.

What a beginner should actually set

For a first pass, dcw_mode = manual with the default dcw_lambda = 0.01 (tuned for CFG ≥ ~2, non-square aspects) is the cheapest, least fussy correction to try. smc_cfg at its default adaptive_smc_alpha = 0.1 is the next thing worth testing if you want sharper small detail. Leave fsg off until you've got a baseline you like - it's the most expensive and most parameter-sensitive of the four.

Installing it

ComfyUI Manager - search SpectrumKSampler, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/sorryhyun/ComfyUI-Spectrum-KSampler

Restart. DCW's auto mode auto-downloads a small fusion-head file to ComfyUI/models/anima_dcw_calibrator/ on first use.

Common issues & troubleshooting

CFG++ isn't having any effect. Check whether smc_cfg is also enabled - SMC wins the shared hook if both are on, and CFG++ is silently ignored.

FSG errors or does nothing. Confirm cfg != 1 and that smc_cfg is off (they're incompatible). Also double-check this patch sits before the Spectrum caching patch in your chain if you're using both - its FSG cache veto only registers in that order.

At CFG 1 and square-ish output, DCW's default correction looks wrong. The bias direction DCW corrects for actually flips at CFG ≈ 1 / 1024². Switch dcw_lambda to roughly -0.015 manually, or prefer auto mode only when CFG is comfortably above 1.

This is tuned for Anima. Every default here - the DCW band choice, the SMC-CFG constants, the FSG bands - was validated against Anima specifically. It may run against other DiT models with compatible sampler internals, but the pack makes no quality promises there.

Categorymodel_patches

Inputs (25)

NameTypeDefaultDescription
modelMODELDiT MODEL to patch with DCW, SMC-CFG, CFG++, and/or FSG.
enabledBOOLEANtrueDisable to pass the input MODEL through unchanged.
dcw_modeCOMBOoffDCW correction mode. 'off' disables correction entirely. 'manual' uses the scalar dcw_lambda × schedule(σ) — predictable, user-tunable. 'auto' uses an OnlineDCWCalibrator fusion head (~few MB, auto-downloaded on first use) to predict per-prompt λ̂ from warmup observations of the post-CFG velocity. Forces band='LL'. Tuned at CFG=4 — at CFG≈1 the head's α̂ direction may overshoot; prefer manual then.
dcw_lambdaFLOAT0.010-1–1DCW post-step bias correction strength (manual mode). 0.0 = disabled. Default +0.01 is the verified hyperparam for LL-only at CFG≥~2 (recovers detail at non-square aspects). At CFG=1 / 1024² use ≈ -0.015. Schedule fixed to one_minus_sigma. Composes with Spectrum + mod guidance; sampler-agnostic. Ignored in auto mode.
dcw_band_maskCOMBOLLRestrict DCW correction to a subset of single-level Haar subbands (manual mode). 'LL' (default) is strictly better than broadband on Anima — improves all four bands while 'all' worsens detail bands. 'all' = paper-form broadband correction. 'HH' / 'LH+HL+HH' are ablation modes. Forced to 'LL' in auto mode.
dcw_calibratorCOMBOFusion-head safetensors artifact (auto mode only). '(auto-download default)' fetches the default head from the ComfyUI-Spectrum-KSampler release page on first use (stored under models/anima_dcw_calibrator/). Custom artifacts are picked up from the loras directory.
smc_cfgBOOLEANfalseEnable α-adaptive SMC-CFG. Mutually exclusive with CFG++ because both replace sampler_cfg_function.
adaptive_smc_alphaFLOAT0.100–1α-adaptive Sliding-Mode Control CFG gain. 0 disables (vanilla CFG combine). 0.2 = production default — k_t := α·mean(|v_cond − v_uncond|) per step keeps the bang-bang correction in-band across CFG/σ/sample (paper's fixed k=0.1 was ~14× off on Anima at CFG=4). Recovers detail (fingers, eyes, text); outputs run slightly darker. Auto-disabled when CFG=1.
smc_cfg_lambdaFLOAT5.00–20SMC-CFG sliding-manifold slope λ. Paper sweep {3,4,5,6}; 5 best. Higher λ tightens the sign() pattern's grip on small-|e| channels (more detail recovery, more darkening); lower λ attenuates both.
cfgppBOOLEANfalseEnable CFG++ σ-scheduled CFG combine. Mutually exclusive with SMC-CFG.
cfgpp_lambdaFLOAT0.00–8CFG++ substrate strength λ (0 = off, plain CFG). Replaces the constant-w cond/uncond combine with the σ-scheduled CFG++ weight (paper App A.2) — the substrate faithful FSG is defined on. λ=1.5 is the production point (tracks CFG=4 saturation/contrast/composition; <1.5 under-guides, >=2 over-saturates). This is a FLOW-space coefficient, not the paper's DDIM λ. Mutually exclusive with SMC-CFG (SMC wins if both on).
fsgBOOLEANfalseForesight Guidance: pre-step latent calibration toward the golden path. Runs K forward-backward fixed-point iterations on the latent before each in-band step (each forced to an actual Spectrum forward; ~3·K extra forwards per in-band step). Needs CFG != 1. Pair with cfgpp_lambda=1.5 for the validated fsg/cfg++ point.
fsg_band_loFLOAT0.590–1FSG σ-band lower bound. The band is where calibration fires. Default [0.59, 0.75] is the 1024-token-tier / 28-step er_sde point. The contracting band moves DOWN for more steps and for low-token (~768px) renders, UP for fewer steps. σ≈0.94 always DIVERGES (the paper's noisy-stage prescription is wrong on Anima) — do not raise hi past ~0.85. Re-tune if you change steps/res.
fsg_band_hiFLOAT0.750–1FSG σ-band upper bound. See fsg_band_lo. Default 0.75 is the 28-step er_sde sweet spot (it was 0.85 at 20-step Euler — the band slid down on the denser grid).
fsg_kINT30–8FSG fixed-point iterations per in-band step (0 = inert). Error ~ρ^K with ρ≈0.93, so K=3 captures ~all the gain; K=2 drift-saturates, K=3 adds visible detail. Each iteration is ~3 extra DiT forwards.
fsg_d_sigmaFLOAT0.100.01–0.3FSG forward-backward stride Δσ. Stability is governed by γ·Δσ; 0.1 contracts at γ≈4. Larger Δσ is what makes the operator diverge — leave at 0.1 unless you also shrink γ.
fsg_gammaFLOAT0.00–16FSG calibration guidance γ (0 = use the CFG scale). Keep ≈ the CFG scale (=4) even on the CFG++ substrate — matching γ to the CFG++ effective weight (~11 in-band) makes the operator DIVERGE (stability is set by γ·Δσ).
replace_existing_cfgBOOLEANfalseAllow this node to overwrite an existing sampler_cfg_function. Leave false unless you intentionally want this patch to win.
stepsoptINT301–10000Downstream sampler step count. Required when cfgpp or fsg is enabled.
cfgoptFLOAT4.00–100Downstream sampler CFG scale. Required when smc_cfg, cfgpp, or fsg is enabled.
sampler_nameoptCOMBODownstream sampler name. Required when cfgpp or fsg is enabled.
scheduleroptCOMBODownstream scheduler name. Required when cfgpp or fsg is enabled.
denoiseoptFLOAT1.000–1Downstream sampler denoise value. Required when cfgpp or fsg is enabled.
clipoptCLIPCLIP encoder. Required when dcw_mode=auto.
positiveoptCONDITIONINGPositive conditioning. Required when dcw_mode=auto.

Outputs (1)

NameTypeDescription
MODELMODELMODEL clone patched with the selected correction hooks, or the input MODEL when disabled.