Skip to content

Commit 47325ae

Browse files
authored
Merge branch 'main' into add-fmod
2 parents 2d20a77 + f7c009e commit 47325ae

File tree

328 files changed

+14274
-2571
lines changed

Some content is hidden

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

328 files changed

+14274
-2571
lines changed

.ci/scripts/test_backend_linux.sh renamed to .ci/scripts/test_backend.sh

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,26 @@ SUITE=$1
1010
FLOW=$2
1111
ARTIFACT_DIR=$3
1212

13-
REPORT_FILE="$ARTIFACT_DIR/test-report-$FLOW-$SUITE.csv"
13+
REPORT_FILE="$ARTIFACT_DIR/test-report-$FLOW-$SUITE.json"
1414

1515
echo "Running backend test job for suite $SUITE, flow $FLOW."
1616
echo "Saving job artifacts to $ARTIFACT_DIR."
1717

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

22+
if [[ "$(uname)" == "Darwin" ]]; then
23+
bash .ci/scripts/setup-conda.sh
24+
eval "$(conda shell.bash hook)"
25+
CONDA_RUN_CMD="${CONDA_RUN} --no-capture-output"
26+
${CONDA_RUN_CMD} pip install awscli==1.37.21
27+
IS_MACOS=1
28+
else
29+
CONDA_RUN_CMD=""
30+
IS_MACOS=0
31+
fi
32+
2333
export PYTHON_EXECUTABLE=python
2434

2535
# CMake options to use, in addition to the defaults.
@@ -50,11 +60,14 @@ if [[ "$FLOW" == *arm* ]]; then
5060
.ci/scripts/setup-arm-baremetal-tools.sh
5161
fi
5262

53-
# We need the runner to test the built library.
54-
PYTHON_EXECUTABLE=python CMAKE_ARGS="$EXTRA_BUILD_ARGS" .ci/scripts/setup-linux.sh --build-tool cmake --build-mode Release --editable true
63+
if [[ $IS_MACOS -eq 1 ]]; then
64+
SETUP_SCRIPT=.ci/scripts/setup-macos.sh
65+
else
66+
SETUP_SCRIPT=.ci/scripts/setup-linux.sh
67+
fi
68+
CMAKE_ARGS="$EXTRA_BUILD_ARGS" ${CONDA_RUN_CMD} $SETUP_SCRIPT --build-tool cmake --build-mode Release --editable true
5569

5670
EXIT_CODE=0
57-
python -m executorch.backends.test.suite.runner $SUITE --flow $FLOW --report "$REPORT_FILE" || EXIT_CODE=$?
58-
71+
${CONDA_RUN_CMD} pytest -c /dev/nul -n auto backends/test/suite/$SUITE/ -m flow_$FLOW --json-report --json-report-file="$REPORT_FILE" || EXIT_CODE=$?
5972
# Generate markdown summary.
60-
python -m executorch.backends.test.suite.generate_markdown_summary "$REPORT_FILE" > ${GITHUB_STEP_SUMMARY:-"step_summary.md"} --exit-code $EXIT_CODE
73+
${CONDA_RUN_CMD} python -m executorch.backends.test.suite.generate_markdown_summary_json "$REPORT_FILE" > ${GITHUB_STEP_SUMMARY:-"step_summary.md"} --exit-code $EXIT_CODE

.ci/scripts/test_backend_macos.sh

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

.ci/scripts/test_llama.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ cmake_install_executorch_libraries() {
159159
-DCMAKE_INSTALL_PREFIX=cmake-out \
160160
-DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \
161161
-DEXECUTORCH_BUILD_QNN="$QNN" \
162+
-DEXECUTORCH_ENABLE_LOGGING=ON \
162163
-DQNN_SDK_ROOT="$QNN_SDK_ROOT"
163164
cmake --build cmake-out -j9 --target install --config "$CMAKE_BUILD_TYPE"
164165
}
@@ -236,7 +237,7 @@ if [[ "${CUSTOM}" == "ON" ]]; then
236237
EXPORT_ARGS="${EXPORT_ARGS} model.use_sdpa_with_kv_cache=true"
237238
fi
238239
if [[ "${QE}" == "ON" ]]; then
239-
EXPORT_ARGS="${EXPORT_ARGS} quantization.embedding_quantize=\"8,1024\""
240+
EXPORT_ARGS="${EXPORT_ARGS} quantization.embedding_quantize=\"8,768\""
240241
fi
241242
if [[ "${MPS}" == "ON" ]]; then
242243
EXPORT_ARGS="${EXPORT_ARGS} backend.mps.enabled=true model.enable_dynamic_shape=false debug.verbose=true"

.ci/scripts/test_llava.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ cmake_build_llava_runner_for_android() {
107107
# only export the one without custom op for now since it's
108108
export_llava() {
109109
echo "Starting to export Llava. This will take about 6 mins"
110-
$PYTHON_EXECUTABLE -m executorch.examples.models.llava.export_llava --pte-name llava.pte --with-artifacts
110+
$PYTHON_EXECUTABLE -m executorch.examples.models.llava.export_llava --pte-name llava.pte --with-artifacts --max-context-len 768
111111
}
112112

113113
# Download a new image
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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 -euo pipefail
9+
10+
echo ">>> Script invoked with arguments: $@"
11+
12+
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
13+
14+
# Download QNN_SDK. If already downloaded, export environment path
15+
source "$(dirname "${BASH_SOURCE[0]}")/../../backends/qualcomm/scripts/install_qnn_sdk.sh"
16+
install_qnn
17+
18+
export EXECUTORCH_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
19+
export LD_LIBRARY_PATH="${QNN_SDK_ROOT}/lib/x86_64-linux-clang"
20+
export PYTHONPATH=".."
21+
cp schema/program.fbs exir/_serialize/program.fbs
22+
cp schema/scalar_type.fbs exir/_serialize/scalar_type.fbs
23+
cp -f build-x86/backends/qualcomm/PyQnnManagerAdaptor.cpython-310-x86_64-linux-gnu.so backends/qualcomm/python
24+
cp -f build-x86/backends/qualcomm/PyQnnWrapperAdaptor.cpython-310-x86_64-linux-gnu.so backends/qualcomm/python
25+
26+
if [[ -z "${PYTHON_EXECUTABLE:-}" ]]; then
27+
PYTHON_EXECUTABLE=python3
28+
fi
29+
30+
which "${PYTHON_EXECUTABLE}"
31+
32+
# -------------------------------
33+
# Parse args
34+
# -------------------------------
35+
EXTRA_FLAGS=""
36+
THRESHOLD=62.0 # default fallback
37+
38+
while [[ $# -gt 0 ]]; do
39+
case "$1" in
40+
--flags)
41+
EXTRA_FLAGS="$2"
42+
shift 2
43+
;;
44+
--threshold)
45+
THRESHOLD="$2"
46+
shift 2
47+
;;
48+
*)
49+
echo "Unknown option: $1"
50+
exit 1
51+
;;
52+
esac
53+
done
54+
55+
# Config
56+
PYTHON_EXECUTABLE="${PYTHON_EXECUTABLE:-python3}"
57+
MODEL="qwen2_5-0_5b"
58+
MAX_SEQ=1024
59+
PTQ="16a4w"
60+
61+
EXTRA_FLAGS="$@"
62+
63+
# Run command and capture *both stdout and stderr*
64+
LOG_FILE="eval_${MODEL}_$(date +%Y%m%d_%H%M%S).log"
65+
66+
echo ">>> Running evaluation with flags: $EXTRA_FLAGS | threshold: $THRESHOLD"
67+
$PYTHON_EXECUTABLE -m executorch.examples.qualcomm.oss_scripts.llama.eval_llama_qnn \
68+
--decoder_model "$MODEL" \
69+
--quant_linear_only \
70+
--max_seq_length "$MAX_SEQ" \
71+
--ptq "$PTQ" \
72+
$EXTRA_FLAGS 2>&1 | tee "$LOG_FILE"
73+
74+
# Extract last word_perplexity
75+
LAST_PERP=$(grep "INFO:root:wikitext:" "$LOG_FILE" | tail -n 1 | sed -E "s/.*'word_perplexity,none': ([0-9.]+).*/\1/")
76+
77+
if [[ -z "$LAST_PERP" ]]; then
78+
echo "❌ Could not find word_perplexity in logs!"
79+
exit 1
80+
fi
81+
82+
echo ">>> Last word_perplexity = $LAST_PERP"
83+
84+
# Compare against threshold
85+
awk -v val="$LAST_PERP" -v thr="$THRESHOLD" 'BEGIN {exit (val > thr)}'
86+
if [[ $? -ne 0 ]]; then
87+
echo "❌ Regression detected: word_perplexity ($LAST_PERP) > threshold ($THRESHOLD)"
88+
exit 1
89+
fi
90+
91+
echo "✅ Check passed: word_perplexity ($LAST_PERP) <= $THRESHOLD"

.ci/scripts/test_wheel_package_qnn.sh

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ PYTHON_VERSION=$1
9898
# Check wheel does NOT contain qualcomm/sdk
9999
# ----------------------------
100100
echo "Checking wheel does not contain qualcomm/sdk..."
101-
SDK_FILES=$(unzip -l "$WHEEL_FILE" | awk '{print $4}' | grep "executorch/backends/qualcomm/sdk" || true)
101+
SDK_FILES=$(unzip -l "$WHEEL_FILE" | awk '{print $4}' | grep -E "executorch/backends/qualcomm/sdk" || true)
102102
if [ -n "$SDK_FILES" ]; then
103103
echo "ERROR: Wheel package contains unexpected qualcomm/sdk files:"
104104
echo "$SDK_FILES"
@@ -111,7 +111,7 @@ fi
111111
# Check .so files in the wheel
112112
# ----------------------------
113113
echo "Checking for .so files inside the wheel..."
114-
WHEEL_SO_FILES=$(unzip -l "$WHEEL_FILE" | awk '{print $4}' | grep "executorch/backends/qualcomm/python" || true)
114+
WHEEL_SO_FILES=$(unzip -l "$WHEEL_FILE" | awk '{print $4}' | grep -E "executorch/backends/qualcomm/python" || true)
115115
if [ -z "$WHEEL_SO_FILES" ]; then
116116
echo "ERROR: No .so files found in wheel under executorch/backends/qualcomm/python"
117117
exit 1
@@ -139,8 +139,30 @@ run_core_tests () {
139139
echo "=== [$LABEL] Installing wheel & deps ==="
140140
"$PIPBIN" install --upgrade pip
141141
"$PIPBIN" install "$WHEEL_FILE"
142-
"$PIPBIN" install torch=="2.9.0.dev20250906" --index-url "https://download.pytorch.org/whl/nightly/cpu"
143-
"$PIPBIN" install --pre torchao --index-url "https://download.pytorch.org/whl/nightly/cpu"
142+
TORCH_VERSION=$(
143+
"$PYBIN" - <<'PY'
144+
import runpy
145+
module_vars = runpy.run_path("torch_pin.py")
146+
print(module_vars["TORCH_VERSION"])
147+
PY
148+
)
149+
150+
NIGHTLY_VERSION=$(
151+
"$PYBIN" - <<'PY'
152+
import runpy
153+
module_vars = runpy.run_path("torch_pin.py")
154+
print(module_vars["NIGHTLY_VERSION"])
155+
PY
156+
)
157+
echo "=== [$LABEL] Install torch==${TORCH_VERSION}.${NIGHTLY_VERSION} ==="
158+
159+
# Install torchao based on the pinned PyTorch version
160+
"$PIPBIN" install torch=="${TORCH_VERSION}.${NIGHTLY_VERSION}" --index-url "https://download.pytorch.org/whl/nightly/cpu"
161+
162+
# Install torchao based on the pinned commit from third-party/ao submodule
163+
pushd "$REPO_ROOT/third-party/ao" > /dev/null
164+
USE_CPP=0 "$PYBIN" setup.py develop
165+
popd > /dev/null
144166

145167
echo "=== [$LABEL] Import smoke tests ==="
146168
"$PYBIN" -c "import executorch; print('executorch imported successfully')"

.ci/scripts/unittest-buck2.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,17 @@ BUILDABLE_KERNELS_PRIM_OPS_TARGETS=$(buck2 query //kernels/prim_ops/... | grep -
3535
for op in "build" "test"; do
3636
buck2 $op $BUILDABLE_OPTIMIZED_OPS \
3737
//examples/selective_build:select_all_dtype_selective_lib_portable_lib \
38+
//extension/llm/custom_ops/spinquant/test:fast_hadamard_transform_test \
39+
//extension/llm/runner/test:test_multimodal_input \
40+
//extension/llm/runner/test:test_generation_config \
3841
//kernels/portable/... \
3942
$BUILDABLE_KERNELS_PRIM_OPS_TARGETS //runtime/backend/... //runtime/core/... \
4043
//runtime/executor: //runtime/kernel/... //runtime/platform/...
4144
done
4245

4346
# Build only without testing
44-
buck2 build //codegen/tools/... # Needs torch for testing which we don't have in our OSS buck setup.
47+
buck2 build //codegen/tools/... \
48+
//extension/llm/runner/io_manager:io_manager \
49+
//extension/llm/modules/... \
50+
//extension/llm/runner:multimodal_runner_lib \
51+
//extension/llm/runner:text_decoder_runner

.github/workflows/_test_backend.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
script: |
5858
set -eux
5959
60-
source .ci/scripts/test_backend_linux.sh "${{ matrix.suite }}" "${{ matrix.flow }}" "${RUNNER_ARTIFACT_DIR}"
60+
source .ci/scripts/test_backend.sh "${{ matrix.suite }}" "${{ matrix.flow }}" "${RUNNER_ARTIFACT_DIR}"
6161
6262
test-backend-macos:
6363
if: ${{ inputs.run-macos }}
@@ -81,4 +81,4 @@ jobs:
8181
# This is needed to get the prebuilt PyTorch wheel from S3
8282
${CONDA_RUN} --no-capture-output pip install awscli==1.37.21
8383
84-
source .ci/scripts/test_backend_macos.sh "${{ matrix.suite }}" "${{ matrix.flow }}" "${RUNNER_ARTIFACT_DIR}"
84+
source .ci/scripts/test_backend.sh "${{ matrix.suite }}" "${{ matrix.flow }}" "${RUNNER_ARTIFACT_DIR}"

.github/workflows/add-unanswered-to-project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Add open issues and open, non-draft PRs to org project (excluding certain authors)
1313
uses: actions/github-script@v7
1414
with:
15-
github-token: ${{ secrets.GITHUB_TOKEN }}
15+
github-token: ${{ secrets.ET_EXT_CONTRIB }}
1616
script: |
1717
const projectId = "PVT_kwDOAUB9vs4A_PUL"; // PyTorch org project 136
1818
const owner = 'pytorch';

.github/workflows/android-release-artifacts.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@ on:
1515
type: choice
1616
options:
1717
- "xnnpack"
18-
- "vulkan+xnnpack"
18+
- "vulkan"
1919
- "qnn"
2020
schedule:
2121
- cron: 0 10 * * *
2222

23-
concurrency:
24-
group: ${{ github.workflow }}-${{ github.ref }}
25-
cancel-in-progress: true
26-
2723
jobs:
2824
check-if-aar-exists:
2925
name: check-if-aar-exists
@@ -34,12 +30,13 @@ jobs:
3430
shell: bash
3531
run: |
3632
VERSION="${{ inputs.version }}"
33+
FLAVOR="${{ inputs.flavor }}"
3734
if [ -z "$VERSION" ]; then
3835
echo "No version name specified. Will create a snapshot AAR"
3936
exit 0
4037
fi
41-
if curl -I "https://ossci-android.s3.amazonaws.com/executorch/release/${VERSION}/executorch.aar" | grep "200 OK"; then
42-
echo "AAR already exists at https://ossci-android.s3.amazonaws.com/executorch/release/${VERSION}/executorch.aar"
38+
if curl -I "https://ossci-android.s3.amazonaws.com/executorch/release/${VERSION}-${FLAVOR}/executorch.aar" | grep "200 OK"; then
39+
echo "AAR already exists at https://ossci-android.s3.amazonaws.com/executorch/release/${VERSION}-${FLAVOR}/executorch.aar"
4340
echo "Will skip build/upload"
4441
exit 1
4542
fi
@@ -93,7 +90,10 @@ jobs:
9390
fi
9491
9592
FLAVOR="${{ inputs.flavor }}"
96-
if [[ "$FLAVOR" == "vulkan+xnnpack" || -z "$FLAVOR" ]]; then
93+
if [[ "$FLAVOR" == "vulkan" || -z "$FLAVOR" ]]; then
94+
curl -O https://sdk.lunarg.com/sdk/download/1.4.321.1/linux/vulkansdk-linux-x86_64-1.4.321.1.tar.xz
95+
tar xf vulkansdk-linux-x86_64-1.4.321.1.tar.xz -C /tmp
96+
export PATH="/tmp/1.4.321.1/x86_64/bin:$PATH"
9797
export EXECUTORCH_BUILD_VULKAN=ON
9898
fi
9999
@@ -145,8 +145,12 @@ jobs:
145145
pip install awscli==1.32.18
146146
AWS_CMD="aws s3 cp"
147147
VERSION="${{ inputs.version }}"
148+
FLAVOR="${{ inputs.flavor }}"
148149
if [ -z "$VERSION" ]; then
149150
VERSION="snapshot-$(date +"%Y%m%d")"
150151
fi
151-
${AWS_CMD} executorch.aar s3://ossci-android/executorch/release/${VERSION}/executorch.aar --acl public-read
152-
${AWS_CMD} executorch.aar.sha256sums s3://ossci-android/executorch/release/${VERSION}/executorch.aar.sha256sums --acl public-read
152+
if [ -z "$FLAVOR" ]; then
153+
FLAVOR="xnnpack"
154+
fi
155+
${AWS_CMD} executorch.aar s3://ossci-android/executorch/release/${VERSION}-${FLAVOR}/executorch.aar --acl public-read
156+
${AWS_CMD} executorch.aar.sha256sums s3://ossci-android/executorch/release/${VERSION}-${FLAVOR}/executorch.aar.sha256sums --acl public-read

0 commit comments

Comments
 (0)