🗄️ Lazy Session Cache
Don't re-run the expensive stuff every loop cycle
- value_in
- value_out
- log
Here's the problem the loop pattern creates: in a self-queuing workflow, everything upstream re-executes on every cycle. That's fine for the cheap stuff, but your video analyzer scanning 900 frames, or a VAE pass on a reference frame, re-running 12 times is pure waste - and on a card that's already at its limit, waste is how you OOM.
LazySessionCache is the pack's answer: capture a value once on cycle 0, then make ComfyUI not execute the nodes feeding it on every later cycle. It's lazy evaluation done with the engine's blessing, not a hack. It and its sibling MasterSwitch are how the pack "amputates" inactive routes so heavy nodes never even load.
How it works
The trick lives in check_lazy_status(), a hook ComfyUI calls before executing a node to ask "do you actually need your inputs?" On current_loop_index == 0, the node returns ["value_in"] - so ComfyUI runs whatever is upstream and the value gets captured into an in-memory cache keyed by the node's unique ID. On every cycle after that, it returns [], which means ComfyUI skips the upstream chain entirely. The node then hands back the cached value.
That's a genuinely different thing from a reroute or a switch that just passes through a stale value - upstream isn't executed at all. For a workflow where the upstream is a full video scan, that's the difference between a 5-second cycle and a 5-minute one.
Inputs and outputs that matter
current_loop_index(INT, required) - wire this fromSequentialLoopStart. It's what decides capture vs. replay.value_in(*, optional) - anything you want held across cycles. It has to be optional, which is exactly what makes lazy evaluation legal; ComfyUI won't try to compute it unless the node asks.value_out(*) - the captured (or replayed) value. Feed this onward.log(STRING) - tells you whether it captured or recovered from cache.
One honest caveat: the cache is a plain Python dict in the process, so it dies with ComfyUI. If the node ever finds the cache empty on a later cycle (say, you restarted mid-loop), it falls back to passing value_in straight through, which is a graceful-enough failure.
When to reach for it
Use it to hold anything that's expensive and doesn't change between cycles - the analyzer's reference_frame, extracted audio, a conditioning pass. Skip it for anything cheap or anything that's supposed to vary per cycle (that's what seeds and indices are for). If you only add one "logic" node from this pack, most people get more value from MasterSwitch; this one shines once your workflow has a genuinely heavy upstream you're duplicating every cycle.
Install
ComfyUI Manager → search "comfyui-sequential-batcher", or:
cd ComfyUI/custom_nodes
git clone https://github.com/Meisoftcoltd/comfyui-sequential-batcher
Restart after installing. No extra model downloads for this node - it's pure orchestration logic. And remember the pack-wide rule: run ComfyUI without --highvram, because the memory-management nodes the loop depends on are blocked under that flag.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| current_loop_index | INT | 0 | — |
| value_inopt | * | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| value_out | * | — |
| log | STRING | — |