Nodes/ComfyUI-sonar/SonarAdvancedCollatzNoise
ComfyUI Node

SonarAdvancedCollatzNoise

The most experimental, slowest thing in the pack

By blepping·Created 3 years ago·Updated 14 days ago· 49
SonarAdvancedCollatzNoise
  • sonar_custom_noise_opt
  • seed_custom_noise
  • mix_custom_noise
  • SONAR_CUSTOM_NOISE
factor1.000
rescale0.000
adjust_scalefalse
chain_length1, 1, 2, 2, 3, 3
chain_offset5
iterations10
iteration_sign_flippingtrue
rmin-8000.000
rmax8000.000
dims-1, -1, -2, -2
flattenfalse
output_modevalues
quantile0.500
quantile_strategyclamp
noise_dtypefloat32
even_multiplier0.500
even_addition0.000
odd_multiplier3.000
odd_addition1.000
integer_mathtrue
add_preserves_signtrue
break_loopstrue
seed_modedefault

Remember the Collatz conjecture - take a number, if it's even halve it, if it's odd triple it and add one, repeat, and it (probably) always reaches 1? SonarAdvancedCollatzNoise turns that number sequence into noise. It's the pack's most experimental node, and the author doesn't sugarcoat it: the node description opens with "Very experimental, also very slow," and the iterations tooltip says the implementation is "EXTREMELY slow." If you're new here, that's your warning shot.

What it does: take random starting values, run Collatz chains on them, and use the resulting sequence (or transformations of it) as noise. Because Collatz chains have a distinctive structure - long runs of halving punctuated by the 3n+1 spikes - the noise has a fractal, structured character that gaussian can't produce. It's the kind of thing that's interesting mainly for the weirdness, not because it's reliably good.

The honest beginner path is to treat this as a "mix it in" node, not a star. The author's own note says it might just about work as initial noise with non-ancestral sampling, but if you get weird results, mix it with other noise types or use ancestral/SDE sampling. Practical settings to reach for:

  • iterations - how many chain passes to run. Each one is expensive. Default 10 is already slow; bump it and go make coffee.
  • chain_length - comma-separated lengths for each iteration, cycled. Longer chains mean more structured noise and much more compute.
  • output_mode - values, ratios, mults, adds, plus seed_x_* and noise_x_* variants that combine the chain with seed or mixed-in noise. This is the biggest single lever on what the output looks like.
  • quantile - runs output through quantile normalization (0.5 default); 0 or 1 disables it. Useful because chain values can spike hard.
  • rmin/rmax - bounds on the starting values. The tooltips are specific: stick within roughly ±9500 if you're on float32, because beyond that Collatz chains hit values float32 can't represent accurately.

Then there's a pile of genuinely deep controls - even_multiplier/odd_multiplier (you can reprogram the Collatz rules themselves), break_loops, seed_mode, integer_math, flatten, dims, quantile_strategy, and three optional noise inputs (sonar_custom_noise_opt, seed_custom_noise, mix_custom_noise) for feeding other noise into the chain generation. The node description's tone tells you the rest: this thing has more knobs than anyone fully understands.

Output is SONAR_CUSTOM_NOISE like the rest of the family. Install is the standard clone:

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

Honest verdict: skip this until you've played with the friendlier noise nodes, and when you do reach for it, budget for slowness and mix the result with gaussian. It's a curiosity that occasionally produces something genuinely striking - just don't expect it to be your daily driver, and don't expect a Collatz-chain noise gen to be fast.

Categoryadvanced/noise

Inputs (26)

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.
adjust_scaleBOOLEANfalseWhen enabled, the output will be normalized to values between -1 and 1 using the last two dimensions (if there are four or more), otherwise dimensions after the first.
chain_lengthSTRING1, 1, 2, 2, 3, 3Comma-separated list of chain lengths. Cannot be empty. Iterations will cycle through the list and wrap. Controls the length of Collatz chains. Note: Using a high chain length may be very slow, especially if combined with many iterations.
chain_offsetINT50–10000Uses values starting at the specified offset. Note: This entails generating chains of length chain_length + chain_offset, which may be quite slow if you use high values.
iterationsINT101–10000Number of iterations to run. Warning: Collatz noise (my implementation, anyway) is EXTREMELY slow.
iteration_sign_flippingBOOLEANtrueControls whether we cycle between flipping the sign on the output from each iteration. May average out weirdness... Or make stuff weirder.
rminFLOAT-8000.000-10000–10000Minimum value a chain can start with. Going as low as -9500 should be safe with float32.
rmaxFLOAT8000.000-10000–10000Maximum value a chain can start with. I don't recommend going over 9500 if you are using the float32 dtype here as that is where the Collatz chain starts to reach values that can't be accurately represented.
dimsSTRING-1, -1, -2, -2Comma-separated list of dimensions. Cannot be empty. May be negative to count from the end of the list. Iterations will cycle through the list and wrap.
flattenBOOLEANfalseControls whether dimensions past the current one selected from the dims parameter will get flattened.
output_modeCOMBOvalues9 options: values, ratios, mults, adds, seed_x_mults, seed_x_adds, +3
quantileFLOAT0.5000–1The initial output of each iteration will be run through quantile normalization. Setting the parameter to 0 or 1 will disable quantile normalization.
quantile_strategyCOMBOclampDetermines how to treat outliers. zero and reverse_zero modes are only useful if you're going to do something like add the result to some other noise. zero will return zero for anything outside the quantile range, reverse_zero only _keeps_ the outliers and zeros everything else.
noise_dtypeCOMBOfloat32Generally should be left at the default. Only float32 and float64 will work if you have quantile normalization enabled.
even_multiplierFLOAT0.500-10000–10000Multiplier to use when the previous link in the chain is even. Collatz uses 0.5 (divides by two) here.
even_additionFLOAT0.000-10000–10000Value to add when the previous link in the chain is even. Collatz uses 0 here.
odd_multiplierFLOAT3.000-10000–10000Multiplier to use when the previous link in the chain is odd. Collatz uses 3 here.
odd_additionFLOAT1.000-10000–10000Value to add when the previous link in the chain is odd. Collatz uses 1 here.
integer_mathBOOLEANtrueControls whether the results during chain generation get truncated to an integer value or not. Should be enabled if you actually want to generate accurate Collatz chains.
add_preserves_signBOOLEANtrueControls whether additions use the same sign as the item they're being added to.
break_loopsBOOLEANtrueControls whether the chain resets back to the seed value once it reaches 1 or 0. Generally should be left enabled, otherwise the chain will oscillate between only a few values for the rest of the length (at least with the Collatz rules).
seed_modeCOMBOdefaultDefault mode just uses whatever the original seed value was. force_odd/force_even will force it to the specified parity by adding one if it doesn't match. Starting from odd seeds might result in longer chains. Enabling the force modes may cause the initial seeds to exceed rmax by one.
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
seed_custom_noiseoptSONAR_CUSTOM_NOISE,OCS_NOISEOptional custom noise to use for initial values for Collatz chains. May be slow as it will generate noise according to the original input size and then crop it. Does this noise type have enough warnings about it being slow? Yeah. Connecting something here will probably make it even slower! The following input types are supported: SONAR_CUSTOM_NOISE, OCS_NOISE
mix_custom_noiseoptSONAR_CUSTOM_NOISE,OCS_NOISEOptional custom noise to use with the output modes starting with 'noise'. The following input types are supported: SONAR_CUSTOM_NOISE, OCS_NOISE

Outputs (1)

NameTypeDescription
SONAR_CUSTOM_NOISESONAR_CUSTOM_NOISEA custom noise chain.