Skip to content
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

[fix] Ensures disabling exp_manager with exp_manager=null does not error #10651

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nemo/collections/common/metrics/perf_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def __init__(
self.cfg = model_config

self.run_cfg = self.cfg.get('run', {})
self.exp_cfg = self.cfg.get('exp_manager', {})
# exp_manager = None is valid and indicates no exp_manager should be initialized
self.exp_cfg = self.cfg.get('exp_manager', {}) or {}
self.train_cfg = self.cfg.get('trainer', {})
self.model_cfg = self.cfg.get('model', {})

Expand Down
11 changes: 8 additions & 3 deletions nemo/collections/nlp/parts/megatron_trainer_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ def _plugins(self) -> list:
use_dist_ckpt = not self.cfg.model.get('fsdp', False) and (
self.cfg.model.get('mcore_gpt', False) or self.cfg.model.get('mcore_bert', False)
)
async_save = self.cfg.get('exp_manager', {}).get('checkpoint_callback_params', {}).get('async_save', False)
# exp_manager == None is valid and indicates no exp_manager should be initialized
async_save = (
(self.cfg.get('exp_manager', {}) or {}).get('checkpoint_callback_params', {}).get('async_save', False)
)
if use_dist_ckpt:
checkpoint_io = DistributedCheckpointIO.from_config(self.cfg.model, async_save)
if async_save:
Expand All @@ -172,10 +175,12 @@ def _callbacks(self, callbacks: Optional[list]) -> list:
if 'enable_progress_bar' not in self.cfg.trainer or self.cfg.trainer.enable_progress_bar:
callbacks.append(CustomProgressBar())

if self.cfg.get('exp_manager', {}).get('checkpoint_callback_params', {}).get('async_save', False):
# exp_manager == None is valid and indicates no exp_manager should be initialized
if (self.cfg.get('exp_manager', {}) or {}).get('checkpoint_callback_params', {}).get('async_save', False):
callbacks.append(AsyncFinalizerCallback())

if self.cfg.get('exp_manager', {}).get('log_tflops_per_sec_per_gpu', True):
# exp_manager == None is valid and indicates no exp_manager should be initialized
if (self.cfg.get('exp_manager', {}) or {}).get('log_tflops_per_sec_per_gpu', True):
callbacks.append(FLOPsMeasurementCallback(self.cfg))

return callbacks
Expand Down
Loading