Skip to content

Commit e5217cf

Browse files
authored
Merge pull request #705 from allenai/dave/checkpoint_style_naming
Change naming convention for HF checkpoints.
2 parents f4b386e + 9bd29c1 commit e5217cf

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

scripts/s3_unshard_to_hf.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,18 @@ def make_parser():
5353
help="If given, remove the local directory if everything runs successfully to free up space on NFS.",
5454
)
5555
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.",
5768
)
5869
parser.add_argument(
5970
"--quiet",
@@ -81,10 +92,12 @@ def s3_unshard_to_hf(args):
8192
# Set directories
8293
sharded_dir = args.local_dir / "sharded"
8394
unsharded_dir = args.local_dir / "unsharded"
84-
if args.old_style_hf:
95+
if args.checkpoint_style == "hf_olmo":
8596
hf_dir = args.local_dir / "hf-olmo"
97+
elif args.checkpoint_style == "transformers":
98+
hf_dir = args.local_dir / "transformers"
8699
else:
87-
hf_dir = args.local_dir / "hf"
100+
raise ValueError(f"Unknown checkpoint style: {args.checkpoint_style}.")
88101
hf_dir.mkdir(exist_ok=True)
89102

90103
# Either download the unsharded checkpoint, or download sharded and unshard.
@@ -111,7 +124,7 @@ def s3_unshard_to_hf(args):
111124

112125
# Convert to HF.
113126
print("Converting to HF.")
114-
if args.old_style_hf:
127+
if args.checkpoint_style == "hf_olmo":
115128
# Convert to old-style checkpoint.
116129
hf_cmd = f"python hf_olmo/convert_olmo_to_hf.py --checkpoint-dir {unsharded_dir}"
117130
subprocess.run(hf_cmd, shell=True, check=True)

0 commit comments

Comments
 (0)