MCPcopy Create free account
hub / github.com/CERT-Lab/lora-sb / create_run_directory

Function create_run_directory

train_arithmetic.py:35–62  ·  view source on GitHub ↗

Create a directory structure for the current training run.

(args)

Source from the content-addressed store, hash-verified

33os.environ['MASTER_PORT'] = '12355'
34
35def create_run_directory(args):
36 """Create a directory structure for the current training run."""
37 # Create base directory for all runs
38 base_dir = "experiments/instruction_tuning"
39
40 # Create timestamp for unique run identification
41 timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
42
43 # Create model name directory (simplified name)
44 model_name = args.model.split('/')[-1]
45
46 # Create run-specific directory with relevant parameters
47 run_name = f"{model_name}__r{args.lora_r}__lr{args.lr}__train_{args.dataset_split.replace('[:','').replace(']','')}"
48
49 # Final directory structure: experiments/model_name/YYYYMMDD_HHMMSS_parameters
50 run_dir = os.path.join(base_dir, model_name, f"{timestamp}_{run_name}")
51
52 # Create directories
53 os.makedirs(run_dir, exist_ok=True)
54 os.makedirs(os.path.join(run_dir, "checkpoints"), exist_ok=True)
55 os.makedirs(os.path.join(run_dir, "logs"), exist_ok=True)
56
57 # Save run configuration
58 config_dict = vars(args)
59 with open(os.path.join(run_dir, "config.json"), 'w') as f:
60 json.dump(config_dict, f, indent=4)
61
62 return run_dir
63
64def finetune():
65 run_dir = create_run_directory(args)

Callers 1

finetuneFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected