Skip to content

Commit 63f0718

Browse files
mergennachinfacebook-github-bot
authored andcommitted
Codemod examples/models/llama2 to examples/models/llama (#6302)
Summary: Pull Request resolved: #6302 Pull Request resolved: #6275 Squash of D64446460, D64446461, D64446462, D64446459 allow-large-files bypass-github-export-checks bypass-github-pytorch-ci-checks bypass-github-executorch-ci-checks bypass-github-torchtune-ci-checks Reviewed By: iseeyuan Differential Revision: D64446900 fbshipit-source-id: f3cfe3d049470581ca1636042fd89f1c4fac2726
1 parent 0a8e007 commit 63f0718

File tree

118 files changed

+654
-655
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+654
-655
lines changed

.ci/scripts/build_llama_android.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ build_llama_runner() {
4848
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
4949
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
5050
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
51-
-Bcmake-android-out/examples/models/llama2 examples/models/llama2
51+
-Bcmake-android-out/examples/models/llama examples/models/llama
5252

53-
cmake --build cmake-android-out/examples/models/llama2 -j4 --config Release
53+
cmake --build cmake-android-out/examples/models/llama -j4 --config Release
5454
}
5555
install_flatc_from_source
5656
install_executorch_and_backend_lib

.ci/scripts/test_llama.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ cmake_install_executorch_libraries() {
125125

126126
cmake_build_llama_runner() {
127127
echo "Building llama runner"
128-
dir="examples/models/llama2"
128+
dir="examples/models/llama"
129129
retry cmake \
130130
-DCMAKE_INSTALL_PREFIX=cmake-out \
131131
-DCMAKE_BUILD_TYPE=Debug \
@@ -206,7 +206,7 @@ if [[ "${QNN}" == "ON" ]]; then
206206
EXPORT_ARGS="${EXPORT_ARGS} -kv -v --qnn --disable_dynamic_shape"
207207
fi
208208
# Add dynamically linked library location
209-
$PYTHON_EXECUTABLE -m examples.models.llama2.export_llama ${EXPORT_ARGS}
209+
$PYTHON_EXECUTABLE -m examples.models.llama.export_llama ${EXPORT_ARGS}
210210

211211
# Create tokenizer.bin.
212212
echo "Creating tokenizer.bin"
@@ -219,15 +219,15 @@ echo "Running ${EXPORTED_MODEL_NAME} in portable mode"
219219
if [[ "${BUILD_TOOL}" == "buck2" ]]; then
220220
# Run model.
221221
# shellcheck source=/dev/null
222-
$BUCK run examples/models/llama2:main -- ${RUNTIME_ARGS} > result.txt
222+
$BUCK run examples/models/llama:main -- ${RUNTIME_ARGS} > result.txt
223223
elif [[ "${BUILD_TOOL}" == "cmake" ]]; then
224224
cmake_install_executorch_libraries
225225
cmake_build_llama_runner
226226
# Run llama runner
227227
NOW=$(date +"%H:%M:%S")
228228
echo "Starting to run llama runner at ${NOW}"
229229
# shellcheck source=/dev/null
230-
cmake-out/examples/models/llama2/llama_main ${RUNTIME_ARGS} > result.txt
230+
cmake-out/examples/models/llama/llama_main ${RUNTIME_ARGS} > result.txt
231231
NOW=$(date +"%H:%M:%S")
232232
echo "Finished at ${NOW}"
233233
else

.ci/scripts/test_model.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ run_portable_executor_runner() {
7575
test_model() {
7676
if [[ "${MODEL_NAME}" == "llama2" ]]; then
7777
# Install requirements for export_llama
78-
bash examples/models/llama2/install_requirements.sh
79-
# Test export_llama script: python3 -m examples.models.llama2.export_llama
80-
"${PYTHON_EXECUTABLE}" -m examples.models.llama2.export_llama -c examples/models/llama2/params/demo_rand_params.pth -p examples/models/llama2/params/demo_config.json
78+
bash examples/models/llama/install_requirements.sh
79+
# Test export_llama script: python3 -m examples.models.llama.export_llama
80+
"${PYTHON_EXECUTABLE}" -m examples.models.llama.export_llama -c examples/models/llama/params/demo_rand_params.pth -p examples/models/llama/params/demo_config.json
8181
run_portable_executor_runner
8282
rm "./${MODEL_NAME}.pte"
8383
fi

.github/workflows/android-perf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ jobs:
160160
161161
if [[ ${{ matrix.model }} =~ ^stories* ]]; then
162162
# Install requirements for export_llama
163-
PYTHON_EXECUTABLE=python bash examples/models/llama2/install_requirements.sh
163+
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
164164
# Test llama2
165165
if [[ ${{ matrix.delegate }} == "xnnpack" ]]; then
166166
DELEGATE_CONFIG="xnnpack+custom+qe"

.github/workflows/apple-perf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ jobs:
162162
if [[ ${{ matrix.model }} =~ ^stories* ]]; then
163163
# Install requirements for export_llama
164164
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
165-
bash examples/models/llama2/install_requirements.sh
165+
bash examples/models/llama/install_requirements.sh
166166
167167
# Test llama2
168168
if [[ ${{ matrix.delegate }} == "xnnpack" ]]; then

.github/workflows/pull.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
# Setup executorch
124124
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh buck2
125125
# Install requirements for export_llama
126-
PYTHON_EXECUTABLE=python bash examples/models/llama2/install_requirements.sh
126+
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
127127
# Test llama2
128128
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh stories110M "${BUILD_TOOL}" "${DTYPE}" "${MODE}"
129129
@@ -222,7 +222,7 @@ jobs:
222222
bash install_requirements.sh --pybind xnnpack
223223
224224
# install Llava requirements
225-
bash examples/models/llama2/install_requirements.sh
225+
bash examples/models/llama/install_requirements.sh
226226
bash examples/models/llava/install_requirements.sh
227227
228228
# run python unittest
@@ -417,7 +417,7 @@ jobs:
417417
# Setup executorch
418418
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh buck2
419419
# Install requirements for export_llama
420-
PYTHON_EXECUTABLE=python bash examples/models/llama2/install_requirements.sh
420+
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
421421
# Test llama2
422422
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh stories110M "${BUILD_TOOL}" "${DTYPE}" "${MODE}"
423423

.github/workflows/trunk.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ jobs:
257257
fi
258258
259259
# Install requirements for export_llama
260-
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash examples/models/llama2/install_requirements.sh
260+
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash examples/models/llama/install_requirements.sh
261261
# Test llama2
262262
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_llama.sh stories110M cmake "${DTYPE}" "${MODE}"
263263
@@ -281,7 +281,7 @@ jobs:
281281
# GITHUB_RUNNER=1 PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/setup-macos.sh "${BUILD_TOOL}"
282282

283283
# # install Llava requirements
284-
# ${CONDA_RUN} bash examples/models/llama2/install_requirements.sh
284+
# ${CONDA_RUN} bash examples/models/llama/install_requirements.sh
285285
# ${CONDA_RUN} bash examples/models/llava/install_requirements.sh
286286

287287
# # run python unittest
@@ -387,7 +387,7 @@ jobs:
387387
cmake --build cmake-out -j9 --target install --config Release
388388
389389
echo "Build llama runner"
390-
dir="examples/models/llama2"
390+
dir="examples/models/llama"
391391
cmake \
392392
-DCMAKE_INSTALL_PREFIX=cmake-out \
393393
-DCMAKE_BUILD_TYPE=Release \
@@ -439,5 +439,5 @@ jobs:
439439
440440
python -m extension.export_util.export_hf_model -hfm=${{ matrix.hf_model_repo }} -o ${ET_MODEL_NAME}
441441
442-
cmake-out/examples/models/llama2/llama_main --model_path=${ET_MODEL_NAME}.pte --tokenizer_path=${TOKENIZER_BIN_FILE} --prompt="My name is"
442+
cmake-out/examples/models/llama/llama_main --model_path=${ET_MODEL_NAME}.pte --tokenizer_path=${TOKENIZER_BIN_FILE} --prompt="My name is"
443443
echo "::endgroup::"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ please visit our documentation website [for the latest release](https://pytorch.
2222

2323
Check out the [Getting Started](https://pytorch.org/executorch/stable/getting-started-setup.html#quick-setup-colab-jupyter-notebook-prototype) page for a quick spin.
2424

25-
Check out the examples of [Llama](./examples/models/llama2/README.md), [Llava](./examples/models/llava/README.md) and [other models](./examples/README.md) running on edge devices using ExecuTorch.
25+
Check out the examples of [Llama](./examples/models/llama/README.md), [Llava](./examples/models/llava/README.md) and [other models](./examples/README.md) running on edge devices using ExecuTorch.
2626

2727

28-
**[UPDATE - 09/25]** We have added support for running [Llama 3.2 1B/3B](./examples/models/llama2/README.md) models via ExecuTorch.
28+
**[UPDATE - 09/25]** We have added support for running [Llama 3.2 1B/3B](./examples/models/llama/README.md) models via ExecuTorch.
2929

3030
## Feedback
3131

backends/qualcomm/runtime/targets.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def define_common_targets():
5353
exclude = ["Logging.h"],
5454
),
5555
define_static_target = True,
56-
link_whole = True, # needed for executorch/examples/models/llama2:main to register QnnBackend
56+
link_whole = True, # needed for executorch/examples/models/llama:main to register QnnBackend
5757
platforms = [ANDROID],
5858
visibility = ["@EXECUTORCH_CLIENTS"],
5959
resources = {

backends/qualcomm/tests/test_qnn_delegate.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@
3737
skip_annotation,
3838
)
3939

40-
from executorch.examples.models.llama2.llama_transformer import (
41-
ModelArgs,
42-
MOEFeedForward,
43-
)
40+
from executorch.examples.models.llama.llama_transformer import ModelArgs, MOEFeedForward
4441

4542
from executorch.examples.qualcomm.utils import setup_common_args_and_variables
4643

@@ -51,7 +48,7 @@
5148
from executorch.examples.models.inception_v3 import InceptionV3Model
5249
from executorch.examples.models.inception_v4 import InceptionV4Model
5350

54-
# from executorch.examples.models.llama2 import Llama2Model
51+
# from executorch.examples.models.llama import Llama2Model
5552
from executorch.examples.models.mobilebert import MobileBertModelExample
5653
from executorch.examples.models.mobilenet_v2 import MV2Model
5754
from executorch.examples.models.mobilenet_v3 import MV3Model

0 commit comments

Comments
 (0)