diff --git a/examples/models/llama/TARGETS b/examples/models/llama/TARGETS index 48c48532f7b..6f3a3f2a3f4 100644 --- a/examples/models/llama/TARGETS +++ b/examples/models/llama/TARGETS @@ -118,6 +118,16 @@ runtime.python_library( ], ) +runtime.python_library( + name = "hf_download", + srcs = [ + "hf_download.py", + ], + deps = [ + "fbsource//third-party/pypi/huggingface-hub:huggingface-hub", + ] +) + runtime.python_library( name = "export_library", srcs = [ @@ -134,6 +144,7 @@ runtime.python_library( "@EXECUTORCH_CLIENTS", ], deps = [ + ":hf_download", ":source_transformation", "//ai_codesign/gen_ai/fast_hadamard_transform:fast_hadamard_transform", "//caffe2:torch", diff --git a/examples/models/llama/export_llama_lib.py b/examples/models/llama/export_llama_lib.py index dc7f763fade..d774c9895f4 100644 --- a/examples/models/llama/export_llama_lib.py +++ b/examples/models/llama/export_llama_lib.py @@ -539,11 +539,17 @@ def export_llama(args) -> str: if not args.checkpoint and args.model in HUGGING_FACE_REPO_IDS: repo_id = HUGGING_FACE_REPO_IDS[args.model] if args.model == "qwen2_5": - from executorch.examples.models.qwen2_5 import convert_weights + from executorch.examples.models.qwen2_5 import ( # pyre-ignore[21] + convert_weights, + ) elif args.model == "phi_4_mini": - from executorch.examples.models.phi_4_mini import convert_weights + from executorch.examples.models.phi_4_mini import ( # pyre-ignore[21] + convert_weights, + ) elif args.model == "smollm2": - from executorch.examples.models.smollm2 import convert_weights + from executorch.examples.models.smollm2 import ( # pyre-ignore[21] + convert_weights, + ) else: raise ValueError( f"Converting weights to meta format for {args.model} is not yet supported" diff --git a/examples/models/llama/hf_download.py b/examples/models/llama/hf_download.py index b09dc5125d9..fbc4240619b 100644 --- a/examples/models/llama/hf_download.py +++ b/examples/models/llama/hf_download.py @@ -36,8 +36,8 @@ def download_and_convert_hf_checkpoint( converted_path = cache_dir / f"{model_name}.pth" if converted_path.exists(): - print(f"✔ Using cached converted model: {converted_path}") - return converted_path + print(f"✔ Using cached converted model: {str(converted_path)}") + return str(converted_path) # 1. Download weights from Hugging Face. print("⬇ Downloading and converting checkpoint...") @@ -46,5 +46,5 @@ def download_and_convert_hf_checkpoint( ) # 2. Convert weights to Meta format. - convert_weights(checkpoint_path, converted_path) - return converted_path + convert_weights(checkpoint_path, str(converted_path)) + return str(converted_path)