Skip to content

Commit c4305b2

Browse files
committed
Update on "Move shim/xplat to shim_et/xplat, try 2"
Looks like in order to get this right, we're going to have to update some internal configuration and originate this PR from internal repo. Supersedes #8583 / D69882927. Differential Revision: [D69955361](https://our.internmc.facebook.com/intern/diff/D69955361/) [ghstack-poisoned]
2 parents 6f061cc + b236303 commit c4305b2

File tree

61 files changed

+1610
-497
lines changed

Some content is hidden

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

61 files changed

+1610
-497
lines changed

.ci/scripts/unittest-macos.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ ${CONDA_RUN} --no-capture-output \
3838
.ci/scripts/setup-macos.sh "${BUILD_TOOL}" "${BUILD_MODE}"
3939

4040
# Install llama3_2_vision dependencies.
41-
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
41+
PYTHON_EXECUTABLE=python \
42+
${CONDA_RUN} --no-capture-output \
43+
./examples/models/llama3_2_vision/install_requirements.sh
4244

4345
if [[ "$BUILD_TOOL" == "cmake" ]]; then
4446
.ci/scripts/unittest-macos-cmake.sh

.github/workflows/trunk.yml

Lines changed: 32 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,13 @@ jobs:
374374
secrets: inherit
375375
strategy:
376376
matrix:
377-
hf_model_repo: [google/gemma-2-2b]
377+
hf_model_id: [
378+
google/gemma-2-2b,
379+
Qwen/Qwen2.5-0.5B,
380+
HuggingFaceTB/SmolLM2-135M,
381+
meta-llama/Llama-3.2-1B,
382+
allenai/OLMo-1B-hf
383+
]
378384
fail-fast: false
379385
with:
380386
secrets-env: EXECUTORCH_HF_TOKEN
@@ -389,66 +395,39 @@ jobs:
389395
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
390396
conda activate "${CONDA_ENV}"
391397
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh cmake
392-
393-
echo "Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a"
394-
rm -rf cmake-out
395-
cmake \
396-
-DCMAKE_INSTALL_PREFIX=cmake-out \
397-
-DCMAKE_BUILD_TYPE=Release \
398-
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
399-
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
400-
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
401-
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
402-
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
403-
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
404-
-DEXECUTORCH_BUILD_XNNPACK=ON \
405-
-DPYTHON_EXECUTABLE=python \
406-
-Bcmake-out .
407-
cmake --build cmake-out -j9 --target install --config Release
408-
409-
echo "Build llama runner"
410-
dir="examples/models/llama"
411-
cmake \
412-
-DCMAKE_INSTALL_PREFIX=cmake-out \
413-
-DCMAKE_BUILD_TYPE=Release \
414-
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
415-
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
416-
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
417-
-DEXECUTORCH_BUILD_XNNPACK=ON \
418-
-DPYTHON_EXECUTABLE=python \
419-
-Bcmake-out/${dir} \
420-
${dir}
421-
cmake --build cmake-out/${dir} -j9 --config Release
422398
echo "::endgroup::"
423399
424-
echo "::group::Set up HuggingFace Dependencies"
425-
if [ -z "$SECRET_EXECUTORCH_HF_TOKEN" ]; then
426-
echo "::error::SECRET_EXECUTORCH_HF_TOKEN is empty. For security reason secrets won't be accessible on forked PRs. Please make sure you submit a non-forked PR."
427-
exit 1
428-
fi
400+
echo "::group::Set up Hugging Face"
429401
pip install -U "huggingface_hub[cli]"
430402
huggingface-cli login --token $SECRET_EXECUTORCH_HF_TOKEN
403+
git clone https://github.com/huggingface/optimum-executorch
404+
cd optimum-executorch
405+
# There is no release yet, for CI stability, always test from the same commit on main
406+
git checkout 6a7e83f3eee2976fa809335bfb78a45b1ea1cb25
407+
pip install .
431408
pip install accelerate sentencepiece
432409
pip list
433410
echo "::endgroup::"
434411
435-
echo "::group::Export to ExecuTorch"
436-
TOKENIZER_FILE=tokenizer.model
437-
TOKENIZER_BIN_FILE=tokenizer.bin
438-
ET_MODEL_NAME=et_model
439-
DOWNLOADED_TOKENIZER_FILE_PATH=$(bash .ci/scripts/download_hf_hub.sh --model_id "${{ matrix.hf_model_repo }}" --files "${TOKENIZER_FILE}")
440-
if [ -f "$DOWNLOADED_TOKENIZER_FILE_PATH/$TOKENIZER_FILE" ]; then
441-
echo "${TOKENIZER_FILE} downloaded successfully at: $DOWNLOADED_TOKENIZER_FILE_PATH"
442-
python -m extension.llm.tokenizer.tokenizer -t "$DOWNLOADED_TOKENIZER_FILE_PATH/$TOKENIZER_FILE" -o ./${TOKENIZER_BIN_FILE}
443-
ls ./tokenizer.bin
444-
else
445-
echo "Failed to download ${TOKENIZER_FILE} from ${{ matrix.hf_model_repo }}."
446-
exit 1
447-
fi
448-
449-
python -m extension.export_util.export_hf_model -hfm=${{ matrix.hf_model_repo }} -o ${ET_MODEL_NAME}
450-
451-
cmake-out/examples/models/llama/llama_main --model_path=${ET_MODEL_NAME}.pte --tokenizer_path=${TOKENIZER_BIN_FILE} --prompt="My name is"
412+
echo "::group::Export and Run ${{ matrix.hf_model_id }}"
413+
# Pass matrix variable as environment variable
414+
export MODEL_ID="${{ matrix.hf_model_id }}"
415+
python -c "
416+
import os
417+
from optimum.executorch import ExecuTorchModelForCausalLM
418+
from transformers import AutoTokenizer
419+
420+
model_id = os.getenv('MODEL_ID')
421+
print(f'Loading model: {model_id}')
422+
model = ExecuTorchModelForCausalLM.from_pretrained(model_id, recipe='xnnpack')
423+
tokenizer = AutoTokenizer.from_pretrained(model_id)
424+
generated_text = model.text_generation(
425+
tokenizer=tokenizer,
426+
prompt='Simply put, the theory of relativity states that',
427+
max_seq_len=64
428+
)
429+
print(generated_text)
430+
"
452431
echo "::endgroup::"
453432
454433

backends/apple/coreml/TARGETS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ runtime.cxx_python_extension(
7676
base_module = "",
7777
visibility = [
7878
"//executorch/examples/apple/coreml/...",
79+
"@EXECUTORCH_CLIENTS",
7980
],
8081
external_deps = [
8182
"pybind11",

backends/arm/_passes/TARGETS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ python_library(
77
deps = [
88
"//executorch/backends/arm:tosa_quant_utils",
99
"//executorch/backends/arm:tosa_utils",
10+
"//executorch/backends/transforms:replace_scalar_with_tensor",
1011
"//executorch/backends/xnnpack/_passes:xnnpack_passes",
1112
"//executorch/exir:lib",
1213
],

backends/arm/operator_support/TARGETS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ python_library(
55
srcs = glob(["*.py"]),
66
typing = True,
77
deps = [
8+
"//executorch/backends/arm/_passes:passes",
9+
"//executorch/backends/arm:tosa_specification",
810
"//executorch/backends/xnnpack/_passes:xnnpack_passes",
911
"//executorch/exir:lib",
10-
"//executorch/backends/arm:tosa_specification"
1112
],
1213
)

backends/arm/test/misc/test_multiple_outputs.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,21 @@ def _test_ethosu_BI_pipeline(
7676
tester.run_method_and_compare_outputs(qtol=1, inputs=test_data)
7777

7878
@pytest.mark.corstone_fvp
79-
def test_u85_BI(self):
79+
def test_u55_BI(self):
8080
module = self.MultipleOutputsModule()
8181
test_data = module.get_inputs()
8282
self._test_ethosu_BI_pipeline(
8383
module,
8484
test_data,
85-
common.get_u85_compile_spec(),
85+
common.get_u55_compile_spec(),
8686
)
8787

8888
@pytest.mark.corstone_fvp
89-
@conftest.expectedFailureOnFVP
90-
# TODO MLETORCH-598
91-
def test_u55_BI(self):
89+
def test_u85_BI(self):
9290
module = self.MultipleOutputsModule()
9391
test_data = module.get_inputs()
9492
self._test_ethosu_BI_pipeline(
9593
module,
9694
test_data,
97-
common.get_u55_compile_spec(),
95+
common.get_u85_compile_spec(),
9896
)

backends/arm/test/ops/test_bmm.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,10 @@ def test_bmm_single_input_tosa_BI(self, test_data_generator: Callable[[], Tuple]
150150
test_data = test_data_generator()
151151
self._test_bmm_tosa_BI_pipeline(self.BMMSingleInput(), test_data)
152152

153+
# Expected to fail on FVP as TOSA.MATMUL is not supported on U55
153154
@parameterized.expand(BMM.test_data_generators)
154155
@pytest.mark.corstone_fvp
155-
@unittest.expectedFailure
156+
@conftest.expectedFailureOnFVP
156157
def test_bmm_u55_BI_xfails(self, test_data_generator: Callable[[], Tuple]):
157158
test_data = test_data_generator()
158159
self._test_bmm_ethosu_BI_pipeline(
@@ -167,10 +168,10 @@ def test_bmm_u85_BI(self, test_data_generator: Callable[[], Tuple]):
167168
self.BMM(), common.get_u85_compile_spec(), test_data
168169
)
169170

170-
# Expected to fail with error: Warning, unsupported fusing of TOSA Rescale previous operator is of type: Memcpy
171+
# Expected to fail on FVP as TOSA.MATMUL is not supported on U55
171172
@parameterized.expand(BMMSingleInput.test_data_generators)
172173
@pytest.mark.corstone_fvp
173-
@unittest.expectedFailure
174+
@conftest.expectedFailureOnFVP
174175
def test_bmm_single_input_u55_BI_xfails(
175176
self, test_data_generator: Callable[[], Tuple]
176177
):

backends/arm/test/ops/test_layer_norm.py

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def test_layer_norm_tosa_BI(
158158
self.LayerNorm(*model_params), (test_data,)
159159
)
160160

161-
@parameterized.expand(test_data_suite[4:])
161+
@parameterized.expand(test_data_suite)
162162
@pytest.mark.corstone_fvp
163163
def test_layer_norm_u55_BI(
164164
self,
@@ -170,36 +170,7 @@ def test_layer_norm_u55_BI(
170170
self.LayerNorm(*model_params), common.get_u55_compile_spec(), (test_data,)
171171
)
172172

173-
# Numerical issues on FVP likely due to mul op, MLETORCH-521
174-
# Skip tests that require transposes.
175-
@parameterized.expand(test_data_suite[:4])
176-
@pytest.mark.corstone_fvp
177-
@conftest.expectedFailureOnFVP
178-
def test_layer_norm_u55_BI_xfails(
179-
self,
180-
test_name: str,
181-
test_data: torch.Tensor,
182-
model_params,
183-
):
184-
self._test_layernorm_ethosu_BI_pipeline(
185-
self.LayerNorm(*model_params), common.get_u55_compile_spec(), (test_data,)
186-
)
187-
188-
# Numerical issues on FVP likely due to mul op, MLETORCH-521
189-
@parameterized.expand(test_data_suite[:-2])
190-
@pytest.mark.corstone_fvp
191-
@conftest.expectedFailureOnFVP
192-
def test_layer_norm_u85_BI_xfails(
193-
self,
194-
test_name: str,
195-
test_data: torch.Tensor,
196-
model_params,
197-
):
198-
self._test_layernorm_ethosu_BI_pipeline(
199-
self.LayerNorm(*model_params), common.get_u85_compile_spec(), (test_data,)
200-
)
201-
202-
@parameterized.expand(test_data_suite[-2:])
173+
@parameterized.expand(test_data_suite)
203174
@pytest.mark.corstone_fvp
204175
def test_layer_norm_u85_BI(
205176
self,

backends/arm/test/ops/test_logsoftmax.py

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import pytest
1212

1313
import torch
14-
from executorch.backends.arm.test import common
14+
from executorch.backends.arm.test import common, conftest
1515
from executorch.backends.arm.test.tester.arm_tester import ArmTester
1616
from executorch.exir.backend.compile_spec_schema import CompileSpec
1717
from parameterized import parameterized
@@ -28,16 +28,17 @@
2828
lambda: ("randn", torch.randn(10, 10, 10, 10), 3),
2929
lambda: ("randn_neg_dim", torch.randn(10, 5, 8, 7), -3),
3030
]
31-
test_data_generators_u55 = [
31+
32+
test_data_generators_FVP = [
3233
# (test_name, test_data, dim)
3334
lambda: ("ones", torch.ones(10, 10), 1),
3435
lambda: ("ones_neg_dim", torch.ones(10, 3, 4), -1),
35-
lambda: ("randn_neg_dim", torch.randn(10, 5, 8, 7), -3),
36-
lambda: ("zeros", torch.zeros(10, 8, 5, 2), 0),
37-
lambda: ("zeros_neg_dim", torch.zeros(10, 7, 8, 9), -4),
36+
lambda: ("randn_neg_dim", torch.randn(1, 5, 8, 7), -3),
37+
lambda: ("zeros", torch.zeros(1, 8, 5, 2), 0),
38+
lambda: ("zeros_neg_dim", torch.zeros(1, 7, 8, 9), -4),
3839
lambda: ("rand", torch.rand(1, 2, 5, 8), 2),
39-
lambda: ("rand_neg_dim", torch.rand(2, 10, 8, 10), -2),
40-
lambda: ("randn", torch.randn(10, 10, 10, 10), 3),
40+
lambda: ("rand_neg_dim", torch.rand(1, 10, 8, 10), -2),
41+
lambda: ("randn", torch.randn(1, 10, 10, 10), 3),
4142
]
4243

4344

@@ -99,7 +100,7 @@ def _test_logsoftmax_tosa_ethos_BI_pipeline(
99100
module: torch.nn.Module,
100101
test_data: Tuple[torch.tensor],
101102
):
102-
(
103+
tester = (
103104
ArmTester(
104105
module,
105106
example_inputs=test_data,
@@ -114,21 +115,10 @@ def _test_logsoftmax_tosa_ethos_BI_pipeline(
114115
.check_not(["executorch_exir_dialects_edge__ops_aten__logsoftmax_default"])
115116
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
116117
.to_executorch()
118+
.serialize()
117119
)
118-
119-
def _test_logsoftmax_tosa_u55_BI_pipeline(
120-
self, module: torch.nn.Module, test_data: Tuple[torch.tensor]
121-
):
122-
self._test_logsoftmax_tosa_ethos_BI_pipeline(
123-
common.get_u55_compile_spec(), module, test_data
124-
)
125-
126-
def _test_logsoftmax_tosa_u85_BI_pipeline(
127-
self, module: torch.nn.Module, test_data: Tuple[torch.tensor]
128-
):
129-
self._test_logsoftmax_tosa_ethos_BI_pipeline(
130-
common.get_u85_compile_spec(), module, test_data
131-
)
120+
if conftest.is_option_enabled("corstone_fvp"):
121+
tester.run_method_and_compare_outputs(inputs=test_data, qtol=1)
132122

133123
@parameterized.expand(test_data_generators)
134124
def test_logsoftmax_tosa_MI(self, test_data_generator: Callable[[], Tuple]):
@@ -141,18 +131,18 @@ def test_logsoftmax_tosa_BI(self, test_data_generator: Callable[[], Tuple]):
141131
test_name, test_data, dim = test_data_generator()
142132
self._test_logsoftmax_tosa_BI_pipeline(self.LogSoftmax(dim=dim), (test_data,))
143133

144-
@parameterized.expand(test_data_generators_u55)
134+
@parameterized.expand(test_data_generators_FVP)
145135
@pytest.mark.flaky # TODO: MLETORCH-460 - Numerically stabler (log)softmax implementation
146136
def test_logsoftmax_tosa_u55_BI(self, test_data_generator: Callable[[], Tuple]):
147137
test_name, test_data, dim = test_data_generator()
148-
self._test_logsoftmax_tosa_u55_BI_pipeline(
149-
self.LogSoftmax(dim=dim), (test_data,)
138+
self._test_logsoftmax_tosa_ethos_BI_pipeline(
139+
common.get_u55_compile_spec(), self.LogSoftmax(dim=dim), (test_data,)
150140
)
151141

152-
@parameterized.expand(test_data_generators)
142+
@parameterized.expand(test_data_generators_FVP)
153143
@pytest.mark.flaky # TODO: MLETORCH-460 - Numerically stabler (log)softmax implementation
154144
def test_logsoftmax_tosa_u85_BI(self, test_data_generator: Callable[[], Tuple]):
155145
test_name, test_data, dim = test_data_generator()
156-
self._test_logsoftmax_tosa_u85_BI_pipeline(
157-
self.LogSoftmax(dim=dim), (test_data,)
146+
self._test_logsoftmax_tosa_ethos_BI_pipeline(
147+
common.get_u85_compile_spec(), self.LogSoftmax(dim=dim), (test_data,)
158148
)

backends/arm/test/ops/test_mean_dim.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from typing import Tuple
1111

1212
import torch
13-
from executorch.backends.arm.test import common
13+
from executorch.backends.arm.test import common, conftest
1414
from executorch.backends.arm.test.tester.arm_tester import ArmTester
1515
from executorch.exir.backend.backend_details import CompileSpec
1616
from parameterized import parameterized
@@ -121,7 +121,7 @@ def _test_adaptive_avg_pool2d_tosa_ethosu_BI_pipeline(
121121
compile_spec: CompileSpec,
122122
test_data: Tuple[torch.tensor],
123123
):
124-
(
124+
tester = (
125125
ArmTester(
126126
module,
127127
example_inputs=test_data,
@@ -141,7 +141,10 @@ def _test_adaptive_avg_pool2d_tosa_ethosu_BI_pipeline(
141141
)
142142
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
143143
.to_executorch()
144+
.serialize()
144145
)
146+
if conftest.is_option_enabled("corstone_fvp"):
147+
tester.run_method_and_compare_outputs(inputs=test_data)
145148

146149
def _test_meandim_tosa_MI_pipeline(
147150
self, module: torch.nn.Module, test_data: Tuple[torch.tensor]
@@ -188,7 +191,7 @@ def _test_meandim_tosa_ethosu_BI_pipeline(
188191
compile_spec: CompileSpec,
189192
test_data: Tuple[torch.tensor],
190193
):
191-
(
194+
tester = (
192195
ArmTester(
193196
module,
194197
example_inputs=test_data,
@@ -207,7 +210,10 @@ def _test_meandim_tosa_ethosu_BI_pipeline(
207210
)
208211
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
209212
.to_executorch()
213+
.serialize()
210214
)
215+
if conftest.is_option_enabled("corstone_fvp"):
216+
tester.run_method_and_compare_outputs(inputs=test_data, qtol=1)
211217

212218
@parameterized.expand(AdaptiveAveragePool2d.test_data_suite)
213219
def test_adaptive_avg_pool2d_tosa_MI(

0 commit comments

Comments
 (0)