Nodes/comfyui-darkil-nodes/Diffusion Model Load Later [darkilNodes]
ComfyUI Node

Diffusion Model Load Later [darkilNodes]

Defer the UNet load until the chain actually needs it

By pytraveler·Created 7 months ago·Updated 15 days ago· 9
Diffusion Model Load Later [darkilNodes]
  • any_trigger
  • MODEL
unet_name
weight_dtype
empty_cachefalse
gc_collectfalse
unload_modelsfalse

ComfyUI loads a model the moment its loader node executes, which in most graphs is immediately. Usually that's fine. But in a big workflow - one with an option switch, a model chooser, or a prep stage you'd rather run first - you don't want a 20GB diffusion model pinned in VRAM while you're still cropping images. This node is Load Diffusion Model with a delayed trigger: it holds the load until some upstream node fires, and then hands you a MODEL for the sampler.

How the deferred load works

The trick is a single any_trigger input of type * (wildcard). You connect anything to it - a boolean, a conditioning, an image, whatever - and because the node depends on that upstream link, it executes only after that link has produced a value. The model loads then, not at graph start. It's not lazy evaluation or scheduling magic; it's just using the execution graph's ordering to push the load to a later point in the chain.

On top of that it gives you real memory controls that the stock loader doesn't:

  • weight_dtype - default, fp8_e4m3fn, fp8_e4m3fn_fast (fp8 + optimization flags), or fp8_e5m2. This is the same fp8 family you see on modern checkpoint loaders; the fast variant trades a little precision for speed.
  • empty_cache (BOOLEAN) - runs ComfyUI's soft_empty_cache() before loading.
  • gc_collect (BOOLEAN) - forces Python's gc.collect().
  • unload_models (BOOLEAN) - calls unload_all_models() first, so you swap from one model to another without the old one lingering.

The inputs that matter

  • any_trigger (*) - the only thing you must wire. Connect whatever should gate the load.
  • unet_name - picked from your diffusion_models folder, same as the stock loader.
  • weight_dtype and the three memory toggles from above.

Output is a single MODEL, straight into the sampler. Under the hood it uses ComfyUI's comfy.sd.load_diffusion_model with the fp8 model_options, so behavior matches the stock loader once it actually runs - the only difference is when.

Where people get burned

The obvious gotcha: don't connect the trigger to something that itself needs the MODEL. If you create a circular dependency, ComfyUI will either error or (worse) silently reorder things. Keep the trigger feeding from the side of the graph that's upstream of the sampler. Also, fp8_e4m3fn_fast changes output slightly - if you're chasing pixel-identical reruns, stay on default.

Installing

It ships in pytraveler/comfyui-darkil-nodes. ComfyUI Manager search ComfyUI-darkil-nodes, or:

cd ComfyUI/custom_nodes
git clone https://github.com/pytraveler/comfyui-darkil-nodes

Restart ComfyUI. No Python dependencies and no model files to download - the models are the ones already in your diffusion_models folder.

CategorydarkilNodes/logic

Inputs (6)

NameTypeDefaultDescription
any_trigger*
unet_nameCOMBO0 options:
weight_dtypeCOMBO4 options: default, fp8_e4m3fn, fp8_e4m3fn_fast, fp8_e5m2
empty_cacheBOOLEANfalse
gc_collectBOOLEANfalse
unload_modelsBOOLEANfalse

Outputs (1)

NameTypeDescription
MODELMODEL