KSampler (Spectrum + Mod Guidance Advanced)
Every knob, plus DCW
- model
- positive
- negative
- latent_image
- clip
- LATENT
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, andridge_lambdaare the forecaster's own math knobs - most people never touch these three. - Modulation guidance is exposed raw. Instead of a
mod_w_profilepreset, you getmod_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), andmod_final_w(steering at the output head,0by default - leave it there unless a specific LoRA needs it). There's also anadapterdropdown for swapping in a custompooled_text_projbeyond 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.manualmode usesdcw_lambdadirectly (+0.01is tuned for CFG ≥ ~2 at non-square aspects; flip to roughly-0.015at CFG 1 / 1024², since the bias direction reverses there).autopredicts a per-prompt λ via a small auto-downloaded fusion head and ignoresdcw_lambda- and conveniently it reuses this node's ownclipandpositiveinputs, so there's nothing extra to wire. - CFG++ and Foresight Guidance are separate controls here.
cfgpp_lambda(0= off,1.5is the validated point) replaces the plain CFG combine with a σ-scheduled one.fsgthen 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.
Inputs (43)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | The model used for denoising the input latent. | |
| seed | INT | 00–18446744073709550000 | — |
| steps | INT | 281–10000 | — |
| cfg | FLOAT | 4.00–100 | — |
| sampler_name | COMBO | 45 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +39 | |
| scheduler | COMBO | 9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3 | |
| positive | CONDITIONING | — | |
| negative | CONDITIONING | — | |
| latent_image | LATENT | — | |
| denoise | FLOAT | 1.000–1 | — |
| clip | CLIP | CLIP encoder for encoding positive quality tags. | |
| adapter | COMBO | pooled_text_proj safetensors adapter. '(auto-download default)' fetches the default ~12MB weight from the anima_lora release page on first use. | |
| quality_tags | STRING | highres, best quality, score_7 | Quality tags to steer generation toward via modulation. |
| quality_neg | STRING | score_1, score_2, score_3, worst quality, lowres, old, bad hands, bad anatomy | Quality-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_w | FLOAT | 3.0-20–20 | Peak modulation guidance strength applied per-block. |
| mod_start_layer | INT | 80–999 | Inclusive first block index that receives the steering delta. 0 = uniform (pre-0413). 8 = protect tonal-DC blocks 0–7 (default). |
| mod_end_layer | INT | 27-1–999 | Exclusive 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_taper | INT | 00–999 | Number of late slots inside [start, end) to scale by taper_scale. 0 disables taper. 2 + end=27 reproduces the 'piecewise' preset. |
| mod_taper_scale | FLOAT | 0.250–1 | Multiplier applied to tapered slots (e.g. 0.25 -> w*0.25). |
| mod_final_w | FLOAT | 0.0-20–20 | w 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_size | FLOAT | 2.001–10 | Initial caching window N — actual forward every floor(N) steps. |
| flex_window | FLOAT | 0.250–2 | Window growth rate — N increases by this after each actual forward. |
| warmup_steps | INT | 60–50 | Number of initial steps that always run actual forwards. |
| blend_w | FLOAT | 0.300–1 | Chebyshev/Taylor blend weight (1.0 = pure Chebyshev). |
| cheby_degree | INT | 31–10 | Number of Chebyshev basis functions. |
| ridge_lambda | FLOAT | 0.100.001–10 | Ridge regression regularization strength. |
| dcw_mode | COMBO | off | DCW 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_lambda | FLOAT | 0.010-1–1 | DCW 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_mask | COMBO | LL | Restrict 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_calibrator | COMBO | Fusion-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_lambda | FLOAT | 0.00–8 | CFG++ 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). |
| fsg | BOOLEAN | false | Foresight 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_lo | FLOAT | 0.590–1 | FSG σ-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_hi | FLOAT | 0.750–1 | FSG σ-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_k | INT | 30–8 | FSG 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_sigma | FLOAT | 0.100.01–0.3 | FSG 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_gamma | FLOAT | 0.00–16 | FSG 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_alpha | FLOAT | 0.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_lambda | FLOAT | 5.00–20 | SMC-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_boost | FLOAT | 1.001–3 | Front-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_band | FLOAT | 0.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_renorm | COMBO | img | Norm 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_frac | FLOAT | 0.500–1 | Partial 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)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |