Nodes/ComfyUI_MieNodes/Mie Loop State Get Float ๐Ÿ‘
ComfyUI Node

Mie Loop State Get Float ๐Ÿ‘

Pulling a running number out of a ComfyUI loop

By MieMieeeeeยทCreated 2 years agoยทUpdated 28 days agoยท 225
Mie Loop State Get Float ๐Ÿ‘
  • loop_ctx
  • FLOAT
โ—„keyfeedback_floatโ–บ
โ—„default_value0.00โ–บ

A ComfyUI for-loop re-executes the same graph on every pass, and everything inside it is thrown away between laps by default. If you're doing something that needs to build on a number as the loop runs - a running average, a shrinking denoise threshold, a score that's supposed to climb until it's good enough - you need a place to keep that number alive across iterations. That's what the Loop State nodes in MieNodes are for, and Get Float is the read side for numeric values.

The mechanism. State in this pack travels as a custom object type, MIE_LOOP_CTX, which some other node in the same Loop category (the loop's own start node, plus the matching Set nodes) threads through your loop and updates each pass. Get Float takes that context and a key string, and returns whatever float is currently stored there. Nothing stored yet - first lap, or a key that doesn't match - and you get default_value back instead of a crash.

The stock key name, feedback_float, points at the intended pattern: some kind of scored feedback loop. Run a check each iteration (a CLIP similarity score, an aesthetic score, a distance metric), write the number into loop state, read it back at the top of the next pass, and decide from there - keep refining, stop early, adjust a parameter based on how close you are.

Inputs and output, straight from the schema.

  • loop_ctx (required) - has to originate from this pack's Loop nodes; the type won't accept a generic number or string standing in for it.
  • key (default feedback_float) - the label under which the value is stored. Rename it if you're tracking more than one number through the loop, since these are free-text and case-sensitive.
  • default_value (default 0) - the fallback before anything's been written.

The single output is a FLOAT, ready to plug into a KSampler's denoise, a CFG value, a comparison node, or anywhere else a number is expected.

Installing. Either search ComfyUI Manager for ComfyUI_MieNodes (the pack's registry title - the individual node class names won't show up as a search term the same way) and install through it, or clone it manually: cd ComfyUI/custom_nodes && git clone https://github.com/MieMieeeee/ComfyUI-MieNodes, restart ComfyUI. This node has no model downloads and no dependencies beyond the pack's base Python install.

A caveat worth stating plainly: the ComfyUI-MieNodes README doesn't cover the Loop category at all - no textual node list, no workflow screenshot, nothing. Everything here comes from reading the node's actual input/output schema and knowing how ComfyUI loops have to work mechanically, not from confirmed author documentation. It should get you running, but if the author ever documents this properly, that write-up wins over this one.

Troubleshooting.

  • You keep getting default_value no matter what. Check the key spelling against whatever the corresponding Set Float node uses upstream - a mismatched key is silent, not an error, so it just looks like the value "isn't sticking."
  • Socket type error on loop_ctx. You're feeding it something other than another Loop-category node's MIE_LOOP_CTX output. Trace what's actually upstream; a plain float or string won't satisfy that input even if the value would make sense.
  • The float looks stuck at one value across every iteration. Almost always means the loop_ctx wire you're reading from isn't the one carrying forward updates - you're probably pulling from the loop's initial state rather than the version that gets rewritten each pass by a Set node.
  • Precision drift on very small deltas. Floats accumulate rounding error over many loop passes the same way they would anywhere else in Python; if you're doing dozens of iterations on a tight threshold, don't be surprised if the comparison needs a small epsilon rather than an exact equality check.
Category๐Ÿ‘ MieNodes/๐Ÿ‘ Loop

Inputs (3)

NameTypeDefaultDescription
loop_ctxMIE_LOOP_CTXโ€”
keySTRINGfeedback_floatโ€”
default_valueFLOAT0.00โ€”

Outputs (1)

NameTypeDescription
FLOATFLOATโ€”