Nodes/ComfyUI-sonar/SonarAdvancedDistroNoise
ComfyUI Node

SonarAdvancedDistroNoise

Sample your noise from any probability distribution torch ships

By blepping·Created 3 years ago·Updated 8 days ago· 49
SonarAdvancedDistroNoise
  • sonar_custom_noise_opt
  • SONAR_CUSTOM_NOISE
factor1.000
rescale0.000
distributionuniform
quantile_norm0.850
quantile_norm_modebatch
result_index-1
exponential_lambd1.00
cauchy_median0.0
cauchy_sigma1.00
geometric_p0.25
log_normal_mean1.00
log_normal_std2.00
normal_mean0.00
normal_std1.00
beta_concentration00.5
beta_concentration10.5
continuous_bernoulli_probs0.5
dirichlet_concentration0.5 0.5
fisher_snedecor_df11.0
fisher_snedecor_df22.0
gamma_concentration1.0
gamma_rate1.0
gumbel_loc1.0
gumbel_scale2.0
inverse_gamma_concentration1.0
inverse_gamma_rate1.0
kumaraswamy_concentration01.0
kumaraswamy_concentration11.0
laplacian_loc0.0
laplacian_scale1.0
lkjcholesky_dim3
lkjcholesky_concentration1.0
lrmvariate_normal_loc0.0 0.0
lrmvariate_normal_cov_factor1.0 0.0
lrmvariate_normal_cov_diag1.0 1.0
mvariate_normal_loc0.0 0.0
mvariate_normal_cov_multiplier1.00
pareto_scale1.0
pareto_alpha1.0
poisson_rate1.5
relaxed_bernoulli_temperature0.75
relaxed_bernoulli_probs0.66
relaxed_onehotcategorical_temperature1.50
relaxed_onehotcategorical_probs0.33 0.66
studentt_loc0.0
studentt_scale1.0
studentt_df1.0
uniform_low0.00
uniform_high1.00
vonmises_loc1.0
vonmises_concentration1.0
weibull_scale1.0
weibull_concentration1.0
wishart_df2.0
wishart_cov_size2
wishart_cov_multiplier1.00

Gaussian noise is the boring default because the math says it's right - but "right" and "interesting" are different goals, and SonarAdvancedDistroNoise exists for the second one. It replaces the sampler's noise with samples drawn from any of 26 probability distributions that PyTorch's torch.distributions provides: uniform, beta, cauchy, exponential, gamma, gumbel, laplacian, poisson, geometric, studentt, weibull, vonmises, and more. Heavy-tailed distributions like Cauchy or Laplacian throw in occasional extreme values that give generations a different texture than smooth gaussian; discrete ones like Poisson or geometric produce grainy, quantized patterns. If you've ever wondered what your latent would look like born from a Gumbel distribution - well, now you can find out.

It's a pick-one node, which is the good news. The distribution dropdown selects your flavor, and the rest of the inputs are organized so you only touch the ones relevant to your choice:

  • factor and rescale - the pack-wide strength controls. rescale non-zero makes this item plus its chained items scale to add up to that value.
  • quantile_norm - default 0.85, and you should probably leave it near there. Distributions with heavy tails will otherwise blow out the noise range, and this clips outliers to the given quantile. Set to 1.0 or 0.0 to disable. (Experimental bonus: negative values treat values closest to zero as the outliers instead.)
  • quantile_norm_mode - what dimensions the normalization considers; batch (the default) flattens first, the nonflat_* modes can inject strong row/column influence.
  • result_index - some distributions return a batch of samples; this picks which one to keep. Negative indexes count from the end.
  • Then the long tail: normal_mean/normal_std for normal, cauchy_median/cauchy_sigma, gamma_concentration/gamma_rate, poisson_rate, uniform_low/uniform_high, beta_concentration0/1, and on down the list. Only the params for your selected distribution actually matter; the rest sit idle.

One heads-up: lots of these parameter fields are strings rather than floats (e.g. "0.5 0.5" for multi-valued ones like dirichlet_concentration), so when you paste a value from the docs, keep the quotes.

Output is SONAR_CUSTOM_NOISE, chained through the optional sonar_custom_noise_opt input, and consumed wherever a custom noise input is accepted - a Sonar sampler, NoisyLatentLike, or SamplerConfigOverride. Install is the standard one-liner with no model files:

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

The trap is the same one the whole pack sets: ancestral/SDE samplers are the ones that inject noise, so that's where your exotic distribution actually appears - pair this with Euler a or DPM++ SDE. And combine it with the quantile_norm default before judging a distribution, because a raw Cauchy sample without clipping will just nuke the latent. Start with laplacian or cauchy, keep the quantile on, and see what texture does to your output before you go full vonmises.

Categoryadvanced/noise

Inputs (57)

NameTypeDefaultDescription
factorFLOAT1.000-10000–10000Scaling factor for the generated noise of this type.
rescaleFLOAT0.0000–10000When non-zero, this custom noise item and other custom noise items items connected to it will have their factor scaled to add up to the specified rescale value. When set to 0, rescaling is disabled.
distributionCOMBOuniformSets the distribution used for noise generation. See: https://pytorch.org/docs/stable/distributions.html
quantile_normFLOAT0.850-1–1When enabled, will normalize generated noise to this quantile (i.e. 0.75 means outliers >75% will be clipped). Set to 1.0 or 0.0 to disable quantile normalization. A value like 0.75 or 0.85 should be reasonable, it really depends on the distribution and how many of the values are extreme. (Experimental) You can use a negative quantile to consider the values closest to zero as extreme.
quantile_norm_modeCOMBObatchControls what dimensions quantile normalization uses. By default, the noise is flattened first. You can try the nonflat versions but they may have a very strong row/column influence. Only applies when quantile_norm is active.
result_indexSTRING-1When noise generation returns a batch of items, it will select the specified index. Negative indexes count from the end. Values outside the valid range will be automatically adjusted. You may enter a space-separated list of values for the case where there might be multiple added batch dimensions. Excess batch dimensions are removed from the end, indexe from result_index are used in order so you may want to enter the indexes in reverse order. Example: If your noise has shape (1, 4, 3, 3) and two 2-sized batch dims are added resulting in (1, 4, 3, 3, 2, 2) and you wanted index 0 from the first additional batch dimension and 1 from the second you would use result_index: 1 0
exponential_lambdFLOAT1.00
cauchy_medianSTRING0.0
cauchy_sigmaFLOAT1.00
geometric_pFLOAT0.25
log_normal_meanFLOAT1.00
log_normal_stdFLOAT2.00
normal_meanFLOAT0.00
normal_stdFLOAT1.00
beta_concentration0STRING0.5
beta_concentration1STRING0.5
continuous_bernoulli_probsSTRING0.5
dirichlet_concentrationSTRING0.5 0.5
fisher_snedecor_df1STRING1.0
fisher_snedecor_df2STRING2.0
gamma_concentrationSTRING1.0
gamma_rateSTRING1.0
gumbel_locSTRING1.0
gumbel_scaleSTRING2.0
inverse_gamma_concentrationSTRING1.0
inverse_gamma_rateSTRING1.0
kumaraswamy_concentration0STRING1.0
kumaraswamy_concentration1STRING1.0
laplacian_locSTRING0.0
laplacian_scaleSTRING1.0
lkjcholesky_dimINT3
lkjcholesky_concentrationSTRING1.0
lrmvariate_normal_locSTRING0.0 0.0
lrmvariate_normal_cov_factorSTRING1.0 0.0
lrmvariate_normal_cov_diagSTRING1.0 1.0
mvariate_normal_locSTRING0.0 0.0
mvariate_normal_cov_multiplierFLOAT1.00
pareto_scaleSTRING1.0
pareto_alphaSTRING1.0
poisson_rateSTRING1.5
relaxed_bernoulli_temperatureFLOAT0.75
relaxed_bernoulli_probsSTRING0.66
relaxed_onehotcategorical_temperatureFLOAT1.50
relaxed_onehotcategorical_probsSTRING0.33 0.66
studentt_locSTRING0.0
studentt_scaleSTRING1.0
studentt_dfSTRING1.0
uniform_lowFLOAT0.00
uniform_highFLOAT1.00
vonmises_locSTRING1.0
vonmises_concentrationSTRING1.0
weibull_scaleSTRING1.0
weibull_concentrationSTRING1.0
wishart_dfSTRING2.0
wishart_cov_sizeINT2
wishart_cov_multiplierFLOAT1.00
sonar_custom_noise_optoptSONAR_CUSTOM_NOISE,OCS_NOISEOptional input for more custom noise items. The following input types are supported: SONAR_CUSTOM_NOISE, OCS_NOISE

Outputs (1)

NameTypeDescription
SONAR_CUSTOM_NOISESONAR_CUSTOM_NOISEA custom noise chain.