πͺ Interval Gate (nhk)
Run a branch every 5th image β ComfyUI's 'every now and then' switch
- input
- output
- gate_enabled
- status
- execution_count
You know the workflow: batch-generating 100 images, and you only want the expensive stuff - a full upscale, a video pass, an extra refinement step - on every 5th frame. Doing that by hand is miserable. IntervalGate exists so you don't have to: it flips a branch on every Nth execution and hands you a boolean to route on.
It lives in the nhk/utility category of the nhknodes pack, alongside its siblings (Cycling Switch, List Selector, Execution Counter). This family of nodes is the pack's reason to exist - small workflow-control utilities that save you from babysitting the queue.
How it works
The node keeps an in-process counter, protected by a thread lock. Each time it executes it increments, and the gate is enabled when execution_count % interval == 0. So with the default interval of 5, the gate fires on executions 5, 10, 15, and so on - every 5th run, not the first 4.
The important thing to understand: IntervalGate never blocks anything on its own. The input passes straight through to output on every single execution. What changes is the gate_enabled boolean. You're meant to wire that into a conditional router or switch node - the pack ships a Conditional Router for exactly this - and have that decide whether the expensive branch runs or a cheap passthrough does. IntervalGate is the clock; the router is the gatekeeper.
Because IS_CHANGED returns NaN, the node re-executes every run even if its inputs haven't changed, which is what lets the counter actually advance in a batch. One thing to keep in mind: the counter lives in memory on the node instance. Reload the workflow or restart ComfyUI and you're back to zero. There's no persistence.
The inputs and outputs
- input - any type. It's a wildcard socket, so it'll happily carry an image, a latent, text, whatever you want passed down the pipe.
- interval (default 5, 1β1000) - how often the gate fires.
- reset_counter (false) - flip this on once to zero the counter back out.
Outputs: output (the passthrough), gate_enabled (BOOLEAN - the one that matters), status (STRING, a human-readable "GATE ENABLED - Execution 5" message), and execution_count (INT, if you want to display or log progress).
Installing
Standard pack install. ComfyUI Manager β search "NHK Nodes" β install β restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Enashka/ComfyUI-nhknodes
No extra dependencies beyond what ComfyUI already ships - the pack's requirements (torch, numpy, pillow, requests) are all present in any stock install. Restart ComfyUI after cloning and you'll find the node under nhk/utility.
Common issues
- "It never fires / it fires on the first image." Check what
execution_countsays. The counter counts executions of this node, not images. If your batch runs as one big queue of 10 items, each run still executes the node once per item, which is what you want - but if you're feeding it a single batched tensor, that's one execution, not N. For per-image intervals, feed it per-image, not per-batch. - "It fires but nothing different happens." You wired
output, notgate_enabled. The output is always live. Route on the boolean.
If you've got a job that needs "this happens sometimes, but not every time," IntervalGate is the node you'd have written yourself - if it weren't already written. Pair it with the pack's Conditional Router and "upscale every 5th image" stops being a prayer and becomes a workflow.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| input | * | Input data to pass through | |
| interval | INT | 51β1000 | Enable gate every N executions (e.g., 5 = every 5th execution) |
| reset_counter | BOOLEAN | false | Reset execution counter back to 0 |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| output | * | β |
| gate_enabled | BOOLEAN | β |
| status | STRING | β |
| execution_count | INT | β |