ComfyUI Node

Batch State

A fixed seed sequence that restarts whenever you change anything

By hustille·Created 3 years ago·Updated 2 years ago· 5
Batch State
    • changed
    • hash
    • count (number)
    • count (int)

    This is the pack's hero node, and it exists to automate one of the oldest pieces of advice in this hobby: change one variable at a time with a fixed seed - otherwise you can't tell which edit changed the image. Batch State makes that a button. It watches the entire workflow, tells you whether anything changed since the last run, and hands you a counter that only advances when nothing changed. Wire that counter into a fixed seed and every Queue click gives you a consecutive seed - and the moment you touch prompt, CFG, or steps, the sequence restarts from the seed's base value.

    The payoff is a batch of images you can actually compare. Run once at seed 100, 101, 102 with one CFG, change the CFG, and get the same seed sequence again against the new setting. That's the A1111-style "study this parameter" workflow the author built the pack around, no manual seed-farming required.

    How it works

    The node hashes the workflow's state - every node's widget values plus the graph's links - with sha256, then compares it to the state from its previous run. Identical state? changed is 0 and count increments. Anything different? changed is 1 and count resets to 0. Like the other stateful nodes in this pack, it forces itself to re-execute on every queue via a NaN IS_CHANGED; if it didn't, ComfyUI would cache the output and the counter would never move.

    The seed trick works because of the interplay: with the seed node set to fixed, its value stays put, the state stays put, and count climbs each run. Sum them (seed + count) and you get a run of consecutive seeds. Set the seed node to randomize and its value changes every run, so the state always differs, count stays at 0, and the sum is just the random seed - which the README points out is the expected behavior, not a bug.

    The outputs

    • changed - 1 if the workflow state changed since the last run, else 0.
    • hash - a hash of the current state. A convenient fingerprint for "which config is this".
    • count (number) and count (int) - the same counter in two types, so you can wire it into whatever input expects which.

    No inputs. It just watches.

    Gotchas

    • State lives in the node instance, per session. Reload the workflow or restart ComfyUI and the counter resets. There's no persistence.
    • It deliberately ignores nodes whose type contains Debug, Show, Function, or Evaluate, so debug plumbing doesn't nudge the hash.
    • It detects changes to typed widget values and connections - not to data flowing on wires like images or latents. Two runs with identical settings produce the same hash, which is the whole design.

    Install

    Via ComfyUI Manager, search "hus' utils" (pack title: hus' utils for ComfyUI). Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/hustille/ComfyUI_hus_utils
    

    Restart ComfyUI. No requirements.txt, no pip step, no model downloads - pure Python standard library, so there's nothing to break.

    Categoryutils/hus

    Inputs (0)

    No inputs

    Outputs (4)

    NameTypeDescription
    changedNUMBER
    hashSTRING
    count (number)NUMBER
    count (int)INT