When this skill is activated, always start your first response with the 🧢 emoji.
ML Ops
A production engineering framework for the full machine learning lifecycle. MLOps bridges the gap between model experimentation and reliable production systems by applying software engineering discipline to ML workloads. This skill covers model deployment strategies, experiment tracking, feature stores, drift monitoring, A/B testing, and versioning - the infrastructure that makes models trustworthy over time. Think of it as DevOps for models: automate everything, measure what matters, and treat reproducibility as a first-class constraint.
When to use this skill
Trigger this skill when the user:
- Deploys a trained model to a production serving endpoint
- Sets up experiment tracking for training runs (parameters, metrics, artifacts)
- Implements canary or shadow deployments for a new model version
- Designs or integrates a feature store for online/offline feature serving
- Sets up monitoring for data drift, prediction drift, or model degradation
- Runs A/B or champion/challenger tests across model versions in production
- Versions models, datasets, or pipelines with DVC or a model registry
- Builds or migrates to an automated training/retraining pipeline
Do NOT trigger this skill for:
- Core model research, architecture design, or hyperparameter search (use an ML
research skill instead - MLOps starts after a candidate model exists)
- General software observability (logs, metrics, traces for non-ML services - use
the backend-engineering skill)
Key principles
- Reproducibility is non-negotiable - Every training run must be reproducible
from scratch: fixed seeds, pinned dependency versions, tracked data splits, and logged hyperparameters. If you cannot reproduce a model, you cannot debug it, audit it, or roll back to it safely.
- Automate the training pipeline - Manual training is a one-way door to
undocumented models. Build an automated pipeline (data ingestion -> preprocessing -> training -> evaluation -> registration) from day one. Humans should only approve a model for promotion, not run the steps.
- Monitor data, not just models - Model metrics degrade because the input data
changes. Track feature distributions in production against training baselines. Data drift is usually the root cause; model drift is the symptom.
- Version everything - Models, datasets, feature definitions, pipeline code,
and environment configs all deserve version control. An unversioned artifact is a liability. Use DVC for data/models, a model registry for lifecycle state, and git for code.
- Treat ML code like production code - Tests, code review, CI/CD, and on-call
rotation apply to training pipelines and serving code. The "it works in the notebook" standard is not a production standard.
Core concepts
ML lifecycle describes the end-to-end journey of a model:
Experiment -> Train -> Validate -> Deploy -> Monitor -> (retrain if drift)
Each stage has gates: an experiment produces a candidate; training on full data with tracked params produces an artifact; validation gates on held-out metrics; deployment chooses a serving strategy; monitoring decides when retraining is needed.
Model registry is the source of truth for model lifecycle state. A model moves through stages: Staging -> Production -> Archived. The registry stores metadata, metrics, lineage, and the artifact URI. MLflow Model Registry, Vertex AI Model Registry, and SageMaker Model Registry are the main options.
Feature stores decouple feature computation from model training and serving. They have two serving paths: an offline store (columnar, batch-oriented, used for training and batch inference) and an online store (low-latency key-value lookup, used at prediction time). The critical guarantee is point-in-time correctness - training features must only use data available before the label timestamp to prevent target leakage.
Data drift occurs when the statistical distribution of input features in production diverges from the training distribution. Concept drift occurs when the relationship between features and labels changes even if feature distributions are stable (e.g., user behavior shifts after a product change).
Shadow deployment runs the new model in parallel with the live model, receiving the same traffic, but its predictions are not served to users. Used to compare behavior before any real traffic exposure.
Common tasks
Design an ML pipeline
Structure pipelines as discrete, testable stages with explicit inputs/outputs:
Data ingestion -> Validation -> Preprocessing -> Training -> Evaluation -> Registration
| | | | |
raw data schema check feature eng model go/no-go
versioned + stats artifact artifact gate
Orchestration choices:
| Need | Tool | |---|---| | Python-native, simple DAGs | Prefect, Apache Airflow | | Kubernetes-native, reproducible | Kubeflow Pipelines, Argo Workflows | | Managed, minimal infra | Vertex AI Pipelines, SageMaker Pipelines | | Git-driven, code-first | ZenML, Metaflow |
Gate evaluation: define a go/no-go threshold before training starts. A model that does not beat baseline (or the current production model) should never reach the registry.
Set up experiment tracking
Track every training run with: parameters (hyperparams, data version), metrics (loss curves, eval metrics), artifacts (model weights, plots), and environment (library versions, hardware).
MLflow pattern:
import mlflow
mlflow.set_experiment("fraud-detection-v2")
with mlflow.start_run(run_name="xgboost-baseline"):
mlflow.log_params({
"max_depth": 6,
"learning_rate": 0.1,
"n_estimators": 200,
"data_version": "2024-03-01"
})
model = train(X_train, y_train)
mlflow.log_metrics({
"auc_roc": evaluate_auc(model, X_val, y_val),
"precision_at_k": precision_at_k(model, X_val, y_val, k=100)
})
mlflow.sklearn.log_model(
model,
artifact_path="model",
registered_model_name="fraud-detector"
)
Key discipline: log the data version (or dataset hash) as a parameter. Without it, you cannot reproduce the run.
Compare runs on the same held-out test set. Never tune on the test set. Use
validation for selection, test set for final reporting only.
Deploy a model with canary rollout
Choose a serving infrastructure before choosing a rollout strategy:
| Serving option | Best for | Trade-off | |---|---|---| | REST microservice (FastAPI + Docker) | Low latency, flexible | You own the infra | | Managed endpoint (Vertex AI, SageMaker) | Reduced ops burden | Cost, vendor lock-in | | Batch prediction job | High throughput, no latency SLA | Not real-time | | Feature-flag-driven (server-side) | A/B testing with business metrics | Needs experimentation platform |
Canary rollout stages:
v1: 100% traffic
-> v2 shadow: 0% served, 100% shadowed (compare outputs)
-> v2 canary: 5% traffic -> monitor error rate + latency
-> v2 staged: 25% -> 50% -> 100% with automated rollback triggers
Define rollback triggers before deploying: error rate > X%, prediction latency p99 > Y ms, or business metric (e.g., conversion rate) drops > Z%.
Implement model monitoring
Monitor three layers - input data, predictions, and business outcomes:
| Layer | Signal | Method | |---|---|---| | Input data | Feature distribution drift | PSI, KS test, chi-squared | | Predictions | Output distribution drift | PSI on prediction histogram | | Business outcome | Actual vs expected labels | Delayed feedback loop |
Population Stability Index (PSI) thresholds:
PSI < 0.1 -> No significant change, model stable
PSI 0.1-0.2 -> Moderate drift, investi