Harmonica

A Self-Adaptation Exemplar for Sustainable MLOps

Ananya Halgatti, Shaunak Biswas, Hiya Bhatt, Srinivasan Rakhunathan, Karthik Vaidhyanathan
SERC, IIIT Hyderabad  

Abstract

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: Setup and Execution

Demo video showing how to set up, configure, and run the Harmonica exemplar, including live self-adaptation in time series and computer vision pipelines.

Architecture Design

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:

  • Managed System – the actual machine learning pipeline (training, inference, data preprocessing) that performs the task.
  • Managing System – a control layer that continuously monitors the system, reasons about sustainability goals, and decides when adaptation is required.
  • Frontend – a lightweight user interface that allows users to configure goals and observe system behavior in real time.

At the core of Harmonica lies a MAPE-K feedback loop (Monitor, Analyze, Plan, Execute over Knowledge). This loop enables the system to:

  • Monitor metrics such as accuracy, energy usage, and runtime cost
  • Detect when the system moves outside acceptable boundaries
  • Select an appropriate adaptation strategy (e.g., model switching or retraining)
  • Apply the adaptation without stopping the pipeline

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.

Harmonica Architecture
High-level architecture of Harmonica showing the Managed System, Managing System, and the MAPE-K feedback loop.

Live Dashboard

Harmonica Dashboard
Real-time visualization of sustainability metrics, thresholds, and adaptation events.

Use Cases

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.

Use Case 1: Time Series Regression

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.

Use Case 2: Computer Vision

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.