-
Notifications
You must be signed in to change notification settings - Fork 230
reduce log #1022
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
Merged
Merged
reduce log #1022
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -260,6 +260,7 @@ def __init__( | |||||
| self._buffered_eval_metrics: MetricsBuffer | None = None | ||||||
| self.training_hooks = None | ||||||
| self.data_hooks = None | ||||||
| self._jit_cache = set() | ||||||
|
|
||||||
| def with_training_hooks(self, training_hooks: hooks.TrainingHooks): | ||||||
| self.training_hooks = training_hooks | ||||||
|
|
@@ -565,13 +566,21 @@ def train( | |||||
| cache_nnx_graph: bool = False, | ||||||
| ) -> None: | ||||||
| """Training loop.""" | ||||||
| logging.log_first_n( | ||||||
| logging.INFO, | ||||||
| f"Training with mesh: {pxla.thread_resources.env.physical_mesh}", | ||||||
| 1, | ||||||
| ) | ||||||
| train_step, eval_step = self.jit_train_and_eval_step(skip_jit) | ||||||
| if not skip_jit: | ||||||
| logging.info( | ||||||
| "Training with mesh: %s. Compiled train_step cache size: %s", | ||||||
| pxla.thread_resources.env.physical_mesh, | ||||||
| train_step.jitted_fn._cache_size(), # pytype: disable=attribute-error,protected-access | ||||||
| cache_size = train_step.jitted_fn._cache_size() # pytype: disable=attribute-error | ||||||
|
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. The
Suggested change
|
||||||
| logging.log_if( | ||||||
| logging.INFO, | ||||||
| f"Compiled train_step cache size: {cache_size}", | ||||||
| lambda: cache_size not in self._jit_cache, | ||||||
| ) | ||||||
| self._jit_cache.add(cache_size) | ||||||
|
|
||||||
| if cache_nnx_graph: | ||||||
| # For performance, cache the nnx graph traversals. However, the training | ||||||
| # loop must _not_ modify the model or optimizer graph in this case. For | ||||||
|
|
||||||
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.
This cache is used to track JIT compilation cache sizes to avoid verbose logging. However, it appears this set is never cleared during the lifetime of the trainer instance. If the trainer is reused in a way that causes recompilations (e.g., by calling
with_loss_fnorwith_gen_model_input_fn), this cache will not be reset. This could lead to misleading logs, as new compilations might not be reported if their cache size has been seen before.Consider clearing this set in the
clear_jit_cachemethod, alongside resetting_jitted_train_step_fnand_jitted_eval_step_fn.