Skip to content

Commit 6116ac8

Browse files
committed
feat(granite): Add support for finding weight mapping files with other names
Branch: GraniteCodeSupport Signed-off-by: Gabe Goodhart <[email protected]>
1 parent 77bac00 commit 6116ac8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

torchchat/cli/convert_hf_checkpoint.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
# This source code is licensed under the license found in the
55
# LICENSE file in the root directory of this source tree.
6+
import glob
67
import json
78
import os
89
import re
@@ -41,7 +42,12 @@ def convert_hf_checkpoint(
4142
print(f"Model config {config.__dict__}")
4243

4344
# Load the json file containing weight mapping
44-
model_map_json = model_dir / "pytorch_model.bin.index.json"
45+
model_map_json_matches = [Path(m) for m in glob.glob(str(model_dir / "*.index.json"))]
46+
assert len(model_map_json_matches) <= 1, "Found multiple weight mapping files"
47+
if len(model_map_json_matches):
48+
model_map_json = model_map_json_matches[0]
49+
else:
50+
model_map_json = model_dir / "pytorch_model.bin.index.json"
4551

4652
# If there is no weight mapping, check for a consolidated model and
4753
# tokenizer we can move. Llama 2 and Mistral have weight mappings, while

0 commit comments

Comments
 (0)