Skip to content

Commit 5dc5c17

Browse files
authored
Merge branch 'main' into dev1/hutton/enable_ARN_mode
2 parents a71631f + 0add080 commit 5dc5c17

File tree

219 files changed

+5550
-1692
lines changed

Some content is hidden

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

219 files changed

+5550
-1692
lines changed

.buckconfig

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

1213
[repository_aliases]
1314
config = prelude
1415
ovr_config = prelude
15-
toolchains = shim
16-
fbcode = shim
17-
fbcode_macros = shim
18-
fbsource = shim
16+
toolchains = shim_et
17+
fbcode = shim_et
18+
fbcode_macros = shim_et
19+
fbsource = shim_et
1920
buck = shim
2021

2122
[cxx]

.ci/scripts/gather_test_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def model_should_run_on_event(model: str, event: str) -> bool:
9090
We put higher priority and fast models to pull request and rest to push.
9191
"""
9292
if event == "pull_request":
93-
return model in ["mv3", "vit"]
93+
return model in ["mv3", "vit", "qwen2_5"] # TODO: remove, just to test the ci
9494
elif event == "push":
9595
# These are super slow. Only run it periodically
9696
return model not in ["dl3", "edsr", "emformer_predict"]

.ci/scripts/setup-linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fi
2222
# have already been installed, so we use PyTorch build from source here instead
2323
# of nightly. This allows CI to test against latest commits from PyTorch
2424
install_executorch "use-pt-pinned-commit"
25-
build_executorch_runner "${BUILD_TOOL}"
25+
build_executorch_runner "${BUILD_TOOL}" "${2:-Release}"
2626

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

.ci/scripts/setup-macos.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ install_pytorch_and_domains
136136
# We build PyTorch from source here instead of using nightly. This allows CI to test against
137137
# the pinned commit from PyTorch
138138
install_executorch "use-pt-pinned-commit"
139-
build_executorch_runner "${BUILD_TOOL}"
139+
build_executorch_runner "${BUILD_TOOL}" "${2:-Release}"
140140

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

.ci/scripts/test_model.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,17 @@ 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
}

.ci/scripts/unittest-buck2.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
buck2 query //runtime/...
11+
12+
# TODO: expand the covered scope of Buck targets.
13+
buck2 build //runtime/core/portable_type/...
14+
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: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
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
16+
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
24+
25+
# The generic Linux job chooses to use base env, not the one setup by the image
26+
eval "$(conda shell.bash hook)"
27+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
28+
conda activate "${CONDA_ENV}"
29+
30+
# Setup swiftshader and Vulkan SDK which are required to build the Vulkan delegate
31+
source .ci/scripts/setup-vulkan-linux-deps.sh
32+
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"
37+
38+
# Install llama3_2_vision dependencies.
39+
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
40+
41+
if [[ "$BUILD_TOOL" == "cmake" ]]; then
42+
.ci/scripts/unittest-linux-cmake.sh
43+
elif [[ "$BUILD_TOOL" == "buck2" ]]; then
44+
.ci/scripts/unittest-buck2.sh
45+
else
46+
echo "Unknown build tool $BUILD_TOOL"
47+
exit 1
48+
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

.ci/scripts/unittest-macos.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
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
16+
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
24+
25+
bash .ci/scripts/setup-conda.sh
26+
eval "$(conda shell.bash hook)"
27+
28+
# Create temp directory for sccache shims
29+
export TMP_DIR=$(mktemp -d)
30+
export PATH="${TMP_DIR}:$PATH"
31+
trap 'rm -rfv ${TMP_DIR}' EXIT
32+
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}"
39+
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
44+
45+
if [[ "$BUILD_TOOL" == "cmake" ]]; then
46+
.ci/scripts/unittest-macos-cmake.sh
47+
elif [[ "$BUILD_TOOL" == "buck2" ]]; then
48+
.ci/scripts/unittest-buck2.sh
49+
else
50+
echo "Unknown build tool $BUILD_TOOL"
51+
exit 1
52+
fi

.ci/scripts/utils.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ build_executorch_runner_cmake() {
109109
pushd "${CMAKE_OUTPUT_DIR}" || return
110110
# This command uses buck2 to gather source files and buck2 could crash flakily
111111
# on MacOS
112-
retry cmake -DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}" -DCMAKE_BUILD_TYPE=Release ..
112+
retry cmake -DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}" -DCMAKE_BUILD_TYPE="${1:-Release}" ..
113113
popd || return
114114

115115
if [ "$(uname)" == "Darwin" ]; then
@@ -124,7 +124,7 @@ build_executorch_runner() {
124124
if [[ $1 == "buck2" ]]; then
125125
build_executorch_runner_buck2
126126
elif [[ $1 == "cmake" ]]; then
127-
build_executorch_runner_cmake
127+
build_executorch_runner_cmake "$2"
128128
else
129129
echo "Invalid build tool $1. Only buck2 and cmake are supported atm"
130130
exit 1

.github/ISSUE_TEMPLATE/bug-report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ body:
2121
A clear and concise description of what the bug is.
2222
2323
```python
24-
# Sample code to reproduce the problem
24+
# Sample code to reproduce the problem. If applicable, also include your model export command.
2525
```
2626
2727
```

.github/scripts/extract_benchmark_results.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,21 +229,22 @@ def extract_ios_metric(
229229

230230
elif method == "forward":
231231
if metric_name == "Clock Monotonic Time, s":
232-
benchmark_result["metric"] = (
233-
"generate_time(ms)"
234-
if "llama" in test_name
235-
else "avg_inference_latency(ms)"
236-
)
232+
benchmark_result["metric"] = "avg_inference_latency(ms)"
237233
benchmark_result["actualValue"] = metric_value * 1000
238234

239235
elif metric_name == "Memory Peak Physical, kB":
240236
# NB: Showing the value in mB is friendlier IMO
241237
benchmark_result["metric"] = "peak_inference_mem_usage(mb)"
242238
benchmark_result["actualValue"] = metric_value / 1024
243239

244-
elif method == "generate" and metric_name == "Tokens Per Second, t/s":
245-
benchmark_result["metric"] = "token_per_sec"
246-
benchmark_result["actualValue"] = metric_value
240+
elif method == "generate":
241+
if metric_name == "Clock Monotonic Time, s":
242+
benchmark_result["metric"] = "generate_time(ms)"
243+
benchmark_result["actualValue"] = metric_value * 1000
244+
245+
elif metric_name == "Tokens Per Second, t/s":
246+
benchmark_result["metric"] = "token_per_sec"
247+
benchmark_result["actualValue"] = metric_value
247248

248249
return benchmark_result
249250

.github/workflows/_unittest.yml

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ on:
77
required: true
88
type: string
99
description: Name of the docker image to use.
10+
build-mode:
11+
required: true
12+
type: string
13+
description: Build mode to use, Debug or Release.
14+
build-tool:
15+
required: true
16+
type: string
17+
description: Build tool to use, cmake or buck2.
1018
python-version:
1119
required: false
1220
type: string
@@ -26,28 +34,7 @@ jobs:
2634
timeout: 90
2735
script: |
2836
set -eux
29-
30-
# The generic Linux job chooses to use base env, not the one setup by the image
31-
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
32-
conda activate "${CONDA_ENV}"
33-
34-
# Setup swiftshader and Vulkan SDK which are required to build the Vulkan delegate
35-
source .ci/scripts/setup-vulkan-linux-deps.sh
36-
37-
# Setup MacOS dependencies as there is no Docker support on MacOS atm
38-
PYTHON_EXECUTABLE=python \
39-
EXECUTORCH_BUILD_PYBIND=ON \
40-
CMAKE_ARGS="-DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
41-
.ci/scripts/setup-linux.sh cmake
42-
43-
# Install llama3_2_vision dependencies.
44-
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
45-
46-
# Run pytest with coverage
47-
pytest -n auto --cov=./ --cov-report=xml
48-
# Run gtest
49-
LLVM_PROFDATA=llvm-profdata-12 LLVM_COV=llvm-cov-12 \
50-
test/run_oss_cpp_tests.sh
37+
.ci/scripts/unittest-linux.sh "${{ inputs.build-tool }}" "${{ inputs.build-mode }}"
5138
5239
macos:
5340
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
@@ -58,27 +45,4 @@ jobs:
5845
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
5946
script: |
6047
set -eux
61-
62-
bash .ci/scripts/setup-conda.sh
63-
64-
# Create temp directory for sccache shims
65-
export TMP_DIR=$(mktemp -d)
66-
export PATH="${TMP_DIR}:$PATH"
67-
trap 'rm -rfv ${TMP_DIR}' EXIT
68-
69-
# Setup MacOS dependencies as there is no Docker support on MacOS atm
70-
PYTHON_EXECUTABLE=python \
71-
EXECUTORCH_BUILD_PYBIND=ON \
72-
CMAKE_ARGS="-DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_MPS=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
73-
${CONDA_RUN} --no-capture-output \
74-
.ci/scripts/setup-macos.sh cmake
75-
76-
# Install llama3_2_vision dependencies.
77-
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
78-
./examples/models/llama3_2_vision/install_requirements.sh
79-
80-
# Run pytest with coverage
81-
${CONDA_RUN} pytest -n auto --cov=./ --cov-report=xml
82-
# Run gtest
83-
LLVM_PROFDATA="xcrun llvm-profdata" LLVM_COV="xcrun llvm-cov" \
84-
${CONDA_RUN} test/run_oss_cpp_tests.sh
48+
.ci/scripts/unittest-macos.sh "${{ inputs.build-tool }}" "${{ inputs.build-mode }}"

.github/workflows/pull.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,18 @@ jobs:
367367
id-token: write
368368
contents: read
369369
with:
370+
build-mode: Debug
371+
build-tool: cmake
372+
docker-image: executorch-ubuntu-22.04-clang12
373+
374+
unittest-buck:
375+
uses: ./.github/workflows/_unittest.yml
376+
permissions:
377+
id-token: write
378+
contents: read
379+
with:
380+
build-mode: Debug
381+
build-tool: buck2
370382
docker-image: executorch-ubuntu-22.04-clang12
371383

372384
unittest-arm:

0 commit comments

Comments
 (0)