forked from SamsungSAILMontreal/TinyRecursiveModels
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsweep.py
More file actions
100 lines (83 loc) · 2.52 KB
/
Copy pathsweep.py
File metadata and controls
100 lines (83 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import os
import subprocess
import sys
from typing import Dict, Any
import wandb
def train() -> None:
"""Training function for wandb sweep that reads config and launches training."""
nproc_per_node = 2
# Construct torchrun command for distributed training
cmd = [
"torchrun",
"--nproc-per-node", str(nproc_per_node),
"--rdzv_backend=c10d",
"--rdzv_endpoint=localhost:0",
"--nnodes=1",
"pretrain.py",
"arch=trm",
"epochs=4000",
"eval_interval=200",
'+load_checkpoint="checkpoints/downloaded/Sanjin2024_TinyRecursiveModels-ARC-AGI-2/step_217602"',
'+in_sweep=True',
]
print(f"Running command: {' '.join(cmd)}")
# Run training
try:
result = subprocess.run(cmd, check=True, capture_output=False, timeout=60*60)
print("Training completed successfully")
except subprocess.CalledProcessError as e:
print(f"Training failed with error: {e}")
raise
def main() -> None:
"""Main function to define and run the sweep."""
# Define sweep configuration
sweep_config: Dict[str, Any] = {
'method': 'bayes',
'metric': {
'name': 'test/accuracy', # Will be logged by evaluators
'goal': 'maximize'
},
'parameters': {
'H_cycles': {
'values': [3, 4]
},
'L_cycles': {
'values': [3, 4]
},
'data': {
'values': ['arc2eval-aug-200', 'arc2eval-aug-400', 'arc2eval-aug-800']
},
'lr': {
'values': [1e-4, 2e-4]
},
'halt_max_steps': {
"values": [8, 16, 24]
}
},
'early_terminate': {
'type': 'hyperband',
'min_iter': 3,
'eta': 2,
's': 2
}
}
# Set project name
project_name = "TinyRecursiveModels-Sweep"
print("Creating wandb sweep...")
print(f"Sweep config: {sweep_config}")
# Create sweep
sweep_id = wandb.sweep(
sweep=sweep_config,
project=project_name
)
print(f"Sweep created with ID: {sweep_id}")
print(f"View sweep at: https://wandb.ai/{wandb.api.default_entity}/{project_name}/sweeps/{sweep_id}")
# Run sweep agent
print("Starting sweep agent...")
wandb.agent(
sweep_id=sweep_id,
function=train,
count=20 # Run 20 trials
)
if __name__ == "__main__":
main()