| name | deployment |
| description | Deploy and optimize trained biomedical ML models for inference. Use when: (1) Exporting models to ONNX or TorchScript, (2) Building inference pipelines with sliding window for 3D volumes or patch-based prediction for WSI, (3) Test-time augmentation (TTA), (4) Optimizing inference speed with torch.compile or quantization, (5) Packaging models as REST APIs or Docker containers for serving.
|
Deployment & Inference
Workflow
Deploying a trained model involves these steps:
- Choose deployment target -- batch processing, REST API, or edge device
- Export the model -- to ONNX, TorchScript, or use torch.compile
- Build the inference pipeline -- with appropriate tiling/windowing strategy
- Optimize -- quantization, half precision, or compilation
- Package -- Docker container, FastAPI server, or batch CLI
Decision Tree
What is the deployment target?
- Local batch processing → Batch inference CLI. See serving.md
- REST API → FastAPI server + Docker. See serving.md
- Cross-framework (e.g., to C++/ONNX Runtime) → ONNX export. See export.md
- PyTorch-only, speed optimization → torch.compile or TorchScript. See export.md
What is the input format?
ASK the user before starting:
- What is the deployment target (local, API, edge)?
- What input data format and typical sizes?
- Any latency or throughput requirements?
References
| File | Read When |
|---|
| references/export.md | Exporting to ONNX (with dynamic axes, verification), TorchScript (tracing vs scripting), torch.compile, quantization |
| references/inference-pipelines.md | Sliding window for 3D volumes (overlap + Gaussian), patch-based WSI inference, TTA for classification and segmentation |
| references/serving.md | FastAPI model server, health checks, Dockerfile with CUDA, batch inference CLI |