@@ -53,7 +53,18 @@ def make_parser():
53
53
help = "If given, remove the local directory if everything runs successfully to free up space on NFS." ,
54
54
)
55
55
parser .add_argument (
56
- "--old_style_hf" , action = "store_true" , help = "If given, convert to 'old-style' HF checkpoint."
56
+ "--checkpoint_style" ,
57
+ default = "hf_olmo" ,
58
+ choices = ["hf_olmo" , "transformers" ],
59
+ help = """Checkpoint style. The `transformers` style works with HF transformers as-is, while
60
+ `hf_olmo` relies on the `hf_olmo` package for conversion. In general, use
61
+ `transformers` for external releases and `hf_olmo` for internal model
62
+ development.""" ,
63
+ )
64
+ parser .add_argument (
65
+ "--hf_olmo" ,
66
+ action = "store_true" ,
67
+ help = "If given, convert to 'hf-olmo' style checkpoints." ,
57
68
)
58
69
parser .add_argument (
59
70
"--quiet" ,
@@ -81,10 +92,12 @@ def s3_unshard_to_hf(args):
81
92
# Set directories
82
93
sharded_dir = args .local_dir / "sharded"
83
94
unsharded_dir = args .local_dir / "unsharded"
84
- if args .old_style_hf :
95
+ if args .checkpoint_style == "hf_olmo" :
85
96
hf_dir = args .local_dir / "hf-olmo"
97
+ elif args .checkpoint_style == "transformers" :
98
+ hf_dir = args .local_dir / "transformers"
86
99
else :
87
- hf_dir = args . local_dir / "hf"
100
+ raise ValueError ( f"Unknown checkpoint style: { args . checkpoint_style } ." )
88
101
hf_dir .mkdir (exist_ok = True )
89
102
90
103
# Either download the unsharded checkpoint, or download sharded and unshard.
@@ -111,7 +124,7 @@ def s3_unshard_to_hf(args):
111
124
112
125
# Convert to HF.
113
126
print ("Converting to HF." )
114
- if args .old_style_hf :
127
+ if args .checkpoint_style == "hf_olmo" :
115
128
# Convert to old-style checkpoint.
116
129
hf_cmd = f"python hf_olmo/convert_olmo_to_hf.py --checkpoint-dir { unsharded_dir } "
117
130
subprocess .run (hf_cmd , shell = True , check = True )
0 commit comments