Skip to content

Commit cd6b6fe

Browse files
authored
Merge branch 'main' into camyllh/benchmark_workflow_cli
2 parents c7f9ea8 + cb3eba0 commit cd6b6fe

File tree

2,108 files changed

+110757
-160171
lines changed

Some content is hidden

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

2,108 files changed

+110757
-160171
lines changed

.buckconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
[buck2]
4141
restarter=true
42+
file_watcher=notify
4243

4344
[oss]
4445
folly_cxx_tests = False

.ci/docker/ci_commit_pins/buck2.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2024-12-16
1+
2025-05-06

.ci/docker/ci_commit_pins/pytorch.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
295f2ed4d103017f7e19a7b8263ece606cd629db
1+
59d5cf083b4f860dea76fe8936076177f9367f10

.ci/docker/requirements-ci.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ parameterized==0.9.0
1717

1818
# Doc build requirements, same as https://github.com/pytorch/pytorch/blob/main/.ci/docker/requirements-docs.txt
1919
sphinx==5.3.0
20+
sphinx-reredirects==0.1.4
2021
sphinx-gallery==0.14.0
2122
breathe==4.34.0
2223
exhale==0.2.3

.ci/scripts/build-qnn-sdk.sh

100644100755
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,12 @@ set -o xtrace
1111

1212
build_qnn_backend() {
1313
echo "Start building qnn backend."
14-
export ANDROID_NDK_ROOT=/opt/ndk
15-
export QNN_SDK_ROOT=/tmp/qnn/2.28.0.241029
14+
export ANDROID_NDK_ROOT=${ANDROID_NDK_ROOT:-/opt/ndk}
15+
export QNN_SDK_ROOT=${QNN_SDK_ROOT:-/tmp/qnn/2.28.0.241029}
1616
export EXECUTORCH_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"
1717

18-
# Workaround to avoid issues around missing flatccrt library (depending on the
19-
# number of jobs used), see issue #7300:
20-
# Build twice (second time with `--no_clean`) to make sure libflatccrt.a is
21-
# available.
22-
# TODO: Remove this workaround once the underlying issue is fixed.
23-
bash backends/qualcomm/scripts/build.sh --skip_aarch64 --job_number 2 --release || \
24-
bash backends/qualcomm/scripts/build.sh --skip_aarch64 --job_number 2 --release --no_clean
18+
parallelism=$(( $(nproc) - 1 ))
19+
bash backends/qualcomm/scripts/build.sh --skip_aarch64 --job_number ${parallelism} --release
2520
}
2621

2722
set_up_aot() {
@@ -33,13 +28,13 @@ set_up_aot() {
3328
cmake .. \
3429
-DCMAKE_INSTALL_PREFIX=$PWD \
3530
-DEXECUTORCH_BUILD_QNN=ON \
31+
-DANDROID_NATIVE_API_LEVEL=30 \
3632
-DQNN_SDK_ROOT=${QNN_SDK_ROOT} \
3733
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
3834
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
3935
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
4036
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
41-
-DPYTHON_EXECUTABLE=python3 \
42-
-DEXECUTORCH_SEPARATE_FLATCC_HOST_PROJECT=OFF
37+
-DPYTHON_EXECUTABLE=python3
4338
cmake --build $PWD --target "PyQnnManagerAdaptor" "PyQnnWrapperAdaptor" -j$(nproc)
4439
# install Python APIs to correct import path
4540
# The filename might vary depending on your Python and host version.

.ci/scripts/build_android_instrumentation.sh

Lines changed: 0 additions & 21 deletions
This file was deleted.

.ci/scripts/check_c10_sync.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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 -eux
9+
ls pytorch/.git || git clone https://github.com/pytorch/pytorch.git
10+
pytorch_pin="$(< .ci/docker/ci_commit_pins/pytorch.txt)"
11+
pushd pytorch
12+
git checkout "$pytorch_pin"
13+
popd
14+
"$(dirname "${BASH_SOURCE[0]}")"/compare_dirs.sh runtime/core/portable_type/c10/c10 pytorch/c10

.ci/scripts/compare_dirs.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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 -eux
9+
10+
# Check if dir1's files are also found in dir2 with the same
11+
# contents. Exempt files named BUCK, CMakeLists.txt, TARGETS, or
12+
# targets.bzl.
13+
14+
if [ $# -ne 2 ]; then
15+
echo "Usage: $0 dir1 dir2" >&2
16+
exit 1
17+
fi
18+
dir1="$1"
19+
dir2="$2"
20+
21+
if [ ! -d "$dir1" ] || [ ! -d "$dir2" ]; then
22+
echo "Error: Both directories must exist" >&2
23+
exit 1
24+
fi
25+
26+
exit_status=0
27+
while IFS= read -r -d '' file; do
28+
base=$(basename "$file")
29+
case "$base" in
30+
"BUCK"|"CMakeLists.txt"|"TARGETS"|"targets.bzl")
31+
continue
32+
;;
33+
esac
34+
# Construct the corresponding path in the second directory
35+
file2="$dir2/${file#$dir1/}"
36+
# Check if the corresponding file exists in the second directory
37+
if [ ! -f "$file2" ]; then
38+
echo "Error: File '$file' found in '$dir1' but not found in '$dir2'" >&2
39+
exit 1
40+
fi
41+
# Compare the contents of the two files using diff
42+
set +ex
43+
differences=$(diff -u -p "$file" "$file2")
44+
set -e # leave x off
45+
# If there are any differences, print an error message and exit with failure status
46+
if [ -n "$differences" ]; then
47+
echo "Error: Mismatch detected in file '$file':" >&2
48+
echo "$differences" >&2
49+
exit_status=1
50+
fi
51+
set -x
52+
done < <(find "$dir1" -type f -print0)
53+
54+
exit $exit_status

.ci/scripts/gather_benchmark_configs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@
2121
"apple_iphone_15": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/3b5acd2e-92e2-4778-b651-7726bafe129d",
2222
"apple_iphone_15+ios_18": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/12c8b15c-8d03-4e07-950d-0a627e7595b4",
2323
"samsung_galaxy_s22": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/e59f866a-30aa-4aa1-87b7-4510e5820dfa",
24+
"samsung_galaxy_s22_private": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/ea6b049d-1508-4233-9a56-5d9eacbe1078",
2425
"samsung_galaxy_s24": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/98f8788c-2e25-4a3c-8bb2-0d1e8897c0db",
2526
"google_pixel_8_pro": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/d65096ab-900b-4521-be8b-a3619b69236a",
27+
"google_pixel_3_private_rooted": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/98d23ca8-ea9e-4fb7-b725-d402017b198d",
28+
"apple_iphone_15_private": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/55929353-2f28-4ee5-bdff-d1a95f58cb28",
2629
}
2730

2831
# Predefined benchmark configurations

.ci/scripts/gather_test_models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from typing import Any
1515

1616
from examples.models import MODEL_NAME_TO_MODEL
17-
from examples.xnnpack import MODEL_NAME_TO_OPTIONS
17+
from examples.xnnpack import MODEL_NAME_TO_OPTIONS, QuantType
1818

1919
DEFAULT_RUNNERS = {
2020
"linux": "linux.2xlarge",
@@ -33,7 +33,7 @@
3333
"dl3": "linux.4xlarge.memory",
3434
"emformer_join": "linux.4xlarge.memory",
3535
"emformer_predict": "linux.4xlarge.memory",
36-
"phi-4-mini": "linux.4xlarge.memory",
36+
"phi_4_mini": "linux.4xlarge.memory",
3737
}
3838
}
3939

@@ -154,7 +154,7 @@ def export_models_for_ci() -> dict[str, dict]:
154154
if backend == "xnnpack":
155155
if name not in MODEL_NAME_TO_OPTIONS:
156156
continue
157-
if MODEL_NAME_TO_OPTIONS[name].quantization:
157+
if MODEL_NAME_TO_OPTIONS[name].quantization != QuantType.NONE:
158158
backend += "-quantization"
159159

160160
if MODEL_NAME_TO_OPTIONS[name].delegation:

.ci/scripts/setup-openvino.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 -ex
9+
10+
# shellcheck source=/dev/null
11+
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
12+
13+
git clone https://github.com/openvinotoolkit/openvino.git
14+
cd openvino && git checkout releases/2025/1
15+
git submodule update --init --recursive
16+
sudo ./install_build_dependencies.sh
17+
mkdir build && cd build
18+
cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_PYTHON=ON
19+
make -j$(nproc)
20+
21+
cd ..
22+
cmake --install build --prefix dist
23+
24+
source dist/setupvars.sh
25+
cd ../backends/openvino
26+
pip install -r requirements.txt
27+
cd scripts
28+
./openvino_build.sh --enable_python

.ci/scripts/test_ios_ci.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
set -e
99

10-
APP_PATH="examples/demo-apps/apple_ios/ExecuTorchDemo/ExecuTorchDemo"
10+
APP_PATH="executorch-examples/mv3/apple/ExecuTorchDemo/ExecuTorchDemo"
1111
MODEL_NAME="mv3"
1212
SIMULATOR_NAME="executorch"
1313

@@ -34,6 +34,10 @@ say() {
3434
echo -e "\033[1m\n\t** $1 **\n\033[0m"
3535
}
3636

37+
say "Cloning the Demo App"
38+
39+
git clone --depth 1 https://github.com/pytorch-labs/executorch-examples.git
40+
3741
say "Installing CoreML Backend Requirements"
3842

3943
./backends/apple/coreml/scripts/install_requirements.sh

.ci/scripts/test_llama.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ $PYTHON_EXECUTABLE -m examples.models.llama.export_llama ${EXPORT_ARGS}
269269

270270
# Create tokenizer.bin.
271271
echo "Creating tokenizer.bin"
272-
$PYTHON_EXECUTABLE -m extension.llm.tokenizer.tokenizer -t tokenizer.model -o tokenizer.bin
272+
$PYTHON_EXECUTABLE -m pytorch_tokenizers.tools.llama2c.convert -t tokenizer.model -o tokenizer.bin
273273

274274

275275
RUNTIME_ARGS="--model_path=${EXPORTED_MODEL_NAME} --tokenizer_path=tokenizer.bin --prompt=Once --temperature=0 --seq_len=10 --warmup=1"

.ci/scripts/test_llama_torchao_lowbit.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ cmake --build cmake-out/examples/models/llama -j16 --config Release
5555
download_stories_model_artifacts
5656

5757
echo "Creating tokenizer.bin"
58-
$PYTHON_EXECUTABLE -m extension.llm.tokenizer.tokenizer -t tokenizer.model -o tokenizer.bin
58+
$PYTHON_EXECUTABLE -m pytorch_tokenizers.tools.llama2c.convert -t tokenizer.model -o tokenizer.bin
5959

6060
# Export model
6161
LLAMA_CHECKPOINT=stories110M.pt
@@ -78,7 +78,6 @@ ${PYTHON_EXECUTABLE} -m examples.models.llama.export_llama \
7878
-qmode "torchao:8da${QLINEAR_BITWIDTH}w" \
7979
--group_size ${QLINEAR_GROUP_SIZE} \
8080
-E "torchao:${QEMBEDDING_BITWIDTH},${QEMBEDDING_GROUP_SIZE}" \
81-
--disable_dynamic_shape \
8281
-d fp32
8382

8483
# Test run

.ci/scripts/test_llava.sh

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ cmake_build_llava_runner_for_android() {
9393
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
9494
-DANDROID_ABI=arm64-v8a \
9595
${LLAVA_COMMON_CMAKE_ARGS} \
96-
-DCMAKE_PREFIX_PATH="$python_lib" \
97-
-DLLAVA_RUNNER_NO_TORCH_DUMMY_IMAGE=ON \
96+
-DCMAKE_PREFIX_PATH="$python_lib" \
9897
-B${BUILD_DIR}/${dir} \
9998
${dir}
10099

@@ -107,11 +106,10 @@ export_llava() {
107106
$PYTHON_EXECUTABLE -m executorch.examples.models.llava.export_llava --pte-name llava.pte --with-artifacts
108107
}
109108

110-
# Download a new image with different size, to test if the model can handle different image sizes
111-
prepare_image_tensor() {
109+
# Download a new image
110+
download_image() {
112111
echo "Downloading image"
113112
curl -o basketball.jpg https://upload.wikimedia.org/wikipedia/commons/7/73/Chicago_Bulls_and_New_Jersey_Nets%2C_March_28%2C_1991.jpg
114-
$PYTHON_EXECUTABLE -m executorch.examples.models.llava.image_util --image-path basketball.jpg --output-path image.pt
115113
}
116114

117115
run_and_verify() {
@@ -121,20 +119,18 @@ run_and_verify() {
121119
echo "Export failed. Abort"
122120
exit 1
123121
fi
124-
if [[ ! -f "image.pt" ]]; then
125-
echo "image.pt is missing."
122+
if [[ ! -f "basketball.jpg" ]]; then
123+
echo "basketball.jpg is missing."
126124
exit 1
127125
fi
128126
if [[ ! -f "tokenizer.bin" ]]; then
129127
echo "tokenizer.bin is missing."
130128
exit 1
131129
fi
132130

133-
134-
135131
RUNTIME_ARGS="--model_path=llava.pte \
136132
--tokenizer_path=tokenizer.bin \
137-
--image_path=image.pt \
133+
--image_path=basketball.jpg \
138134
--prompt=ASSISTANT: \
139135
--temperature=0 \
140136
--seq_len=650"
@@ -149,13 +145,8 @@ run_and_verify() {
149145

150146
# verify result.txt
151147
RESULT=$(cat result.txt)
152-
# set the expected prefix to be the same as prompt because there's a bug in sdpa_with_kv_cache that causes <unk> tokens.
153-
if [[ "$(uname)" == "Darwin" ]]; then
154-
EXPECTED_PREFIX="ASSISTANT: image captures a basketball game in progress, with several players on the court. One of the players is dribbling the ball, while the others are in various"
155-
else
156-
# set the expected prefix to be the same as prompt because there's a bug in sdpa_with_kv_cache that causes <unk> tokens.
157-
EXPECTED_PREFIX="ASSISTANT:"
158-
fi
148+
EXPECTED_PREFIX="ASSISTANT: image captures a basketball game in progress, with several players on the court. "
149+
159150
if [[ "${RESULT}" == *"${EXPECTED_PREFIX}"* ]]; then
160151
echo "Expected result prefix: ${EXPECTED_PREFIX}"
161152
echo "Actual result: ${RESULT}"
@@ -184,5 +175,5 @@ fi
184175
export_llava
185176

186177
# Step3. Run
187-
prepare_image_tensor
178+
download_image
188179
run_and_verify

0 commit comments

Comments
 (0)