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 log_config #1432

Merged
merged 7 commits into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion llmfoundry/command_utils/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def evaluate_model(

if should_log_config:
log.info('Evaluation config:')
log_config(logged_config)
log_config(trainer.logger, logged_config)

log.info(f'Starting eval for {model_name}...')
if torch.cuda.is_available():
Expand Down
2 changes: 1 addition & 1 deletion llmfoundry/command_utils/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ def train(cfg: DictConfig) -> Trainer:

if train_cfg.log_config:
log.info('Logging config')
log_config(logged_cfg)
log_config(trainer.logger, logged_cfg)
log_dataset_uri(logged_cfg)
torch.cuda.empty_cache()
gc.collect()
Expand Down
12 changes: 3 additions & 9 deletions llmfoundry/utils/config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
)

import mlflow
from composer.loggers import Logger
from composer.utils import dist, parse_uri
from omegaconf import MISSING, DictConfig, ListConfig, MissingMandatoryValue
from omegaconf import OmegaConf as om
Expand Down Expand Up @@ -571,21 +572,14 @@ def process_init_device(model_cfg: dict[str, Any], fsdp_config: Optional[dict]):
return init_context


def log_config(cfg: dict[str, Any]) -> None:
def log_config(logger: Logger, cfg: Dict[str, Any]) -> None:
snarayan21 marked this conversation as resolved.
Show resolved Hide resolved
"""Logs the current config and updates the wandb and mlflow configs.

This function can be called multiple times to update the wandb and MLflow
config with different variables.
"""
print(om.to_yaml(cfg))
loggers = cfg.get('loggers', None) or {}
if 'wandb' in loggers:
import wandb
if wandb.run:
wandb.config.update(cfg)

if 'mlflow' in loggers and mlflow.active_run():
mlflow.log_params(params=cfg)
logger.log_hyperparameters(cfg)


def _parse_source_dataset(cfg: dict[str, Any]) -> list[tuple[str, str, str]]:
Expand Down
Loading