整数递增丨动态
A counter that ticks every run — your batch loop finally knows where it is
- source
- 整数
ComfyUI's seed widgets have that little control_after_generate dropdown - fixed, increment, decrement, randomize - that fires after a run. DynamicIntegerIncrement is the standalone version of that idea, except it ticks on your signal instead of hiding in a dropdown. You wire any kind of trigger into its source input, and every time the graph runs (and data flows through), it steps an integer by value_size and hands you the running total. It's the node you reach for when you need a counter for batch filenames, iteration indices, or seed stepping that the graph itself drives.
It lives in ComfyUI-QING's data-tools category (display name 整数递增丨动态). This is plumbing in the purest sense - a tiny stateful utility whose whole job is to make the graph behave like a small program. If you've fought with control_after_generate ordering (the classic "you already overwrote your good seed" injury), you'll appreciate a counter that increments exactly when you say so.
How it works. Under the hood it keeps per-node-instance state in memory - a dict keyed by the node's UNIQUE_ID, so separate copies of the node don't share a counter. When source has data flowing, it applies the control mode:
- 数值固定 (fixed) - output stays at
value_size. - 数值增加 (increment) - adds
value_sizeeach run. - 数值减少 (decrement) - subtracts it.
- 数值随机 (random) - adds a random value between
-value_sizeand+value_size.
And critically, it overrides IS_CHANGED to return float("NaN"), the plumbing-layer idiom that forces the node to re-execute every run - so the counter actually advances on repeated runs instead of being swallowed by ComfyUI's output-caching. That's the same trick the KB's node-plumbing essay documents; here it's the whole point of the node.
The inputs that matter.
source- optional,*typed. This is your trigger. Any connected value counts as "data flowing"; the node doesn't care what type it is.value_size- the step, an INT (default 1, can be negative).control- the four-mode dropdown above.clear_value- set true to reset this instance's counter to 0.
The output (整数, INT) is the current value after the step.
How to install. ComfyUI-QING is one pack covering all 79 nodes - search "ComfyUI-QING" in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/GAO-SHIQING/ComfyUI-QING
cd ComfyUI-QING
python install_dependencies.py
Restart afterward. The README's clone URL is missing an "H" (GAOSHI-QING) - use the URL above or Manager. --mirror helps if you're in China.
Troubleshooting. The classic confusion: the counter only advances when source has something flowing through it. Leave source unconnected and the node holds whatever value it has - no ticks. That's by design (the docstring says "只要左侧输入端口有数据传递" - only when the left input has data does it update), but it reads as "broken" the first time. Second gotcha: the state is in-memory, so restarting ComfyUI resets every counter to 0 - if your numbering has to survive a restart, this isn't the node for that. Third: because it's always-dirty (NaN), it also defeats ComfyUI's cache for anything downstream - which is what you want for a live counter, but don't put it upstream of an expensive sampler chain you expect to be cached.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| value_size | INT | 1-2147483648–2147483647 | — |
| control | COMBO | 数值增加 | 4 options: 数值固定, 数值增加, 数值减少, 数值随机 |
| clear_value | BOOLEAN | false | — |
| sourceopt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 整数 | INT | — |