Nodes/Kyusu Nodes/πŸ”’ Cycle Int (1-8)
ComfyUI Node

πŸ”’ Cycle Int (1-8)

Batch-Queue Everything Automatically

By TaIIo4KuHΒ·Created 4 months agoΒ·Updated 4 months agoΒ· 0
πŸ”’ Cycle Int (1-8)
    • INT
    β—„start1β–Ί
    β—„end8β–Ί

    The switches in this pack are only half the story. The other half is this: a node that counts up on every queued run, and wraps back to the start when it hits the top. Wire it into an 8-way input switch, set the queue batch count to 8, press go, and ComfyUI runs your workflow eight times - once per input - without you touching anything. That's Cycle Int (1-8), and it's the automation half of kyusu-nodes' whole gimmick.

    How it actually works

    Two integers, start and end (defaults 1 and 8). The node remembers where it is per node instance and hands out start, then start + 1, then start + 2… up to end, then wraps back to start. The source is explicit about the two mechanisms that make it tick, and they're both worth knowing:

    It reruns every queue item. ComfyUI caches aggressively and only re-executes nodes whose inputs changed. To force itself to run fresh every time, the node's IS_CHANGED method returns float("NaN") - NaN never equals itself, so the cache check always fails and the node always fires. That's the same "always-rerun" trick every counter and random-picker node in the ecosystem uses.

    Its state is per-node and per-session. The current value lives in a class-level dictionary keyed by the node's unique ID, not in the workflow file. Each run it reads its slot, advances it, writes it back. Consequences: the value is never saved with your workflow, and it resets to start when you restart ComfyUI. Close the app and the next run starts back at 1.

    One more guard in the code: if you set end below start, it quietly clamps end up to start, so you always get at least one value.

    What to wire it into

    The intended pairing is Kyusu/logic's three 8-way switches - Model, CLIP, Text - all driven from the same Cycle Int output. Set start 1, end 8, batch count 8, and one press flips through every model/CLIP/prompt combination you wired. Because it wraps instead of stalling, you never have to manually reset it before the next batch.

    The only other input that matters is your queue batch count, and that's on the ComfyUI toolbar, not the node.

    Install

    Pure Python, no dependencies, no models:

    cd ComfyUI/custom_nodes
    git clone https://github.com/TaIIo4KuH/kyusu-nodes
    

    or ComfyUI Manager β†’ "Kyusu Nodes", then restart.

    Gotchas

    • It forgets itself on restart. The counter is session memory, not workflow data. Save a workflow mid-cycle, reload it tomorrow, and it starts back at start. That's by design and stated in the source - don't build a production batch pipeline on it.
    • It only advances when it runs. The whole batch-count trick depends on ComfyUI executing the graph once per queue item. If something upstream errors on run 3, run 3's value is still consumed and the counter moves on - the node advances regardless of whether the rest of the graph succeeded.
    • NaN reruns are contagious-ish. Forcing a rerun defeats the cache for whatever reads this node. Here that's a handful of switches, so it's cheap. Just know that if you staple this onto something heavy, "always dirty" has a cost.

    If you want persistence across restarts, you're in the wrong tool - this one is a batch-comparison stepper, not a workflow-state manager.

    CategoryKyusu/logic

    Inputs (2)

    NameTypeDefaultDescription
    startINT10–1000000β€”
    endINT81–1000000β€”

    Outputs (1)

    NameTypeDescription
    INTINTβ€”