WandbNamer#

class WandbNamer(keys=(), sep='-', format_numbers=True, extra=None)[source]#

Bases: HookBase

Auto-generate cfg.wandb_run_name from selected config values.

Joins the resolved values of the requested (possibly nested) config keys with a separator, optionally formatting large numbers with K/M/B suffixes, then appends any extra strings, to build a descriptive W&B run name. Runs once in modify_config (before the writer is built), so the name is in place before logging starts. Registered as WandbNamer.

Parameters:
  • keys (tuple) – Config keys to include in the name, in order. Supports dotted nested access such as "data.train.max_len" or "model.type"; keys that resolve to None are skipped. Defaults to ().

  • sep (str) – Separator joining the parts. Defaults to "-".

  • format_numbers (bool) – If True, render numeric values with K/M/B suffixes (e.g. 1000000 -> "1M"). Defaults to True.

  • extra (str or tuple, optional) – Extra string(s) appended after the keyed parts, e.g. "fft" or "scratch". A bare string is wrapped to a one-tuple. Defaults to None.

Note

If wandb_run_name was set on the command line (present in cfg._cli_options), this hook leaves it untouched. So --options wandb_run_name=my-name overrides the auto-generated name.

Example

Add to cfg.hooks; once in modify_config (before the writer is built) it sets cfg.wandb_run_name from the joined config values:

hooks = [
    dict(type="WandbNamer",
         keys=("model.type", "data.train.max_len", "seed"),
         extra="fft"),
]
# → sets cfg.wandb_run_name = "Sonata-v1m1-1M-0-fft" (left untouched if
#   wandb_run_name was passed on the CLI)
modify_config(cfg)[source]#

Build wandb_run_name from specified keys.