File tree Expand file tree Collapse file tree 3 files changed +24
-7
lines changed Expand file tree Collapse file tree 3 files changed +24
-7
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,16 @@ runtime.python_library(
118
118
],
119
119
)
120
120
121
+ runtime.python_library(
122
+ name = "hf_download",
123
+ srcs = [
124
+ "hf_download.py",
125
+ ],
126
+ deps = [
127
+ "fbsource//third-party/pypi/huggingface-hub:huggingface-hub",
128
+ ]
129
+ )
130
+
121
131
runtime.python_library(
122
132
name = "export_library",
123
133
srcs = [
@@ -134,6 +144,7 @@ runtime.python_library(
134
144
"@EXECUTORCH_CLIENTS",
135
145
],
136
146
deps = [
147
+ ":hf_download",
137
148
":source_transformation",
138
149
"//ai_codesign/gen_ai/fast_hadamard_transform:fast_hadamard_transform",
139
150
"//caffe2:torch",
Original file line number Diff line number Diff line change @@ -539,11 +539,17 @@ def export_llama(args) -> str:
539
539
if not args .checkpoint and args .model in HUGGING_FACE_REPO_IDS :
540
540
repo_id = HUGGING_FACE_REPO_IDS [args .model ]
541
541
if args .model == "qwen2_5" :
542
- from executorch .examples .models .qwen2_5 import convert_weights
542
+ from executorch .examples .models .qwen2_5 import ( # pyre-ignore[21]
543
+ convert_weights ,
544
+ )
543
545
elif args .model == "phi_4_mini" :
544
- from executorch .examples .models .phi_4_mini import convert_weights
546
+ from executorch .examples .models .phi_4_mini import ( # pyre-ignore[21]
547
+ convert_weights ,
548
+ )
545
549
elif args .model == "smollm2" :
546
- from executorch .examples .models .smollm2 import convert_weights
550
+ from executorch .examples .models .smollm2 import ( # pyre-ignore[21]
551
+ convert_weights ,
552
+ )
547
553
else :
548
554
raise ValueError (
549
555
f"Converting weights to meta format for { args .model } is not yet supported"
Original file line number Diff line number Diff line change @@ -36,8 +36,8 @@ def download_and_convert_hf_checkpoint(
36
36
converted_path = cache_dir / f"{ model_name } .pth"
37
37
38
38
if converted_path .exists ():
39
- print (f"✔ Using cached converted model: { converted_path } " )
40
- return converted_path
39
+ print (f"✔ Using cached converted model: { str ( converted_path ) } " )
40
+ return str ( converted_path )
41
41
42
42
# 1. Download weights from Hugging Face.
43
43
print ("⬇ Downloading and converting checkpoint..." )
@@ -46,5 +46,5 @@ def download_and_convert_hf_checkpoint(
46
46
)
47
47
48
48
# 2. Convert weights to Meta format.
49
- convert_weights (checkpoint_path , converted_path )
50
- return converted_path
49
+ convert_weights (checkpoint_path , str ( converted_path ) )
50
+ return str ( converted_path )
You can’t perform that action at this time.
0 commit comments