Skip to content

Lazy Index Switch

Selects and forwards exactly one of up to 10 inputs by index, without evaluating the others until needed. The node is lazy: only the input matching the chosen index is computed and passed through, which helps avoid unnecessary processing on non-selected branches.
Preview

Usage

Use this node as a multiplexer to route one of several candidate values (of any type) based on an index. It’s ideal for choosing between multiple images, prompts, models, or other resources at runtime while preventing computation of unselected branches.

Inputs

FieldRequiredTypeDescriptionExample
indexTrueINTZero-based selector for which input value to forward (0 selects value0, 1 selects value1, etc.). Valid range is 0–9.2
value0TrueWILDCARDCandidate value for index 0. Evaluated lazily only if index is 0.An image tensor or any other data type
value1FalseWILDCARDCandidate value for index 1. Evaluated lazily only if index is 1.A text prompt or any other data type
value2FalseWILDCARDCandidate value for index 2. Evaluated lazily only if index is 2.A model reference or any other data type
value3FalseWILDCARDCandidate value for index 3. Evaluated lazily only if index is 3.Any supported data type
value4FalseWILDCARDCandidate value for index 4. Evaluated lazily only if index is 4.Any supported data type
value5FalseWILDCARDCandidate value for index 5. Evaluated lazily only if index is 5.Any supported data type
value6FalseWILDCARDCandidate value for index 6. Evaluated lazily only if index is 6.Any supported data type
value7FalseWILDCARDCandidate value for index 7. Evaluated lazily only if index is 7.Any supported data type
value8FalseWILDCARDCandidate value for index 8. Evaluated lazily only if index is 8.Any supported data type
value9FalseWILDCARDCandidate value for index 9. Evaluated lazily only if index is 9.Any supported data type

Outputs

FieldTypeDescriptionExample
valueWILDCARDThe selected input corresponding to the provided index. The output type matches whatever type the chosen input provides.If index=2 and value2 is an image, the output is that image

Important Notes

  • Lazy evaluation: Only the branch matching the current index is computed; all others are not evaluated.
  • Index range: Valid indices are 0–9. Ensure the chosen index corresponds to a connected input.
  • Type consistency downstream: Because the output type depends on the selected input, ensure downstream nodes can handle the possible types you may route.
  • Missing input: If the selected valueN is not connected or unavailable, the output will be empty/None.

Troubleshooting

  • No output when selecting an index: Verify the corresponding valueN input is connected and produces a value.
  • Downstream type errors: Ensure all potential routed inputs are of a type acceptable to downstream nodes, or add type-specific branches before merging.
  • Unexpected branch computation: Check that only the selected index is active; the node is lazy and should not trigger unselected branches.
  • Index selects an unconnected slot: Connect the matching valueN or change the index to a connected input.