Skip to content

Commit 0b83772

Browse files
committed
Update on "[ExecuTorch] Arm Ethos: Buckify Linear operator tests"
As title. Differential Revision: [D70018299](https://our.internmc.facebook.com/intern/diff/D70018299/) [ghstack-poisoned]
2 parents 0106f26 + 5bd93d5 commit 0b83772

File tree

277 files changed

+6401
-1916
lines changed

Some content is hidden

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

277 files changed

+6401
-1916
lines changed

.ci/scripts/gather_test_models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,12 @@ def model_should_run_on_target_os(model: str, target_os: str) -> bool:
104104
For example, a big model can be disabled in macos due to the limited macos resources.
105105
"""
106106
if target_os == "macos":
107+
# Disabled in macos due to limited resources, and should stay that way even if
108+
# we otherwise re-enable.
107109
return model not in ["llava"]
108-
return True
110+
# Disabled globally because we have test-llava-runner-linux that does a more
111+
# comprehensive E2E test of llava.
112+
return model not in ["llava"]
109113

110114

111115
def export_models_for_ci() -> dict[str, dict]:

.ci/scripts/test_model.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,17 @@ test_model() {
9191
# Install requirements for llama vision.
9292
bash examples/models/llama3_2_vision/install_requirements.sh
9393
fi
94-
# python3 -m examples.portable.scripts.export --model_name="llama2" should works too
94+
if [[ "${MODEL_NAME}" == "qwen2_5" ]]; then
95+
# Install requirements for export_llama
96+
bash examples/models/llama/install_requirements.sh
97+
# Test export_llama script: python3 -m examples.models.llama.export_llama.
98+
# Use Llama random checkpoint with Qwen 2.5 1.5b model configuration.
99+
"${PYTHON_EXECUTABLE}" -m examples.models.llama.export_llama --model "${MODEL_NAME}" -c examples/models/llama/params/demo_rand_params.pth -p examples/models/qwen2_5/1_5b_config.json
100+
rm "./${MODEL_NAME}.pte"
101+
return # Skip running with portable executor runnner since portable doesn't support Qwen's biased linears.
102+
fi
103+
104+
# Export a basic .pte and run the model.
95105
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export --model_name="${MODEL_NAME}" "${STRICT}"
96106
run_portable_executor_runner
97107
}

.ci/scripts/unittest-linux.sh

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,26 @@ eval "$(conda shell.bash hook)"
2727
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
2828
conda activate "${CONDA_ENV}"
2929

30-
# Setup swiftshader and Vulkan SDK which are required to build the Vulkan delegate
31-
source .ci/scripts/setup-vulkan-linux-deps.sh
30+
if [[ "$BUILD_TOOL" == "cmake" ]]; then
31+
# Setup swiftshader and Vulkan SDK which are required to build the Vulkan delegate
32+
source .ci/scripts/setup-vulkan-linux-deps.sh
3233

33-
PYTHON_EXECUTABLE=python \
34-
EXECUTORCH_BUILD_PYBIND=ON \
35-
CMAKE_ARGS="-DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
36-
.ci/scripts/setup-linux.sh "$BUILD_TOOL" "$BUILD_MODE"
34+
PYTHON_EXECUTABLE=python \
35+
EXECUTORCH_BUILD_PYBIND=ON \
36+
CMAKE_ARGS="-DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
37+
.ci/scripts/setup-linux.sh "$BUILD_TOOL" "$BUILD_MODE"
3738

38-
# Install llama3_2_vision dependencies.
39-
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
39+
# Install llama3_2_vision dependencies.
40+
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
4041

41-
if [[ "$BUILD_TOOL" == "cmake" ]]; then
4242
.ci/scripts/unittest-linux-cmake.sh
4343
elif [[ "$BUILD_TOOL" == "buck2" ]]; then
44+
# Removing this breaks sccache in the Buck build, apparently
45+
# because TMPDIR gets messed up? Please feel free to fix this and
46+
# speed up this CI job!
47+
PYTHON_EXECUTABLE=python \
48+
.ci/scripts/setup-linux.sh "$BUILD_TOOL" "$BUILD_MODE"
49+
4450
.ci/scripts/unittest-buck2.sh
4551
else
4652
echo "Unknown build tool $BUILD_TOOL"

.ci/scripts/unittest-macos.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ export TMP_DIR=$(mktemp -d)
3030
export PATH="${TMP_DIR}:$PATH"
3131
trap 'rm -rfv ${TMP_DIR}' EXIT
3232

33-
# Setup MacOS dependencies as there is no Docker support on MacOS atm
34-
PYTHON_EXECUTABLE=python \
35-
EXECUTORCH_BUILD_PYBIND=ON \
36-
CMAKE_ARGS="-DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_MPS=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
37-
${CONDA_RUN} --no-capture-output \
38-
.ci/scripts/setup-macos.sh "${BUILD_TOOL}" "${BUILD_MODE}"
33+
if [[ "$BUILD_TOOL" == "cmake" ]]; then
34+
# Setup MacOS dependencies as there is no Docker support on MacOS atm
35+
PYTHON_EXECUTABLE=python \
36+
EXECUTORCH_BUILD_PYBIND=ON \
37+
CMAKE_ARGS="-DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_MPS=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
38+
${CONDA_RUN} --no-capture-output \
39+
.ci/scripts/setup-macos.sh "${BUILD_TOOL}" "${BUILD_MODE}"
3940

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

45-
if [[ "$BUILD_TOOL" == "cmake" ]]; then
4646
.ci/scripts/unittest-macos-cmake.sh
4747
elif [[ "$BUILD_TOOL" == "buck2" ]]; then
4848
.ci/scripts/unittest-buck2.sh

.github/workflows/pull.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,30 @@ jobs:
5656
# Build and test ExecuTorch with the add model on portable backend.
5757
PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh "add" "${BUILD_TOOL}" "portable"
5858
59+
test-pip-install-editable-mode-linux:
60+
name: test-pip-install-editable-mode-linux
61+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
62+
permissions:
63+
id-token: write
64+
contents: read
65+
strategy:
66+
fail-fast: false
67+
with:
68+
runner: linux.2xlarge
69+
docker-image: executorch-ubuntu-22.04-clang12
70+
submodules: 'true'
71+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
72+
timeout: 90
73+
script: |
74+
# The generic Linux job chooses to use base env, not the one setup by the image
75+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
76+
conda activate "${CONDA_ENV}"
77+
# Debug
78+
which pip
79+
PYTHON_EXECUTABLE=python bash ./install_executorch.sh --editable --pybind xnnpack --use-pt-pinned-commit
80+
# Try to import extension library
81+
python -c "from executorch.extension.llm.custom_ops import custom_ops"
82+
5983
test-models-linux:
6084
name: test-models-linux
6185
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
@@ -480,7 +504,7 @@ jobs:
480504
481505
# Setup install_requirements for llama
482506
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
483-
507+
484508
# Test static llama weight sharing and accuracy
485509
PYTHON_EXECUTABLE=python bash .ci/scripts/test_qnn_static_llama.sh
486510

.github/workflows/trunk.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,31 @@ jobs:
3636
3737
PYTHONPATH="${PWD}" python .ci/scripts/gather_test_models.py --target-os macos --event "${GITHUB_EVENT_NAME}"
3838
39+
test-pip-install-editable-mode-macos:
40+
name: test-pip-install-editable-mode-macos
41+
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
42+
permissions:
43+
id-token: write
44+
contents: read
45+
strategy:
46+
fail-fast: false
47+
with:
48+
runner: macos-m1-stable
49+
python-version: '3.11'
50+
submodules: 'true'
51+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
52+
timeout: 90
53+
script: |
54+
# The generic Linux job chooses to use base env, not the one setup by the image
55+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
56+
conda activate "${CONDA_ENV}"
57+
# Debug
58+
which pip
59+
bash .ci/scripts/setup-conda.sh
60+
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash ./install_executorch.sh --editable --pybind xnnpack
61+
# Try to import extension library
62+
python -c "from executorch.extension.llm.custom_ops import custom_ops"
63+
3964
test-models-macos:
4065
name: test-models-macos
4166
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,6 @@
7070
[submodule "third-party/pocketfft"]
7171
path = third-party/pocketfft
7272
url = https://github.com/mreineck/pocketfft
73+
[submodule "shim"]
74+
path = shim
75+
url = https://github.com/facebook/buck2-shims-meta

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
/examples/llm_manual @larryliu0820
3333
/examples/llm_pte_finetuning @JacobSzwejbka
3434
/examples/mediatek @cccclai
35-
/examples/models @lucylq
35+
/examples/models @lucylq @jackzhxng
3636
/examples/portable @larryliu0820 @manuelcandales
3737
/examples/qualcomm @cccclai
3838
/examples/selective_build @lucylq @larryliu0820 @JacobSzwejbka

backends/arm/arm_vela.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
from typing import List
1313

1414
import numpy as np
15-
from ethosu.vela import vela # type: ignore
15+
16+
try:
17+
from ethosu.vela import vela # type: ignore
18+
19+
has_vela = True
20+
except ImportError:
21+
has_vela = False
1622

1723

1824
# Pack either input or output tensor block, compose the related arrays into
@@ -45,6 +51,11 @@ def vela_compile(
4551
"""
4652
Compile a TOSA graph to a binary stream for ArmBackendEthosU using Vela.
4753
"""
54+
if not has_vela:
55+
raise RuntimeError(
56+
"ethos-u-vela pip package couldn't be imported. Make sure it's installed!"
57+
)
58+
4859
with tempfile.TemporaryDirectory() as tmpdir:
4960
tosaname = "out.tosa"
5061
tosa_path = os.path.join(tmpdir, tosaname)

backends/arm/operator_support/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# pyre-unsafe
77

88
from . import ( # noqa
9-
bitwise_support,
109
convolution_support,
1110
pool_2d_support,
1211
reduce_sum_support,

0 commit comments

Comments
 (0)