-
Notifications
You must be signed in to change notification settings - Fork 482
Enable training with Tensorboard tracking #209
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
Changes from 9 commits
01f7ba0
76e82e2
848a80b
52e1a30
63180a3
650b986
343e2e2
86f3391
fcb49fe
342bc0c
7650a13
1574227
1e2beeb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ class AccelerateRLTrainer(BaseRLTrainer): | |
def __init__(self, config, **kwargs): | ||
super().__init__(config, **kwargs) | ||
self.max_length = config.train.seq_length | ||
self.accelerator = Accelerator(log_with=config.train.trackers) | ||
self.accelerator = Accelerator(log_with=config.train.tracker, logging_dir=config.train.logging_dir) | ||
if int(os.environ.get("WORLD_SIZE", 1)) > 1: | ||
torch.distributed.barrier(device_ids=[int(os.environ.get("LOCAL_RANK", 0))]) | ||
|
||
|
@@ -78,19 +78,32 @@ def __init__(self, config, **kwargs): | |
dist_config = get_distributed_config(self.accelerator) | ||
config_dict["distributed"] = dist_config | ||
init_trackers_kwargs = {} | ||
if "wandb" in config.train.trackers: | ||
# HACK: Tensorboard doesn't like nested dict as hyperparams | ||
config_dict_flat = {a:b for (k,v) in config_dict.items() for (a,b) in v.items() if not isinstance(b, dict)} | ||
|
||
if config.train.tracker not in ("wandb", "tensorboard"): | ||
raise ValueError(f"Only supported trackers are wandb and tensorboard, got {config.train.tracker}") | ||
|
||
if config.train.tracker == "wandb": | ||
init_trackers_kwargs["wandb"] = { | ||
"name": run_name, | ||
"entity": self.config.train.entity_name, | ||
"group": self.config.train.group_name, | ||
"tags": ["/".join(get_git_tag())], | ||
"mode": "disabled" if os.environ.get("debug", False) else "online", | ||
} | ||
self.accelerator.init_trackers( | ||
project_name=self.config.train.project_name, | ||
config=config_dict, | ||
init_kwargs=init_trackers_kwargs, | ||
) | ||
"name": run_name, | ||
"entity": self.config.train.entity_name, | ||
"group": self.config.train.group_name, | ||
"tags": ["/".join(get_git_tag())], | ||
"mode": "disabled" if os.environ.get("debug", False) else "online", | ||
} | ||
|
||
self.accelerator.init_trackers( | ||
project_name=self.config.train.project_name, | ||
config=config_dict, | ||
init_kwargs=init_trackers_kwargs, | ||
) | ||
else: | ||
|
||
self.accelerator.init_trackers( | ||
project_name=self.config.train.project_name, | ||
config=config_dict_flat, | ||
) | ||
|
||
|
||
def setup_model(self): | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use trlx.utils.modeling.flatten_dict here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the suggestion! I replaced the dict comprehension with a call to flatten_dict(), since tensorboard also doesn't like lists I added a couple lines to split the optimizer betas