Skip to main content

PyTorch Template

The PyTorch template scaffolds a production-ready ML project with PyTorch, torchvision, and common ML dependencies. Two variants are available:
  • pytorch: basic inference template for deployment
  • pytorch-train: complete training pipeline with checkpoints, validation, and metrics

Quick Start

The model type (classification, regression, etc.) is selected interactively during cirron init.

Project Structure

For shared files (Dockerfile, .gitignore, README.md, .env.example, tests), see Common files.

Cirron-specific bits

cirron.yaml

The generated config wires the training entrypoint and runtime:

Profiling hooks

The generated train.py and inference.py integrate with the Cirron SDK. Call ci.profile() once at module top so traces show up in cirron traces:
The PyTorch hooks then auto-instrument forward/backward/optimizer steps. For explicit regions the hooks don’t cover, use ci.scope as a context manager:

requirements.txt

Model Types

  • Classification: nn.CrossEntropyLoss, softmax output. Default architecture is a small CNN.
  • Regression: nn.MSELoss, linear output. Default architecture is a fully-connected MLP.
The interactive cirron init prompt selects which one is generated into src/model.py.

Usage

GPU Support

The generated code automatically detects CUDA via torch.cuda.is_available() and falls back to CPU. To target a GPU build, set runtime: gpu in cirron.yaml.

Next Steps

TensorFlow Template

Alternative deep learning framework

scikit-learn Template

Traditional ML algorithms

Common files

Dockerfile, tests, and shared scaffolding

Deployment

Deploy your trained model