Nodes/ComfyUI-ppm/SamplerGradientEstimation
ComfyUI Node

SamplerGradientEstimation

The gradient-estimation sampler with a gamma knob

By pamparamm·Created 2 years ago·Updated about 16 hours ago· 265
SamplerGradientEstimation
    • SAMPLER
    sampler_name
    gamma2.00

    Gradient Estimation is one of those samplers that has quietly become a favorite on the newer flow-matching models - people doing careful XY sampler sweeps on Lumina and similar architectures keep landing on it as one of the best-looking, most detail-preserving options. This node is ComfyUI-ppm's version of it, and the reason to use this one over whatever's in your stock dropdown is a single exposed parameter: gamma. That's the dial that actually changes what the sampler does, and here you get to turn it.

    What it is and how it works

    Gradient estimation is a sampling method that improves on plain Euler by using a smarter extrapolation of the denoising direction between steps - roughly, it estimates the "gradient" of the trajectory and steps along it more accurately, which tends to hold fine detail better at a given step count. gamma is the extrapolation coefficient: it controls how much the sampler leans on that estimated direction versus playing it safe. Higher gamma extrapolates more aggressively.

    The node outputs a SAMPLER object, which is the custom-sampling pattern in ComfyUI - you don't wire it into a KSampler, you feed it into SamplerCustom or SamplerCustomAdvanced alongside your sigmas and guider. If you've used any of the RES4LYF-style custom samplers, this slots in the exact same way: it replaces the sampler node, nothing else in the graph changes.

    The inputs that matter

    Only two, and one of them is the whole point:

    • sampler_name (COMBO) - pick the base sampler variant to run gradient estimation on top of. Leave it at whatever the sensible default is unless you're deliberately experimenting.
    • gamma (default 2, range 2–5) - the extrapolation strength. This is the knob. The default of 2 is the floor and a safe starting point; nudge it up toward 3–4 for more aggressive stepping if detail is soft, back toward 2 if you're seeing overshoot or artifacts. Small changes matter here, so move it a little at a time.

    Output: SAMPLERSamplerCustom / SamplerCustomAdvanced.

    Install

    No models, no dependencies - pure sampling.

    • ComfyUI Manager: search "ComfyUI-ppm", install, restart.
    • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/pamparamm/ComfyUI-ppm, then restart.

    Common issues & troubleshooting

    "It won't connect to my KSampler." Right - it's a custom sampler. Its SAMPLER output goes into SamplerCustom or SamplerCustomAdvanced, not a plain KSampler. If you're not set up for custom sampling, that's the one-time graph change you need to make.

    Where it shines vs. where it doesn't. Community sweeps put gradient estimation near the top on flow-matching models like Lumina - it's genuinely worth trying there. On SD 1.5 and SDXL finetunes, DPM++ 2M Karras is still the safe default and this won't obviously beat it. Match the tool to the model.

    Cranking gamma makes it worse. Too much extrapolation overshoots the trajectory and you get artifacts or a smeary look. It's a fine-tuning parameter, not a "more is better" one - if higher gamma degrades the image, come back down toward 2.

    Pin your seed when comparing. Sampler differences on a single image are easy to mistake for seed luck. Change only the sampler (or only gamma) on a fixed seed, and generate a few, before deciding it's better.

    Pack rule from the author: erroring after an update? Delete the node and re-add it.

    Categorysampling/custom_sampling/samplers

    Inputs (2)

    NameTypeDefaultDescription
    sampler_nameCOMBO2 options: gradient_estimation, gradient_estimation_cfg_pp
    gammaFLOAT2.002–5

    Outputs (1)

    NameTypeDescription
    SAMPLERSAMPLER