Nodes/SpectrumKSampler/DiT Spectrum Patch Advanced
ComfyUI Node

DiT Spectrum Patch Advanced

The same caching, minus the wrong guesses

By sorryhyun·Created 4 months ago·Updated 23 days ago· 25
DiT Spectrum Patch Advanced
  • model
  • MODEL
steps30
window_size2.00
flex_window0.25
warmup_steps6
tail_actual_steps3
blend_w0.30
cheby_degree3
ridge_lambda0.10
history_size100
enabledtrue
one_sampler_onlyfalse
verbosefalse
compat_policylegacy

Same MODEL → MODEL caching patcher as DiT Spectrum Patch, plus exactly one extra control: compat_policy. The plain patch node assumes your sampling setup is simple - one positive branch, one negative branch, a stock sampler. The moment that stops being true - multi-positive conditioning, exact artist mixes, regional or masked conditioning, a Custom Sampler graph, or model wrappers that need to run on every single call - this is the node that keeps Spectrum from quietly caching something it shouldn't.

What compat_policy actually changes

Spectrum forecasts DiT features from the history of previous actual steps. That's fine when there's one clean cond/uncond pair. It gets risky when there are several distinct conditioning branches (say, multiple artists in an exact-mix setup) that each need their own forecast history - mix them up and you get predictions blending trajectories that were never supposed to blend.

  • legacy (default) - the original, fastest behavior. Caches whenever the normal schedule says to, unless an explicit veto callback blocks it. Existing model wrappers may get bypassed on cached steps, same as the original implementation always did.
  • conservative - before allowing a cached prediction, it actually checks: valid batch split, matching latent shape, expected step count, no unsafe wrapper present, no veto callback blocking it. Fails any of those and the step runs an actual DiT forward instead of a guess.
  • strict - everything conservative checks, plus it requires ComfyUI's per-conditioning UUID branch keys to be present before caching. This is the one to reach for with exact artist mixes or multi-positive conditioning, because it's the only mode that keeps each conditioning branch's forecast history genuinely separate rather than sharing one coarse cache across all of them.

One wrinkle worth knowing: under conservative and strict, any model_function_wrapper already attached upstream is treated as unsafe by default unless it explicitly sets __spectrum_cache_safe__ = True. That's a safety-first default, but it means an untagged attention-backend swap or similar wrapper will force full actual forwards under those two policies even if it would have been perfectly fine to cache around. If you want the old fastest behavior with an untagged wrapper chain, use legacy; if you maintain the wrapper, tag it cache-safe instead.

Everything else is identical to the base patch

steps (must match your downstream sampler), window_size/flex_window/warmup_steps (the caching schedule), tail_actual_steps (final steps always forced actual), blend_w/cheby_degree/ridge_lambda (forecaster math), history_size, enabled (kill switch), one_sampler_only (limit to the first sampler run in a workflow, useful for hi-res-fix second passes), and verbose for logging step decisions. Output is a patched MODEL.

What a beginner should actually set

For exact artist mixes, use the recommended chain from the pack's own docs - DiT Spectrum Patch Advanced after DiT CFG-FSG/DCW Patch, with the mixer's exact positive conditioning going straight to the sampler - and start compat_policy at strict. Drop to legacy only if you've confirmed a simpler graph and just want the fastest option.

Installing it

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

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

Restart - no weight downloads specific to this node.

Common issues & troubleshooting

Barely any speedup under strict. That's usually correct behavior, not a bug - if ComfyUI's per-conditioning UUID keys aren't available in your graph (some Custom Sampler setups don't propagate them), strict falls back to actual forwards rather than risk mixing conditioning branches. If you're confident your graph is simple, conservative or legacy will cache more aggressively.

Speed dropped after adding another model wrapper upstream. Check whether that wrapper sets __spectrum_cache_safe__. Under conservative/strict an untagged wrapper is assumed unsafe and forces full compute on every step, which is slow but correct - legacy is the workaround if you'd rather trade correctness assumptions for speed.

Artist mix colors are bleeding between artists. That's exactly the failure mode strict exists to prevent - if you're seeing it, double-check you're actually on strict and that UUID keys are present in your graph, not silently falling back.

Tuned for Anima. As with the rest of the pack, this caching mechanism was built and validated on Anima's DiT. It may run on other DiT models with compatible sampler internals, but quality and stability aren't guaranteed there.

Categorymodel_patches

Inputs (14)

NameTypeDefaultDescription
modelMODELDiT MODEL to patch with Spectrum.
stepsINT301–10000Must match the downstream sampler's steps.
window_sizeFLOAT2.001–10Initial caching window; 1.0 disables cached steps.
flex_windowFLOAT0.250–2Window growth after each actual forward.
warmup_stepsINT60–10000Initial steps forced to actual DiT forwards.
tail_actual_stepsINT30–10000Final steps forced to actual DiT forwards.
blend_wFLOAT0.300–1Chebyshev/Taylor blend weight; 1.0 is pure Chebyshev.
cheby_degreeINT31–10Chebyshev polynomial degree.
ridge_lambdaFLOAT0.100.001–10Ridge regression regularization strength.
history_sizeINT1005–10000Forecaster buffer size.
enabledBOOLEANtrue
one_sampler_onlyBOOLEANfalseApply Spectrum only to the first sampler run that uses this patched MODEL within a workflow run; later sampler runs (e.g. hi-res fix) pass through. Re-arms on each new workflow execution.
verboseBOOLEANfalseLog actual/cached step decisions.
compat_policyCOMBOlegacyHow safely Spectrum is allowed to skip DiT blocks. 'legacy' is the fastest old behavior. 'conservative' runs an actual DiT forward instead of a cached prediction when wrappers, latent shape, step count, or veto checks look unsafe. 'strict' is the safest choice for exact artist/multi-conditioning mixes: it also requires ComfyUI per-conditioning UUIDs before caching.

Outputs (1)

NameTypeDescription
MODELMODEL