Nodes/ComfyUI-TJ_NODE/Queue Loop (TJ)
ComfyUI Node

Queue Loop (TJ)

Batch your seeds and LoRAs with Queue Loop (TJ)

By designloves2·Created 4 months ago·Updated 3 days ago· 13
Queue Loop (TJ)
    • index
    • index_text
    • queue_count
    auto_settrue
    queue_count50
    current_index1
    current_queue0
    start_index1
    end_index4
    step1
    index_loop_modeIndex Loop

    You know the loop. Change the seed, run. Change it again, run. Fifty more times because you're testing LoRAs and want to compare them all. Queue Loop (TJ) automates exactly that: it re-queues the whole workflow a set number of times, and hands you an index that changes every run so you can drive seeds, LoRA picks, or anything else through the iterations. It's the difference between babysitting ComfyUI and letting it churn while you go do something else.

    How it works

    The mechanism is a frontend/backend handshake. On each run the node outputs the current index and the number of times it should loop (queue_count); the frontend sees the loop wants to continue, increments its internal counters, and queues the next run automatically. It also returns float("nan") from its change-detection so ComfyUI never serves a cached result from a previous identical run - a detail that quietly prevents a whole class of "why is it not advancing" bugs.

    The knobs:

    • queue_count - total iterations. Default 50, which is a lot; set it to how many variants you actually want.
    • start_index / end_index / step - the range the index walks. Want every other seed from 1 to 10? start 1, end 10, step 2.
    • index_loop_mode - Index Loop wraps back to the start when it hits the end (run forever over a range); Index Stop at End halts the queue when the range is exhausted.

    Outputs: index (INT) - the current iteration, wire this into a seed widget or a LoRA loader's index; index_text (STRING), same value as text for filename prefixes and such; queue_count (INT), the total so downstream knows the plan. auto_set (default on) publishes them as wireless providers.

    Using it with the pack's pieces

    Queue Loop is the engine behind a couple of TJ workflow patterns. Pair its index with Index LoRA Loader (TJ) and it walks your LoRA folder one model per run, testing each automatically. Pair queue_count with the Index LoRA Loader Counter (TJ) and the loop count stays in sync with how many LoRAs you actually have - the counter reads the loader's widget values directly (no graph link) specifically to avoid the circular reference a direct connection would create. The pack also has an Images Compare Sheet - Queue Loop (TJ) that accumulates every loop iteration's output into one comparison sheet, which turns the whole thing into an automated A/B grid.

    Installing it

    Standard pack install:

    cd ComfyUI/custom_nodes
    git clone https://github.com/designloves2/ComfyUI-TJ_NODE
    

    or ComfyUI Manager → ComfyUI-TJ_NODE → restart. No dependencies beyond the pack.

    Common issues

    If your loop only runs once or repeats the same index, the usual culprits are a stale ComfyUI frontend (hard-refresh) or the loop node being inside a subgraph the frontend isn't watching. And a genuine warning from the maintainer: recent versions fixed the case where connected inputs were ignored when typing values directly - the node now reflects connected sources' current values immediately, so if you're feeding queue_count from a counter, trust the wire, not the number you typed.

    Category ✨ TJ_Node/Utility

    Inputs (8)

    NameTypeDefaultDescription
    auto_setBOOLEANtrue
    queue_countINT501–1000000
    current_indexINT11–1000000
    current_queueINT00–1000000
    start_indexINT11–1000000
    end_indexINT41–1000000
    stepINT11–1000000
    index_loop_modeCOMBOIndex Loop2 options: Index Stop at End, Index Loop

    Outputs (3)

    NameTypeDescription
    indexINT
    index_textSTRING
    queue_countINT