Model Load
Load weights into a model you already built — the architecture must match
- model
- model
CdlModelLoad is the other half of the pack's save/load pair: it reads a .pt state_dict from disk and applies it to a cdlModel you provide. The keyword there is provide - unlike loading a checkpoint in normal ComfyUI, you don't get a model back from the file. You bring the architecture, this node pours the weights into it.
That's the one rule that trips everyone: the architecture must match the saved state_dict, exactly. Save a LeNet with num_classes=10, load it into a LeNet with num_classes=5, and PyTorch's load_state_dict will throw a shape mismatch error. Save and load are designed as a symmetric pair - CdlModelSave writes state_dict, CdlModelLoad reads it back - and they only work together cleanly when the network structure lines up. The pack's model-utils flow is: build with CdlLeNet (or any model node), optionally save it, and later reconstruct the same model node settings before loading.
How it works
It calls torch.load(path, map_location="cpu") to read the file, then model.load_state_dict(sd) to copy the weights into your model instance, then returns the model. Loading to CPU first means the file can be read regardless of where the model will live - a small but real convenience. The path is whatever you pass in; the default is model.pt, which lands relative to ComfyUI's working directory unless you give an absolute path.
Inputs and output
model- thecdlModelthat will receive the weights. Must match the saved architecture.path- aSTRING, defaultmodel.pt. Use a full path likeC:/models/my_model.ptto be safe about where it writes.
The single output is model - the same instance you passed in, now with the loaded weights.
Installing ComfyDL
It ships with the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/Cynthia-lxx/ComfyDL
pip install -r ComfyDL/requirements.txt
Restart ComfyUI. The only extra dependency is matplotlib; torch comes with ComfyUI. ComfyUI Manager users: search "ComfyDL", and if it's not in the built-in list (the pack isn't published to the official Comfy Registry yet), use Install via Git URL with the repo link.
Common issues
The shape-mismatch error is the headline failure - "size mismatch for …" from load_state_dict. Double-check num_classes and any other shape-driving settings match what you saved with. Second, it only reads state_dict files, not full checkpoint bundles; if someone hands you a full torch.save(model) blob, this node won't know what to do with it. And the path semantics trip people: model.pt with no directory resolves relative to wherever ComfyUI was launched. Give it an absolute path and you remove a whole class of "where did my file go" confusion.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| model | cdlModel | — | |
| path | STRING | model.pt | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| model | cdlModel | — |