This article is contributed. See the original author and article here.
At Microsoft Build 2021 we launched the public preview of 2.0 CLI and REST APIs for Azure Machine Learning, enabling users to accelerate the iterative model training and deployment process while tracking the model lifecycle, enabling a complete MLOps experience.
Azure Machine Learning (Azure ML) has evolved organically over the past few years. With our 2.0 CLI and ARM REST APIs, we offer a streamlined experience for model training and deployment optimized for ISVs and ML professionals.
Announcing the 2.0 CLI, backed by durable ARM APIs
The ml extension to the Azure CLI is the improved interface for Azure Machine Learning users. It enables you to train and deploy models from the command line, with features that accelerate scaling the data science process up and out, all while tracking the model lifecycle.
Using the CLI enables you to run distributed training jobs on GPU compute, automatically sweep hyperparameters to improve your results, and then monitor jobs in the AML studio user interface to see all details including important metrics, metadata and artifacts like the trained model, checkpoints and logs.
Additionally, the CLI is optimized to support YAML-based job, endpoint, and asset specifications to enable users to create, manage, and deploy models with proper CI/CD (or GitOps) best practices for an end-to-end MLOps solution.
To get started with the 2.0 machine learning CLI extension for Azure, please check the link here .
A job in Azure ML enables you to prepare and train machine learning models. It enables you to configure:
- What to run: your code
- How to run it: either an optimized prebuilt docker container from AML or one of your choice from your own docker registry
- Where to run it: either fully managed, scalable compute in Azure, locally on your desktop or (via Azure Arc if we want to call this out)
Train a machine learning model by creating a training job
Here is an example training job which invokes the user’s python script from a local directory and automatically mounts data in Azure Storage.
Easy to optimize the model training process with Sweep Jobs
Azure Machine Learning enables you to tune the hyperparameters more efficiently for your machine learning models. You can configure a hyperparameter tuning job, called a sweep job, and submit it via the CLI. For more information on Azure Machine Learning’s hyperparameter tuning offering, see the Hyperparameters tuning a model.
You can modify the job.yml into job-sweep.yml to sweep over hyperparameters:
VS Code support for job authoring and resource creation
The Azure Machine Learning extension for VS Code has been revamped for 2.0 CLI compatibility, with added features such as completions and diagnostics for your YAML-based specification files. You can continue to manage resources directly from within the editor and create new ones with starting templates. Within the template files, you can use the extension language support to fetch completions, previews, and diagnostics for machine learning resources in your workspace.
Once you are finished authoring the specification file, you can submit via the CLI from directly within VS Code (tip: right-click in the file itself to view the ‘Azure ML: Create Resource’ command). The extension will streamline invoking the right CLI commands on your behalf. To get started with the extension for creating, authoring, and submitting 2.0 CLI specification files, please follow this documentation.
OSS-based examples for training and deployment
Azure ML is announcing a new set of YAML-based examples for training and deploying models using popular open-source libraries like PyTorch, LightGBM, FastAI, R, and TensorFlow. All examples leverage open-source logging via the MLFlow library and do not require Azure-specific code inside of the user training script.
Examples are tested and validated using GitHub Actions against the latest Azure ML release. Official documentation on docs.microsoft.com leverages these tested snippets to ensure a smooth, working experience for users to get started.
You can find the new examples here: azureml-examples/cli at main · Azure/azureml-examples (github.com) .
ARM REST APIs, templates, and examples
With full ARM support for model training jobs and endpoint creation, ISVs can use Azure ML to create and manage machine learning resources as first-class Azure entities.
Examples using ARM REST APIs
- Train a model using ARM REST APIs: Train models with REST (preview) – Azure Machine Learning | Microsoft Docs
- Deploy a model using ARM REST APIs: azureml-examples/how-to-deploy-rest.sh at main · Azure/azureml-examples (github.com)
- ARM template to create a workspace and train a model: azureml-examples/readme.md at arm-deploy-example · Azure/azureml-examples (github.com)
Additional documentation on REST APIs is available here:
- Azure Machine Learning REST APIs | Microsoft Docs
- Jobs – Create Or Update – REST API (Azure Machine Learning) | Microsoft Docs
- Batch Endpoints – Create Or Update – REST API (Azure Machine Learning) | Microsoft Docs
- Online Endpoints – Create Or Update – REST API (Azure Machine Learning) | Microsoft Docs
In summary, the new Azure ML REST APIs and helps ML teams focus more on the business problem than the underlying infrastructure. It provides a simple developer interface to train, deploy and score models and help in the operational aspects of the end-to-end MLOps lifecycle.
Please try our new examples and templates and share your feedback with us. You can use az feedback directly from the new CLI :)
Brought to you by Dr. Ware, Microsoft Office 365 Silver Partner, Charleston SC.