Skip to content

Commit 3383c30

Browse files
authored
Merge branch 'main' into vgf_spec_bug
2 parents ca004e4 + f8b4835 commit 3383c30

File tree

138 files changed

+4658
-510
lines changed

Some content is hidden

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

138 files changed

+4658
-510
lines changed

.ci/scripts/build-mediatek-sdk.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ build_neuron_backend() {
1414
export NEURON_BUFFER_ALLOCATOR_LIB=${MEDIATEK_SDK_ROOT}/libneuron_buffer_allocator.so
1515
export EXECUTORCH_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"
1616

17-
1817
cd ${EXECUTORCH_ROOT}
1918
./backends/mediatek/scripts/mtk_build.sh
19+
./examples/mediatek/mtk_build_examples.sh
2020
}
2121

2222
build_neuron_backend

.ci/scripts/test_llama_lora.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -exu
9+
# shellcheck source=/dev/null
10+
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
11+
12+
cmake_install_executorch_libraries() {
13+
echo "Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a"
14+
rm -rf cmake-out
15+
retry cmake --preset llm \
16+
-DCMAKE_INSTALL_PREFIX=cmake-out \
17+
-DCMAKE_BUILD_TYPE=Release
18+
cmake --build cmake-out -j9 --target install --config Release
19+
}
20+
21+
cmake_build_llama_runner() {
22+
echo "Building llama runner"
23+
pushd extension/llm/tokenizers
24+
echo "Updating tokenizers submodule"
25+
git submodule update --init
26+
popd
27+
dir="examples/models/llama"
28+
retry cmake \
29+
-DBUILD_TESTING=OFF \
30+
-DCMAKE_INSTALL_PREFIX=cmake-out \
31+
-DCMAKE_BUILD_TYPE=Release \
32+
-Bcmake-out/${dir} \
33+
${dir}
34+
cmake --build cmake-out/${dir} -j9 --config Release
35+
}
36+
37+
cleanup_files() {
38+
echo "Deleting downloaded and generated files"
39+
rm -rf "${DOWNLOADED_PATH}/"
40+
rm result.txt
41+
}
42+
43+
# Download model artifacts from HF Hub.
44+
# Hosting in personal repo for now.
45+
HF_MODEL_REPO="lucylq/llama3_1B_lora"
46+
DOWNLOADED_PATH=$(
47+
bash "$(dirname "${BASH_SOURCE[0]}")/download_hf_hub.sh" \
48+
--model_id "${HF_MODEL_REPO}" \
49+
--files "adapter_config.json" "adapter_model.pt" "consolidated.00.pth" "params.json" "tokenizer.model"
50+
)
51+
EXPORTED_MODEL_NAME="llama_3_2_1B_lora.pte"
52+
# Export model.
53+
$PYTHON_EXECUTABLE -m extension.llm.export.export_llm \
54+
base.checkpoint="${DOWNLOADED_PATH}/consolidated.00.pth" \
55+
base.params="${DOWNLOADED_PATH}/params.json" \
56+
base.adapter_checkpoint="${DOWNLOADED_PATH}/adapter_model.pt" \
57+
base.adapter_config="${DOWNLOADED_PATH}/adapter_config.json" \
58+
base.tokenizer_path="${DOWNLOADED_PATH}/tokenizer.model" \
59+
model.use_kv_cache=true \
60+
model.use_sdpa_with_kv_cache=true \
61+
model.dtype_override="fp32" \
62+
backend.xnnpack.enabled=true \
63+
backend.xnnpack.extended_ops=true \
64+
export.output_name="${EXPORTED_MODEL_NAME}"
65+
66+
# Build llama runner.
67+
cmake_install_executorch_libraries
68+
cmake_build_llama_runner
69+
70+
PROMPT="What happens if you eat watermelon seeds?"
71+
# Run llama runner
72+
RUNTIME_ARGS="--model_path=${EXPORTED_MODEL_NAME} --tokenizer_path=${DOWNLOADED_PATH}/tokenizer.model --temperature=0 --seq_len=20 --warmup=1"
73+
74+
NOW=$(date +"%H:%M:%S")
75+
echo "Starting to run llama runner at ${NOW}"
76+
# shellcheck source=/dev/null
77+
cmake-out/examples/models/llama/llama_main --prompt="${PROMPT}" ${RUNTIME_ARGS} > result.txt
78+
NOW=$(date +"%H:%M:%S")
79+
echo "Finished at ${NOW}"
80+
81+
RESULT=$(cat result.txt)
82+
EXPECTED_PREFIX="What happens if you eat watermelon seeds? Watermelon seeds are a good source of vitamin C,"
83+
84+
if [[ "${RESULT}" == "${EXPECTED_PREFIX}"* ]]; then
85+
echo "Expected result prefix: ${EXPECTED_PREFIX}"
86+
echo "Actual result: ${RESULT}"
87+
echo "Success"
88+
cleanup_files
89+
else
90+
echo "Expected result prefix: ${EXPECTED_PREFIX}"
91+
echo "Actual result: ${RESULT}"
92+
echo "Failure; results not the same"
93+
94+
cleanup_files
95+
exit 1
96+
fi

.github/workflows/pull.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,36 @@ jobs:
687687
# run llama runner in eager mode
688688
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama_runner_eager.sh
689689
690+
test-llama-lora-linux:
691+
name: test-llama-lora-linux
692+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
693+
permissions:
694+
id-token: write
695+
contents: read
696+
strategy:
697+
fail-fast: false
698+
with:
699+
runner: linux.24xlarge
700+
docker-image: ci-image:executorch-ubuntu-22.04-clang12
701+
submodules: 'recursive'
702+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
703+
timeout: 90
704+
script: |
705+
# The generic Linux job chooses to use base env, not the one setup by the image
706+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
707+
conda activate "${CONDA_ENV}"
708+
709+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool "cmake"
710+
711+
# Install llama requirements
712+
bash examples/models/llama/install_requirements.sh
713+
714+
# install a recent version of torchtune.
715+
PYTHON_EXECUTABLE=python python -m pip install torchtune==0.7.0.dev20250730 --extra-index-url https://download.pytorch.org/whl/nightly/cpu
716+
717+
# run llama runner in eager mode
718+
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama_lora.sh
719+
690720
test-mediatek-models-linux:
691721
name: test-mediatek-models-linux
692722
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ if(NOT EXECUTORCH_SELECT_OPS_YAML STREQUAL ""
849849
LIB_NAME
850850
"executorch_selected_kernels"
851851
OPS_SCHEMA_YAML
852-
"${EXECUTORCH_SELECT_OPS_LIB}"
852+
"${EXECUTORCH_SELECT_OPS_YAML}"
853853
ROOT_OPS
854854
"${EXECUTORCH_SELECT_OPS_LIST}"
855855
INCLUDE_ALL_OPS

backends/arm/test/ops/test_abs.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
EthosU85PipelineINT,
1616
TosaPipelineFP,
1717
TosaPipelineINT,
18+
VgfPipeline,
1819
)
1920

2021
aten_op = "torch.ops.aten.abs.default"
@@ -66,3 +67,25 @@ def test_abs_u85_INT(test_data: torch.Tensor):
6667
Abs(), test_data(), aten_op, exir_op, run_on_fvp=True
6768
)
6869
pipeline.run()
70+
71+
72+
@common.parametrize("test_data", Abs.test_parameters)
73+
@common.SkipIfNoModelConverter
74+
def test_abs_vgf_FP(test_data: input_t1):
75+
pipeline = VgfPipeline[input_t1](
76+
Abs(), test_data(), aten_op, exir_op, tosa_version="TOSA-1.0+FP"
77+
)
78+
pipeline.run()
79+
80+
81+
@common.parametrize("test_data", Abs.test_parameters)
82+
@common.SkipIfNoModelConverter
83+
def test_abs_vgf_INT(test_data: input_t1):
84+
pipeline = VgfPipeline[input_t1](
85+
Abs(),
86+
test_data(),
87+
aten_op,
88+
exir_op,
89+
tosa_version="TOSA-1.0+INT",
90+
)
91+
pipeline.run()

backends/arm/test/ops/test_acosh.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
EthosU85PipelineINT,
1515
TosaPipelineFP,
1616
TosaPipelineINT,
17+
VgfPipeline,
1718
)
1819

1920
input_t = Tuple[torch.Tensor] # Input x
@@ -112,3 +113,27 @@ def test_acosh_u85_INT_xfail(test_data: Tuple):
112113
run_on_fvp=False,
113114
)
114115
pipeline.run()
116+
117+
118+
@common.parametrize("test_data", test_data_suite)
119+
@common.SkipIfNoModelConverter
120+
def test_acosh_vgf_FP(test_data: Tuple):
121+
pipeline = VgfPipeline[input_t](
122+
Acosh(),
123+
(test_data(),),
124+
aten_op,
125+
tosa_version="TOSA-1.0+FP",
126+
)
127+
pipeline.run()
128+
129+
130+
@common.parametrize("test_data", test_data_suite)
131+
@common.SkipIfNoModelConverter
132+
def test_acosh_vgf_INT(test_data: Tuple):
133+
pipeline = VgfPipeline[input_t](
134+
Acosh(),
135+
(test_data(),),
136+
aten_op,
137+
tosa_version="TOSA-1.0+INT",
138+
)
139+
pipeline.run()

backends/arm/test/ops/test_adaptive_avg_pool2d.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
EthosU85PipelineINT,
1515
TosaPipelineFP,
1616
TosaPipelineINT,
17+
VgfPipeline,
1718
)
1819

1920
exir_op = "executorch_exir_dialects_edge__ops_aten_avg_pool2d_default"
@@ -161,3 +162,31 @@ def test_adaptive_avg_pool2d_u85_INT(test_module):
161162
exir_ops=exir_op,
162163
)
163164
pipeline.run()
165+
166+
167+
@common.parametrize("test_module", test_modules)
168+
@common.SkipIfNoModelConverter
169+
def test_adaptive_avg_pool2d_vgf_FP(test_module):
170+
model, input_tensor = test_module()
171+
pipeline = VgfPipeline[input_t](
172+
model,
173+
input_tensor,
174+
[],
175+
exir_op,
176+
tosa_version="TOSA-1.0+FP",
177+
)
178+
pipeline.run()
179+
180+
181+
@common.parametrize("test_module", test_modules)
182+
@common.SkipIfNoModelConverter
183+
def test_adaptive_avg_pool2d_vgf_INT(test_module):
184+
model, input_tensor = test_module()
185+
pipeline = VgfPipeline[input_t](
186+
model,
187+
input_tensor,
188+
[],
189+
exir_op,
190+
tosa_version="TOSA-1.0+INT",
191+
)
192+
pipeline.run()

backends/arm/test/ops/test_addmm.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
EthosU85PipelineINT,
1414
TosaPipelineFP,
1515
TosaPipelineINT,
16+
VgfPipeline,
1617
)
1718

1819
aten_op = "torch.ops.aten.addmm.default"
@@ -155,3 +156,29 @@ def test_addmm_u85_INT(test_data: Tuple):
155156
exir_ops=exir_op,
156157
)
157158
pipeline.run()
159+
160+
161+
@common.parametrize("test_data", test_data_suite)
162+
@common.SkipIfNoModelConverter
163+
def test_addmm_vgf_FP(test_data: input_t1):
164+
pipeline = VgfPipeline[input_t1](
165+
Addmm(),
166+
(*test_data,),
167+
aten_op=aten_op,
168+
exir_op=exir_op,
169+
tosa_version="TOSA-1.0+FP",
170+
)
171+
pipeline.run()
172+
173+
174+
@common.parametrize("test_data", test_data_suite)
175+
@common.SkipIfNoModelConverter
176+
def test_addmm_vgf_INT(test_data: input_t1):
177+
pipeline = VgfPipeline[input_t1](
178+
Addmm(),
179+
(*test_data,),
180+
aten_op=[],
181+
exir_op=exir_op,
182+
tosa_version="TOSA-1.0+INT",
183+
)
184+
pipeline.run()

backends/arm/test/ops/test_alias_copy.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
EthosU85PipelineINT,
1313
TosaPipelineFP,
1414
TosaPipelineINT,
15+
VgfPipeline,
1516
)
1617

1718
input_t1 = Tuple[torch.Tensor]
@@ -83,3 +84,29 @@ def test_alias_u85_INT(test_data: input_t1):
8384
AliasCopy.aten_op,
8485
AliasCopy.exir_op,
8586
).run()
87+
88+
89+
@common.parametrize("test_data", AliasCopy.test_data)
90+
@common.SkipIfNoModelConverter
91+
def test_alias_vgf_FP(test_data: input_t1):
92+
pipeline = VgfPipeline[input_t1](
93+
AliasCopy(),
94+
test_data(),
95+
AliasCopy.aten_op,
96+
AliasCopy.exir_op,
97+
tosa_version="TOSA-1.0+FP",
98+
)
99+
pipeline.run()
100+
101+
102+
@common.parametrize("test_data", AliasCopy.test_data)
103+
@common.SkipIfNoModelConverter
104+
def test_alias_vgf_INT(test_data: input_t1):
105+
pipeline = VgfPipeline[input_t1](
106+
AliasCopy(),
107+
test_data(),
108+
AliasCopy.aten_op,
109+
AliasCopy.exir_op,
110+
tosa_version="TOSA-1.0+INT",
111+
)
112+
pipeline.run()

0 commit comments

Comments
 (0)