MLOps Implementation Patterns
Guide for implementing MLOps features that integrate with OptAIC's resource-based architecture.
When to Use
Apply when:
- Creating ML Model Definitions (MLModuleDef) with 5 code components
- Implementing Model Instances in MLOps Center
- Building training, inference, or monitoring pipelines
- Integrating with model registry (MLflow or internal)
- Implementing model categories (signal, regime, relevance, combining)
MLOps Three-Tier Model
MLModuleDef (Definition) ModelInstance (Config) Execution (Runs)
──────────────────────── ────────────────────── ─────────────────
XGBSignalModelDef → SPX_Alpha_Model → TrainingRun
(5 code components) (datasets + config) InferenceRun
MonitoringRun
↓
ModelVersion
ML Model Categories
| Category |
Purpose |
Typical Outputs |
| Signal Model |
Generate alpha signals |
Signal dataset [-1, 1] |
| Macro Regime Model |
Classify market regimes |
Regime labels/probabilities |
| Relevance Model |
Score feature importance |
Relevance scores |
| Signal Combining Model |
Combine multiple signals |
Combined signal |
| Signal Filtering Model |
Filter/rank signals |
Filtered signal set |
Implementation Workflow
1. Create MLModuleDef (5 Components)
MLModelDef/
├── model/ # Model architecture + hyperparameter schema
├── training/ # Trainer + evaluator
├── inference/ # Predictor + batch inference
├── monitoring/ # Data drift + performance monitoring
├── tests/ # Test suite for all components
└── docs/ # Documentation
See references/mlmodule-structure.md.
2. Create Model Instance
Compose MLModuleDef + datasets + config. See references/model-instance.md.
3. Implement Pipelines
- TrainingPipeline → reads datasets, produces ModelVersion
- InferencePipeline → reads features + model, writes predictions
- MonitoringPipeline → reads data/preds, emits metrics/alerts
See references/mlops-pipelines.md.
4. Integrate with Registry
See references/model-registry.md.
5. Create UI Components (MLOps Center)
Two views required:
- Model Instance View - registered models with configs
- Execution View - training, registry, inference, monitoring
See references/mlops-center-ui.md.
Critical Rules
- 5-component structure - MLModuleDef must have model, training, inference, monitoring, tests
- Activity emission - All runs emit activities (training, inference, monitoring)
- Lineage tracking - Link dataset versions → model version → prediction dataset
- Guardrails - Validate model outputs (e.g., signal bounds)
- PIT correctness - No lookahead in training or inference
Tech Stack
| Tool |
Purpose |
Mode |
| MLflow |
Experiment tracking, model registry |
Optional (--with-mlflow) |
| Evidently |
Data drift, performance monitoring, test suites |
Always available |
| WhyLogs |
Lightweight data profiling |
Optional |
| Prefect |
Workflow orchestration |
Optional (--with-prefect) |
Unified ML SDK (optaic.mlops)
All MLOps infrastructure is wrapped in a unified SDK for seamless development:
from optaic.mlops import tracking, registry, monitoring, pipeline
from optaic.mlops.base import BaseModel, BaseTrainer
from optaic.mlops.data import load_dataset
Key modules:
tracking - Experiment logging (wraps MLflow)
registry - Model versioning (wraps MLflow Model Registry)
monitoring - Drift & performance (wraps Evidently)
pipeline - Orchestration (wraps Prefect)
data - PIT-aware dataset access
base - Base classes for model definitions
See references/unified-sdk.md and Blueprint section 8.9.
Reference Files
- Unified SDK -
optaic.mlops SDK patterns
- MLModuleDef Structure - 5-component package
- Model Instance - Configuration patterns
- MLOps Pipelines - Training/inference/monitoring
- Model Registry - Version management
- MLOps Center UI - Two-view architecture
- MLflow + Evidently Integration - Experiment tracking & monitoring
1---2name: mlops-patterns3description: Follow these patterns when implementing MLOps features in OptAIC. Use for ML model definitions (5-component structure), model instances, training/inference pipelines, model registry, and monitoring. Covers signal models, macro regime models, relevance models, and signal combining/filtering models.4---5
6# MLOps Implementation Patterns
7
8Guide for implementing MLOps features that integrate with OptAIC's resource-based architecture.
9
10## When to Use
11
12Apply when:
13- Creating ML Model Definitions (MLModuleDef) with 5 code components
14- Implementing Model Instances in MLOps Center
15- Building training, inference, or monitoring pipelines
16- Integrating with model registry (MLflow or internal)
17- Implementing model categories (signal, regime, relevance, combining)
18
19## MLOps Three-Tier Model
20
21```
22MLModuleDef (Definition) ModelInstance (Config) Execution (Runs)
23──────────────────────── ────────────────────── ─────────────────
24XGBSignalModelDef → SPX_Alpha_Model → TrainingRun
25 (5 code components) (datasets + config) InferenceRun
26 MonitoringRun
27 ↓
28 ModelVersion
29```
30
31## ML Model Categories
32
33| Category | Purpose | Typical Outputs |
34|----------|---------|-----------------|
35| **Signal Model** | Generate alpha signals | Signal dataset [-1, 1] |
36| **Macro Regime Model** | Classify market regimes | Regime labels/probabilities |
37| **Relevance Model** | Score feature importance | Relevance scores |
38| **Signal Combining Model** | Combine multiple signals | Combined signal |
39| **Signal Filtering Model** | Filter/rank signals | Filtered signal set |
40
41## Implementation Workflow
42
43### 1. Create MLModuleDef (5 Components)
44
45```
46MLModelDef/
47├── model/ # Model architecture + hyperparameter schema
48├── training/ # Trainer + evaluator
49├── inference/ # Predictor + batch inference
50├── monitoring/ # Data drift + performance monitoring
51├── tests/ # Test suite for all components
52└── docs/ # Documentation
53```
54
55See [references/mlmodule-structure.md](references/mlmodule-structure.md).
56
57### 2. Create Model Instance
58
59Compose MLModuleDef + datasets + config. See [references/model-instance.md](references/model-instance.md).
60
61### 3. Implement Pipelines
62
63- **TrainingPipeline** → reads datasets, produces ModelVersion
64- **InferencePipeline** → reads features + model, writes predictions
65- **MonitoringPipeline** → reads data/preds, emits metrics/alerts
66
67See [references/mlops-pipelines.md](references/mlops-pipelines.md).
68
69### 4. Integrate with Registry
70
71See [references/model-registry.md](references/model-registry.md).
72
73### 5. Create UI Components (MLOps Center)
74
75Two views required:
76- **Model Instance View** - registered models with configs
77- **Execution View** - training, registry, inference, monitoring
78
79See [references/mlops-center-ui.md](references/mlops-center-ui.md).
80
81## Critical Rules
82
831. **5-component structure** - MLModuleDef must have model, training, inference, monitoring, tests
842. **Activity emission** - All runs emit activities (training, inference, monitoring)
853. **Lineage tracking** - Link dataset versions → model version → prediction dataset
864. **Guardrails** - Validate model outputs (e.g., signal bounds)
875. **PIT correctness** - No lookahead in training or inference
88
89## Tech Stack
90
91| Tool | Purpose | Mode |
92|------|---------|------|
93| **MLflow** | Experiment tracking, model registry | Optional (`--with-mlflow`) |
94| **Evidently** | Data drift, performance monitoring, test suites | Always available |
95| **WhyLogs** | Lightweight data profiling | Optional |
96| **Prefect** | Workflow orchestration | Optional (`--with-prefect`) |
97
98## Unified ML SDK (`optaic.mlops`)
99
100All MLOps infrastructure is wrapped in a unified SDK for seamless development:
101
102```python
103from optaic.mlops import tracking, registry, monitoring, pipeline
104from optaic.mlops.base import BaseModel, BaseTrainer
105from optaic.mlops.data import load_dataset
106```
107
108**Key modules:**
109- `tracking` - Experiment logging (wraps MLflow)
110- `registry` - Model versioning (wraps MLflow Model Registry)
111- `monitoring` - Drift & performance (wraps Evidently)
112- `pipeline` - Orchestration (wraps Prefect)
113- `data` - PIT-aware dataset access
114- `base` - Base classes for model definitions
115
116See [references/unified-sdk.md](references/unified-sdk.md) and Blueprint section 8.9.
117
118## Reference Files
119
120- [Unified SDK](references/unified-sdk.md) - `optaic.mlops` SDK patterns
121- [MLModuleDef Structure](references/mlmodule-structure.md) - 5-component package
122- [Model Instance](references/model-instance.md) - Configuration patterns
123- [MLOps Pipelines](references/mlops-pipelines.md) - Training/inference/monitoring
124- [Model Registry](references/model-registry.md) - Version management
125- [MLOps Center UI](references/mlops-center-ui.md) - Two-view architecture
126- [MLflow + Evidently Integration](references/mlflow-evidently-integration.md) - Experiment tracking & monitoring