ComfyUI Node

ODE EMA Sampler

A Detail-Aware Sampler With Training Wheels

By MilitantHitchhiker·Created 2 years ago·Updated 11 months ago· 3
ODE EMA Sampler
    • sampler
    stats_downsample64
    detail_gain_max0.35
    detail_power0.50
    detail_schedule_power4.0

    The ODE EMA Sampler (class ODE-EMA Sampler, displayed as "ODE EMA Sampler") is the most self-aware sampler in the Switchblade Pack, and the name tells you almost everything: it's an ODE-style sampler (no random noise per step, deterministic given a seed) with an EMA - exponential moving average - stabilizer built in. The idea is to give you detail-aware sampling without the classic artifact of adaptive samplers, which is crawling, unstable texture. It's a hypothesis, neatly packaged with honest controls.

    How it works

    Under the hood it's a sigma-space ODE: each step predicts the denoised image, computes a direction d = (x - x0) / sigma, and steps along it. The interesting part is how it shapes that direction. It builds a per-pixel "cone" - a smooth SPD matrix that lightly weights the direction based on local gradient statistics from Sobel edge detection - and stabilizes that cone across steps with an EMA (factor 0.7), which is what's supposed to stop the crawling-texture failure mode that plagues naive adaptive samplers.

    The detail emphasis is where the four inputs come in. Edge-aware gain is computed from the same gradient stats, scaled by how far you are through the schedule: it ramps up as sigma approaches zero, i.e. late in generation, when fine detail matters. Robust statistics (median/MAD) and a downsampling step keep the whole thing stable and, per the source, cut the per-step cost on high resolutions.

    The inputs that matter

    • stats_downsample - INT, default 64. Downscales the gradient stats for robustness; also the main cost lever at high resolution. Leave it unless you're tuning for speed.
    • detail_gain_max - FLOAT, default 0.35. Maximum edge-aware gain; 0 disables detail emphasis entirely and turns this into a plain ODE with the cone. That's your control setting.
    • detail_power - FLOAT, default 0.5. Nonlinearity on the edge response; the source suggests 0.8–1.5 as reasonable, so the default is conservative.
    • detail_schedule_power - FLOAT, default 4.0. How hard the gain ramps up near the end of the schedule.

    Output is sampler (SAMPLER), wired into the sampler input of SamplerCustom.

    Installing it

    It ships in the Switchblade Pack: ComfyUI Manager → search MilitantHitchhiker-SwitchbladePack → install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MilitantHitchhiker/MilitantHitchhiker-SwitchbladePack
    

    Restart. Pure torch, no extra dependencies.

    The honest take

    This one is worth more of your time than the pack's other samplers, if only because it ships with the discipline the others lack: a documented "off" value (detail_gain_max = 0) so you can isolate whether the feature does anything. The implementation is the most polished in the pack - cached kernels, fp32 math for stability, an EMA precisely because adaptive schemes usually go wrong - and the parameter names map cleanly to what they do.

    Still, it's a single author's experiment with zero community track record (a forum search for the sampler name turns up nothing), so calibrate expectations. It's an ODE, so it will converge and reproduce - good for A/B tests. Run the same seed through detail_gain_max = 0 vs 0.35 and look for actual detail differences, then be suspicious of the high end: detail_power and detail_schedule_power max out where the sane territory ends, and aggressive late-step emphasis is exactly the kind of sharpening that trades clean edges for artifacts. And remember the flow-model caveat that applies to all custom schedule shaping - this family of tricks is safer territory on SD 1.5/SDXL than on Flux.

    CategoryMilitantAI/Switchblade/Generation

    Inputs (4)

    NameTypeDefaultDescription
    stats_downsampleINT641–64
    detail_gain_maxFLOAT0.350–0.5
    detail_powerFLOAT0.500–0.5
    detail_schedule_powerFLOAT4.02–4

    Outputs (1)

    NameTypeDescription
    samplerSAMPLER