Conversation
This commit introduces support for automated profiling and performance tracking using Google Cloud ML Diagnostics. It enables on-demand xprof and integrates the diagnostics package into both the generation and training scripts. Changes: - Added `docs/profiling.md` to guide users on enabling ML diagnostics. - Added default ML Diagnostics config settings to base config files. - Created `Profiler` class in `max_utils.py` to abstract JAX profiling and ML Diagnostics. - Replaced `activate_profiler` / `deactivate_profiler` in trainers with the unified `Profiler` class. - Added `ensure_machinelearning_job_runs` initialization to execution scripts.
entrpn
approved these changes
Apr 16, 2026
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.
Description
This PR integrates Google Cloud ML Diagnostics and XProf profiling into MaxDiffusion. It provides users the ability to automatically profile and track performance metrics of their training and generation runs via the Cluster Director console. The ML Diagnostics package is kept as an optional dependency so it doesn't bloat the environment for users who don't need it.
Note: This PR only cover the profiling. Another PR will be sent to handle metrics.
Changes
docs/profiling.mdwhich explains manual installation, configuration, and troubleshooting for ML Diagnostics.enable_ml_diagnostics,profiler_gcs_path, andenable_ondemand_xprofflags to all base configuration files (base*.yml,ltx*.yml, etc.).max_utils.py):Profilerclass (usable both as an object and a context manager) to abstract away the standard JAX profiler and the new ML Diagnosticsxprofprofiler.ensure_machinelearning_job_runsto initialize the diagnostics job securely, safely bypassing execution if the optionalgoogle-cloud-mldiagnosticslibrary is missing.BaseWanTrainer,DreamboothTrainer,FluxTrainer,StableDiffusionXLTrainer, andStableDiffusionTrainerto use the unifiedProfilerclass.Testing