Skip to content

Commit 6dffa75

Browse files
committed
Update base for Update on "[ExecuTorch] Arm Ethos: Add ArmTester TARGET"
As title. Differential Revision: [D69714022](https://our.internmc.facebook.com/intern/diff/D69714022/) [ghstack-poisoned]
2 parents 857642b + 728c255 commit 6dffa75

File tree

45 files changed

+1578
-441
lines changed

Some content is hidden

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

45 files changed

+1578
-441
lines changed

.buckconfig

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
root = .
99
prelude = third-party/prelude
1010
shim = shim
11+
shim_et = shim_et
1112

1213
[repository_aliases]
1314
config = prelude
1415
ovr_config = prelude
15-
toolchains = shim
16-
fbcode = shim
17-
fbcode_macros = shim
18-
fbsource = shim
16+
toolchains = shim_et
17+
fbcode = shim_et
18+
fbcode_macros = shim_et
19+
fbsource = shim_et
1920
buck = shim
2021

2122
[cxx]

.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/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_partition_decomposed_quantized_ops.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ def test_softplus_tosa_BI(test_data: input_t1):
6060
pipeline.pop_stage("check_not.exir")
6161
# check that all ops in exir_op except add are rejected
6262
pipeline.add_stage_after(
63-
"partition", pipeline.tester.check, exir_op[1:], suffix="exir_post_partition"
63+
"to_edge_transform_and_lower",
64+
pipeline.tester.check,
65+
exir_op[1:],
66+
suffix="exir_post_partition",
6467
)
6568
pipeline.run()

backends/arm/test/ops/test_conv2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def test_conv2d_tosa_BI(test_module):
370370
pipeline = TosaPipelineBI[input_t](
371371
test_module, test_module.get_inputs(), aten_op, exir_op
372372
)
373-
pipeline.change_args("run_method_and_compare_outputs.0", qtol=1)
373+
pipeline.change_args("run_method_and_compare_outputs", qtol=1)
374374
pipeline.run()
375375

376376

backends/arm/test/passes/test_cast_int64_pass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import torch
99
from executorch.backends.arm._passes.cast_int64_pass import CastInt64ToInt32Pass
1010

11-
from executorch.backends.arm.test.tester.test_pipeline import TestPassPipeline
11+
from executorch.backends.arm.test.tester.test_pipeline import PassPipeline
1212

1313
input_t = Tuple[torch.Tensor] # Input x
1414

@@ -28,7 +28,7 @@ def test_int64_model_tosa_BI():
2828
"executorch_exir_dialects_edge__ops_dim_order_ops__to_dim_order_copy_default": 1,
2929
"executorch_exir_dialects_edge__ops_aten_add_Tensor": 1,
3030
}
31-
pipeline = TestPassPipeline[input_t](
31+
pipeline = PassPipeline[input_t](
3232
module,
3333
module.get_inputs(),
3434
tosa_version="TOSA-0.80+BI",

backends/arm/test/passes/test_fold_qdq_pass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from executorch.backends.arm._passes.fold_qdq_with_annotated_qparams_pass import (
1010
FoldAndAnnotateQParamsPass,
1111
)
12-
from executorch.backends.arm.test.tester.test_pipeline import TestPassPipeline
12+
from executorch.backends.arm.test.tester.test_pipeline import PassPipeline
1313

1414

1515
input_t = Tuple[torch.Tensor, torch.Tensor] # Input x, y
@@ -32,7 +32,7 @@ def test_fold_qdq_pass_tosa_BI():
3232
is removed from the representation.
3333
"""
3434
module = SimpleQuantizeModel()
35-
pipeline = TestPassPipeline[input_t](
35+
pipeline = PassPipeline[input_t](
3636
module,
3737
module.get_inputs(),
3838
tosa_version="TOSA-0.80+BI",

backends/arm/test/passes/test_fuse_batchnorm_pass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import torch
99
from executorch.backends.arm._passes.fuse_batchnorm2d_pass import FuseBatchnorm2DPass
1010
from executorch.backends.arm.test import common
11-
from executorch.backends.arm.test.tester.test_pipeline import TestPassPipeline
11+
from executorch.backends.arm.test.tester.test_pipeline import PassPipeline
1212

1313
input_t = Tuple[torch.Tensor] # Input x
1414

@@ -138,7 +138,7 @@ def forward(self, x):
138138
@common.parametrize("module", modules)
139139
def test_fuse_batchnorm_tosa_MI(module):
140140
"""Test various cases where the batchnorm should and shouldn't be fused."""
141-
pipeline = TestPassPipeline[input_t](
141+
pipeline = PassPipeline[input_t](
142142
module,
143143
module.get_inputs(),
144144
tosa_version="TOSA-0.80+MI",

backends/arm/test/passes/test_insert_table_ops_pass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
FoldAndAnnotateQParamsPass,
1212
)
1313
from executorch.backends.arm._passes.insert_table_ops import InsertTableOpsPass
14-
from executorch.backends.arm.test.tester.test_pipeline import TestPassPipeline
14+
from executorch.backends.arm.test.tester.test_pipeline import PassPipeline
1515

1616
input_t = Tuple[torch.Tensor] # Input x
1717

@@ -27,7 +27,7 @@ def get_inputs(self) -> input_t:
2727

2828
def test_insert_table_tosa_BI():
2929
module = Sigmoid()
30-
pipeline = TestPassPipeline[input_t](
30+
pipeline = PassPipeline[input_t](
3131
module,
3232
module.get_inputs(),
3333
tosa_version="TOSA-0.80+BI",

backends/arm/test/passes/test_meandim_to_averagepool2d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
ConvertMeanDimToAveragePoolPass,
1212
)
1313
from executorch.backends.arm.test import common
14-
from executorch.backends.arm.test.tester.test_pipeline import TestPassPipeline
14+
from executorch.backends.arm.test.tester.test_pipeline import PassPipeline
1515

1616

1717
input_t = Tuple[torch.Tensor, torch.Tensor] # Input x
@@ -65,7 +65,7 @@ def test_meandim_to_avgpool_tosa_BI(module):
6565
Tests the MeanDimToAveragePool2dPass which converts mean.dim to average_pool2d
6666
for the special case where dim is [-1, -2] and keepdim is True.
6767
"""
68-
pipeline = TestPassPipeline[input_t](
68+
pipeline = PassPipeline[input_t](
6969
module,
7070
module.get_inputs(),
7171
tosa_version="TOSA-0.80+BI",

0 commit comments

Comments
 (0)