Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Commit

Permalink
log eval settings in wandb run
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Friedowitz committed Jan 19, 2024
1 parent 3f0c8f0 commit 5090cf5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/flamingo/integrations/wandb/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,27 @@
from wandb.apis.public import Run as ApiRun

from flamingo.integrations.wandb import ArtifactType, WandbArtifactConfig, WandbRunConfig
from flamingo.types import BaseFlamingoConfig


@contextlib.contextmanager
def wandb_init_from_config(config: WandbRunConfig, *, resume: str | None = None):
def wandb_init_from_config(
config: WandbRunConfig,
*,
resume: str | None = None,
parameters: BaseFlamingoConfig | None = None,
):
"""Initialize a W&B run from the internal run configuration."""
init_kwargs = dict(
id=config.run_id,
name=config.name,
project=config.project,
entity=config.entity,
group=config.run_group,
config=parameters.dict() if parameters else None,
resume=resume,
)
with wandb.init(**init_kwargs, resume=resume) as run:
with wandb.init(**init_kwargs) as run:
yield run


Expand Down
6 changes: 5 additions & 1 deletion src/flamingo/jobs/lm_harness/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ def load_and_evaluate(config: LMHarnessJobConfig) -> dict[str, Any]:
@ray.remote
def evaluation_task(config: LMHarnessJobConfig) -> None:
if config.tracking is not None:
with wandb_init_from_config(config.tracking, resume="never") as run:
with wandb_init_from_config(
config.tracking,
resume="allow",
parameters=config.evaluator, # Log eval settings in W&B run
) as run:
eval_results = load_and_evaluate(config)
artifact = build_evaluation_artifact(run.name, eval_results)
run.log_artifact(artifact)
Expand Down

0 comments on commit 5090cf5

Please sign in to comment.