Peek Step Index
Turn SamplerPeekAdvanced's step list into a plain number
- step_index
PeekStepIndex is a tiny conversion node: it takes the step_indices output of SamplerPeekAdvanced and hands back a single integer step index. One input, one output, no settings. If it looks too simple to deserve its own node, that's sort of the point - but there's a genuine reason it exists.
Here's the subtlety. SamplerPeekAdvanced's step_indices output is typed as INT, but it isn't one number - it's a tensor carrying one step index per preview frame you collected. If you decoded steps 5, 10, and 15, you get a 3-element batch. That's exactly right for pairing with the preview_images batch, but it's the wrong shape for anything downstream that wants "a number." Most nodes that take an INT expect a scalar, and plugging a batch in just doesn't work.
PeekStepIndex collapses the batch to its first value and returns it as a clean INT. In practice that first value is almost always what you want: the step at which your earliest preview was captured.
Why you'd actually reach for it
The most common use is wiring the current step into StepExpression so you can build step-relative logic outside the sampler itself. SamplerPeekAdvanced's own decode_expr and cfg_expr already know the step internally, but the moment you want to gate or schedule something else on the same run - a different node, a value switch, a denoise tweak - you need the step as a plain number, and this is the bridge.
It's also handy for bookkeeping. If you're saving preview frames and want to label or filter them by which step produced them, a scalar index is a lot easier to reason about than a tensor.
Install
Comes with the comfyui-sampler-peek pack:
cd ComfyUI/custom_nodes
git clone https://github.com/Prohect/comfyui-sampler-peek
Restart ComfyUI. No extra dependencies or models. (ComfyUI Manager users can just search comfyui-sampler-peek.) Beware: the README's own clone command references the old aria4comfyui repo, which is gone - use the URL above.
The one caveat
You only get the first step index. If your decode expression matched several steps, the other indices aren't lost (they're still in the original step_indices tensor), but this node only surfaces one. If you genuinely need the full list, keep working with the raw output. For feeding a scalar downstream - which is what 99% of people want - first value is the right call. When no previews were collected, it returns 0, matching the sampler's empty-batch behavior.
A thin node, honestly, but it's the glue that makes the pack's other pieces compose, and it costs nothing to have in your back pocket.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| step_indices | INT | Step indices tensor from SamplerPeekAdvanced |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| step_index | INT | — |