MCPcopy Create free account
hub / github.com/dcharatan/flowmap / run_common_training_setup

Function run_common_training_setup

flowmap/misc/common_training_setup.py:16–59  ·  view source on GitHub ↗
(
    cfg: CommonCfg,
    cfg_dict: DictConfig,
)

Source from the content-addressed store, hash-verified

14
15
16def run_common_training_setup(
17 cfg: CommonCfg,
18 cfg_dict: DictConfig,
19) -> tuple[list[Callback], Logger, Path | None, Path]:
20 torch.set_float32_matmul_precision("highest")
21
22 # Set up callbacks.
23 callbacks = [
24 LearningRateMonitor("step", True),
25 ModelCheckpoint(
26 (LOG_PATH / "checkpoints") if cfg.wandb.mode == "disabled" else None,
27 every_n_train_steps=cfg.checkpoint.every_n_train_steps,
28 save_top_k=-1,
29 ),
30 ]
31
32 # Set up logging.
33 if cfg.wandb.mode == "disabled":
34 logger = LocalLogger()
35 output_dir = LOG_PATH
36 else:
37 output_dir = Path(
38 hydra.core.hydra_config.HydraConfig.get()["runtime"]["output_dir"]
39 )
40 output_dir = output_dir / cfg.wandb.name
41 logger = WandbLogger(
42 project=cfg.wandb.project,
43 name=cfg.wandb.name,
44 mode=cfg.wandb.mode,
45 tags=cfg.wandb.tags,
46 group=cfg.wandb.group,
47 config=OmegaConf.to_container(cfg_dict),
48 log_model="all",
49 save_dir=output_dir,
50 )
51
52 # Log code to wandb if rank is 0. On rank != 0, wandb.run is None.
53 if wandb.run is not None:
54 wandb.run.log_code("flowmap")
55
56 # Prepare the checkpoint for loading.
57 checkpoint_path = update_checkpoint_path(cfg.checkpoint.load, cfg.wandb)
58
59 return callbacks, logger, checkpoint_path, output_dir

Callers 2

pretrainFunction · 0.85
overfitFunction · 0.85

Calls 2

LocalLoggerClass · 0.85
update_checkpoint_pathFunction · 0.85

Tested by

no test coverage detected