Pt Load Model
Pick up where your last training run left off
- model
- model
Training a model in ComfyUI is fun until you close the app and lose the weights. Pt Load Model is the node that gets them back. You feed it a model architecture node and the name of a saved weights file, and it loads the trained weights into that architecture so you can resume training or run inference.
This is the load half of the pack's save/load pair. ComfyUI-Pt-Wrapper (HowToSD's 200-node no-code PyTorch training pack, the spin-off of ComfyUI-Data-Analysis) has a Pt Save Model node that writes state_dict files, and this node reads them back. It sits at the start of the inference half of a workflow: the "fine-tune once, deploy forever" pattern. The README's example projects - dog vs cat classifier, ResNet on CIFAR-10, the from-scratch Transformer on IMDB - all end with a model you can reload this way.
How it works. The mechanism is simple under the hood, which is exactly why it's reliable: it loads the file with torch.load(..., weights_only=True) and calls load_state_dict() on the model you pass in. Two inputs:
model- aPTMODELarchitecture node, e.g. Ptn Resnet Model or one of the Transformer model nodes. The architecture has to match the weights file, or the load fails with a shape mismatch. This is the classic "did you wire the right architecture?" trap.model_path- a string, defaultmodel.pkl. Important: paths are resolved relative to the pack's ownmodels/directory. So the default resolves toComfyUI/custom_nodes/ComfyUI-Pt-Wrapper/models/model.pkl. Drop your trained file there and give the node its filename.
Output is model, a PTMODEL with the loaded weights, ready for a training or inference node.
Two design details worth knowing. First, IS_CHANGED returns NaN - a deliberate hack that tells ComfyUI "never cache me, always run me." So the node re-loads the file on every execution rather than skipping because "nothing changed." Second, weights_only=True means it refuses to unpickle arbitrary Python objects - a good security default (the ComfyUI ecosystem has had real malware incidents around custom nodes, and loading weights is exactly the kind of operation a malicious file exploits). If you saved with a PyTorch version that writes non-tensor objects into the pickle, this can refuse a file that an older loader accepted.
Common issues. The big three: (1) shape mismatch / missing keys - the architecture node doesn't match what was saved; re-check input_dim, output_dim, and layer counts against the save. (2) FileNotFoundError - you put the file in the wrong folder; it's the pack's models/ dir, not ComfyUI's model folders. (3) Load fails after a PyTorch update - weights_only=True is stricter, and model files saved by the pack itself are usually fine, but if you hand it a checkpoint from somewhere else, expect friction.
Install: via ComfyUI Manager (search "ComfyUI-Pt-Wrapper") or:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
then restart. The pack pulls a heavy dependency stack (transformers, datasets, sentencepiece, a pinned gensim) on first install - give it a minute. No model downloads required here; this node reads files you already saved.
Troubleshooting quick hits: if the load silently "succeeds" but predictions are garbage, you loaded mismatched weights or the wrong file - check the path string, it's the usual culprit. If Manager's install breaks your environment, it's the pinned gensim colliding with another pack; remove the conflicting package and reinstall.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| model | PTMODEL | — | |
| model_path | STRING | model.pkl | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| model | PTMODEL | — |