Nodes/SpectrumKSampler/KSampler (Spectrum + Mod Guidance Advanced)
ComfyUI Node

KSampler (Spectrum + Mod Guidance Advanced)

Every knob, plus DCW

By sorryhyun·Created 4 months ago·Updated 22 days ago· 25
KSampler (Spectrum + Mod Guidance Advanced)
  • model
  • positive
  • negative
  • latent_image
  • clip
  • LATENT
seed0
steps28
cfg4.0
sampler_name
scheduler
denoise1.00
adapter
quality_tagshighres, best quality, score_7
quality_negscore_1, score_2, score_3, worst quality, lowres, old, bad hands, bad anatomy
mod_w3.0
mod_start_layer8
mod_end_layer27
mod_taper0
mod_taper_scale0.25
mod_final_w0.0
window_size2.00
flex_window0.25
warmup_steps6
blend_w0.30
cheby_degree3
ridge_lambda0.10
dcw_modeoff
dcw_lambda0.010
dcw_band_maskLL
dcw_calibrator
cfgpp_lambda0.0
fsgfalse
fsg_band_lo0.59
fsg_band_hi0.75
fsg_k3
fsg_d_sigma0.10
fsg_gamma0.0
adaptive_smc_alpha0.10
smc_cfg_lambda5.0
xattn_boost1.00
xattn_boost_band0.85
xattn_boost_renormimg
xattn_boost_renorm_frac0.50

This is the node you reach for once the plain KSampler (Spectrum) is working and you want to actually tune it - or once you need the one feature the simple node doesn't have at all: DCW. Same idea underneath (Chebyshev-forecasted block caching to skip most of Anima's transformer compute), but every preset is unwound into raw parameters, and the full correction stack - DCW, SMC-CFG, CFG++, Foresight Guidance, cross-attn boost - lives here in its tunable form instead of behind a single switch.

What's different from the simple node

The core caching mechanism is the same training-free trick this whole pack is built on - the same family as TeaCache-style accelerators, just tuned specifically for Anima's DiT. Where it diverges:

  • No SEA / refresh_ratio. This node uses the plain growing-window schedule directly: window_size (starting cache window), flex_window (how fast the window grows after each real forward - raise this for more speed), warmup_steps (steps forced to full compute up front). blend_w, cheby_degree, and ridge_lambda are the forecaster's own math knobs - most people never touch these three.
  • Modulation guidance is exposed raw. Instead of a mod_w_profile preset, you get mod_w (peak steering strength), mod_start_layer / mod_end_layer (which transformer blocks receive the delta - default 8 to 27, protecting Anima's early tonal-DC blocks and its final compensation block), mod_taper / mod_taper_scale (soften the last few steered blocks), and mod_final_w (steering at the output head, 0 by default - leave it there unless a specific LoRA needs it). There's also an adapter dropdown for swapping in a custom pooled_text_proj beyond the auto-downloaded default.
  • DCW lives here, full stop. dcw_mode (off / manual / auto) is a post-step correction for flow-matching's SNR-t bias - it nudges each step's output toward (or away from) the post-CFG prediction, restricted by default to the Haar low-frequency subband (dcw_band_mask = LL), which the pack's own testing found strictly better than correcting the full spectrum. manual mode uses dcw_lambda directly (+0.01 is tuned for CFG ≥ ~2 at non-square aspects; flip to roughly -0.015 at CFG 1 / 1024², since the bias direction reverses there). auto predicts a per-prompt λ via a small auto-downloaded fusion head and ignores dcw_lambda - and conveniently it reuses this node's own clip and positive inputs, so there's nothing extra to wire.
  • CFG++ and Foresight Guidance are separate controls here. cfgpp_lambda (0 = off, 1.5 is the validated point) replaces the plain CFG combine with a σ-scheduled one. fsg then runs pre-step latent calibration on top of it via forward-backward fixed-point iterations (fsg_k, default 3, each iteration costs roughly three extra DiT forwards) inside a σ band (fsg_band_lo/fsg_band_hi, tuned for the 1024px / 28-step case - re-tune if you change either).

The trap worth knowing before you flip switches

cfgpp_lambda and adaptive_smc_alpha (SMC-CFG) are mutually exclusive - both replace the same CFG-combine hook, and SMC wins if you leave both nonzero, so your CFG++ setting silently does nothing. If you want the Foresight Guidance path, set adaptive_smc_alpha = 0 and cfgpp_lambda = 1.5 together - that's the pack's own validated pairing. And fsg needs cfg != 1; on an Anima Turbo-style low-CFG setup it has nothing to calibrate against. One more from the tooltip worth respecting: keep fsg_gamma near your CFG scale (Anima's default is 4) - pushing it up toward CFG++'s effective in-band weight (~11) makes the calibration diverge instead of converge.

What a beginner should actually set

Start with window_size/flex_window at defaults, dcw_mode = off, adaptive_smc_alpha at its default 0.1 for a mild detail bump, and everything FSG-related left alone. Get a baseline you like, then start turning on DCW or FSG one at a time - this node has enough interacting switches that changing three things at once makes it hard to tell what helped.

Installing it

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

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

Restart. Mod guidance's ~12MB adapter and DCW's auto-calibrator both auto-download on first use (to models/anima_mod_guidance/ and models/anima_dcw_calibrator/ respectively) - expect a short pause the first time you flip either on.

Common issues & troubleshooting

CFG++ isn't doing anything. Check adaptive_smc_alpha - if it's nonzero, SMC-CFG has already claimed the CFG-combine hook and your cfgpp_lambda is being ignored.

FSG produces no visible change. It's inert at cfg = 1, and fsg_k = 0 disables it outright even if the boolean is on.

Output looks noticeably darker with SMC-CFG on. That's expected - the α-adaptive combine clamps a small consistently-signed brightness component in Anima's velocity prediction along with the noise. Lower adaptive_smc_alpha or smc_cfg_lambda if the darkening bothers you more than the detail recovery is worth.

This is Anima-tuned, not universal. Every correction here - mod guidance, DCW, SMC-CFG's tuned constants - was derived from Anima's own training pipeline. It may run on other DiT checkpoints with compatible sampler internals, but the pack doesn't promise quality there.

Categorysampling

Inputs (43)

NameTypeDefaultDescription
modelMODELThe model used for denoising the input latent.
seedINT00–18446744073709550000
stepsINT281–10000
cfgFLOAT4.00–100
sampler_nameCOMBO45 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +39
schedulerCOMBO9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3
positiveCONDITIONING
negativeCONDITIONING
latent_imageLATENT
denoiseFLOAT1.000–1
clipCLIPCLIP encoder for encoding positive quality tags.
adapterCOMBOpooled_text_proj safetensors adapter. '(auto-download default)' fetches the default ~12MB weight from the anima_lora release page on first use.
quality_tagsSTRINGhighres, best quality, score_7Quality tags to steer generation toward via modulation.
quality_negSTRINGscore_1, score_2, score_3, worst quality, lowres, old, bad hands, bad anatomyQuality-negative baseline for the mod-guidance steering axis (delta = proj(quality_tags) − proj(quality_neg)). Leave EMPTY to reuse the CFG negative (legacy behavior). Set a clean counter-pole (e.g. 'worst quality, score_1') to decouple the quality axis from the broad CFG negative, which is anti-correlated with the intended quality direction. Does NOT change the CFG negative itself.
mod_wFLOAT3.0-20–20Peak modulation guidance strength applied per-block.
mod_start_layerINT80–999Inclusive first block index that receives the steering delta. 0 = uniform (pre-0413). 8 = protect tonal-DC blocks 0–7 (default).
mod_end_layerINT27-1–999Exclusive last block + 1. 27 (default, Anima has 28 blocks) skips the final compensation block — matches the 'step_i8_skip27' preset + the anima_lora CLI. -1 = all remaining blocks.
mod_taperINT00–999Number of late slots inside [start, end) to scale by taper_scale. 0 disables taper. 2 + end=27 reproduces the 'piecewise' preset.
mod_taper_scaleFLOAT0.250–1Multiplier applied to tapered slots (e.g. 0.25 -> w*0.25).
mod_final_wFLOAT0.0-20–20w applied at final_layer. 0.0 = don't disturb the output head (default). Set non-zero only if your LoRA needs final-layer steering.
window_sizeFLOAT2.001–10Initial caching window N — actual forward every floor(N) steps.
flex_windowFLOAT0.250–2Window growth rate — N increases by this after each actual forward.
warmup_stepsINT60–50Number of initial steps that always run actual forwards.
blend_wFLOAT0.300–1Chebyshev/Taylor blend weight (1.0 = pure Chebyshev).
cheby_degreeINT31–10Number of Chebyshev basis functions.
ridge_lambdaFLOAT0.100.001–10Ridge regression regularization strength.
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.
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 γ·Δσ).
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.
xattn_boostFLOAT1.001–3Front-loaded cross-attn boost λ. 1.0 = off (exact identity). Scales every block's cross-attn residual on the conditional forward at high σ (the plan-writing window where text drive lives), strengthening weak-tag adherence and relation/attribute bindings without changing the render style. Norm-matched by default (renorm 'img' ρ0.5 — tunable on the Advanced node) so the boosted state stays on the trained norm shell instead of burning saturation. ~1.5 recommended; up to 3.0 for stubborn tags (higher λ can amplify unwanted caption tags like framing/crop priors). Boosts only actual forwards; forecast steps extrapolate from the boosted features. Composes with SMC-CFG / CFG++ / FSG / mod-guidance.
xattn_boost_bandFLOAT0.850–1σ cutoff for the cross-attn boost (fires at σ ≥ band). Default 0.85 = the cross-attn drive-floor σ (~10 of 28 shifted-schedule steps). Raise toward 0.95 for a tighter high-σ-only window; below ~0.85 the boost has little text drive left to amplify. Ignored when xattn_boost = 1.0.
xattn_boost_renormCOMBOimgNorm matching for the cross-attn boost (shipped default 'img'). The raw gain pushes hidden states off the norm distribution the next block was trained on (saturation burn / framing drift on complex prompts); 'img' rescales the post-cross-attn state so the per-image mean token norm stays on its unboosted shell — the boost becomes a rotation toward the text direction, keeping the token-norm peaks that carry highlights/neon. 'tok' matches every token individually (clamps exactly those peaks → flat grey tone; reference only). 'off' = raw gain. Inert while xattn_boost = 1.0.
xattn_boost_renorm_fracFLOAT0.500–1Partial norm-match exponent ρ (scale**ρ). 1.0 = full match back to the unboosted norm shell, 0.0 = raw boost. 0.5 at λ 2 was the validated tone sweet spot. Ignored when renorm = 'off'.

Outputs (1)

NameTypeDescription
LATENTLATENT