Nodes/ComfyUI-PepeUtils/Pepe Lazy Route
ComfyUI Node

Pepe Lazy Route

Pick one of eight branches and only run that one

By Pepehoschi·Created 5 months ago·Updated 2 days ago· 0
Pepe Lazy Route
  • choice_0
  • choice_1
  • choice_2
  • choice_3
  • choice_4
  • choice_5
  • choice_6
  • choice_7
  • output
choice_index0

Most of ComfyUI is "run everything, all the time." But a workflow with alternatives - two upscale paths, an optional refiner, a fast and a slow sampler - shouldn't have to execute both just because one is chosen. Pepe Lazy Route is the router that picks one of eight inputs and, crucially, only evaluates that one. The unselected branches don't run, which means they don't cost you VRAM or time.

The natural partner is Pepe Image Filter. You generate a batch, the filter pops up and asks which way to go, and its choice_index drives this node to the matching branch. You've built a decision point into the workflow, and the paths not taken are skipped rather than computed and thrown away.

How it works

The mechanism is ComfyUI's lazy evaluation, and it's worth understanding because it's what separates this from a plain switch. A normal A/B switch (the family this belongs to in ComfyUI's plumbing layer) selects which input to pass, but ComfyUI has typically already evaluated both. A lazy node instead tells the executor which inputs it actually needs, through check_lazy_status - this node reports "I only need choice_0", say - so the executor walks backward and evaluates only that branch's upstream. A second sampling pass sitting on choice_1 is dead code when choice_index says 0. That's the whole point of the node, and the reason to reach for it over a switch.

The inputs:

  • choice_index - the selector, an integer 0–7, designed to be fed by Pepe Image Filter's choice_index output (it's marked forceInput, so wire it rather than typing).
  • choice_0 through choice_7 - the eight alternative branch results, all wildcard * sockets, so it routes images, latents, models, conditioning - whatever you're comparing.

The output is a single output socket returning the selected value.

Wiring it up

Connect each possible branch result to its numbered input, connect the selector, and use output as the single downstream consumer. Because all eight inputs share one wildcard output, keep the branch results type-compatible - you don't want to route a LATENT on choice_0 and an IMAGE on choice_1 into something that expects one specific type. All branch results connected to one router should be the same type.

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/Pepehoschi/ComfyUI-PepeUtils.git

or ComfyUI Manager → ComfyUI-PepeUtils, restart. No extra dependencies; lazy routing is part of the ComfyUI execution engine, not a bolt-on.

The catch, and its sibling

Lazy routing has a real limit: ComfyUI schedules every output node (Save Image, Preview Image) as its own terminal path. So if one of your unselected branches ends in its own Save node, that save still fires regardless of what a lazy router upstream says - the router can't suppress a terminal elsewhere in the graph. That's exactly what Pepe Route Split exists for: it blocks every route except the selected one right at the split, so branches that end independently in their own Save/Preview nodes work. Use Lazy Route when branches reconverge into one consumer; use Route Split when they diverge to their own outputs.

CategoryPepeUtils/flow

Inputs (9)

NameTypeDefaultDescription
choice_indexINT00–7Zero-based choice index from Pepe Image Filter
choice_0opt*
choice_1opt*
choice_2opt*
choice_3opt*
choice_4opt*
choice_5opt*
choice_6opt*
choice_7opt*

Outputs (1)

NameTypeDescription
output*