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

Function train

glue.py:434–588  ·  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

432
433
434def train(config: om.DictConfig) -> None:
435 """Main training logic.
436
437 Args:
438 config (DictConfig): Configuration composed by OmegaConf
439 """
440 start_time = time.time()
441
442 # Initial default seed
443 reproducibility.seed_all(config.default_seed)
444
445 # Quiet down WandB
446 os.environ["WANDB_SILENT"] = "true"
447
448 # Set tokenizer parallelism
449 os.environ["TOKENIZERS_PARALLELISM"] = "false"
450
451 # Confirm GPUs if parallel=True
452 if config.parallel:
453 assert (
454 torch.cuda.device_count() > 0
455 ), "Can only use parallel mode if GPUs are available. Please set parallel=False."
456
457 # Downloads the starting checkpoint ahead of time so that
458 # the different tasks don't all try to download it at the same time
459 if config.get("starting_checkpoint_load_path", None):
460 local_pretrain_checkpoint_path = download_starting_checkpoint(
461 config.starting_checkpoint_load_path,
462 config.local_pretrain_checkpoint_folder,
463 )
464 else:
465 local_pretrain_checkpoint_path = None
466
467 # Builds round 1 configs and runs them
468 round_1_task_names = {
469 # glue:
470 *{"cola", "sst2", "qqp", "qnli", "mnli"},
471 # superglue:
472 *{"boolq", "cb", "multirc", "wic"},
473 # misc:
474 *{"swag", "eurlex"},
475 }
476 round_1_job_configs = create_job_configs(
477 config, round_1_task_names, local_pretrain_checkpoint_path
478 )
479
480 round_1_results = {}
481 if len(round_1_job_configs) > 0:
482 if config.parallel:
483 round_1_results = run_jobs_parallel(round_1_job_configs)
484 else:
485 round_1_results = run_jobs_serial(round_1_job_configs)
486
487 # Builds up the information needed to run the second round, starting from the MNLI checkpoints
488 checkpoint_paths = {}
489 for job_name, output_dict in round_1_results.items():
490 job_results = output_dict["result"]
491 job_values = get_values_from_path(job_name, separator="_")

Callers 3

test_superglue_scriptFunction · 0.90
test_glue_scriptFunction · 0.90
glue.pyFile · 0.70

Calls 8

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_superglue_scriptFunction · 0.72
test_glue_scriptFunction · 0.72