Skip to content

Commit 470645d

Browse files
authored
Merge branch 'main' into pr_model_improve
2 parents e132e2c + 94a8bc7 commit 470645d

File tree

637 files changed

+17620
-6797
lines changed

Some content is hidden

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

637 files changed

+17620
-6797
lines changed
File renamed without changes.
File renamed without changes.

.Package.swift/backend_mps/dummy.swift

Whitespace-only changes.

.Package.swift/backend_mps_debug/dummy.swift

Whitespace-only changes.

.Package.swift/backend_xnnpack/dummy.swift

Whitespace-only changes.

.Package.swift/backend_xnnpack_debug/dummy.swift

Whitespace-only changes.

.Package.swift/executorch/dummy.swift

Whitespace-only changes.

.Package.swift/executorch_debug/dummy.swift

Whitespace-only changes.

.Package.swift/kernels_custom/dummy.swift

Whitespace-only changes.

.Package.swift/kernels_custom_debug/dummy.swift

Whitespace-only changes.

.Package.swift/kernels_optimized/dummy.swift

Whitespace-only changes.

.Package.swift/kernels_optimized_debug/dummy.swift

Whitespace-only changes.

.Package.swift/kernels_portable/dummy.swift

Whitespace-only changes.

.Package.swift/kernels_portable_debug/dummy.swift

Whitespace-only changes.

.Package.swift/kernels_quantized/dummy.swift

Whitespace-only changes.

.Package.swift/kernels_quantized_debug/dummy.swift

Whitespace-only changes.

.buckconfig

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

1213
[repository_aliases]
14+
bazel_skylib = shim
1315
config = prelude
1416
ovr_config = prelude
15-
toolchains = shim
16-
fbcode = shim
17+
toolchains = shim_et
18+
fbcode = shim_et
1719
fbcode_macros = shim
18-
fbsource = shim
20+
fbsource = shim_et
1921
buck = shim
22+
gh_facebook_buck2_shims_meta = shim
2023

2124
[cxx]
2225
cxxflags = -g -std=c++17

.ci/docker/ci_commit_pins/pytorch.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
27e35de6c288bffad1b4d18b393579c1d1a95547
1+
08434df1f2f88c9770e59246caa2ff9c6f613270

.ci/docker/common/install_java.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
apt-get update
11+
12+
apt-get install -y --no-install-recommends openjdk-17-jdk

.ci/docker/ubuntu/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ ARG BUCK2_VERSION
3030
COPY ./common/install_buck.sh install_buck.sh
3131
RUN bash ./install_buck.sh && rm install_buck.sh
3232

33+
# Install java
34+
COPY ./common/install_java.sh install_java.sh
35+
RUN bash ./install_java.sh && rm install_java.sh
36+
3337
# Setup user
3438
COPY ./common/install_user.sh install_user.sh
3539
RUN bash ./install_user.sh && rm install_user.sh

.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/setup-linux.sh

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,17 @@ set -exu
1010
# shellcheck source=/dev/null
1111
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
1212

13-
BUILD_TOOL=$1
14-
if [[ -z "${BUILD_TOOL:-}" ]]; then
15-
echo "Missing build tool (require buck2 or cmake), exiting..."
16-
exit 1
17-
else
18-
echo "Setup Linux for ${BUILD_TOOL} ..."
19-
fi
13+
read -r BUILD_TOOL BUILD_MODE EDITABLE < <(parse_args "$@")
2014

2115
# As Linux job is running inside a Docker container, all of its dependencies
2216
# have already been installed, so we use PyTorch build from source here instead
2317
# of nightly. This allows CI to test against latest commits from PyTorch
24-
install_executorch "use-pt-pinned-commit"
25-
build_executorch_runner "${BUILD_TOOL}" "${2:-Release}"
18+
if [[ "${EDITABLE:-false}" == "true" ]]; then
19+
install_executorch --use-pt-pinned-commit --editable
20+
else
21+
install_executorch --use-pt-pinned-commit
22+
fi
23+
build_executorch_runner "${BUILD_TOOL}" "${BUILD_MODE}"
2624

2725
if [[ "${GITHUB_BASE_REF:-}" == *main* || "${GITHUB_BASE_REF:-}" == *gh* ]]; then
2826
do_not_use_nightly_on_ci

.ci/scripts/setup-macos.sh

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,7 @@ set -exu
1010
# shellcheck source=/dev/null
1111
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
1212

13-
BUILD_TOOL=$1
14-
if [[ -z "${BUILD_TOOL:-}" ]]; then
15-
echo "Missing build tool (require buck2 or cmake), exiting..."
16-
exit 1
17-
else
18-
echo "Setup MacOS for ${BUILD_TOOL} ..."
19-
fi
13+
read -r BUILD_TOOL BUILD_MODE EDITABLE < <(parse_args "$@")
2014

2115
install_buck() {
2216
if ! command -v zstd &> /dev/null; then
@@ -135,8 +129,12 @@ print_cmake_info
135129
install_pytorch_and_domains
136130
# We build PyTorch from source here instead of using nightly. This allows CI to test against
137131
# the pinned commit from PyTorch
138-
install_executorch "use-pt-pinned-commit"
139-
build_executorch_runner "${BUILD_TOOL}" "${2:-Release}"
132+
if [[ "$EDITABLE" == "true" ]]; then
133+
install_executorch --use-pt-pinned-commit --editable
134+
else
135+
install_executorch --use-pt-pinned-commit
136+
fi
137+
build_executorch_runner "${BUILD_TOOL}" "${BUILD_MODE}"
140138

141139
if [[ "${GITHUB_BASE_REF:-}" == *main* || "${GITHUB_BASE_REF:-}" == *gh* ]]; then
142140
do_not_use_nightly_on_ci

.ci/scripts/test_ane_static_llama.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
# Copyright (c) Qualcomm Innovation Center, Inc.
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 -exu
9+
10+
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
11+
12+
export EXECUTORCH_ROOT="$(dirname "${BASH_SOURCE[0]}")/../.."
13+
14+
if [[ -z "${PYTHON_EXECUTABLE:-}" ]]; then
15+
PYTHON_EXECUTABLE=python3
16+
fi
17+
18+
which "${PYTHON_EXECUTABLE}"
19+
20+
pushd $EXECUTORCH_ROOT/examples/apple/coreml/llama
21+
22+
# Download stories llama110m artifacts
23+
download_stories_model_artifacts
24+
25+
python export.py -n model.pte -p params.json -c stories110M.pt --seq_length 32 --max_seq_length 64 --dtype fp16 --coreml-quantize c4w
26+
27+
popd

.ci/scripts/test_model.sh

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,26 @@ 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+
if [[ "${MODEL_NAME}" == "phi-4-mini" ]]; then
104+
# Install requirements for export_llama
105+
bash examples/models/llama/install_requirements.sh
106+
# Test export_llama script: python3 -m examples.models.llama.export_llama.
107+
"${PYTHON_EXECUTABLE}" -m examples.models.llama.export_llama --model "${MODEL_NAME}" -c examples/models/llama/params/demo_rand_params.pth -p examples/models/phi-4-mini/config.json
108+
run_portable_executor_runner
109+
rm "./${MODEL_NAME}.pte"
110+
return
111+
fi
112+
113+
# Export a basic .pte and run the model.
95114
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export --model_name="${MODEL_NAME}" "${STRICT}"
96115
run_portable_executor_runner
97116
}
@@ -154,6 +173,7 @@ test_model_with_qnn() {
154173
export LD_LIBRARY_PATH=$QNN_SDK_ROOT/lib/x86_64-linux-clang/
155174
export PYTHONPATH=$EXECUTORCH_ROOT/..
156175

176+
EXTRA_FLAGS=""
157177
if [[ "${MODEL_NAME}" == "dl3" ]]; then
158178
EXPORT_SCRIPT=deeplab_v3
159179
elif [[ "${MODEL_NAME}" == "mv3" ]]; then
@@ -166,6 +186,12 @@ test_model_with_qnn() {
166186
EXPORT_SCRIPT=inception_v3
167187
elif [[ "${MODEL_NAME}" == "vit" ]]; then
168188
EXPORT_SCRIPT=torchvision_vit
189+
elif [[ "${MODEL_NAME}" == "mb" ]]; then
190+
EXPORT_SCRIPT=mobilebert_fine_tune
191+
EXTRA_FLAGS="--num_epochs 1"
192+
pip install scikit-learn
193+
elif [[ "${MODEL_NAME}" == "w2l" ]]; then
194+
EXPORT_SCRIPT=wav2letter
169195
elif [[ "${MODEL_NAME}" == "edsr" ]]; then
170196
EXPORT_SCRIPT=edsr
171197
# Additional deps for edsr
@@ -179,7 +205,7 @@ test_model_with_qnn() {
179205
# TODO(guangyang): Make QNN chipset matches the target device
180206
QNN_CHIPSET=SM8450
181207

182-
"${PYTHON_EXECUTABLE}" -m examples.qualcomm.scripts.${EXPORT_SCRIPT} -b ${CMAKE_OUTPUT_DIR} -m ${QNN_CHIPSET} --compile_only
208+
"${PYTHON_EXECUTABLE}" -m examples.qualcomm.scripts.${EXPORT_SCRIPT} -b ${CMAKE_OUTPUT_DIR} -m ${QNN_CHIPSET} --compile_only $EXTRA_FLAGS
183209
EXPORTED_MODEL=$(find "./${EXPORT_SCRIPT}" -type f -name "${MODEL_NAME}*.pte" -print -quit)
184210
}
185211

.ci/scripts/unittest-buck2.sh

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

99
# TODO: expand this to //...
10-
buck2 query //runtime/...
10+
# TODO: can't query cadence & vulkan backends
11+
buck2 query "//backends/apple/... + //backends/example/... + \
12+
//backends/mediatek/... + //backends/test/... + //backends/transforms/... + \
13+
//backends/xnnpack/... + //configurations/... + //kernels/portable/cpu/... + \
14+
//runtime/... + //schema/... + //test/... + //util/..."
1115

1216
# TODO: expand the covered scope of Buck targets.
1317
buck2 build //runtime/core/portable_type/...

.ci/scripts/unittest-linux.sh

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,36 @@
66
# LICENSE file in the root directory of this source tree.
77
set -eux
88

9-
BUILD_TOOL=$1
10-
if [[ $BUILD_TOOL =~ ^(cmake|buck2)$ ]]; then
11-
echo "Running unittests for ${BUILD_TOOL} ..."
12-
else
13-
echo "Missing build tool (require buck2 or cmake), exiting..."
14-
exit 1
15-
fi
9+
# shellcheck source=/dev/null
10+
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
1611

17-
BUILD_MODE=$2
18-
if [[ "${BUILD_MODE:-}" =~ ^(Debug|Release)$ ]]; then
19-
echo "Running tests in build mode ${BUILD_MODE} ..."
20-
else
21-
echo "Unsupported build mode ${BUILD_MODE}, options are Debug or Release."
22-
exit 1
23-
fi
12+
read -r BUILD_TOOL BUILD_MODE EDITABLE < <(parse_args "$@")
2413

2514
# The generic Linux job chooses to use base env, not the one setup by the image
2615
eval "$(conda shell.bash hook)"
2716
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
2817
conda activate "${CONDA_ENV}"
2918

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

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"
23+
PYTHON_EXECUTABLE=python \
24+
EXECUTORCH_BUILD_PYBIND=ON \
25+
CMAKE_ARGS="-DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
26+
.ci/scripts/setup-linux.sh "$@"
3727

38-
# Install llama3_2_vision dependencies.
39-
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
28+
# Install llama3_2_vision dependencies.
29+
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
4030

41-
if [[ "$BUILD_TOOL" == "cmake" ]]; then
4231
.ci/scripts/unittest-linux-cmake.sh
4332
elif [[ "$BUILD_TOOL" == "buck2" ]]; then
33+
# Removing this breaks sccache in the Buck build, apparently
34+
# because TMPDIR gets messed up? Please feel free to fix this and
35+
# speed up this CI job!
36+
PYTHON_EXECUTABLE=python \
37+
.ci/scripts/setup-linux.sh "$@"
38+
4439
.ci/scripts/unittest-buck2.sh
4540
else
4641
echo "Unknown build tool $BUILD_TOOL"

.ci/scripts/unittest-macos.sh

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,10 @@
66
# LICENSE file in the root directory of this source tree.
77
set -eux
88

9-
BUILD_TOOL=$1
10-
if [[ $BUILD_TOOL =~ ^(cmake|buck2)$ ]]; then
11-
echo "Running unittests for ${BUILD_TOOL} ..."
12-
else
13-
echo "Missing build tool (require buck2 or cmake), exiting..."
14-
exit 1
15-
fi
9+
# shellcheck source=/dev/null
10+
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
1611

17-
BUILD_MODE=$2
18-
if [[ $BUILD_MODE =~ ^(Debug|Release)$ ]]; then
19-
echo "Running tests in build mode ${BUILD_MODE} ..."
20-
else
21-
echo "Unsupported build mode ${BUILD_MODE}, options are Debug or Release."
22-
exit 1
23-
fi
12+
read -r BUILD_TOOL BUILD_MODE EDITABLE < <(parse_args "$@")
2413

2514
bash .ci/scripts/setup-conda.sh
2615
eval "$(conda shell.bash hook)"
@@ -30,19 +19,19 @@ export TMP_DIR=$(mktemp -d)
3019
export PATH="${TMP_DIR}:$PATH"
3120
trap 'rm -rfv ${TMP_DIR}' EXIT
3221

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}"
22+
if [[ "$BUILD_TOOL" == "cmake" ]]; then
23+
# Setup MacOS dependencies as there is no Docker support on MacOS atm
24+
PYTHON_EXECUTABLE=python \
25+
EXECUTORCH_BUILD_PYBIND=ON \
26+
CMAKE_ARGS="-DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_MPS=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
27+
${CONDA_RUN} --no-capture-output \
28+
.ci/scripts/setup-macos.sh "$@"
3929

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
30+
# Install llama3_2_vision dependencies.
31+
PYTHON_EXECUTABLE=python \
32+
${CONDA_RUN} --no-capture-output \
33+
./examples/models/llama3_2_vision/install_requirements.sh
4434

45-
if [[ "$BUILD_TOOL" == "cmake" ]]; then
4635
.ci/scripts/unittest-macos-cmake.sh
4736
elif [[ "$BUILD_TOOL" == "buck2" ]]; then
4837
.ci/scripts/unittest-buck2.sh

0 commit comments

Comments
 (0)