Diffusion Model Load Later [darkilNodes]
Defer the UNet load until the chain actually needs it
- any_trigger
- MODEL
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), orfp8_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'ssoft_empty_cache()before loading.gc_collect(BOOLEAN) - forces Python'sgc.collect().unload_models(BOOLEAN) - callsunload_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 yourdiffusion_modelsfolder, same as the stock loader.weight_dtypeand 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.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| any_trigger | * | — | |
| unet_name | COMBO | 0 options: | |
| weight_dtype | COMBO | 4 options: default, fp8_e4m3fn, fp8_e4m3fn_fast, fp8_e5m2 | |
| empty_cache | BOOLEAN | false | — |
| gc_collect | BOOLEAN | false | — |
| unload_models | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |