ComfyUI Node

Step Every N

Change It Every N, Not Every Frame

By 5agado·Created 12 months ago·Updated 17 days ago· 1
Step Every N
    • SEED
    seed0
    increment_every_n1
    current_index0

    Seed control in batch and loop workflows is one of those things that looks trivial until you actually want it. "Every image should look totally different" and "the first three frames should be variations of the same idea, then the fourth should move on" are different problems, and a plain seed widget gives you neither. Step Every N is the node for the second one: it holds the seed steady for N iterations, then bumps it.

    The math, since it's simple enough to sanity-check

    The source formula is:

    modified_seed = current_index + (seed // increment_every_n)
    

    seed // increment_every_n is integer division, so with a base seed of 10 and increment_every_n = 3, the seed stays at 3 for indices 0, 1, 2, then becomes 4 at index 3, 5 at index 6, and so on. Set increment_every_n = 1 and you get a seed that steps every iteration - effectively the "different each time" mode. The node's own description puts it as "increment seed every N steps," and the source even spells out the example: N=3 means the seed changes at indices 3, 6, 9...

    Inputs and output

    • seed (INT, default 0) - your base seed.
    • increment_every_n (INT, default 1) - step cadence.
    • current_index (INT, default 0) - the loop counter you feed in from your iterator or counter node.
    • Output: SEED (INT) - wire this straight into a KSampler's seed input.

    When you'd actually use it

    Anywhere you're looping over a batch and want grouped variation. A common pattern: generating video frame batches or multi-image sets where you want a few near-identical shots per seed before exploring - exactly the "same seed for N frames, then step" cadence that keeps a video's first frames coherent while still varying the sequence. It's also handy for A/B comparisons where you want a handful of seeds, not thousands.

    The one thing to know: this node doesn't track anything itself. It's stateless - the current_index has to come from outside (a Counter node, an iterator, whatever your loop uses). Forget to wire the index and you'll feed a constant seed forever and wonder why nothing changes. That's not a bug, it's the design; the node is a pure function of its three inputs.

    Install is the standard pack dance - ComfyUI Manager → "Sagado Nodes for ComfyUI", or git clone https://github.com/5agado/ComfyUI-Sagado-Nodes into custom_nodes, pip install -r requirements.txt, restart. No models, no deps beyond the pack's base four.

    It's a small node, but if you've ever hand-rolled a "seed that changes every third image" with a math node and a modulo, you'll appreciate not having to think about it again.

    CategorySagado-Nodes

    Inputs (3)

    NameTypeDefaultDescription
    seedINT0
    increment_every_nINT1
    current_indexINT0

    Outputs (1)

    NameTypeDescription
    SEEDINT