|
| 1 | +<!-- |
| 2 | + Copyright 2024 Google LLC |
| 3 | +
|
| 4 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + you may not use this file except in compliance with the License. |
| 6 | + You may obtain a copy of the License at |
| 7 | +
|
| 8 | + https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | + Unless required by applicable law or agreed to in writing, software |
| 11 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + See the License for the specific language governing permissions and |
| 14 | + limitations under the License. |
| 15 | + --> |
| 16 | + |
| 17 | +# Running a workload with ML Diagnostics Enabled |
| 18 | +This guide provides an overview on how to enable ML Diagnostics for your MaxText workload. |
| 19 | + |
| 20 | +## Overview |
| 21 | +Google Cloud ML Diagnostics is an end-to-end managed platform for ML Engineers to optimize and diagnose their AI/ML workloads on Google Cloud. The product allows ML Engineers to collect and visualize all their workload metrics, configs and profiles with one single platform, all within the same UI. This platform works for any ML workload (training, inference, etc) including working with Maxtext/Maxdiffusion as well as any orchestrator on TPU including GKE as well as custom orchestrator. The current product offering focuses on workloads running on XLA-based frameworks (JAX, Pytorch XLA, Tensorflow/Keras) on Google Cloud TPUs and GPUs. Current support is for JAX on Google Cloud TPUs only. |
| 22 | + |
| 23 | +Google Cloud ML Diagnostics includes the following features: |
| 24 | +- SDK: An open source ML Diagnostics [SDK](https://github.com/AI-Hypercomputer/google-cloud-mldiagnostics?tab=readme-ov-file) to use with your ML workload in order to enable managed ML workload diagnostics experience on Google Cloud |
| 25 | +- Integration with JAX and Pytorch framework and libraries (only JAX supported for Preview) |
| 26 | +- Metrics/configs/profiles management: |
| 27 | +Track workload metrics, including model quality, model performance and system metrics. |
| 28 | +Track workload configs including software configs, system configs as well as user-defined configs |
| 29 | +- Manage profile sessions |
| 30 | +Managed XProf: Managed profiling with [XProf](https://openxla.org/xprof), which allows faster loading of large profiles, supports multiple users simultaneously accessing profiles and supports easy to use out-of-the-box features such as multi-host profiling and on-demand profiling. |
| 31 | +- Visualization of metrics/configs/profiles in both Cluster Director and Google Kubernetes Engine on the Google Cloud console |
| 32 | +- Link sharing for ML runs and profiles for easy collaboration |
| 33 | + |
| 34 | +## Enabling ML Diagnostics on Maxtext Workload |
| 35 | +MaxText has integrated the ML Diagnostics SDK in its code. You can enable ML Diagnostics with the **managed-mldiagnostics** flag. If this is enabled, it will |
| 36 | + |
| 37 | +- create a managed MachineLearning run with all the MaxText configs |
| 38 | +- upload profiling traces, if the profiling is enabled by profiler="xplane". |
| 39 | +- upload training metrics, at the defined log_period interval. |
| 40 | + |
| 41 | +### Run Maxtext via XPK |
| 42 | +1. Enable ML Diagnostics to just capture Maxtext metrics and configs |
| 43 | + |
| 44 | + xpk workload create\ |
| 45 | + --cluster ${CLUSTER_NAME}\ |
| 46 | + --workload ${USER}-tpu-job\ |
| 47 | + --base-docker-image maxtext_base_image\ |
| 48 | + --tpu-type v5litepod-256\ |
| 49 | + --num-slices 1\ |
| 50 | + --command "python3 -m MaxText.train src/MaxText/configs/base.yml run_name=${USER}-tpu-job base_output_directory=${BASE_OUTPUT_DIR} dataset_path=${DATASET_PATH} steps=100 log_period=10 managed_mldiagnostics=True" |
| 51 | + |
| 52 | +2. Enable ML Diagnostics to capture Maxtext metrics, configs and singlehost profiles (on the first TPU device) |
| 53 | + |
| 54 | + xpk workload create\ |
| 55 | + --cluster ${CLUSTER_NAME}\ |
| 56 | + --workload ${USER}-tpu-job\ |
| 57 | + --base-docker-image maxtext_base_image\ |
| 58 | + --tpu-type v5litepod-256\ |
| 59 | + --num-slices 1\ |
| 60 | + --command "python3 -m MaxText.train src/MaxText/configs/base.yml run_name=${USER}-tpu-job base_output_directory=${BASE_OUTPUT_DIR} dataset_path=${DATASET_PATH} steps=100 log_period=10 profiler=xplane managed_mldiagnostics=True" |
| 61 | + |
| 62 | +3. Enable ML Diagnostics to capture Maxtext metrics, configs and multihost profiles (on all TPU devices) |
| 63 | + |
| 64 | + xpk workload create\ |
| 65 | + --cluster ${CLUSTER_NAME}\ |
| 66 | + --workload ${USER}-tpu-job\ |
| 67 | + --base-docker-image maxtext_base_image\ |
| 68 | + --tpu-type v5litepod-256\ |
| 69 | + --num-slices 1\ |
| 70 | + --command "python3 -m MaxText.train src/MaxText/configs/base.yml run_name=${USER}-tpu-job base_output_directory=${BASE_OUTPUT_DIR} dataset_path=${DATASET_PATH} steps=100 log_period=10 profiler=xplane upload_all_profiler_results=True managed_mldiagnostics=True" |
| 71 | +### Run Maxtext via Pathways |
| 72 | +1. Enable ML Diagnostics to just capture Maxtext metrics and configs |
| 73 | + |
| 74 | + xpk workload create-pathways\ |
| 75 | + --cluster ${CLUSTER_NAME}\ |
| 76 | + --workload ${USER}-tpu-job\ |
| 77 | + --base-docker-image maxtext_base_image\ |
| 78 | + --tpu-type v5litepod-256\ |
| 79 | + --num-slices 1\ |
| 80 | + --command "python3 -m MaxText.train src/MaxText/configs/base.yml run_name=${USER}-tpu-job base_output_directory=${BASE_OUTPUT_DIR} dataset_path=${DATASET_PATH} steps=100 enable_single_controller=True log_period=10 managed_mldiagnostics=True" |
| 81 | + |
| 82 | +2. Enable ML Diagnostics to capture Maxtext metrics, configs and singlehost profiles (on the first TPU device) |
| 83 | + |
| 84 | + xpk workload create-pathways\ |
| 85 | + --cluster ${CLUSTER_NAME}\ |
| 86 | + --workload ${USER}-tpu-job\ |
| 87 | + --base-docker-image maxtext_base_image\ |
| 88 | + --tpu-type v5litepod-256\ |
| 89 | + --num-slices 1\ |
| 90 | + --command "python3 -m MaxText.train src/MaxText/configs/base.yml run_name=${USER}-tpu-job base_output_directory=${BASE_OUTPUT_DIR} dataset_path=${DATASET_PATH} steps=100 enable_single_controller=True log_period=10 profiler=xplane managed_mldiagnostics=True" |
| 91 | + |
| 92 | +3. Enable ML Diagnostics to capture Maxtext metrics, configs and multihost profiles (on all TPU devices) |
| 93 | + |
| 94 | + xpk workload create-pathways\ |
| 95 | + --cluster ${CLUSTER_NAME}\ |
| 96 | + --workload ${USER}-tpu-job\ |
| 97 | + --base-docker-image maxtext_base_image\ |
| 98 | + --tpu-type v5litepod-256\ |
| 99 | + --num-slices 1\ |
| 100 | + --command "python3 -m MaxText.train src/MaxText/configs/base.yml run_name=${USER}-tpu-job base_output_directory=${BASE_OUTPUT_DIR} dataset_path=${DATASET_PATH} steps=100 enable_single_controller=True log_period=10 profiler=xplane upload_all_profiler_results=True managed_mldiagnostics=True" |
0 commit comments