Skip to content

Add Google Cloud ML Diagnostics metrics collection support - #1374

Open
rapatchi wants to merge 2 commits into
apple:mainfrom
rapatchi:mldiag-metrics
Open

Add Google Cloud ML Diagnostics metrics collection support#1374
rapatchi wants to merge 2 commits into
apple:mainfrom
rapatchi:mldiag-metrics

Conversation

@rapatchi

@rapatchi rapatchi commented Sep 2, 2026

Copy link
Copy Markdown

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.

🥞 Stacked PR

Note

This PR is stacked on top of #1371.
👉 Review ONLY the incremental metrics diff

@rapatchi
rapatchi requested review from a team as code owners September 2, 2026 07:56
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant