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

Fixed seeding before instantiation of mlflow logger causes identical run names #613

Open
ChristianHinge opened this issue Oct 17, 2023 · 0 comments

Comments

@ChristianHinge
Copy link

ChristianHinge commented Oct 17, 2023

MLFlow generates random run names using the random module. Since random.seed is set before instantiation of the mlflow logger, the same run name is always generated.

https://stackoverflow.com/questions/76053273/how-can-i-set-the-seed-that-mlflow-uses-to-randomly-generate-run-names

My current fix is to instantiate the loggers before the line:
L.seed_everything(cfg.seed, workers=True)

and forcing the setup of the logger during instatiation by logging some dummy variable:

...
    for _, lg_conf in logger_cfg.items():
        if isinstance(lg_conf, DictConfig) and "_target_" in lg_conf:
            log.info(f"Instantiating logger <{lg_conf._target_}>")
            _logger = hydra.utils.instantiate(lg_conf)
            logger.append(_logger)
            _logger.log_metrics({"dummy": 0})

    return logger

If the above is not added, the setup of the logger (which includes generating a random name), only happens at log_hyperparameters, and thus the seed would already be set and the run name would again be identical.

This feels like a hacky solution. Do you have any suggestions on a propper way to address the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant