Nodes/D2 Nodes ComfyUI/D2 Refiner Steps A1111
ComfyUI Node

D2 Refiner Steps A1111

The math node for SDXL refiner passes, A1111-style

By da2el-ai·Created 2 years ago·Updated 4 days ago· 66
D2 Refiner Steps A1111
    • steps
    • start
    • end
    • refiner_start
    steps25
    denoise1.00
    switch_at0.20

    Every SDXL refiner workflow eventually hits the same question: when exactly does the second model take over, and how many steps does it actually get? D2 Refiner Steps A1111 is a tiny calculator that answers it, using the same denoise math that Stable Diffusion webui's img2img used back in the day. You feed it three numbers and it hands back the four step values you plug into two KSamplers. That's the entire job, and it does it without error.

    Why the math exists

    The subtle part of a refiner pass is that img2img with denoise < 1 doesn't run all your steps - it runs steps / denoise total, skips the first (real_steps - steps), and samples the rest. If you set "20 steps, denoise 0.5" you're really doing 40 latent steps and only keeping the last 20. So when you add a second model on top, you can't just say "steps 10" - you have to compute the true boundaries. That's what this node does for you, and getting it wrong is exactly how people end up with a refiner that never actually touches the image or one that erases the base model's work entirely.

    How it works

    Inputs are steps (your intended visible step count), denoise (the img2img strength of the first pass, 0–1), and switch_at (what fraction of the way through you want the refiner to start - 0.2 means 20%). The outputs are the four values that matter:

    • steps - the real total step count (floor(steps / denoise))
    • start - where the first KSampler's sampling begins
    • end - where the first KSampler stops
    • refiner_start - where the refiner KSampler begins (just past end)

    Wire steps, start, end into a KSampler(Advanced) for the base model, and steps, refiner_start, end into the second one for the refiner. The pack's docs recommend pairing this with the D2 Refiner Steps Tester node to eyeball the computed values before you commit - that's a free debug step that costs nothing and catches silly mistakes.

    What beginners miss

    The classic confusion is treating switch_at as "denoise of the refiner." It isn't - it's purely the timing of the handoff. A switch_at of 0.2 means the refiner takes over after 20% of the sampling schedule, not that it redraws at 0.2 strength. If you want the refiner to have more influence, you raise switch_at, and if you want it to just lightly refine the tail, you keep it low.

    Second gotcha: because real_steps = steps / denoise can come out fractional, everything is floored to integers. That's intentional - samplers need discrete steps - but it means your "20 visible steps" might be 19 after the math. Fine. Don't fight it.

    Installing

    Part of D2 Nodes ComfyUI:

    cd ComfyUI/custom_nodes
    git clone https://github.com/da2el-ai/D2-nodes-ComfyUI
    

    or search "D2 Nodes ComfyUI" in ComfyUI Manager. No model files, no heavy dependencies - it's pure arithmetic.

    This isn't the node for everyone. If you use a single model, you don't need it. If you use SDXL's base-plus-refiner pattern (or a second pass with a detailer), this is the fastest way to make the two samplers agree on where the baton passes, and you'll never hand-calculate these numbers again. It also pairs with D2 Refiner Steps for the non-img2img case - that one skips denoise and just takes the plain start/end split - but if you're doing any kind of img2img, this is the version you want.

    CategoryD2/Refiner

    Inputs (3)

    NameTypeDefaultDescription
    stepsINT25
    denoiseFLOAT1.000–1
    switch_atFLOAT0.200–1

    Outputs (4)

    NameTypeDescription
    stepsINT
    startINT
    endINT
    refiner_startINT