Machine Learning Enabled Systems (MLS) operate in dynamic environments where changes in data, workload, or execution context can degrade performance, increase cost, and negatively impact sustainability. While MLOps supports automation across the ML lifecycle, it provides limited support for runtime adaptation driven by sustainability goals.
This paper presents Harmonica, a self-adaptation exemplar for sustainable MLOps pipelines. Built on the HarmonE approach, Harmonica integrates a configurable MAPE-K loop that separates adaptation intent from execution tactics. It continuously monitors sustainability metrics, evaluates them against adaptation boundaries, and automatically triggers architectural adaptations such as model switching or retraining.
We demonstrate Harmonica through time series regression and computer vision case studies, showing how it enables controlled experimentation with sustainability-aware adaptation strategies while improving system stability and reducing manual intervention.
Demo video showing how to set up, configure, and run the Harmonica exemplar, including live self-adaptation in time series and computer vision pipelines.
Harmonica is designed as a self-adaptive wrapper around existing machine learning pipelines. Instead of changing how models are trained or deployed, Harmonica observes the system while it runs and intervenes only when necessary.
The architecture is divided into three clearly separated parts:
At the core of Harmonica lies a MAPE-K feedback loop (Monitor, Analyze, Plan, Execute over Knowledge). This loop enables the system to:
By keeping adaptation logic separate from the ML pipeline itself, Harmonica allows researchers and practitioners to experiment with sustainability-aware strategies without rewriting existing systems.
The redesigned Harmonica frontend provides a persistent sidebar and dedicated views for observing the live managed system, inspecting available models, configuring adaptation policies, and reviewing the adaptation history.
Harmonica integrates with MLflow to make retraining,
model versioning, and runtime adaptation telemetry observable across
the ML lifecycle. Tracking is configured at startup, with the MLflow
UI served locally at http://localhost:5001.
Retraining is launched as an actual MLflow Project for the regression or computer-vision system. The MAPE-K loop can trigger retraining automatically when adaptation conditions are violated, while CLI execution remains available for debugging.
Each retrain records model-specific hyperparameters and held-out
evaluation metrics. A managed-system session also opens an
harmone-adaptations MLflow run and streams continuous
telemetry such as score, energy, drift, model usage, switches,
and retraining events.
Retrained LSTM, SVM, and Ridge models, as well as computer-vision models, are registered in MLflow. The Harmonica Models view exposes registry versions alongside the disk-based Versioned Model Repository.
The frontend provides persistent MLflow access and resolves the current session, experiment, active model, registered model, and active alias version so users can move directly from Harmonica into the corresponding MLflow records.
Harmonica is intended as an exemplar: a reference system that helps researchers and practitioners study self-adaptation in real-world MLOps pipelines. To demonstrate its flexibility, we evaluate Harmonica across two different application domains.
In this scenario, Harmonica is applied to a traffic flow prediction pipeline. The system continuously predicts future traffic volume using machine learning models with different accuracy and energy profiles.
As data characteristics change over time (for example, due to seasonal effects or sudden traffic disruptions), Harmonica detects performance degradation and automatically adapts by switching models or triggering retraining. This allows the system to balance prediction accuracy against energy consumption without manual intervention.
The second use case focuses on object detection in driving scenarios. Multiple vision models with different computational costs are available, ranging from lightweight models to more accurate but energy-intensive ones.
Harmonica monitors runtime behavior and selects suitable models based on the current sustainability goals. This demonstrates how the same adaptation mechanisms can be reused across domains, even when the underlying ML tasks are fundamentally different.
Together, these use cases show how Harmonica supports experimentation with sustainability-aware adaptation strategies across the ML lifecycle, rather than being tied to a single application or model type.