Skip to content

Commit 2635f22

Browse files
authored
Merge branch 'main' into marlin-remove-unused-param
2 parents 9465e41 + aaf0ecc commit 2635f22

File tree

116 files changed

+3845
-1497
lines changed

Some content is hidden

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

116 files changed

+3845
-1497
lines changed

.ci/scripts/build_llama_android.sh

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,12 @@ install_executorch_and_backend_lib() {
2222
ANDROID_NDK=/opt/ndk
2323
BUCK2=buck2
2424
ANDROID_ABI=arm64-v8a
25-
cmake -DBUCK2="${BUCK2}" \
25+
cmake --preset llm \
26+
-DBUCK2="${BUCK2}" \
2627
-DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" \
2728
-DANDROID_ABI="${ANDROID_ABI}" \
2829
-DCMAKE_INSTALL_PREFIX=cmake-android-out \
2930
-DCMAKE_BUILD_TYPE=Release \
30-
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
31-
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
32-
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
33-
-DEXECUTORCH_BUILD_XNNPACK=ON \
34-
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
35-
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
36-
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
3731
-DXNNPACK_ENABLE_ARM_BF16=OFF \
3832
-Bcmake-android-out .
3933

@@ -51,11 +45,7 @@ build_llama_runner() {
5145
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK"/build/cmake/android.toolchain.cmake \
5246
-DANDROID_ABI="${ANDROID_ABI}" \
5347
-DCMAKE_INSTALL_PREFIX=cmake-android-out \
54-
-DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=python \
55-
-DEXECUTORCH_BUILD_XNNPACK=ON \
56-
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
57-
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
58-
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
48+
-DCMAKE_BUILD_TYPE=Release \
5949
-Bcmake-android-out/examples/models/llama examples/models/llama
6050

6151
cmake --build cmake-android-out/examples/models/llama -j4 --config Release

.ci/scripts/test_llama.sh

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,11 @@ which "${PYTHON_EXECUTABLE}"
152152
cmake_install_executorch_libraries() {
153153
echo "Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a"
154154
rm -rf cmake-out
155-
retry cmake \
155+
retry cmake --preset llm \
156156
-DCMAKE_INSTALL_PREFIX=cmake-out \
157157
-DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \
158-
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
159-
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
160-
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
161-
-DEXECUTORCH_BUILD_KERNELS_CUSTOM="$CUSTOM" \
162-
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
163-
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
164-
-DEXECUTORCH_BUILD_XNNPACK="$XNNPACK" \
165-
-DEXECUTORCH_BUILD_MPS="$MPS" \
166-
-DEXECUTORCH_BUILD_COREML="$COREML" \
167158
-DEXECUTORCH_BUILD_QNN="$QNN" \
168159
-DQNN_SDK_ROOT="$QNN_SDK_ROOT" \
169-
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
170160
-Bcmake-out .
171161
cmake --build cmake-out -j9 --target install --config "$CMAKE_BUILD_TYPE"
172162
}
@@ -181,10 +171,6 @@ cmake_build_llama_runner() {
181171
retry cmake \
182172
-DCMAKE_INSTALL_PREFIX=cmake-out \
183173
-DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \
184-
-DEXECUTORCH_BUILD_KERNELS_CUSTOM="$CUSTOM" \
185-
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
186-
-DEXECUTORCH_BUILD_XNNPACK="$XNNPACK" \
187-
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
188174
-Bcmake-out/${dir} \
189175
${dir}
190176
cmake --build cmake-out/${dir} -j9 --config "$CMAKE_BUILD_TYPE"

.github/workflows/build-presets.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
preset: [macos-arm64, pybind]
23+
preset: [macos, ios, ios-simulator, pybind, llm]
2424
with:
2525
job-name: build
2626
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
@@ -32,14 +32,14 @@ jobs:
3232
set -eux
3333
${CONDA_RUN} ./install_requirements.sh > /dev/null
3434
${CONDA_RUN} cmake --preset ${{ matrix.preset }}
35-
${CONDA_RUN} cmake --build cmake-out --parallel
35+
${CONDA_RUN} cmake --build cmake-out -j$(( $(sysctl -n hw.ncpu) - 1 ))
3636
3737
linux:
3838
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
3939
strategy:
4040
fail-fast: false
4141
matrix:
42-
preset: [pybind]
42+
preset: [linux, pybind, llm]
4343
runner: [linux.2xlarge, linux.arm64.2xlarge]
4444
docker-image: [executorch-ubuntu-22.04-clang12, executorch-ubuntu-22.04-gcc11-aarch64]
4545
# Excluding specific runner + docker image combinations that don't make sense:
@@ -65,4 +65,4 @@ jobs:
6565
6666
./install_requirements.sh > /dev/null
6767
cmake --preset ${{ matrix.preset }}
68-
cmake --build cmake-out --parallel
68+
cmake --build cmake-out -j$(( $(nproc) - 1 ))

.github/workflows/trunk.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,3 +692,29 @@ jobs:
692692
build-mode: Release
693693
build-tool: cmake
694694
docker-image: executorch-ubuntu-22.04-clang12
695+
696+
unittest-nxp-neutron:
697+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
698+
permissions:
699+
id-token: write
700+
contents: read
701+
with:
702+
runner: linux.2xlarge
703+
docker-image: executorch-ubuntu-22.04-clang12
704+
submodules: 'true'
705+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
706+
timeout: 90
707+
script: |
708+
set -eux
709+
710+
# The generic Linux job chooses to use base env, not the one setup by the image
711+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
712+
conda activate "${CONDA_ENV}"
713+
714+
# Build and install Executorch
715+
PYTHON_EXECUTABLE=python \
716+
CMAKE_ARGS="-DEXECUTORCH_BUILD_NXP_NEUTRON=ON" \
717+
.ci/scripts/setup-linux.sh --build-tool "cmake"
718+
719+
# Run pytest
720+
PYTHON_EXECUTABLE=python bash backends/nxp/run_unittests.sh

.lintrunner.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,6 @@ exclude_patterns = [
390390
"backends/arm/test/ops/**",
391391
"backends/vulkan/quantizer/**",
392392
"backends/vulkan/test/**",
393-
"backends/cadence/aot/quantizer/**",
394393
"backends/qualcomm/quantizer/**",
395394
"examples/qualcomm/**",
396395
"backends/xnnpack/quantizer/**",

CMakePresets.json

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
"binaryDir": "${sourceDir}/cmake-out"
88
},
99
{
10-
"name": "macos-arm64",
11-
"displayName": "Build everything buildable on macOS arm64",
10+
"name": "macos",
11+
"displayName": "Build everything buildable on macOS",
1212
"inherits": ["common"],
1313
"generator": "Xcode",
1414
"cacheVariables": {
1515
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/third-party/ios-cmake/ios.toolchain.cmake",
16-
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/macos-arm64.cmake",
16+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/macos.cmake",
1717
"PLATFORM": "MAC_ARM64",
1818
"DEPLOYMENT_TARGET": "10.15"
1919
},
@@ -23,6 +23,54 @@
2323
"rhs": "Darwin"
2424
}
2525
},
26+
{
27+
"name": "ios",
28+
"displayName": "Build everything buildable on iOS",
29+
"inherits": ["common"],
30+
"generator": "Xcode",
31+
"cacheVariables": {
32+
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/third-party/ios-cmake/ios.toolchain.cmake",
33+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/ios.cmake",
34+
"PLATFORM": "OS64",
35+
"DEPLOYMENT_TARGET": "17.0"
36+
},
37+
"condition": {
38+
"lhs": "${hostSystemName}",
39+
"type": "equals",
40+
"rhs": "Darwin"
41+
}
42+
},
43+
{
44+
"name": "ios-simulator",
45+
"displayName": "Build everything buildable on iOS simulator",
46+
"inherits": ["common"],
47+
"generator": "Xcode",
48+
"cacheVariables": {
49+
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/third-party/ios-cmake/ios.toolchain.cmake",
50+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/ios.cmake",
51+
"PLATFORM": "SIMULATORARM64",
52+
"DEPLOYMENT_TARGET": "17.0"
53+
},
54+
"condition": {
55+
"lhs": "${hostSystemName}",
56+
"type": "equals",
57+
"rhs": "Darwin"
58+
}
59+
},
60+
{
61+
"name": "linux",
62+
"displayName": "Build everything buildable on Linux",
63+
"inherits": ["common"],
64+
"cacheVariables": {
65+
"CMAKE_SYSTEM_NAME": "Linux",
66+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/linux.cmake"
67+
},
68+
"condition": {
69+
"lhs": "${hostSystemName}",
70+
"type": "equals",
71+
"rhs": "Linux"
72+
}
73+
},
2674
{
2775
"name": "pybind",
2876
"displayName": "Build pybindings exported in the wheel",
@@ -36,6 +84,26 @@
3684
"string": "${hostSystemName}",
3785
"list": ["Darwin", "Linux", "Windows"]
3886
}
87+
},
88+
{
89+
"name": "llm",
90+
"displayName": "Build LLM libraries",
91+
"inherits": [
92+
"common"
93+
],
94+
"cacheVariables": {
95+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/llm.cmake",
96+
"CMAKE_OSX_DEPLOYMENT_TARGET": "10.15"
97+
},
98+
"condition": {
99+
"type": "inList",
100+
"string": "${hostSystemName}",
101+
"list": [
102+
"Darwin",
103+
"Linux",
104+
"Windows"
105+
]
106+
}
39107
}
40108
]
41109
}

backends/arm/scripts/install_reference_model.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ tosa_reference_model_url="https://git.gitlab.arm.com/tosa/tosa-reference-model.g
1313
tosa_reference_model_0_80_branch="v0.80"
1414
tosa_reference_model_0_80_rev="70ed0b40fa831387e36abdb4f7fb9670a3464f5a"
1515
tosa_serialization_lib_0_80_rev="v0.80.1"
16-
tosa_reference_model_1_0_rev="4d17b5b960cd986d8cb8052188fbe3ae494789e8"
16+
tosa_reference_model_1_0_rev="d102f426dd2e3c1f25bbf23292ec8ee51aa9c677"
1717

1818
script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
1919

backends/arm/test/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def pytest_configure(config):
4444
if getattr(config.option, "fast_fvp", False):
4545
pytest._test_options["fast_fvp"] = config.option.fast_fvp # type: ignore[attr-defined]
4646

47-
pytest._test_options["tosa_version"] = "0.80" # type: ignore[attr-defined]
47+
pytest._test_options["tosa_version"] = "1.0" # type: ignore[attr-defined]
4848
if config.option.arm_run_tosa_version:
4949
pytest._test_options["tosa_version"] = config.option.arm_run_tosa_version
5050

@@ -81,7 +81,7 @@ def try_addoption(*args, **kwargs):
8181
nargs="+",
8282
help="List of two files. Firstly .pt file. Secondly .json",
8383
)
84-
try_addoption("--arm_run_tosa_version", action="store", default="0.80")
84+
try_addoption("--arm_run_tosa_version", action="store", default="1.0")
8585

8686

8787
def pytest_sessionstart(session):

backends/arm/test/test_arm_baremetal.sh

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ _setup_msg="please refer to ${et_root_dir}/examples/arm/setup.sh to properly ins
1717

1818

1919
TEST_SUITE=$1
20+
TOSA_VERSION="${2:-TOSA-1.0+INT}"
2021

2122
# Source the tools
2223
# This should be prepared by the setup.sh
@@ -138,8 +139,8 @@ test_run_ethosu_fvp() { # End to End model tests using run.sh
138139

139140
# TOSA quantized
140141
echo "${TEST_SUITE_NAME}: Test ethos-u target TOSA"
141-
examples/arm/run.sh --et_build_root=arm_test/test_run --target=TOSA --model_name=add
142-
examples/arm/run.sh --et_build_root=arm_test/test_run --target=TOSA --model_name=mul
142+
examples/arm/run.sh --et_build_root=arm_test/test_run --target=${TOSA_VERSION} --model_name=add
143+
examples/arm/run.sh --et_build_root=arm_test/test_run --target=${TOSA_VERSION} --model_name=mul
143144

144145
# Ethos-U55
145146
echo "${TEST_SUITE_NAME}: Test ethos-u target Ethos-U55"
@@ -168,17 +169,17 @@ test_models_tosa() { # End to End model tests using model_test.py
168169

169170
# TOSA quantized
170171
echo "${TEST_SUITE_NAME}: Test ethos-u target TOSA"
171-
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=TOSA --model=mv2
172-
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=TOSA --model=mv3
173-
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=TOSA --model=lstm
174-
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=TOSA --model=edsr
175-
# python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=TOSA --model=emformer_transcribe # Takes long time to run
176-
# python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=TOSA --model=emformer_join # Takes long time to run
177-
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=TOSA --model=w2l
178-
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=TOSA --model=ic3
179-
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=TOSA --model=ic4
180-
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=TOSA --model=resnet18
181-
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=TOSA --model=resnet50
172+
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=${TOSA_VERSION} --model=mv2
173+
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=${TOSA_VERSION} --model=mv3
174+
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=${TOSA_VERSION} --model=lstm
175+
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=${TOSA_VERSION} --model=edsr
176+
# python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=${TOSA_VERSION} --model=emformer_transcribe # Takes long time to run
177+
# python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=${TOSA_VERSION} --model=emformer_join # Takes long time to run
178+
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=${TOSA_VERSION} --model=w2l
179+
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=${TOSA_VERSION} --model=ic3
180+
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=${TOSA_VERSION} --model=ic4
181+
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=${TOSA_VERSION} --model=resnet18
182+
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=${TOSA_VERSION} --model=resnet50
182183

183184
echo "${TEST_SUITE_NAME}: PASS"
184185
}

backends/arm/util/arm_model_evaluator.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import torch
2020
from torch.nn.modules import Module
21+
from torch.utils._pytree import tree_flatten
2122
from torch.utils.data import DataLoader
2223
from torchvision import datasets, transforms # type: ignore[import-untyped]
2324

@@ -28,20 +29,6 @@
2829
logger.setLevel(logging.INFO)
2930

3031

31-
def flatten_args(args) -> tuple | list:
32-
flattened_args: list = []
33-
if isinstance(args, torch.Tensor):
34-
return [args]
35-
36-
for arg in args:
37-
if isinstance(arg, (tuple, list)):
38-
flattened_args.extend(arg)
39-
else:
40-
flattened_args.append(arg)
41-
42-
return tuple(flattened_args)
43-
44-
4532
class GenericModelEvaluator:
4633
REQUIRES_CONFIG = False
4734

@@ -72,8 +59,8 @@ def get_model_error(self) -> defaultdict:
7259
- Maximum percentage error
7360
- Mean absolute error
7461
"""
75-
fp32_outputs = flatten_args(self.fp32_model(*self.example_input))
76-
int8_outputs = flatten_args(self.int8_model(*self.example_input))
62+
fp32_outputs, _ = tree_flatten(self.fp32_model(*self.example_input))
63+
int8_outputs, _ = tree_flatten(self.int8_model(*self.example_input))
7764

7865
model_error_dict = defaultdict(list)
7966

backends/cadence/aot/compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def prepare_and_convert_pt2(
123123
assert isinstance(model_gm, torch.fx.GraphModule)
124124

125125
# Prepare
126-
prepared_model = prepare_pt2e(model_gm, quantizer) # pyre-ignore[6]
126+
prepared_model = prepare_pt2e(model_gm, quantizer)
127127

128128
# Calibrate
129129
# If no calibration data is provided, use the inputs

backends/cadence/aot/quantizer/TARGETS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ python_library(
99
],
1010
deps = [
1111
"//caffe2:torch",
12+
"//pytorch/ao:torchao",
1213
],
1314
)
1415

@@ -34,7 +35,6 @@ python_library(
3435
":patterns",
3536
":utils",
3637
"//caffe2:torch",
37-
"//executorch/backends/xnnpack/quantizer:xnnpack_quantizer_utils",
3838
],
3939
)
4040

backends/cadence/aot/quantizer/patterns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from torch import fx
1717
from torch._ops import OpOverload
18-
from torch.ao.quantization.quantizer import (
18+
from torchao.quantization.pt2e.quantizer import (
1919
DerivedQuantizationSpec,
2020
SharedQuantizationSpec,
2121
)

0 commit comments

Comments
 (0)