Nodes/comfyui-cns_sampler_patch/CNS Sampler Patch (Colored Noise)
ComfyUI Node

CNS Sampler Patch (Colored Noise)

Your sampler doesn't have to inject white noise — CNS Sampler Patch recolors it

By namemechan·Created 3 months ago·Updated 2 months ago· 0
CNS Sampler Patch (Colored Noise)
  • sampler
  • sampler
strength1.00
gamma_power0.50
gamma_scale2.0

Every ancestral sampler in ComfyUI - euler_ancestral, dpmpp_2s_ancestral, dpmpp_sde, and friends - injects fresh white noise at each step. White noise is the boring default: equal energy in every frequency band, every step of the way. The catch is that diffusion models don't build images that way. Early steps settle the low-frequency skeleton - composition, color, layout - and fine detail is a late-game event. So for most of the trajectory, ancestral samplers are dumping half their noise budget into bands that are already done.

CNS Sampler Patch is a tiny node that fixes exactly that. It's a ComfyUI port of the Colored Noise Diffusion Sampling paper (Davidson et al., May 2026), and instead of white noise it injects colored noise: quiet in the low-frequency band once the structure is in place, loud in the high-frequency bands while detail is still unresolved. Same model, same step count, same seed logic - only the noise changes. If your euler_ancestral runs look a little mushy and extra steps stop adding texture, this is aimed at you.

How it actually works

The node wraps the SAMPLER you feed it and intercepts its internal noise_sampler callable, so it lives inside the sampling loop rather than patching your model. Each step it runs a Haar wavelet transform on the current noisy latent x_t and measures the energy in the four subbands - LL, LH, HL, HH. That energy fraction is treated as a live "how built is this band" proxy. The deficit (1 − γ) is raised to an exponent to get per-band weights, RMS-normalized so mean(β²) = 1, applied to the white noise in the wavelet domain, and transformed back. Variance is preserved per step, which is the CNS paper's energy-budget condition.

Here's the clever part, and the honest tradeoff. The original paper precomputes a γ(f,t) progress matrix via a separate ODE prepass, and the popular alternative port makes you download that .pt file. This node instead approximates γ on the fly from the current latent's subband energies - no precomputed matrices, no model files, nothing to audit. It's a rougher approximation and the author says so plainly in the README, but it's also the reason this thing works on any ancestral sampler with zero setup. One caution from the paper's early community reception: the official proof-of-concept images were small 256×256 class-conditional benchmarks, and testers' verdict on the concept has been "improves microdetail, sometimes wobbles macro structure." Worth trying, not a miracle worker.

The three knobs

  • strength (default 1.0) - lerp between plain white noise (0.0) and full CNS (1.0). Start at 1.0; lower toward 0.7 only if artifacts show up.
  • gamma_power (default 0.5) - exponent on the "how unfinished" deficit. 0.5 is the paper's square-root default, smooth and proportional. Higher (0.75–1.0) routes more aggressively and sharpens detail; lower drifts back toward white noise.
  • gamma_scale (default 2.0) - how early CNS starts intervening. Early steps haven't separated low- and high-frequency energy yet, so a small difference can trigger premature re-routing. Dividing the energy ratios by this softens that. If your early steps look unstable or blurry, raise it - the paper's range runs to 25.

The output is a single SAMPLER, which you feed straight into SamplerCustomAdvanced. That's the whole graph: KSamplerSelect → CNS Sampler Patch → SamplerCustomAdvanced.

Wiring it up

Install via ComfyUI Manager (search "CNS Sampler Patch") or the usual route:

cd ComfyUI/custom_nodes
git clone https://github.com/namemechan/comfyui-cns_sampler_patch

Then restart ComfyUI. That's it - there's no requirements.txt and no model download; it's pure PyTorch, which ComfyUI already ships. The node appears under sampling/custom_sampling/samplers. Heads up if you browse the repo: the README is written in Korean, but the node tooltips and this article cover everything you need to actually use it.

When it does nothing (and other gotchas)

The most common "it's broken" moment is actually correct behavior. Deterministic ODE samplers - euler, dpmpp_2m, ddim - never call noise_sampler, so the patch passes through inert by design. If your output is byte-identical to before, check you're on euler_ancestral, euler_ancestral_cfg_pp, dpm_2_ancestral, dpmpp_2s_ancestral, or dpmpp_sde. If the image does change but the structure looks off, ease off: strength down to 0.7, gamma_scale up to 3–5. And if a step's coloring ever fails, the code logs [CNS] Warning: coloring skipped at this step and silently falls back to white noise - so a quiet console isn't automatically a healthy one. Also worth knowing: this is sampler-level, so it stacks cleanly with model-level patches (the author's own DCW patch is designed to run alongside it without hook conflicts).

Recommended starts from the author: most models run 1.0 / 0.5 / 2.0; for Flux or Anima on euler_ancestral_cfg_pp, nudge gamma_scale to 3.0.

Categorysampling/custom_sampling/samplers

Inputs (4)

NameTypeDefaultDescription
samplerSAMPLER
strengthFLOAT1.000–1[CNS] Effect strength. Lerp between white noise (0.0) and fully colored noise (1.0). Start at 1.0 and reduce only if artifacts appear.
gamma_powerFLOAT0.500.1–2[CNS] Exponent applied to the subband deficit before computing β. 0.5 (√) = CNS paper default — smooth, proportional routing. Higher (0.75–1.0) → sharper frequency routing, more aggressive. Lower (0.25–0.4) → softer routing, closer to white noise.
gamma_scaleFLOAT2.00.1–25[CNS] γ proxy divider. Scales down the subband energy ratios before computing deficits, preventing premature over-routing. Equivalent to 'γ Divider' in CNS paper (range 1.73–25.0). 1.0 = most aggressive (full energy ratio). 2.0–5.0 = recommended starting range for most models. Increase if early steps show structural instability.

Outputs (1)

NameTypeDescription
samplerSAMPLER