From 5d7d54e4d4ce7ab4dc594977fd4357f44394950d Mon Sep 17 00:00:00 2001 From: Jack Zhang <32371937+jackzhxng@users.noreply.github.com> Date: Wed, 5 Mar 2025 12:23:21 -0800 Subject: [PATCH 1/2] Fix phi4mini test model --- .ci/scripts/gather_test_models.py | 2 +- .ci/scripts/test_model.sh | 2 +- examples/models/__init__.py | 2 +- examples/models/llama/export_llama_lib.py | 2 +- examples/models/phi-4-mini/__init__.py | 14 ++++++++++++++ 5 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 examples/models/phi-4-mini/__init__.py diff --git a/.ci/scripts/gather_test_models.py b/.ci/scripts/gather_test_models.py index a0cc9efd521..632a185e3b1 100755 --- a/.ci/scripts/gather_test_models.py +++ b/.ci/scripts/gather_test_models.py @@ -90,7 +90,7 @@ def model_should_run_on_event(model: str, event: str) -> bool: We put higher priority and fast models to pull request and rest to push. """ if event == "pull_request": - return model in ["mv3", "vit"] + return model in ["mv3", "vit", "phi-4-mini"] elif event == "push": # These are super slow. Only run it periodically return model not in ["dl3", "edsr", "emformer_predict"] diff --git a/.ci/scripts/test_model.sh b/.ci/scripts/test_model.sh index 65d04dc3886..c4cb0a8595f 100755 --- a/.ci/scripts/test_model.sh +++ b/.ci/scripts/test_model.sh @@ -100,7 +100,7 @@ test_model() { rm "./${MODEL_NAME}.pte" return # Skip running with portable executor runnner since portable doesn't support Qwen's biased linears. fi - if [[ "${MODEL_NAME}" == "phi4_mini" ]]; then + if [[ "${MODEL_NAME}" == "phi-4-mini" ]]; then # Install requirements for export_llama bash examples/models/llama/install_requirements.sh # Test export_llama script: python3 -m examples.models.llama.export_llama. diff --git a/examples/models/__init__.py b/examples/models/__init__.py index 778138a1802..26c84c48fc6 100644 --- a/examples/models/__init__.py +++ b/examples/models/__init__.py @@ -35,7 +35,7 @@ "llava": ("llava", "LlavaModel"), "efficient_sam": ("efficient_sam", "EfficientSAM"), "qwen2_5": ("qwen2_5", "Qwen2_5Model"), - "phi4_mini": ("phi4_mini", "Phi4MiniModel"), + "phi-4-mini": ("phi-4-mini", "Phi4MiniModel"), } __all__ = [ diff --git a/examples/models/llama/export_llama_lib.py b/examples/models/llama/export_llama_lib.py index 6e5eca11d0e..2319ec0c6a7 100644 --- a/examples/models/llama/export_llama_lib.py +++ b/examples/models/llama/export_llama_lib.py @@ -93,7 +93,7 @@ "llama3_2", "static_llama", "qwen2_5", - "phi4_mini", + "phi-4-mini", ] TORCHTUNE_DEFINED_MODELS = ["llama3_2_vision"] diff --git a/examples/models/phi-4-mini/__init__.py b/examples/models/phi-4-mini/__init__.py new file mode 100644 index 00000000000..056f2c26314 --- /dev/null +++ b/examples/models/phi-4-mini/__init__.py @@ -0,0 +1,14 @@ +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +from executorch.examples.models.llama.model import Llama2Model + + +class Phi4MiniModel(Llama2Model): + def __init__(self, **kwargs): + super().__init__(**kwargs) + + +__all__ = [ + "Phi4MiniModel", +] From 87a78df85e5b420db8e603e6757f755f59f6645f Mon Sep 17 00:00:00 2001 From: Jack Zhang <32371937+jackzhxng@users.noreply.github.com> Date: Wed, 5 Mar 2025 16:27:35 -0800 Subject: [PATCH 2/2] Remove pull trigger since done testing --- .ci/scripts/gather_test_models.py | 2 +- .ci/scripts/test_model.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.ci/scripts/gather_test_models.py b/.ci/scripts/gather_test_models.py index 632a185e3b1..a0cc9efd521 100755 --- a/.ci/scripts/gather_test_models.py +++ b/.ci/scripts/gather_test_models.py @@ -90,7 +90,7 @@ def model_should_run_on_event(model: str, event: str) -> bool: We put higher priority and fast models to pull request and rest to push. """ if event == "pull_request": - return model in ["mv3", "vit", "phi-4-mini"] + return model in ["mv3", "vit"] elif event == "push": # These are super slow. Only run it periodically return model not in ["dl3", "edsr", "emformer_predict"] diff --git a/.ci/scripts/test_model.sh b/.ci/scripts/test_model.sh index c4cb0a8595f..5940affc109 100755 --- a/.ci/scripts/test_model.sh +++ b/.ci/scripts/test_model.sh @@ -107,6 +107,7 @@ test_model() { "${PYTHON_EXECUTABLE}" -m examples.models.llama.export_llama --model "${MODEL_NAME}" -c examples/models/llama/params/demo_rand_params.pth -p examples/models/phi-4-mini/config.json run_portable_executor_runner rm "./${MODEL_NAME}.pte" + return fi # Export a basic .pte and run the model.