Nodes/DistanceSampler/SamplerDistanceAdvanced
ComfyUI Node

SamplerDistanceAdvanced

Every dial the DistanceSampler pack hides from you

By Extraltodeus·Created 2 years ago·Updated about a year ago· 44
SamplerDistanceAdvanced
    • SAMPLER
    resample3
    resample_end-1
    cfgpptrue
    eta0.00
    s_noise1.00
    distance_step_eta0.00
    distance_step_s_noise1.00
    use_softmaxfalse
    use_slerpfalse
    perp_stepfalse
    use_negativefalse
    smoothfalse
    sharpenfalse
    distance_first0
    distance_last-1
    eta_first0
    eta_last-1
    distance_eta_first0
    distance_eta_last-1

    If SamplerDistance is the set-and-forget version of this pack, SamplerDistanceAdvanced is the version that dumps all 18 parameters on you and says good luck. Same core algorithm underneath - each step makes several candidate predictions and fuses them by proximity weighting, so agreeing predictions carry more weight - but now you get every flag the pack author ever tinkered with, including a few he'd rather you not touch. Most people land here because they want exactly one of three things: the negative-assisted variant, the smoother slerp combination, or the ability to only run the expensive distance logic for part of the schedule. All three are exposed.

    The inputs people actually use

    The full list is long, so let's separate the useful from the decorative.

    The ones that change the output character:

    • use_negative (default false) - the "n" variant. When on, the unconditional (negative) prediction is fed into the distance-score calculation, so candidates are also weighted by how far they are from the negative. The author's own note: "This tends to give images with less errors from my testing," and it's what he samples with by default. Results do shift depending on your negative prompt, so expect to tune it.
    • use_slerp (default false) - combines candidate predictions by spherical interpolation instead of a weighted average. The difference is more obvious when use_negative is on. This is the setting the pack's own named presets (Distance, Distance_n, Distance_p) all use.
    • distance_first / distance_last (defaults 0 and -1, i.e. every step) - restrict the expensive distance sampling to a slice of the schedule. Steps are zero-based and negatives count from the end. This is the community's favorite trick with this sampler: people running it to fix anatomy in video keep it on for only the first 25–50% of steps, which is where structure and limbs get decided, then hand the rest to a cheap finish. Same benefit, far less compute.
    • eta and s_noise - ancestral (Euler-A style) noise on the main steps. 0 means deterministic. Bump eta for a bit more variation; s_noise is "leave at 1.0" per the tooltip.
    • distance_step_eta - the same ancestral idea, but for the internal distance steps. Experimental; the tooltip suggests a low value like 0.25 if you try it.

    The knobs the author warns you off:

    • smooth - "Not recommended, will make everything brighter. Not smoother." That's a direct quote. Don't.
    • sharpen - "Not recommended, attempts to sharpen the results but instead tends to make things fuzzy." Also don't.
    • perp_step - "Experimental, not yet recommended."

    The deep end: use_softmax swaps the min/max-normalized weighting for a softmax; eta_first/eta_last and distance_eta_first/distance_eta_last let you gate the ancestral settings to step ranges the same way distance_first/distance_last gate the main logic. Plus resample, resample_end, and cfgpp, which behave exactly as in the simple node - cfgpp still defaults true and still wants a low CFG.

    A default that's a trap

    Here's the thing people miss: this node is not the same config as the "Distance" sampler in your KSampler dropdown. The dropdown presets ship with cfgpp=false, use_slerp=true, and a taper down to Heun (resample_end=1). The node defaults to cfgpp=true, use_slerp=false, and constant resampling (resample_end=-1) - meaning if you just drop it in, you're getting CFG++ behavior with the slowest, most CFG-sensitive settings. Set cfgpp=false, use_slerp=true, resample_end=1 if you want the "Distance_n"-style experience the README showcases.

    Install, output, and troubleshooting

    Installs exactly like its sibling - once. ComfyUI Manager search "DistanceSampler," or git clone https://github.com/Extraltodeus/DistanceSampler into custom_nodes and restart. No dependencies, no model downloads. The output is a single SAMPLER that feeds SamplerCustomAdvanced's sampler input; you supply a scheduler (the pack suggests beta or AYS). If you run into tensor shape errors, the README's fix is to uncomment the Distance_fast fallbacks in presets_to_add.py, which swap the end-of-schedule slerp for a weighted average. And yes, it's slow - that's the deal, compensate with 4–10 steps, not by giving it more.

    Categorysampling/custom_sampling/samplers

    Inputs (19)

    NameTypeDefaultDescription
    resampleINT3-1–320 all along gives Euler. 1 gives Heun. Anything starting from 2 will use the distance method. -1 will do remaining steps + 1 as the resample value. This can be pretty slow.
    resample_endINT-1-1–32How many resamples for the end. -1 means constant.
    cfgppBOOLEANtrueControls whether to use CFG++ sampling. When enabled, you should set CFG to a fairly low value.
    etaFLOAT0.000–32Controls the ancestralness of the main sampler steps. 0.0 means to use non-ancestral sampling. Note: May not work well with some of the other options.
    s_noiseFLOAT1.00-100–100Scale factor for ancestral noise added during sampling. Generally should be left at 1.0 and only has an effect when ancestral sampling is used.
    distance_step_etaFLOAT0.000–32Experimental option that allows using ancestral sampling for the internal distance steps. When used, should generally be a fairly low value such as 0.25. 0.0 means to use non-ancestral sampling for the internal distance steps.
    distance_step_s_noiseFLOAT1.00-100–100Scale factor for ancestral noise added in the internal distance steps. Generally should be left at 1.0 and only has an effect when distance_step_eta is non-zero.
    use_softmaxBOOLEANfalseRather than using a min/max normalization and an exponent will use a softmax instead.
    use_slerpBOOLEANfalseWill SLERP the predictions instead of doing a weighted average. The difference is more obvious when using use_negative.
    perp_stepBOOLEANfalseExperimental, not yet recommended.
    use_negativeBOOLEANfalseWill use the negative prediction to prepare the distance scores. This tends to give images with less errors from my testing.
    smoothBOOLEANfalseNot recommended, will make everything brighter. Not smoother.
    sharpenBOOLEANfalseNot recommended, attempts to sharpen the results but instead tends to make things fuzzy.
    distance_firstINT0-10000–10000First step to use distance sampling. You can use negative values to count from the end. Note: Steps are zero-based.
    distance_lastINT-1-10000–10000Last step to use distance sampling. You can use negative values to count from the end. Note: Steps are zero-based.
    eta_firstINT0-10000–10000First step to use ancestral sampling. Only applies when ETA is non-zero. You can use negative values to count from the end. Note: Steps are zero-based.
    eta_lastINT-1-10000–10000Last step to use ancestral sampling. Only applies when ETA is non-zero. You can use negative values to count from the end. Note: Steps are zero-based.
    distance_eta_firstINT0-10000–10000First step to use ancestral sampling for the distance steps. Only applies when distance ETA is non-zero. You can use negative values to count from the end. Note: Steps are zero-based.
    distance_eta_lastINT-1-10000–10000Last step to use ancestral sampling for the distance steps. Only applies when distance ETA is non-zero. You can use negative values to count from the end. Note: Steps are zero-based.

    Outputs (1)

    NameTypeDescription
    SAMPLERSAMPLER