Skip to content

Commit 3288eda

Browse files
authored
Merge branch 'pytorch:main' into add-profiling-to-xnn-executor-runner-2
2 parents 2752ba2 + 8ef6c79 commit 3288eda

File tree

173 files changed

+2963
-1541
lines changed

Some content is hidden

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

173 files changed

+2963
-1541
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
00e3eea170ce5db8ea9c62ce5e48f13886cd6d20
1+
aec9b2ab77389967ef39bb9c10662fd0fe3e185a

.ci/scripts/test_llama.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
1111

1212
MODEL_NAME=$1 # stories110M
1313
BUILD_TOOL=$2 # buck2 or cmake
14-
DTYPE=$3 # fp16 or fp32
14+
DTYPE=$3 # fp16, bf16, or fp32
1515
MODE=${4:-"xnnpack+custom"} # portable or xnnpack+custom or xnnpack+custom+qe
1616
UPLOAD_DIR=${5:-}
1717
if [[ $# -lt 4 ]]; then # Assuming 4 mandatory args
@@ -29,7 +29,7 @@ if [[ -z "${BUILD_TOOL:-}" ]]; then
2929
fi
3030

3131
if [[ -z "${DTYPE:-}" ]]; then
32-
echo "Missing dtype, choose fp16 or fp32, exiting..."
32+
echo "Missing dtype, choose fp16, bf16, or fp32, exiting..."
3333
exit 1
3434
fi
3535

@@ -174,6 +174,8 @@ fi
174174
EXPORTED_MODEL_NAME="llama2"
175175
if [[ "${DTYPE}" == "fp16" ]]; then
176176
EXPORTED_MODEL_NAME="${EXPORTED_MODEL_NAME}_h"
177+
elif [[ "${DTYPE}" == "bf16" ]]; then
178+
EXPORTED_MODEL_NAME="${EXPORTED_MODEL_NAME}_bf"
177179
elif [[ "${DTYPE}" == "fp32" ]]; then
178180
:
179181
else

.github/workflows/pull.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ jobs:
9191
dtype: [fp32]
9292
build-tool: [buck2, cmake]
9393
mode: [portable, xnnpack+custom, xnnpack+custom+qe]
94+
include:
95+
- dtype: bf16
96+
build-tool: cmake
97+
mode: portable
98+
- dtype: bf16
99+
build-tool: buck2
100+
mode: portable
94101
fail-fast: false
95102
with:
96103
runner: linux.2xlarge

.github/workflows/trunk.yml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,10 @@ jobs:
223223
strategy:
224224
matrix:
225225
dtype: [fp32]
226-
build-tool: [buck2, cmake]
227226
mode: [portable, xnnpack+kv+custom, mps, coreml]
227+
include:
228+
- dtype: bf16
229+
mode: portable
228230
fail-fast: false
229231
with:
230232
runner: macos-m1-stable
@@ -235,25 +237,12 @@ jobs:
235237
script: |
236238
237239
DTYPE=${{ matrix.dtype }}
238-
BUILD_TOOL=${{ matrix.build-tool }}
239240
MODE=${{ matrix.mode }}
240241
241-
if [[ "${BUILD_TOOL}" == "buck2" ]]; then
242-
# TODO: Will add more modes that don't support buck2
243-
if [[ "${MODE}" == "mps" ]]; then
244-
echo "mps doesn't support buck2."
245-
exit 0
246-
fi
247-
if [[ "${MODE}" == "coreml" ]]; then
248-
echo "coreml doesn't support buck2."
249-
exit 0
250-
fi
251-
fi
252-
253242
bash .ci/scripts/setup-conda.sh
254243
255244
# Setup executorch
256-
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/setup-macos.sh "${BUILD_TOOL}"
245+
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/setup-macos.sh cmake
257246
258247
if [[ "${MODE}" == "mps" ]]; then
259248
# Install mps delegate
@@ -268,7 +257,7 @@ jobs:
268257
# Install requirements for export_llama
269258
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash examples/models/llama2/install_requirements.sh
270259
# Test llama2
271-
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_llama.sh stories110M "${BUILD_TOOL}" "${DTYPE}" "${MODE}"
260+
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_llama.sh stories110M cmake "${DTYPE}" "${MODE}"
272261
273262
# # TODO(jackzhxng): Runner consistently runs out of memory before test finishes. Try to find a more powerful runner.
274263
# test-llava-runner-macos:
@@ -406,6 +395,10 @@ jobs:
406395
echo "::endgroup::"
407396
408397
echo "::group::Set up HuggingFace Dependencies"
398+
if [ -z "$SECRET_EXECUTORCH_HF_TOKEN" ]; then
399+
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."
400+
exit 1
401+
fi
409402
pip install -U "huggingface_hub[cli]"
410403
huggingface-cli login --token $SECRET_EXECUTORCH_HF_TOKEN
411404
pip install accelerate sentencepiece

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL "Build the Runner Util extension"
184184

185185
option(EXECUTORCH_BUILD_EXTENSION_TENSOR "Build the Tensor extension" OFF)
186186

187+
option(EXECUTORCH_BUILD_EXTENSION_TRAINING "Build the training extension" OFF)
188+
187189
option(EXECUTORCH_BUILD_GTESTS "Build googletest based test binaries" OFF)
188190

189191
option(EXECUTORCH_BUILD_MPS "Build the MPS backend" OFF)
@@ -637,6 +639,10 @@ if(EXECUTORCH_BUILD_EXTENSION_MODULE)
637639
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/module)
638640
endif()
639641

642+
if(EXECUTORCH_BUILD_EXTENSION_TRAINING)
643+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/training)
644+
endif()
645+
640646
if(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL)
641647
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/runner_util)
642648
endif()

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ please visit our documentation website [for the latest release](https://pytorch.
2222

2323
Check out the [Getting Started](https://pytorch.org/executorch/stable/getting-started-setup.html#quick-setup-colab-jupyter-notebook-prototype) page for a quick spin.
2424

25+
Check out the examples of [Llama](./examples/models/llama2/README.md), [Llava](./examples/models/llava/README.md) and [other models](./examples/README.md) running on edge devices using ExecuTorch.
26+
2527
## Feedback
2628

2729
We welcome any feedback, suggestions, and bug reports from the community to help

backends/apple/coreml/scripts/install_requirements.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ rm -rf "$COREML_DIR_PATH/third-party"
2424
mkdir "$COREML_DIR_PATH/third-party"
2525

2626
echo "${green}ExecuTorch: Cloning coremltools."
27-
git clone --depth 1 --branch 8.0b2 "https://github.com/apple/coremltools.git" $COREMLTOOLS_DIR_PATH
27+
git clone --depth 1 --branch 8.0 "https://github.com/apple/coremltools.git" $COREMLTOOLS_DIR_PATH
2828
cd $COREMLTOOLS_DIR_PATH
2929

3030
STATUS=$?

backends/arm/test/models/test_mobilenet_v2_arm.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def test_mv2_tosa_BI(self):
8484
)
8585

8686
def test_mv2_u55_BI(self):
87-
(
87+
tester = (
8888
ArmTester(
8989
self.mv2,
9090
example_inputs=self.model_inputs,
@@ -96,4 +96,9 @@ def test_mv2_u55_BI(self):
9696
.check(list(self.operators_after_quantization))
9797
.partition()
9898
.to_executorch()
99+
.serialize()
99100
)
101+
if common.is_option_enabled("corstone300"):
102+
tester.run_method_and_compare_outputs(
103+
atol=1.0, qtol=1, inputs=self.model_inputs
104+
)

backends/cadence/aot/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ def get_ops_count(graph_module: torch.fx.GraphModule) -> Dict[str, int]:
104104
):
105105
continue
106106
# If the op is already present, increment the count
107-
if get_edge_overload_packet(node.target).__name__ in freq:
108-
freq[get_edge_overload_packet(node.target).__name__] += 1
107+
if node.target._name in freq:
108+
freq[node.target._name] += 1
109109
# else, add a new entry
110110
else:
111-
freq[get_edge_overload_packet(node.target).__name__] = 1
111+
freq[node.target._name] = 1
112112
return freq
113113

114114

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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 -euo pipefail
9+
10+
unset CMAKE_PREFIX_PATH
11+
git submodule sync
12+
git submodule update --init
13+
./install_requirements.sh
14+
15+
rm -rf cmake-out
16+
17+
STEPWISE_BUILD=false
18+
19+
if $STEPWISE_BUILD; then
20+
echo "Building ExecuTorch"
21+
cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
22+
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \
23+
-DCMAKE_BUILD_TYPE=Release \
24+
-DEXECUTORCH_ENABLE_EVENT_TRACER=OFF \
25+
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
26+
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
27+
-DEXECUTORCH_BUILD_PTHREADPOOL=OFF \
28+
-DEXECUTORCH_BUILD_CPUINFO=OFF \
29+
-DEXECUTORCH_ENABLE_LOGGING=ON \
30+
-DEXECUTORCH_USE_DL=OFF \
31+
-DEXECUTORCH_BUILD_CADENCE=OFF \
32+
-DFLATC_EXECUTABLE="$(which flatc)" \
33+
-Bcmake-out .
34+
35+
echo "Building any Cadence-specific binaries on top"
36+
cmake -DBUCK2="$BUCK" \
37+
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \
38+
-DCMAKE_INSTALL_PREFIX=cmake-out \
39+
-DCMAKE_BUILD_TYPE=Release \
40+
-DEXECUTORCH_BUILD_HOST_TARGETS=ON \
41+
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \
42+
-DEXECUTORCH_BUILD_PTHREADPOOL=OFF \
43+
-DEXECUTORCH_BUILD_CADENCE=ON \
44+
-DFLATC_EXECUTABLE="$(which flatc)" \
45+
-DEXECUTORCH_ENABLE_LOGGING=ON \
46+
-DEXECUTORCH_ENABLE_PROGRAM_VERIFICATION=ON \
47+
-DEXECUTORCH_USE_DL=OFF \
48+
-DBUILD_EXECUTORCH_PORTABLE_OPS=ON \
49+
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF \
50+
-DPYTHON_EXECUTABLE=python3 \
51+
-DEXECUTORCH_NNLIB_OPT=ON \
52+
-DEXECUTORCH_BUILD_GFLAGS=ON \
53+
-DHAVE_FNMATCH_H=OFF \
54+
-Bcmake-out/backends/cadence \
55+
backends/cadence
56+
cmake --build cmake-out/backends/cadence -j16
57+
else
58+
echo "Building Cadence toolchain with ExecuTorch packages"
59+
cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags"
60+
cmake -DBUCK2="$BUCK" \
61+
-DCMAKE_PREFIX_PATH="${cmake_prefix_path}" \
62+
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \
63+
-DCMAKE_INSTALL_PREFIX=cmake-out \
64+
-DCMAKE_BUILD_TYPE=Release \
65+
-DEXECUTORCH_BUILD_HOST_TARGETS=ON \
66+
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \
67+
-DEXECUTORCH_BUILD_PTHREADPOOL=OFF \
68+
-DEXECUTORCH_BUILD_CADENCE=OFF \
69+
-DFLATC_EXECUTABLE="$(which flatc)" \
70+
-DEXECUTORCH_ENABLE_LOGGING=ON \
71+
-DEXECUTORCH_ENABLE_PROGRAM_VERIFICATION=ON \
72+
-DEXECUTORCH_USE_DL=OFF \
73+
-DBUILD_EXECUTORCH_PORTABLE_OPS=ON \
74+
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF \
75+
-DPYTHON_EXECUTABLE=python3 \
76+
-DEXECUTORCH_NNLIB_OPT=ON \
77+
-DEXECUTORCH_BUILD_GFLAGS=ON \
78+
-DHAVE_FNMATCH_H=OFF \
79+
-DEXECUTORCH_ENABLE_EVENT_TRACER=OFF \
80+
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
81+
-DEXECUTORCH_BUILD_CPUINFO=OFF \
82+
-Bcmake-out
83+
cmake --build cmake-out --target install --config Release -j16
84+
fi
85+
86+
echo "Run simple model to verify cmake build"
87+
python3 -m examples.portable.scripts.export --model_name="add"
88+
xt-run --turbo cmake-out/executor_runner --model_path=add.pte

0 commit comments

Comments
 (0)