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

Make experiment tracking optional #226

Merged
merged 3 commits into from
Jan 27, 2023
Merged
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
18 changes: 11 additions & 7 deletions trlx/trainer/accelerate_base_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,16 @@ def __init__(self, config, **kwargs):

run_name = "/".join([script_name, model_name, num_gpus]) + f":{branch}"

if self.accelerator.is_main_process and not ray.is_initialized():
if (
config.train.tracker is not None
and self.accelerator.is_main_process
and not ray.is_initialized()
):
config_dict = self.config.to_dict()
dist_config = get_distributed_config(self.accelerator)
config_dict["distributed"] = dist_config
init_trackers_kwargs = {}

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,
Expand All @@ -101,7 +100,7 @@ def __init__(self, config, **kwargs):
config=config_dict,
init_kwargs=init_trackers_kwargs,
)
else: # only other supported tracker is tensorboard
elif config.train.tracker == "tensorboard":
config_dict_flat = flatten_dict(
config_dict
) # flatten config for tensorboard, split list in hparams into flatten config
Expand All @@ -116,6 +115,11 @@ def __init__(self, config, **kwargs):
project_name=self.config.train.project_name,
config=config_dict_flat,
)
else:
raise ValueError(
f"Only supported trackers are `wandb` and `tensorboard`. Got: `{config.train.tracker}`. "
"Set `tracker` to `None` to disable tracking."
)

def setup_model(self):
"""
Expand Down