Repository navigation
Wire MaxText RL profiling and metrics onto tunix's targeted RL profiler and ML Diagnostics. - #5438
Open
copybara-service[bot] wants to merge 1 commit into
Open
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
copybara-service
Bot
requested review from
A9isha,
NuojCheng,
RissyRan,
SurbhiJainUSC,
abhinavclemson,
aireenmei,
bvandermoon,
darisoy,
dipannita08,
gagika,
gobbleturk,
hengtaoguo,
huytransformer,
igorts-git,
jiangjy1982,
khatwanimohit,
richjames0,
shralex,
shuningjin,
vipannalla and
xibinliu
as code owners
September 29, 2026 07:55
copybara-service
Bot
force-pushed
the
test_978806139
branch
3 times, most recently
from
September 29, 2026 08:56
d023f95 to
1f7cd48
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
copybara-service
Bot
force-pushed
the
test_978806139
branch
4 times, most recently
from
September 29, 2026 10:09
7635468 to
35ee463
Compare
copybara-service
Bot
force-pushed
the
test_978806139
branch
from
October 9, 2026 12:41
35ee463 to
8534751
Compare
copybara-service
Bot
force-pushed
the
test_978806139
branch
10 times, most recently
from
October 16, 2026 09:51
91577a7 to
146c056
Compare
…er and ML Diagnostics. The Tunix-based RL trainer used tunix's SFT-era step profiler, which only traces the actor on process 0 and never the vLLM rollout, and it had no ML Diagnostics integration. Tunix now provides a per-role, invocation-counted `RLProfileConfig` and an `MLDiagScalarBackend`; this change maps the MaxText RL config onto them. * `profiler=xplane` builds a tunix `RLProfileConfig` from the new `rl.profiler_start_invocation`, `rl.profiler_num_invocations` and `rl.profiler_timeout_secs` keys, producing one `<role>_invocation_<n>` trace per role. Non-managed traces land in `tensorboard_dir`; with `managed_mldiagnostics=true` the tunix ML Diagnostics backend writes under the MLRun's `gcs_path` (`managed_mldiagnostics_dir`), so `RLProfileConfig.mldiagnostics_dir` is not forwarded (tunix's JAX backend would otherwise prefer it over `tensorboard_dir`). * `managed_mldiagnostics=true` creates the ML Diagnostics run before the `RLCluster` (tunix's `RLProfiler` preflights the active run), uploads the trainer config (plus `sampler.<key>` for any sampler-side differences on multi-slice topologies), and installs `MLDiagScalarBackend` next to `TensorboardBackend` as the tunix metrics backends. `RLConfig` now derives `managed_mldiagnostics_dir` like `MaxTextConfig` does and rejects a non-`gs://` directory or on-demand profiling combined with `profiler=xplane` at config time. * `common/managed_mldiagnostics.py` changes accordingly. `ManagedMLDiagnostics` stays a process-wide singleton (the RL trainer constructs it once at startup; pretrain's `common/profiler.py` is unchanged). It gains an optional `sampler_config`: when it is the same object as the trainer config (single-slice, colocated) the merge is skipped and the run config is a flat dict with no `sampler.` keys; when it is a distinct object (multi-slice, disaggregated) only keys whose values differ are added as `sampler.<key>`. The JSON-serializability filter now also catches `ValueError` so NaN/Inf values are dropped instead of failing the upload. Because `gcloud_stub.mldiagnostics_modules()` returns a stub object rather than `None` when the SDK is absent, availability is detected via the returned stub flag (`mldiagnostics_available()`); `ManagedMLDiagnostics` logs a warning when the SDK is in stub mode, while pretrain keeps its previous warn-and-continue behavior. * With `managed_mldiagnostics=false` the metrics backends are left to tunix's defaults, so non-managed runs log exactly as before. With `managed_mldiagnostics=true` the backends are listed explicitly (`MLDiagScalarBackend` plus `TensorboardBackend` when `enable_tensorboard` is set); a non-empty explicit list replaces tunix's defaults, so managed runs do not get tunix's W&B backend in OSS (or the CLU backend internally). * The step-window profiling flags (`profiler_steps`, `skip_first_n_steps_for_profiler`, `profile_periodically_period`, ...) are removed from `RLConfig` via a `ProfilingCore` mixin that only keeps `profiler`; they have no consumer on the Tunix RL path and are rejected with the list of valid fields. Pretrain/SFT keep the full `Profiling` mixin. The in-tree RL scripts are updated to the new keys. * On Pathways, `pathwaysutils` traces worker 0 only (`max_num_hosts=1`), so a disaggregated sampler never appears in the rollout trace. A new `rl.profiler_max_num_hosts` key (default 1) parameterizes a wrapper around `jax.profiler.start_trace` to trace worker hosts across all slices. * Format `tfds_data_processing_c4_mlperf.py` to satisfy repo-wide `pyink` pre-commit checks. PiperOrigin-RevId: 978806139
copybara-service
Bot
force-pushed
the
test_978806139
branch
from
October 16, 2026 11:09
146c056 to
4b48f3a
Compare
This branch has not been deployed
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.
Wire MaxText RL profiling and metrics onto tunix's targeted RL profiler and ML Diagnostics.
The Tunix-based RL trainer used tunix's SFT-era step profiler, which only
traces the actor on process 0 and never the vLLM rollout, and it had no
ML Diagnostics integration. Tunix now provides a per-role, invocation-counted
RLProfileConfigand anMLDiagScalarBackend; this change maps the MaxTextRL config onto them.
profiler=xplanebuilds a tunixRLProfileConfigfrom the newrl.profiler_start_invocation,rl.profiler_num_invocationsandrl.profiler_timeout_secskeys, producing one<role>_invocation_<n>traceper role. Non-managed traces land in
tensorboard_dir; withmanaged_mldiagnostics=truethe tunix ML Diagnostics backend writes underthe MLRun's
gcs_path(managed_mldiagnostics_dir), soRLProfileConfig.mldiagnostics_diris not forwarded (tunix's JAX backendwould otherwise prefer it over
tensorboard_dir).managed_mldiagnostics=truecreates the ML Diagnostics run before theRLCluster(tunix'sRLProfilerpreflights the active run), uploads thetrainer config (plus
sampler.<key>for any sampler-side differences onmulti-slice topologies), and installs
MLDiagScalarBackendnext toTensorboardBackendas the tunix metrics backends.RLConfignow derivesmanaged_mldiagnostics_dirlikeMaxTextConfigdoes and rejects anon-
gs://directory or on-demand profiling combined withprofiler=xplaneat config time.
common/managed_mldiagnostics.pychanges accordingly.ManagedMLDiagnosticsstays a process-wide singleton (the RL trainer constructs it once at startup;
pretrain's
common/profiler.pyis unchanged). It gains an optionalsampler_config: when it is the same object as the trainer config(single-slice, colocated) the merge is skipped and the run config is a flat
dict with no
sampler.keys; when it is a distinct object (multi-slice,disaggregated) only keys whose values differ are added as
sampler.<key>.The JSON-serializability filter now also catches
ValueErrorso NaN/Infvalues are dropped instead of failing the upload. Because
gcloud_stub.mldiagnostics_modules()returns a stub object rather thanNonewhen the SDK is absent, availability is detected via the returnedstub flag (
mldiagnostics_available());ManagedMLDiagnosticslogs awarning when the SDK is in stub mode, while pretrain keeps its previous
warn-and-continue behavior.
managed_mldiagnostics=falsethe metrics backends are left to tunix'sdefaults, so non-managed runs log exactly as before. With
managed_mldiagnostics=truethe backends are listed explicitly(
MLDiagScalarBackendplusTensorboardBackendwhenenable_tensorboardis set); a non-empty explicit list replaces tunix's defaults, so managed runs
do not get tunix's W&B backend in OSS (or the CLU backend internally).
profiler_steps,skip_first_n_steps_for_profiler,profile_periodically_period, ...) areremoved from
RLConfigvia aProfilingCoremixin that only keepsprofiler; they have no consumer on the Tunix RL path and are rejected withthe list of valid fields. Pretrain/SFT keep the full
Profilingmixin. Thein-tree RL scripts are updated to the new keys.
pathwaysutilstraces worker 0 only (max_num_hosts=1), so adisaggregated sampler never appears in the rollout trace. A new
rl.profiler_max_num_hostskey (default 1) parameterizes a wrapper aroundjax.profiler.start_traceto trace worker hosts across all slices.tfds_data_processing_c4_mlperf.pyto satisfy repo-widepyinkpre-commit checks.