Skip to content

Commit e566706

Browse files
authored
Merge branch 'main' into main
2 parents c3f3266 + e37129d commit e566706

File tree

225 files changed

+4134
-3023
lines changed

Some content is hidden

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

225 files changed

+4134
-3023
lines changed

.buckconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
shim_et = shim_et
1212

1313
[repository_aliases]
14+
bazel_skylib = shim
1415
config = prelude
1516
ovr_config = prelude
1617
toolchains = shim_et
1718
fbcode = shim_et
18-
fbcode_macros = shim_et
19+
fbcode_macros = shim
1920
fbsource = shim_et
2021
buck = shim
22+
gh_facebook_buck2_shims_meta = shim
2123

2224
[cxx]
2325
cxxflags = -g -std=c++17

.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
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: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ test_model() {
100100
rm "./${MODEL_NAME}.pte"
101101
return # Skip running with portable executor runnner since portable doesn't support Qwen's biased linears.
102102
fi
103+
if [[ "${MODEL_NAME}" == "phi4_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+
fi
103111

104112
# Export a basic .pte and run the model.
105113
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export --model_name="${MODEL_NAME}" "${STRICT}"
@@ -164,6 +172,7 @@ test_model_with_qnn() {
164172
export LD_LIBRARY_PATH=$QNN_SDK_ROOT/lib/x86_64-linux-clang/
165173
export PYTHONPATH=$EXECUTORCH_ROOT/..
166174

175+
EXTRA_FLAGS=""
167176
if [[ "${MODEL_NAME}" == "dl3" ]]; then
168177
EXPORT_SCRIPT=deeplab_v3
169178
elif [[ "${MODEL_NAME}" == "mv3" ]]; then
@@ -176,6 +185,12 @@ test_model_with_qnn() {
176185
EXPORT_SCRIPT=inception_v3
177186
elif [[ "${MODEL_NAME}" == "vit" ]]; then
178187
EXPORT_SCRIPT=torchvision_vit
188+
elif [[ "${MODEL_NAME}" == "mb" ]]; then
189+
EXPORT_SCRIPT=mobilebert_fine_tune
190+
EXTRA_FLAGS="--num_epochs 1"
191+
pip install scikit-learn
192+
elif [[ "${MODEL_NAME}" == "w2l" ]]; then
193+
EXPORT_SCRIPT=wav2letter
179194
elif [[ "${MODEL_NAME}" == "edsr" ]]; then
180195
EXPORT_SCRIPT=edsr
181196
# Additional deps for edsr
@@ -189,7 +204,7 @@ test_model_with_qnn() {
189204
# TODO(guangyang): Make QNN chipset matches the target device
190205
QNN_CHIPSET=SM8450
191206

192-
"${PYTHON_EXECUTABLE}" -m examples.qualcomm.scripts.${EXPORT_SCRIPT} -b ${CMAKE_OUTPUT_DIR} -m ${QNN_CHIPSET} --compile_only
207+
"${PYTHON_EXECUTABLE}" -m examples.qualcomm.scripts.${EXPORT_SCRIPT} -b ${CMAKE_OUTPUT_DIR} -m ${QNN_CHIPSET} --compile_only $EXTRA_FLAGS
193208
EXPORTED_MODEL=$(find "./${EXPORT_SCRIPT}" -type f -name "${MODEL_NAME}*.pte" -print -quit)
194209
}
195210

.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: 5 additions & 16 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
# The generic Linux job chooses to use base env, not the one setup by the image
2615
eval "$(conda shell.bash hook)"
@@ -34,7 +23,7 @@ if [[ "$BUILD_TOOL" == "cmake" ]]; then
3423
PYTHON_EXECUTABLE=python \
3524
EXECUTORCH_BUILD_PYBIND=ON \
3625
CMAKE_ARGS="-DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
37-
.ci/scripts/setup-linux.sh "$BUILD_TOOL" "$BUILD_MODE"
26+
.ci/scripts/setup-linux.sh "$@"
3827

3928
# Install llama3_2_vision dependencies.
4029
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
@@ -45,7 +34,7 @@ elif [[ "$BUILD_TOOL" == "buck2" ]]; then
4534
# because TMPDIR gets messed up? Please feel free to fix this and
4635
# speed up this CI job!
4736
PYTHON_EXECUTABLE=python \
48-
.ci/scripts/setup-linux.sh "$BUILD_TOOL" "$BUILD_MODE"
37+
.ci/scripts/setup-linux.sh "$@"
4938

5039
.ci/scripts/unittest-buck2.sh
5140
else

.ci/scripts/unittest-macos.sh

Lines changed: 4 additions & 15 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)"
@@ -36,7 +25,7 @@ if [[ "$BUILD_TOOL" == "cmake" ]]; then
3625
EXECUTORCH_BUILD_PYBIND=ON \
3726
CMAKE_ARGS="-DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_MPS=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
3827
${CONDA_RUN} --no-capture-output \
39-
.ci/scripts/setup-macos.sh "${BUILD_TOOL}" "${BUILD_MODE}"
28+
.ci/scripts/setup-macos.sh "$@"
4029

4130
# Install llama3_2_vision dependencies.
4231
PYTHON_EXECUTABLE=python \

.ci/scripts/utils.sh

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ install_executorch() {
2424
which pip
2525
# Install executorch, this assumes that Executorch is checked out in the
2626
# current directory.
27-
if [[ "${1:-}" == "use-pt-pinned-commit" ]]; then
28-
./install_executorch.sh --pybind xnnpack --use-pt-pinned-commit
29-
else
30-
./install_executorch.sh --pybind xnnpack
31-
fi
27+
./install_executorch.sh --pybind xnnpack "$@"
3228
# Just print out the list of packages for debugging
3329
pip list
3430
}
@@ -166,3 +162,52 @@ do_not_use_nightly_on_ci() {
166162
exit 1
167163
fi
168164
}
165+
166+
167+
parse_args() {
168+
local args=("$@")
169+
local i
170+
local BUILD_TOOL=""
171+
local BUILD_MODE=""
172+
local EDITABLE=""
173+
for ((i=0; i<${#args[@]}; i++)); do
174+
case "${args[$i]}" in
175+
--build-tool)
176+
BUILD_TOOL="${args[$((i+1))]}"
177+
i=$((i+1))
178+
;;
179+
--build-mode)
180+
BUILD_MODE="${args[$((i+1))]}"
181+
i=$((i+1))
182+
;;
183+
--editable)
184+
EDITABLE="${args[$((i+1))]}"
185+
i=$((i+1))
186+
;;
187+
*)
188+
echo "Invalid argument: ${args[$i]}"
189+
exit 1
190+
;;
191+
esac
192+
done
193+
194+
if [ -z "$BUILD_TOOL" ]; then
195+
echo "Missing build tool (require buck2 or cmake), exiting..."
196+
exit 1
197+
elif ! [[ $BUILD_TOOL =~ ^(cmake|buck2)$ ]]; then
198+
echo "Require buck2 or cmake for --build-tool, got ${BUILD_TOOL}, exiting..."
199+
exit 1
200+
fi
201+
BUILD_MODE="${BUILD_MODE:-Release}"
202+
if ! [[ "$BUILD_MODE" =~ ^(Debug|Release)$ ]]; then
203+
echo "Unsupported build mode ${BUILD_MODE}, options are Debug or Release."
204+
exit 1
205+
fi
206+
EDITABLE="${EDITABLE:-false}"
207+
if ! [[ $EDITABLE =~ ^(true|false)$ ]]; then
208+
echo "Require true or false for --editable, got ${EDITABLE}, exiting..."
209+
exit 1
210+
fi
211+
212+
echo "$BUILD_TOOL $BUILD_MODE $EDITABLE"
213+
}

.github/workflows/_android.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
# The generic Linux job chooses to use base env, not the one setup by the image
2626
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
2727
conda activate "${CONDA_ENV}"
28-
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh buck2
28+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool buck2
2929
export ARTIFACTS_DIR_NAME=artifacts-to-be-uploaded
3030
3131
# Build LLM Demo for Android

0 commit comments

Comments
 (0)