← PyTorch learning pathPyTorch · Module 9 of 10
Saving, exporting and serving
Persist and deploy PyTorch models.
📖 Key ideas
- Save weights: torch.save(model.state_dict(), "model.pt").
- Load: model.load_state_dict(torch.load("model.pt")).
- Export: torch.export / ONNX for other runtimes.
- Serve with FastAPI, TorchServe or cloud endpoints.
- Mobile/edge: ExecuTorch.
💡 Real-life example: state_dict is the recipe card of learned numbers; the model class is the kitchen that uses it.
state_dictDictionary of model weights
ONNXOpen model exchange format
TorchServePyTorch model server
ExecuTorchOn-device PyTorch runtime