Nodes/MTB Nodes/Smart Step (mtb)
ComfyUI Node Runs on cloud

Smart Step (mtb)

Stop doing step-count math for KSampler Advanced

By melMass·Created 3 years ago·Updated about a month ago· 721
Smart Step (mtb)
    • step
    • start
    • end
    step20
    start_percent0
    end_percent0

    KSampler (Advanced) wants start_at_step and end_at_step as plain integers. Percentages are how humans actually think about "apply this for the first third of sampling" - and every time you change your total step count, you have to redo the arithmetic by hand. Smart Step just does that arithmetic for you.

    The mechanism

    It's genuinely simple, and that's the whole appeal: give it a total step count and a start/end percentage, and it hands back the corresponding integer step indices. Change step from 20 to 30 later and you don't have to recompute anything - the percentages stay meaningful and the node recalculates the integers automatically.

    Inputs and outputs

    • step - your total sampling steps (1–10000, default 20). Should match whatever you're actually running in your sampler.
    • start_percent / end_percent - 0–100, where in the schedule this window starts and ends.

    Outputs mirror the inputs conceptually but as usable integers: step (echoes the total back out, handy for wiring the same number elsewhere without a second node), start, and end - the two integer step indices, which plug straight into a KSampler (Advanced)'s start_at_step/end_at_step, or anywhere else in the graph that wants a step number instead of a percent.

    Why you'd want this

    Multi-stage sampling - a base pass plus a refiner, a LoRA or ControlNet you only want active for part of the schedule, a conditioning switch partway through - all comes down to "this thing is active from step X to step Y." Describing that in percent instead of raw step numbers is easier to reason about and survives you tweaking the total step count without breaking the intent. It's a small node, but it's the kind of small node that saves you from a silently-wrong workflow after you bump steps from 20 to 30 and forget your hardcoded start_at_step: 6 was tuned for the old total.

    Installing it

    Through ComfyUI Manager: search "MTB Nodes," install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/melMass/comfy_mtb
    

    then restart. If it's not in the node search afterward, go into the comfy_mtb folder and run pip install -r requirements.txt - that's the standard fix when Manager's automatic dependency install misses something for this pack.

    Common issues

    This is one of the lighter-weight nodes in the pack - pure arithmetic, no image libraries, no model files - so it's unlikely to be the thing that fails to load. If you do see the pack's generic startup warning about some nodes not loading, that's almost always about the optional face-swap/DeepBump extras, not this one. The one mistake worth flagging: start_percent and end_percent aren't validated against each other, so setting start_percent higher than end_percent hands your sampler a nonsensical (or reversed) step range - keep start below end, same as you would setting the values by hand.

    Categorymtb/conditioning

    Inputs (3)

    NameTypeDefaultDescription
    stepINT201–10000
    start_percentINT00–100
    end_percentINT00–100

    Outputs (3)

    NameTypeDescription
    stepINT
    startINT
    endINT