Skip to content
Open
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
28 changes: 26 additions & 2 deletions dmlcloud/core/callbacks/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@
class DiagnosticsCallback(Callback):
"""
A callback that logs diagnostics information at the beginning of training.

Args:
verbose_config: If True, print full config. If False, print only key fields (default: False).
"""

def __init__(self, verbose_config: bool = False):
self.verbose_config = verbose_config

def _experiment_header(
self,
name: str | None,
Expand Down Expand Up @@ -78,8 +84,26 @@ def pre_run(self, pipe):

diagnostics = self._general_diagnostics()

diagnostics += '\n* CONFIG:\n'
diagnostics += '\n'.join(f' {line}' for line in OmegaConf.to_yaml(pipe.config, resolve=True).splitlines())
if self.verbose_config:
# Print full config
diagnostics += '\n* CONFIG:\n'
diagnostics += '\n'.join(f' {line}' for line in OmegaConf.to_yaml(pipe.config, resolve=True).splitlines())
else:
# Print only key config fields for brevity
diagnostics += '\n* CONFIG SUMMARY:\n'
key_fields = ['name', 'datamodules', 'batch_size', 'lr', 'base_lr', 'epochs', 'loss', 'compile', 'wandb_project']
for field in key_fields:
if field in pipe.config:
value = pipe.config[field]
# Truncate long values
value_str = str(value)
if len(value_str) > 100:
value_str = value_str[:97] + '...'
diagnostics += f' - {field}: {value_str}\n'

# Show model modules count
if 'model' in pipe.config and 'modules' in pipe.config.model:
diagnostics += f' - model.modules: {len(pipe.config.model.modules)} modules\n'

dml_logging.info(diagnostics)

Expand Down
4 changes: 3 additions & 1 deletion dmlcloud/core/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ def __init__(self, config: Optional[Union[OmegaConf, Dict]] = None, name: Option
self.stages = []
self.callbacks = CallbackList()

self.add_callback(DiagnosticsCallback(), CbPriority.DIAGNOSTICS)
# Check config for verbose_config setting (default: False for concise output)
verbose_config = self.config.get('verbose_config', False)
self.add_callback(DiagnosticsCallback(verbose_config=verbose_config), CbPriority.DIAGNOSTICS)
self.add_callback(GitDiffCallback(), CbPriority.GIT)
self.add_callback(_ForwardCallback(), CbPriority.OBJECT_METHODS) # methods have priority 0
if self.device.type == 'cuda':
Expand Down