Serving & deployment
Export a trained DeepPurpose model to TorchScript or ONNX, stream a chunked CSV through batch prediction, or wrap it in a FastAPI predict endpoint.
DeepPurpose models can be deployed for production serving using various export formats. This guide covers model serialization and deployment patterns.
Deployment options
| Format | Use Case | Pros | Cons |
|---|---|---|---|
| Native PyTorch | Development, research | Full flexibility | Requires PyTorch runtime |
| TorchScript | Production serving | No Python dependency | Limited dynamic behavior |
| ONNX | Cross-platform | Broad runtime support | May not support all encoders |
Export to TorchScript
TorchScript enables deployment without Python runtime:
Note: Graph neural network encoders (MPNN, DGL_*) may have limited TorchScript support due to dynamic graph operations.
Export to ONNX
Batch-serving job pattern
For large-scale virtual screening, use batch processing:
For command-line batch serving:
REST API serving
Wrap the model in a simple Flask/FastAPI service:
Run with: uvicorn serve:app --host 0.0.0.0 --port 8000
Metadata to keep
- Model format (ONNX vs. TorchScript) and opset if ONNX.
- Encoder types (
drug_encoding,target_encoding) used during training. - DeepPurpose version, PyTorch version, and CUDA version if GPU-based.
- Training dataset and split method for reproducibility.
- Git commit hash for the training code.
Was this page helpful?
DeepPurpose quickstart
Pick one of five DeepPurpose task types, a workflow preset and a drug and protein encoder pair, then run a model-zoo inference and export predictions.csv.
Training & tuning
Train a DTI model by pairing a drug and a protein encoder, tune train_epoch, LR, batch_size and cls_hidden_dims, then save the checkpoint with its config.