MCPcopy Create free account
hub / github.com/AnswerDotAI/ModernBERT / train

Function train

eval.py:500–671  ·  view source on GitHub ↗

Main training logic. Args: config (DictConfig): Configuration composed by OmegaConf

(config: om.DictConfig)

Source from the content-addressed store, hash-verified

498
499
500def train(config: om.DictConfig) -> None:
501 """Main training logic.
502
503 Args:
504 config (DictConfig): Configuration composed by OmegaConf
505 """
506 # these subtasks require the parent task to have been run
507 round_2_task_names = config.get(
508 "round_2_task_names",
509 {
510 "mnli": {"rte", "mrpc", "stsb"},
511 "swag": {"copa"},
512 },
513 )
514
515 start_time = time.time()
516
517 # Initial default seed
518 reproducibility.seed_all(config.default_seed)
519
520 # Quiet down WandB
521 os.environ["WANDB_SILENT"] = "true"
522
523 # Set tokenizer parallelism
524 os.environ["TOKENIZERS_PARALLELISM"] = "false"
525
526 # Confirm GPUs if parallel=True
527 if config.parallel:
528 assert (
529 torch.cuda.device_count() > 0
530 ), "Can only use parallel mode if GPUs are available. Please set parallel=False."
531
532 # Downloads the starting checkpoint ahead of time so that
533 # the different tasks don't all try to download it at the same time
534 if config.get("starting_checkpoint_load_path", None):
535 local_pretrain_checkpoint_path = download_starting_checkpoint(
536 config.starting_checkpoint_load_path,
537 config.local_pretrain_checkpoint_folder,
538 )
539 else:
540 local_pretrain_checkpoint_path = None
541
542 # Builds round 1 configs and runs them by first filtering out all round 2 tasks
543 if round_2_task_names:
544 round_2_tasks = [task for tasks in round_2_task_names.values() for task in tasks]
545 else:
546 round_2_tasks = []
547 round_1_task_names = [task for task in TASK_NAME_TO_CLASS.keys() if task not in round_2_tasks]
548
549 round_1_job_configs = create_job_configs(config, round_1_task_names, local_pretrain_checkpoint_path)
550
551 round_1_results = {}
552 if len(round_1_job_configs) > 0:
553 if config.parallel:
554 round_1_results = run_jobs_parallel(round_1_job_configs)
555 else:
556 round_1_results = run_jobs_serial(round_1_job_configs)
557

Callers 3

test_eval_scriptFunction · 0.90
eval.pyFile · 0.70

Calls 9

runMethod · 0.80
create_job_configsFunction · 0.70
run_jobs_parallelFunction · 0.70
run_jobs_serialFunction · 0.70
get_values_from_pathFunction · 0.70
_print_tableFunction · 0.70
updateMethod · 0.45

Tested by 2

test_eval_scriptFunction · 0.72