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

Add EnvironmentLogger Callback #1350

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

josejg
Copy link
Contributor

@josejg josejg commented Jul 12, 2024

This is a new callback to simplify logging environment metadata for reproducibility purposes:

  • Git Commits for packages under workspace_dir, useful for mcli integrations
  • Package versions for core dependencies, e.g. transformers
  • Nvidia versions, including cuda, cuddn and nccl
  • Docker image and tag
  • Distributed info
  • System info
  • Gpu info

Main change is that GitPython now becomes a dependency. It is already a composer[dev] dependency. I was not sure if it was worth gating under a additional dependency

@josejg josejg requested review from a team as code owners July 12, 2024 00:11
@josejg
Copy link
Contributor Author

josejg commented Jul 12, 2024

I tested it with both MLflow and Wandb, where it produced the following

MLFlow

image

Wandb

image

Copy link
Collaborator

@mvpatel2000 mvpatel2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be included in the state data and logged? @eracah

@josejg
Copy link
Contributor Author

josejg commented Jul 29, 2024

Pushed an update fixing the failing checks. Let me know if it's good to go or if there's anything that needs to be changed

Copy link
Contributor

@b-chu b-chu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments and questions. Agreed with Mihir, it seems useful to incorporate this as state dict metadata instead of relying on loggers.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename file to env_logging_callback

from composer.loggers import Logger


class EnvironmentLoggerCallback(Callback):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to EnvironmentLoggingCallback

The collected information is logged as hyperparameters at the start of model fitting.
"""

PACKAGES_TO_LOG = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make private module level constant

@@ -75,6 +75,7 @@
'tenacity>=8.2.3,<9',
'catalogue>=2,<3',
'typer<1',
'GitPython==3.1.43',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this a range?

Comment on lines +131 to +134
'world_size': int(os.environ.get('WORLD_SIZE', 1)),
'local_world_size': int(os.environ.get('LOCAL_WORLD_SIZE', 1)),
'rank': int(os.environ.get('RANK', 0)),
'local_rank': int(os.environ.get('LOCAL_RANK', 0)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get from composer instead?

}

def _get_docker_info(self) -> dict[str, Any]:
from mcli import sdk
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not a new dependency?

self.env_data['distributed_info'] = self._get_distributed_info()

# Log the collected data
logger.log_hyperparameters({'environment_data': self.env_data})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this get logged to mosaciml logger?

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

Successfully merging this pull request may close these issues.

None yet

3 participants