-
Notifications
You must be signed in to change notification settings - Fork 602
Support MLPerf training logging compliance for MaxText #5118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zxhe-sean
wants to merge
1
commit into
main
Choose a base branch
from
mlperf_logging
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+363
−6
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| google-jetstream @ https://github.com/AI-Hypercomputer/JetStream/archive/29329e8e73820993f77cfc8efe34eb2a73f5de98.zip | ||
| mlperf-logging @ https://github.com/mlcommons/logging/archive/38ab22670527888c8eb7825a4ece176fcc36a95d.zip | ||
| mlperf-logging @ https://github.com/mlcommons/logging/archive/refs/tags/6.0.0-rc6.zip |
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,6 +76,7 @@ | |
| from maxtext.utils import sharding | ||
| from maxtext.utils import maxtext_utils_nnx | ||
| from maxtext.utils import train_utils | ||
| from maxtext.utils import mllog_utils | ||
| from maxtext.utils.gradient_accumulation import gradient_accumulation_loss_and_grad | ||
| from maxtext.utils.vocabulary_tiling import vocab_tiling_linen_loss, vocab_tiling_nnx_loss | ||
|
|
||
|
|
@@ -884,6 +885,15 @@ def training_loop_iteration( | |
| step_time_delta = datetime.datetime.now() - last_step_completion | ||
| last_step_completion = datetime.datetime.now() | ||
|
|
||
| completed_step = step + 1 | ||
| mllog_utils.tracked_stats( | ||
| config, | ||
| completed_step, | ||
| step_time_delta.total_seconds(), | ||
| metrics["scalar"]["learning/loss"], | ||
| start_step=start_step, | ||
| ) | ||
|
|
||
| checkpointing.maybe_save_checkpoint(checkpoint_manager, state, config, data_iterator, step) | ||
|
|
||
| if dump_hlo and step == (dump_step if dump_step >= 0 else start_step): | ||
|
|
@@ -906,6 +916,7 @@ def training_loop_iteration( | |
| # Explicitly reset the eval iterator and counters before starting the eval loop | ||
| eval_data_iterator.reset() | ||
| metric_logger_instance.reset_eval_metrics() | ||
| mllog_utils.eval_start(config, completed_step, start_step=start_step) | ||
| max_logging.log(f"Starting eval after train step {step}") | ||
|
|
||
| eval_step_count = 0 | ||
|
|
@@ -1017,7 +1028,9 @@ def train_loop(config, recorder, state=None): | |
| compiled_stats = compiled.memory_analysis() | ||
| max_utils.print_compiled_memory_stats(compiled_stats) | ||
| prof = profiler.Profiler(config, offset_step=start_step) | ||
| metric_logger_instance = metric_logger.MetricLogger(config=config, learning_rate_schedule=learning_rate_schedule) | ||
| metric_logger_instance = metric_logger.MetricLogger( | ||
| config=config, learning_rate_schedule=learning_rate_schedule, start_step=start_step | ||
| ) | ||
|
|
||
| # Write train config params, num model params, and XLA flags to tensorboard | ||
| if isinstance(model, nn.Module): | ||
|
|
@@ -1079,6 +1092,11 @@ def train_loop(config, recorder, state=None): | |
| try: | ||
| python_vars["last_step_completion"] = datetime.datetime.now() | ||
|
|
||
| mllog_utils.init_print(config, start_step) | ||
| mllog_utils.init_stop() | ||
| mllog_utils.run_start() | ||
| mllog_utils.block_start(config, start_step) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have the block_start at the beginning. The block_stop is only in eval_start. If we do not have the eval. The block_stop will not be added. |
||
|
|
||
| # Using while loop to allow for potential dynamic 'steps' adjustment in future | ||
| while python_vars["step"] < immutable_data["steps"]: | ||
| training_loop_iteration(jax_device_state, python_vars, immutable_data) | ||
|
|
@@ -1089,7 +1107,6 @@ def train_loop(config, recorder, state=None): | |
|
|
||
| if immutable_data["save_checkpoint_on_completion"]: | ||
| checkpointing.maybe_save_checkpoint(checkpoint_manager, state, config, data_iterator) | ||
|
|
||
| if checkpoint_manager is not None: | ||
| # in case the last checkpoint_period checkpoint is still in progress | ||
| checkpointing.wait_until_finished(checkpoint_manager) | ||
|
|
@@ -1101,6 +1118,9 @@ def train_loop(config, recorder, state=None): | |
| finally: | ||
| if _job_completed_gracefully: | ||
| record_goodput(recorder, RECORD_JOB_END_TIME) | ||
| samples_count = (python_vars["step"] - immutable_data["start_step"]) * config.global_batch_size_to_train_on | ||
| mllog_utils.run_stop(status="success", current_epoch_num=samples_count) | ||
| mllog_utils.flush_and_sync() | ||
| metric_logger_instance.flush_metrics_and_cleanup() | ||
| train_utils.maybe_cleanup_dcn_throttling(config) | ||
|
|
||
|
|
@@ -1135,6 +1155,7 @@ def initialize(argv: Sequence[str]) -> tuple[pyconfig.HyperParameters, Any]: | |
| max_utils.bootstrap_transformer_engine_cgemm(config) | ||
|
|
||
| # Create the Goodput recorder | ||
| mllog_utils.init_start(config) | ||
| recorder = create_goodput_recorder(config) | ||
|
|
||
| return config, recorder | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check whether train_step has +1 before _finalize_eval_metrics.