Mlops
MLOps and Model Registry
What is MLOps?
MLOps (Machine Learning Operations) applies DevOps practices to ML systems: versioning, testing, deployment, and monitoring of ML models in production.
MLOps Lifecycle
Model Registry
Core Features
| Feature | Purpose |
|---------|---------|
| Versioning | Track model versions with metadata |
| Staging | Manage dev/staging/prod environments |
| Lineage | Track data and code used for training |
| Metadata | Store hyperparameters, metrics, artifacts |
| Access control | Permissions and audit logs |
Popular Tools
| Tool | Type | Highlights |
|------|------|------------|
| MLflow | Open source | Most popular, flexible |
| Weights & Biases | Commercial | Great UI, experiment tracking |
| Neptune.ai | Commercial | Easy integration |
| Kubeflow | Open source | Kubernetes-native |
| SageMaker Model Registry | AWS | Integrated with SageMaker |
| Vertex AI Model Registry | GCP | Integrated with Vertex |
Model Deployment Patterns
Blue-Green Deployment
- Maintain two identical production environments
- Switch traffic between them
- Easy rollback
Canary Deployment
[100% → Old Model]
↓
[95% Old, 5% New] → Monitor
↓
[50% Old, 50% New] → Monitor
↓
[100% → New Model]Shadow Deployment
- New model receives traffic but responses not used
- Compare outputs to current production
- Validate before real deployment
Rollback Strategies
1. Instant rollback: Point to previous model version
2. Gradual rollback: Shift traffic back incrementally
3. Automatic rollback: Trigger on metric thresholds
CI/CD for ML
**Example: GitHub Actions ML Pipeline**
on: [push]
jobs:
train:
steps:
- run: python train.py
- run: mlflow register-model
validate:
steps:
- run: python validate.py
deploy:
if: validation passes
steps:
- run: ./deploy_to_production.shBest Practices
- Version everything: code, data, models, configs
- Automate testing: data validation, model quality
- Monitor in production: data drift, model degradation
- Document: model cards, data sheets, runbooks