Add Google Cloud ML Diagnostics metrics collection support - #1374
Open
rapatchi wants to merge 2 commits into
Open
Add Google Cloud ML Diagnostics metrics collection support#1374rapatchi wants to merge 2 commits into
rapatchi wants to merge 2 commits into
Conversation
Introduce integration with `google_cloud_mldiagnostics` to support automated profiler (xprof) tracing on Google Cloud Platform. * Add `ManagedMLDiagnostics` singleton (`axlearn/common/managed_mldiagnostics.py`) to initialize a Google Cloud ML Diagnostics deferred run using `AXLEARN_JOB_NAME` and manage starting/stopping xprof tracing sessions. * Configure GKE launcher and TPU environment (`axlearn/cloud/gcp/tpu.py`, `axlearn/cloud/gcp/jobset_utils.py`) to inject `AXLEARN_JOB_NAME` into container environments and label pods with `managed-mldiagnostics-gke: true` when enabled. * Add `--enable_ml_diagnostics_xprof` and `--ml_diagnostics_region` flags to `axlearn/common/launch_trainer.py`. * Route profiler tracing in `SpmdTrainer` and `SpmdEvaler` through `ManagedMLDiagnostics` when `enable_ml_diagnostics_xprof` is active. * Add `axlearn/cloud/gcp/scripts/get_mldiag_urls.sh` helper script to extract profiler session TensorBoard URLs and Cloud Console URLs as JSON. * Add unit test coverage in `managed_mldiagnostics_test.py`, `trainer_test.py`, `evaler_test.py`, `launch_trainer_test.py`, and `jobset_utils_test.py`. TAG=agy CONV=2c9c481e-b3c4-463b-9064-6d33e10bb9cf
Add support for recording and uploading training and evaluation metrics to Google Cloud ML Diagnostics. * Extend `ManagedMLDiagnostics` with a mapping dictionary `_METRIC_TO_METRIC_TYPE_NAME` and a `record_metric()` method to route AXLearn metrics (such as loss, learning rate, gradient norm, and step time) to GCP ML Diagnostics MetricTypes. * Add `MLDiagnosticsMetricsWriter` to `axlearn/common/summary_writer.py` and `inject_mldiagnostics_writer()` helper to automatically wrap existing summary writers into a `CompositeWriter`. * Inject `MLDiagnosticsMetricsWriter` into `SpmdTrainer` and `SpmdEvaler` when metrics recording is enabled. * Add `--enable_ml_diagnostics_metrics` flag to `axlearn/common/launch_trainer.py`. * Update GKE job launcher to recognize `enable_ml_diagnostics_metrics=True` when applying the `managed-mldiagnostics-gke` label. * Add unit test coverage in `managed_mldiagnostics_test.py`, `summary_writer_test.py`, `trainer_test.py`, `launch_trainer_test.py`, and `jobset_utils_test.py`. TAG=agy CONV=2c9c481e-b3c4-463b-9064-6d33e10bb9cf
rapatchi
force-pushed
the
mldiag-metrics
branch
from
September 2, 2026 08:28
c4a2cbc to
4a7bd30
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for recording and uploading training and evaluation metrics to
Google Cloud ML Diagnostics.
ManagedMLDiagnosticswith a mapping dictionary_METRIC_TO_METRIC_TYPE_NAMEand a
record_metric()method to route AXLearn metrics (such as loss, learning rate,gradient norm, and step time) to GCP ML Diagnostics MetricTypes.
MLDiagnosticsMetricsWritertoaxlearn/common/summary_writer.pyandinject_mldiagnostics_writer()helper to automatically wrap existing summary writersinto a
CompositeWriter.MLDiagnosticsMetricsWriterintoSpmdTrainerandSpmdEvalerwhenmetrics recording is enabled.
--enable_ml_diagnostics_metricsflag toaxlearn/common/launch_trainer.py.enable_ml_diagnostics_metrics=Truewhenapplying the
managed-mldiagnostics-gkelabel.managed_mldiagnostics_test.py,summary_writer_test.py,trainer_test.py,launch_trainer_test.py, andjobset_utils_test.py.🥞 Stacked PR
Note
This PR is stacked on top of #1371.
👉 Review ONLY the incremental metrics diff