计次内循环首
The patched, in-process loop head with a data backhaul
- DOWHILE
- 循环次数
- seed
- 回传数据
- 总数
- 步长
ForInnerStart (计次内循环首) opens the pack's inner counted loop - the one that runs inside a single ComfyUI execution instead of re-queueing the graph every iteration like the older ForStart/ForEnd pair. Same counter idea (total, step, current index), but it runs in-process, carries data back around the loop, and pairs with ForInnerEnd, which collects every iteration's result into one batch.
"内循环" translates to "inner loop." Think of it as the loop you use when the loop is part of a larger workflow rather than the whole workflow - a refinement pass inside a bigger pipeline, not the top-level "render these 20 images" driver.
How it works
At a glance it looks like ForStart: you set total, stop and the starting i, and you get back the total, the iteration count, and a per-iteration seed. The difference is the backhaul. This start node accepts returned data from the loop's end and pushes it back into the next pass - so iteration N can see what iteration N-1 produced. That's what makes iterative refinement loops (denoise, check, refine again) possible inside one graph. Its DOWHILE output carries the loop token that ForInnerEnd uses to identify the loop.
And the catch, again: this family lives on the author's patch to ComfyUI's execution.py. The start node on its own is just a counter; the loop control is patched into the executor. No patch, no loop.
The inputs and outputs
- total (INT, 0–99999) - iteration count.
- stop (INT, 1–999) - step size per pass.
- i (INT, 0–99999) - starting index.
Outputs worth knowing:
- DOWHILE - the loop token; wire to ForInnerEnd's
start. - 循环次数 (INT) - current iteration.
- seed (INT) - deterministic per-iteration seed, seeded from the index.
- 回传数据 (*) - the data returned from the previous pass (the backhaul).
- 总数 / 步长 (INT) - total and step, passed through for convenience.
Install
Standard pack install:
cd ComfyUI/custom_nodes
git clone https://github.com/yanlang0123/ComfyUI_Lam
then restart and apply the execution.py patch (修改文件.bat / .sh in the repo) - this node's loop behavior depends on it. Re-apply after every ComfyUI update; core updates overwrite the patch and the loop silently degrades into errors.
Common issues
- Loop body doesn't repeat - the patch is missing or was overwritten by an update. Re-run it.
- Previous pass's data not visible - the backhaul needs ForInnerEnd feeding its result back into the loop; check that
objreturns on every iteration, not just the last. - Counts but only the last result survives - you're reading
endObjon the end node instead of the accumulatedobjs. Both exist; grab the right one.
If you don't need iteration-to-iteration data, the plain ForStart/ForEnd pair avoids the patch entirely. If you do - if the loop is a refinement loop - this is the one.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| total | INT | 00–99999 | — |
| stop | INT | 11–999 | — |
| i | INT | 00–99999 | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| DOWHILE | DOWHILE | — |
| 循环次数 | INT | — |
| seed | INT | — |
| 回传数据 | * | — |
| 总数 | INT | — |
| 步长 | INT | — |