Skip to content

Add Google Cloud ML Diagnostics integration for profiling and metrics#1371

Open
rapatchi wants to merge 1 commit into
apple:mainfrom
rapatchi:mldiag-integration
Open

Add Google Cloud ML Diagnostics integration for profiling and metrics#1371
rapatchi wants to merge 1 commit into
apple:mainfrom
rapatchi:mldiag-integration

Conversation

@rapatchi

@rapatchi rapatchi commented Jul 7, 2026

Copy link
Copy Markdown

Introduce integration with google_cloud_mldiagnostics to support automated profiler (xprof) tracing and metric collection on Google Cloud Platform.

  • Add ManagedMLDiagnostics (axlearn/common/managed_mldiagnostics.py), a thread-safe singleton wrapper that maps common AXLearn metrics (such as loss, learning rate, and step time) to their corresponding GCP ML Diagnostics MetricTypes and uploads them.
  • Add MLDiagnosticsMetricsWriter to axlearn/common/summary_writer.py which writes scalar metrics to the diagnostics singleton.
  • Add --enable_ml_diagnostics, --ml_diagnostics_run_name, and --ml_diagnostics_region flags to launch_trainer.py.
  • In launch_trainer.py, automatically inject MLDiagnosticsMetricsWriter into the trainer and evalers' summary writers if ML Diagnostics is enabled. If the configured writer is not a composite, wrap it in a CompositeWriter alongside the new writer.
  • Update SpmdTrainer and SpmdEvaler to route profiler tracing through the ML Diagnostics xprof module when enabled, instead of direct jax.profiler calls.
  • Pass the trainer's ml_diagnostics configuration to all evalers to enable profiler tracing on them.
  • Add unit tests in managed_mldiagnostics_test.py, summary_writer_test.py, trainer_test.py, evaler_test.py and launch_trainer_test.py to cover initialization, metric mapping, writer injection, and xprof tracing logic.

@rapatchi
rapatchi requested a review from a team as a code owner July 7, 2026 14:17
@rapatchi
rapatchi force-pushed the mldiag-integration branch 5 times, most recently from 1376906 to 551d10d Compare July 10, 2026 08:28
@rapatchi
rapatchi requested a review from a team as a code owner July 10, 2026 08:28
Introduce integration with `google_cloud_mldiagnostics` to support automated
profiler (xprof) tracing and metric collection on Google Cloud Platform.

* Add `ManagedMLDiagnostics` (`axlearn/common/managed_mldiagnostics.py`), a
  thread-safe singleton wrapper that maps common AXLearn metrics (such as loss,
  MFU, learning rate, and step time) to their corresponding GCP ML Diagnostics
  MetricTypes and uploads them. The run name is automatically resolved from
  the `AXLEARN_JOB_NAME` environment variable.
* Configure GKE launcher (`axlearn/cloud/gcp/tpu.py`, `axlearn/cloud/gcp/jobset_utils.py`)
  to inject `AXLEARN_JOB_NAME` (containing GKE job name) into containers.
* Add `MLDiagnosticsMetricsWriter` to `axlearn/common/summary_writer.py`
  which writes scalar metrics to the diagnostics singleton.
* Add `--enable_ml_diagnostics_xprof`, `--enable_ml_diagnostics_metrics`, and
  `--ml_diagnostics_region` flags to `launch_trainer.py`.
* In `launch_trainer.py`, automatically inject `MLDiagnosticsMetricsWriter`
  into the trainer and evalers' summary writers if ML Diagnostics metrics are enabled.
  If the configured writer is not a composite, wrap it in a `CompositeWriter`
  alongside the new writer.
* Update `SpmdTrainer` and `SpmdEvaler` to route profiler tracing through
  the ML Diagnostics `xprof` module when xprof is enabled, instead of direct
  `jax.profiler` calls.
* Pass the trainer's `ml_diagnostics` configuration to all evalers to enable
  profiler tracing and/or metrics on them.
* Add unit tests in `managed_mldiagnostics_test.py`, `summary_writer_test.py`,
  `trainer_test.py`, `evaler_test.py` and `launch_trainer_test.py` to cover
  initialization, metric mapping, writer injection, and xprof tracing logic.
@rapatchi
rapatchi force-pushed the mldiag-integration branch from 551d10d to c282ef8 Compare July 15, 2026 04:57
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