MLops
Darshika Srivastava
Associate Project Manager @ HuQuo | MBA,Amity Business School
MLOps Principles
As machine learning and AI propagate in software products and services, we need to establish best practices and tools to test, deploy, manage, and monitor ML models in real-world production. In short, with MLOps we strive to avoid “technical debt” in machine learning applications.
SIG MLOps defines “an optimal MLOps experience [as] one where Machine Learning assets are treated consistently with all other software assets within a CI/CD environment. Machine Learning models can be deployed alongside the services that wrap them and the services that consume them as part of a unified release process.” By codifying these practices, we hope to accelerate the adoption of ML/AI in software systems and fast delivery of intelligent software. In the following, we describe a set of important concepts in MLOps such as Iterative-Incremental Development, Automation, Continuous Deployment, Versioning, Testing, Reproducibility, and Monitoring.
Iterative-Incremental Process in MLOps
The complete MLOps process includes three broad phases of “Designing the ML-powered application”, “ML Experimentation and Development”, and “ML Operations”.
The first phase is devoted to business understanding, data understanding and designing the ML-powered software. In this stage, we identify our potential user, design the machine learning solution to solve its problem, and assess the further development of the project. Mostly, we would act within two categories of problems - either increasing the productivity of the user or increasing the interactivity of our application.
Initially, we define ML use-cases and prioritize them. The best practice for ML projects is to work on one ML use case at a time. Furthermore, the design phase aims to inspect the available data that will be needed to train our model and to specify the functional and non-functional requirements of our ML model. We should use these requirements to design the architecture of the ML-application, establish the serving strategy, and create a test suite for the future ML model.
The follow-up phase “ML Experimentation and Development” is devoted to verifying the applicability of ML for our problem by implementing Proof-of-Concept for ML Model. Here, we run iteratively different steps, such as identifying or polishing the suitable ML algorithm for our problem, data engineering, and model engineering. The primary goal in this phase is to deliver a stable quality ML model that we will run in production.
The main focus of the “ML Operations” phase is to deliver the previously developed ML model in production by using established DevOps practices such as testing, versioning, continuous delivery, and monitoring.
All three phases are interconnected and influence each other. For example, the design decision during the design stage will propagate into the experimentation phase and finally influence the deployment options during the final operations phase.
Automation
The level of automation of the Data, ML Model, and Code pipelines determines the maturity of the ML process. With increased maturity, the velocity for the training of new models is also increased. The objective of an MLOps team is to automate the deployment of ML models into the core software system or as a service component. This means, to automate the complete ML-workflow steps without any manual intervention. Triggers for automated model training and deployment can be calendar events, messaging, monitoring events, as well as changes on data, model training code, and application code.
Automated testing helps discovering problems quickly and in early stages. This enables fast fixing of errors and learning from mistakes.
To adopt MLOps, we see three levels of automation, starting from the initial level with manual model training and deployment, up to running both ML and CI/CD pipelines automatically.
The following picture shows the automated ML pipeline with CI/CD routines:
The MLOps stages that reflect the process of ML pipeline automation are explained in the following table:
MLOps StageOutput of the Stage ExecutionDevelopment & Experimentation (ML algorithms, new ML models)Source code for pipelines: Data extraction, validation, preparation, model training, model evaluation, model testingPipeline Continuous Integration (Build source code and run tests)Pipeline components to be deployed: packages and executables.Pipeline Continuous Delivery (Deploy pipelines to the target environment)Deployed pipeline with new implementation of the model.Automated Triggering (Pipeline is automatically executed in production. Schedule or trigger are used)Trained model that is stored in the model registry.Model Continuous Delivery (Model serving for prediction)Deployed model prediction service (e.g. model exposed as REST API)Monitoring (Collecting data about the model performance on live data)Trigger to execute the pipeline or to start a new experiment cycle.
After analyzing the MLOps Stages, we might notice that the MLOps setup requires several components to be installed or prepared. The following table lists those components:
MLOps Setup ComponentsDescriptionSource ControlVersioning the Code, Data, and ML Model artifacts.Test & Build ServicesUsing CI tools for (1) Quality assurance??for all ML artifacts, and (2) Building packages and executables for pipelines.Deployment ServicesUsing CD tools for deploying pipelines to the target environment.Model RegistryA registry for storing already trained ML models.Feature StorePreprocessing input data as features to be consumed in the model training pipeline and during the model serving.ML Metadata StoreTracking metadata of model training, for example model name, parameters, training data, test data, and metric results.ML Pipeline OrchestratorAutomating the steps of the ML experiments.
领英推荐
Continuous X
To understand Model deployment, we first specify the “ML assets” as ML model, its parameters and hyperparameters, training scripts, training and testing data. We are interested in the identity, components, versioning, and dependencies of these ML artifacts. The target destination for an ML artifact may be a (micro-) service or some infrastructure components. A deployment service provides orchestration, logging, monitoring, and notification to ensure that the ML models, code and data artifacts are stable.
MLOps is an ML engineering culture that includes the following practices:
Versioning
The goal of the versioning is to treat ML training scrips, ML models and data sets for model training as first-class citizens in DevOps processes by tracking ML models and data sets with version control systems. The common reasons when ML model and data changes (according to SIG MLOps ) are the following:
Analogously to the best practices for developing reliable software systems, every ML model specification (ML training code that creates an ML model) should go through a code review phase. Furthermore, every ML model specification should be versioned in a VCS to make the training of ML models auditable and reproducible.
Further reading: How do we manage ML models? Model Management Frameworks
Experiments Tracking
Machine Learning development is a highly iterative and research-centric process. In contrast to the traditional software development process, in ML development, multiple experiments on model training can be executed in parallel before making the decision what model will be promoted to production.
The experimentation during ML development might have the following scenario: One way to track multiple experiments is to use different (Git-) branches, each dedicated to the separate experiment. The output of each branch is a trained model. Depending on the selected metric, the trained ML models are compared with each other and the appropriate model is selected. Such low friction branching is fully supported by the tool DVC , which is an extension of Git and an open-source version control system for machine learning projects. Another popular tool for ML experiments tracking is the Weights and Biases (wandb) library, which automatically tracks the hyperparameters and metrics of the experiments.
Testing
The complete development pipeline includes three essential components, data pipeline, ML model pipeline, and application pipeline. In accordance with this separation we distinguish three scopes for testing in ML systems: tests for features and data, tests for model development, and tests for ML infrastructure.
Features and Data Tests
Tests for Reliable Model Development
We need to provide specific testing support for detecting ML-specific errors.
ML infrastructure test