Skip to content

Commit d7284e9

Browse files
Merge branch 'main' into fix-lifted-constants-with-no-user-input
2 parents 36f9903 + 19a3002 commit d7284e9

File tree

830 files changed

+27886
-9271
lines changed

Some content is hidden

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

830 files changed

+27886
-9271
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/common/install_base.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ install_ubuntu() {
2626
libssl-dev \
2727
zip
2828

29+
# These libraries are needed by TorchVision
30+
apt-get install -y --no-install-recommends \
31+
libjpeg-dev \
32+
libpng-dev
33+
2934
# Cleanup package manager
3035
apt-get autoclean && apt-get clean
3136
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

.ci/docker/common/install_conda.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,16 @@ install_miniconda() {
3131

3232
install_python() {
3333
pushd /opt/conda
34-
# Install the correct Python version
34+
# Install the selected Python version for CI jobs
3535
as_ci_user conda create -n "py_${PYTHON_VERSION}" -y --file /opt/conda/conda-env-ci.txt python="${PYTHON_VERSION}"
36+
37+
# From https://github.com/pytorch/pytorch/blob/main/.ci/docker/common/install_conda.sh
38+
if [[ $(uname -m) == "aarch64" ]]; then
39+
conda_install "openblas==0.3.28=*openmp*"
40+
else
41+
conda_install mkl=2022.1.0 mkl-include=2022.1.0
42+
fi
43+
3644
popd
3745
}
3846

@@ -53,7 +61,7 @@ fix_conda_ubuntu_libstdcxx() {
5361
# PyTorch sev: https://github.com/pytorch/pytorch/issues/105248
5462
# Ref: https://github.com/pytorch/pytorch/blob/main/.ci/docker/common/install_conda.sh
5563
if grep -e "2[02].04." /etc/issue >/dev/null; then
56-
rm "/opt/conda/envs/py_${PYTHON_VERSION}/lib/libstdc++.so.6"
64+
rm /opt/conda/envs/py_${PYTHON_VERSION}/lib/libstdc++.so*
5765
fi
5866
}
5967

.ci/scripts/build_llama_android.sh

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

13+
if [[ -z "${PYTHON_EXECUTABLE:-}" ]]; then
14+
PYTHON_EXECUTABLE=python3
15+
fi
16+
which "${PYTHON_EXECUTABLE}"
17+
1318
install_executorch_and_backend_lib() {
1419
echo "Installing executorch and xnnpack backend"
1520
clean_executorch_install_folders

.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}"
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}"
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_llava.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ fi
3030
NPROC=8
3131
if hash nproc &> /dev/null; then NPROC=$(nproc); fi
3232

33+
python_lib=$($PYTHON_EXECUTABLE -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')
3334
EXECUTORCH_COMMON_CMAKE_ARGS=" \
3435
-DCMAKE_INSTALL_PREFIX=${BUILD_DIR} \
35-
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
36+
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
3637
-DEXECUTORCH_ENABLE_LOGGING=ON \
3738
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
3839
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
@@ -92,7 +93,7 @@ cmake_build_llava_runner_for_android() {
9293
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
9394
-DANDROID_ABI=arm64-v8a \
9495
${LLAVA_COMMON_CMAKE_ARGS} \
95-
-DCMAKE_PREFIX_PATH="$python_lib" \
96+
-DCMAKE_PREFIX_PATH="$python_lib" \
9697
-DLLAVA_RUNNER_NO_TORCH_DUMMY_IMAGE=ON \
9798
-B${BUILD_DIR}/${dir} \
9899
${dir}

.ci/scripts/test_model.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,29 @@ 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+
104+
# Export a basic .pte and run the model.
95105
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export --model_name="${MODEL_NAME}" "${STRICT}"
96106
run_portable_executor_runner
97107
}
98108

99109
build_cmake_xnn_executor_runner() {
100110
echo "Building xnn_executor_runner"
101-
SITE_PACKAGES="$(${PYTHON_EXECUTABLE} -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
102-
CMAKE_PREFIX_PATH="${SITE_PACKAGES}/torch"
103111

104112
(rm -rf ${CMAKE_OUTPUT_DIR} \
105113
&& mkdir ${CMAKE_OUTPUT_DIR} \
106114
&& cd ${CMAKE_OUTPUT_DIR} \
107115
&& retry cmake -DCMAKE_BUILD_TYPE=Release \
108116
-DEXECUTORCH_BUILD_XNNPACK=ON \
109-
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \
110117
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" ..)
111118

112119
cmake --build ${CMAKE_OUTPUT_DIR} -j4

.ci/scripts/test_qnn_static_llama.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
13+
export QNN_SDK_ROOT=/tmp/qnn/2.28.0.241029
14+
export LD_LIBRARY_PATH="${QNN_SDK_ROOT}/lib/x86_64-linux-clang"
15+
export PYTHONPATH=".."
16+
cp schema/program.fbs exir/_serialize/program.fbs
17+
cp schema/scalar_type.fbs exir/_serialize/scalar_type.fbs
18+
cp -f build-x86/backends/qualcomm/PyQnnManagerAdaptor.cpython-310-x86_64-linux-gnu.so backends/qualcomm/python
19+
cp -f build-x86/backends/qualcomm/PyQnnWrapperAdaptor.cpython-310-x86_64-linux-gnu.so backends/qualcomm/python
20+
21+
if [[ -z "${PYTHON_EXECUTABLE:-}" ]]; then
22+
PYTHON_EXECUTABLE=python3
23+
fi
24+
25+
which "${PYTHON_EXECUTABLE}"
26+
27+
# Although static llama CI does not require graphviz, it is required by test_qnn_delegate.py
28+
pip install graphviz
29+
30+
# Download stories llama110m artifacts
31+
download_stories_model_artifacts
32+
echo "Creating tokenizer.bin"
33+
$PYTHON_EXECUTABLE -m extension.llm.tokenizer.tokenizer -t tokenizer.model -o tokenizer.bin
34+
35+
set +e
36+
# Compile only as weight sharing is not applicable on x86
37+
$PYTHON_EXECUTABLE backends/qualcomm/tests/test_qnn_delegate.py -k TestExampleLLMScript.test_llama_stories_110m --model SM8650 --build_folder build-android/ --executorch_root . --artifact_dir . --llama_artifacts . --compile_only
38+
exit_code1=$?
39+
40+
# Checks accuracy with weight sharing disabled since x86 does not support weight sharing.
41+
$PYTHON_EXECUTABLE backends/qualcomm/tests/test_qnn_delegate.py -k TestExampleLLMScript.test_llama_stories_110m --model SM8650 --build_folder build-x86/ --executorch_root . --artifact_dir . --llama_artifacts . --enable_x86_64
42+
exit_code2=$?
43+
44+
# Check the exit codes and print messages
45+
if [ $exit_code1 -ne 0 ]; then
46+
echo "Static Llama compile only with weight sharing test failed. $exit_code1."
47+
fi
48+
49+
if [ $exit_code2 -ne 0 ]; then
50+
echo "Static Llama accuracy test failed. $exit_code2."
51+
fi
52+
53+
# Return failure if either program failed
54+
if [ $exit_code1 -ne 0 ] || [ $exit_code2 -ne 0 ]; then
55+
exit 1
56+
else
57+
exit 0
58+
fi
59+
set -e

.ci/scripts/test_quantized_aot_lib.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@ CMAKE_OUTPUT_DIR=cmake-out
1616

1717
build_cmake_quantized_aot_lib() {
1818
echo "Building quantized aot lib"
19-
SITE_PACKAGES="$(${PYTHON_EXECUTABLE} -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
20-
CMAKE_PREFIX_PATH="${SITE_PACKAGES}/torch"
2119
(rm -rf ${CMAKE_OUTPUT_DIR} \
2220
&& mkdir ${CMAKE_OUTPUT_DIR} \
2321
&& cd ${CMAKE_OUTPUT_DIR} \
2422
&& retry cmake -DCMAKE_BUILD_TYPE=Release \
25-
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \
2623
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED_AOT=ON \
2724
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" ..)
2825

.ci/scripts/unittest-buck2.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env 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+
set -eux
8+
9+
# TODO: expand this to //...
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/..."
15+
16+
# TODO: expand the covered scope of Buck targets.
17+
buck2 build //runtime/core/portable_type/...
18+
buck2 test //runtime/core/portable_type/...

.ci/scripts/unittest-linux-cmake.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env 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+
set -eux
8+
9+
# Run pytest with coverage
10+
pytest -n auto --cov=./ --cov-report=xml
11+
# Run gtest
12+
LLVM_PROFDATA=llvm-profdata-12 LLVM_COV=llvm-cov-12 \
13+
test/run_oss_cpp_tests.sh

.ci/scripts/unittest-linux.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env 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+
set -eux
8+
9+
# shellcheck source=/dev/null
10+
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
11+
12+
read -r BUILD_TOOL BUILD_MODE EDITABLE < <(parse_args "$@")
13+
14+
# The generic Linux job chooses to use base env, not the one setup by the image
15+
eval "$(conda shell.bash hook)"
16+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
17+
conda activate "${CONDA_ENV}"
18+
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
22+
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 "$@"
27+
28+
# Install llama3_2_vision dependencies.
29+
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
30+
31+
.ci/scripts/unittest-linux-cmake.sh
32+
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+
39+
.ci/scripts/unittest-buck2.sh
40+
else
41+
echo "Unknown build tool $BUILD_TOOL"
42+
exit 1
43+
fi

.ci/scripts/unittest-macos-cmake.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env 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+
set -eux
8+
9+
# Run pytest with coverage
10+
${CONDA_RUN} pytest -n auto --cov=./ --cov-report=xml
11+
# Run gtest
12+
LLVM_PROFDATA="xcrun llvm-profdata" LLVM_COV="xcrun llvm-cov" \
13+
${CONDA_RUN} test/run_oss_cpp_tests.sh

0 commit comments

Comments
 (0)