ComfyUI Node

Pt Save Model

Save your trained model without ever touching a terminal

By HowToSD·Created about a year ago·Updated about a year ago· 7
Pt Save Model
  • model
  • model full path
model_pathmodel.pkl

Pt Save Model is where your ComfyUI training run actually lands on disk. The whole pitch of ComfyUI-Pt-Wrapper is that you can train a PyTorch model - the README shows dog-vs-cat classifiers, ResNet on CIFAR-10 at ~94% accuracy, even a Transformer from scratch for IMDB text classification - without writing Python. All of that is theater if you can't keep the trained weights afterward. This node is the save button.

What it actually does

It takes a PTMODEL - that's the custom type the pack's model nodes (Linear, Conv, ResNet, Transformer, Chained) output - and a model_path string, and saves the model's weights to a file using torch.save. Two things are worth understanding about how it saves:

It saves the state_dict, not the whole model. That means weights and biases, but not the architecture - the class definition, the layer structure. To load it back later you need to rebuild the exact same model structure with the pack's model nodes and then load the state dict into it. Save a Linear model, load it back into a Linear node with the same config; don't expect to swap in a Conv model and have it work.

Relative paths land inside the pack's own models/ folder. A default model.pkl resolves to ComfyUI/custom_nodes/ComfyUI-Pt-Wrapper/models/model.pkl. You can also pass an absolute path if you want it somewhere saner - like a folder you'll actually remember.

The input that matters is model_path, a string field defaulting to model.pkl. Just type a filename, or a path. The output is a single STRING labeled model full path - the resolved absolute path of what you saved. Wire that into Pt Show Text (or anything that takes a string) and you'll see exactly where the file went, which beats hunting through your filesystem.

How to install it

Pt Save Model is part of ComfyUI-Pt-Wrapper. ComfyUI Manager: search ComfyUI-Pt-Wrapper, install, restart. Or clone:

cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper

Restart after. Heads-up on the pack's requirements.txt: it's heavy (transformers, datasets, accelerate, peft, gensim, sentencepiece, plus pandas/scikit-learn/scipy). For a training pack that's expected, but first install is slow and version conflicts with other nodes are possible.

Gotchas

The classic mistake is forgetting the architecture caveat. Since this saves only weights, you need the matching model nodes with matching configs on the load side - and the pack's own training docs stress matching the setup between train and eval workflows. If loading gives you a "missing keys" or size-mismatch error, it's almost always a config mismatch, not a corrupted file.

Also, .pkl is the default extension but it's just a torch-saved file; the name doesn't matter to PyTorch. And there's no overwrite protection - save twice to the same path and the second run silently replaces the first. If you're training multiple models in one session, change the path per run or you'll be saving over your own work.

CategoryData Analysis

Inputs (2)

NameTypeDefaultDescription
modelPTMODEL
model_pathSTRINGmodel.pkl

Outputs (1)

NameTypeDescription
model full pathSTRING