Nodes/ComfyUI-sonar/SonarCustomNoiseParameters
ComfyUI Node

SonarCustomNoiseParameters

The node that fixes the pack's reproducibility problem

By blepping·Created 3 years ago·Updated 14 days ago· 49
SonarCustomNoiseParameters
  • custom_noise
  • SONAR_CUSTOM_NOISE
factor1.000
rng_state_offset0
rng_offset_modedisabled
rng_modedefault
frames_to_channelsfalse
ensure_square_aspect_ratiofalse
fix_invalidfalse
override_dtypedefault
override_devicedefault
normalizedefault

SonarCustomNoiseParameters doesn't generate noise itself - it wraps another SONAR_CUSTOM_NOISE chain and lets you control how that noise gets generated. It's the plumbing node, and the one that answers the pack's most annoying quirk: the README admits that noise gets generated on GPU or CPU "probably inconsistently," which means the same seed can give different results on different GPUs. This node is where you take control of that, plus dtype, RNG behavior, and a few fixups for weird latents.

What it actually does

Feed a custom_noise chain in, set your overrides, get the same chain out with the overrides applied. The output type is still SONAR_CUSTOM_NOISE, so it slots into any chain position. Its superpower is making non-deterministic noise deterministic, or deliberately independent.

The settings that matter:

  • rng_mode - default (nothing special), separate (creates its own generator and saves/restores state, covering the Python random module too), or fork (uses the current RNG state but restores it afterward). If you want your noise independent of whatever else is sampling, separate is the one.
  • rng_state_offset - the author's clever rename. It's a seed, but not called seed on purpose, because ComfyUI's default seed widget auto-increments and the author wants you to be able to not have that. Plug an INT primitive in if you want auto-increment.
  • rng_offset_mode - disabled, override, or add, controlling how that offset interacts with the seed the sampler would otherwise use. add is handy for per-frame offsets in video/batch work.
  • override_dtype - mostly leave alone, but float64 is the useful one if you're seeing precision artifacts; the tooltip explicitly says to avoid the int and float8 types.
  • override_device - cpu, gpu, or default. This is your reproducibility switch: pin to cpu and you remove a whole class of "seed changed between runs" weirdness, at the cost of speed.

The fixups

Three toggles that exist because real latents are messy:

  • frames_to_channels - for 5D video latents, moves the frame dimension into channels. Many noise generators can't handle 5D directly. The tooltip says it's safe to enable for all models.
  • ensure_square_aspect_ratio - rearranges H/W to be square, padding with zeros. Helps noise types that choke on extreme aspect ratios, and handles 3D (single spatial dimension) latents.
  • fix_invalid - replaces NaNs and infinities with 0. If you're getting black or corrupted outputs from a noise type you just pushed too far, flip this on before debugging anything else.

Plus the standard factor, normalize (default/forced/disabled), and a custom_noise input.

Install

Standard pack install: ComfyUI Manager → search "ComfyUI-sonar" → Install → restart, or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/blepping/ComfyUI-sonar

No models, no extra deps. If you hit the GPU-vs-CPU seed divergence the README warns about, this node - specifically override_device and rng_mode - is the fix, and it's the reason to install this node even if you otherwise leave the noise toybox alone.

Categoryadvanced/noise

Inputs (11)

NameTypeDefaultDescription
factorFLOAT1.000-10000–10000Scaling factor for the generated noise of this type.
custom_noiseSONAR_CUSTOM_NOISE,OCS_NOISEAllows connecting a custom noise chain. The following input types are supported: SONAR_CUSTOM_NOISE, OCS_NOISE
rng_state_offsetINT00–10000In other words, seed. Avoiding using the word seed here to suppress ComfyUI's annoying default behavior. If you want stuff like auto-increment you can connect an INT primitive node.
rng_offset_modeCOMBOdisabledControls the seed passed to the noise sampler and also seeding when rng_mode is set to separate. Most noise samplers don't care about the seed so this generally will only have an effect in when rng_mode is set to separate.
rng_modeCOMBOdefaultdefault mode doesn't do anything special. separate mode creates a generator and saves/restores the state when generating noise (also includes the Python random module). fork uses the existing RNG state (for both Torch and Python random module) but restores it to whatever it was before the custom noise was called.
frames_to_channelsBOOLEANfalseOnly applicable for 5D latents (video models). Will move the frame dimension into channels, may be necessary if a noise type can't deal with 5D latents directly. It's safe to enable this for all models.
ensure_square_aspect_ratioBOOLEANfalseWill rearrange the height/width sizes to be square, padding with zeros if necessary. May help some noise types work better with extreme aspect ratios, can also deal with 3D (1 spatial dimension) latents.
fix_invalidBOOLEANfalseReplaces any NaNs or infinite values with 0.
override_dtypeCOMBOdefaultCan be used to override the dtype the noise is generated with. Not all noise generators support all types. I don't recommend using the int or float8 types. Probably the most useful override is float64.
override_deviceCOMBOdefaultdefault just uses whatever device normally would be used. gpu will use ComfyUI's default GPU device and also toggle the cpu_noise flag off. cpu will use the CPU device and toggle the cpu_noise flag on.
normalizeCOMBOdefaultControls whether noise is normalized to 1.0 strength.

Outputs (1)

NameTypeDescription
SONAR_CUSTOM_NOISESONAR_CUSTOM_NOISEA custom noise chain.