Skip to content

Commit b34ce37

Browse files
committed
Merge remote-tracking branch 'origin/main' into jni-layer-llama-1
2 parents 43d8e5e + 4fc602b commit b34ce37

File tree

297 files changed

+11350
-2512
lines changed

Some content is hidden

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

297 files changed

+11350
-2512
lines changed

.ci/scripts/build-qnn-sdk.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ set -o xtrace
1111

1212
build_qnn_backend() {
1313
echo "Start building qnn backend."
14-
export ANDROID_NDK_ROOT=${ANDROID_NDK_ROOT:-/opt/ndk}
15-
export QNN_SDK_ROOT=${QNN_SDK_ROOT:-/tmp/qnn/2.28.0.241029}
14+
# Source QNN configuration
15+
source "$(dirname "${BASH_SOURCE[0]}")/../../backends/qualcomm/scripts/install_qnn_sdk.sh"
16+
setup_android_ndk
17+
install_qnn
1618
export EXECUTORCH_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"
1719

1820
parallelism=$(( $(nproc) - 1 ))

.ci/scripts/setup-qnn-deps.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ set -ex
1010
source "$(dirname "${BASH_SOURCE[0]}")/../../backends/qualcomm/scripts/install_qnn_sdk.sh"
1111

1212
setup_libcpp 12
13+
setup_android_ndk
1314
install_qnn

.ci/scripts/setup-vulkan-linux-deps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ install_vulkan_sdk() {
4343
export PATH="${PATH}:${_vulkan_sdk_dir}/${VULKAN_SDK_VERSION}/x86_64/bin/"
4444
}
4545

46-
VULKAN_SDK_VERSION="1.3.296.0"
46+
VULKAN_SDK_VERSION="1.4.321.1"
4747

4848
install_swiftshader
4949
install_vulkan_sdk "${VULKAN_SDK_VERSION}"

.ci/scripts/setup-windows.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
param (
2+
[string]$editable = $false
3+
)
4+
5+
conda create --yes --quiet -n et python=3.12
6+
conda activate et
7+
8+
# Activate the VS environment - this is required for Dynamo to work, as it uses MSVC.
9+
# There are a bunch of environment variables that it requires.
10+
# See https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line.
11+
& "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64
12+
13+
# Install test dependencies
14+
pip install -r .ci/docker/requirements-ci.txt
15+
16+
if ($editable -eq 'true') {
17+
install_executorch.bat --editable
18+
} else {
19+
install_executorch.bat
20+
}
21+
if ($LASTEXITCODE -ne 0) {
22+
Write-Host "Installation was unsuccessful. Exit code: $LASTEXITCODE."
23+
exit $LASTEXITCODE
24+
}

.ci/scripts/test_llama.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,12 @@ echo "COREML option ${COREML}"
119119

120120
if [[ "${MODE}" =~ .*qnn.* ]]; then
121121
QNN=ON
122+
123+
# Download QNN_SDK. If already downloaded, export environment path
124+
source "$(dirname "${BASH_SOURCE[0]}")/../../backends/qualcomm/scripts/install_qnn_sdk.sh"
125+
install_qnn
126+
122127
export EXECUTORCH_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
123-
export QNN_SDK_ROOT=/tmp/qnn/2.28.0.241029
124128
export LD_LIBRARY_PATH="${QNN_SDK_ROOT}/lib/x86_64-linux-clang"
125129
export PYTHONPATH=".."
126130
cp schema/program.fbs exir/_serialize/program.fbs
@@ -150,6 +154,7 @@ cmake_install_executorch_libraries() {
150154
echo "Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a"
151155
rm -rf cmake-out
152156
retry cmake --preset llm \
157+
-DEXECUTORCH_BUILD_TESTS=ON \
153158
-DBUILD_TESTING=OFF \
154159
-DCMAKE_INSTALL_PREFIX=cmake-out \
155160
-DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \
@@ -166,6 +171,7 @@ cmake_build_llama_runner() {
166171
popd
167172
dir="examples/models/llama"
168173
retry cmake \
174+
-DEXECUTORCH_BUILD_TESTS=ON \
169175
-DBUILD_TESTING=OFF \
170176
-DCMAKE_INSTALL_PREFIX=cmake-out \
171177
-DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \

.ci/scripts/test_model.ps1

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
param (
2+
[string]$modelName,
3+
[string]$backend,
4+
[string]$buildDir = "cmake-out",
5+
[bool]$strict = $false
6+
)
7+
8+
Set-PSDebug -Trace 1
9+
$ErrorActionPreference = 'Stop'
10+
$PSNativeCommandUseErrorActionPreference = $true
11+
12+
function ExportModel-Portable {
13+
param (
14+
[string]$model_name,
15+
[bool]$strict
16+
)
17+
18+
$exportParams = "--model_name", "$modelName"
19+
if ($strict) {
20+
$exportParams += "--strict"
21+
}
22+
python -m examples.portable.scripts.export @exportParams | Write-Host
23+
if ($LASTEXITCODE -ne 0) {
24+
Write-Host "Model export failed. Exit code: $LASTEXITCODE."
25+
exit $LASTEXITCODE
26+
}
27+
28+
"$modelName.pte"
29+
}
30+
31+
function ExportModel-Xnnpack {
32+
param (
33+
[string]$model_name,
34+
[bool]$quantize
35+
)
36+
37+
if $(quantize) {
38+
python -m examples.xnnpack.aot_compiler --model_name="${MODEL_NAME}" --delegate --quantize | Write-Host
39+
$modelFile = "$($modelName)_xnnpack_q8.pte"
40+
} else {
41+
python -m examples.xnnpack.aot_compiler --model_name="${MODEL_NAME}" --delegate | Write-Host
42+
$modelFile = "$($modelName)_xnnpack_fp32.pte"
43+
}
44+
if ($LASTEXITCODE -ne 0) {
45+
Write-Host "Model export failed. Exit code: $LASTEXITCODE."
46+
exit $LASTEXITCODE
47+
}
48+
49+
$modelFile
50+
}
51+
52+
# Build the runner
53+
if (Test-Path -Path $buildDir) {
54+
Remove-Item -Path $buildDir -Recurse -Force
55+
}
56+
New-Item -Path $buildDir -ItemType Directory
57+
Push-Location $buildDir
58+
cmake .. --preset windows
59+
cmake --build . -t executor_runner -j16 --config Release
60+
if ($LASTEXITCODE -ne 0) {
61+
Write-Host "Runner build failed. Exit code: $LASTEXITCODE."
62+
exit $LASTEXITCODE
63+
}
64+
$executorBinaryPath = Join-Path -Path $buildDir -ChildPath "Release\executor_runner.exe"
65+
Pop-Location
66+
67+
# Export the model
68+
switch ($backend) {
69+
"portable" {
70+
$model_path = ExportModel-Portable -model_name $modelName -strict $strict
71+
}
72+
"xnnpack-f32" {
73+
$model_path = ExportModel-Xnnpack -model_name $modelName -quantize $false
74+
}
75+
"xnnpack-q8" {
76+
$model_path = ExportModel-Xnnpack -model_name $modelName -quantize $true
77+
}
78+
default {
79+
Write-Host "Unknown backend $backend."
80+
exit 1
81+
}
82+
}
83+
84+
# Run the runner
85+
& "$executorBinaryPath" --model_path="$model_path"
86+
if ($LASTEXITCODE -ne 0) {
87+
Write-Host "Model execution failed. Exit code: $LASTEXITCODE."
88+
exit $LASTEXITCODE
89+
}

.ci/scripts/test_qnn_static_llama.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ set -euxo pipefail
99

1010
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
1111

12+
# Source QNN configuration
13+
source "$(dirname "${BASH_SOURCE[0]}")/../../backends/qualcomm/scripts/qnn_config.sh"
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+
1218
export EXECUTORCH_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
13-
export QNN_SDK_ROOT=/tmp/qnn/2.28.0.241029
1419
export LD_LIBRARY_PATH="${QNN_SDK_ROOT}/lib/x86_64-linux-clang"
1520
export PYTHONPATH=".."
1621
cp schema/program.fbs exir/_serialize/program.fbs

.ci/scripts/unittest-windows.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
param (
2+
[string]$editable = $false
3+
)
4+
5+
Set-PSDebug -Trace 1
6+
$ErrorActionPreference = 'Stop'
7+
$PSNativeCommandUseErrorActionPreference = $true
8+
9+
# Run pytest with coverage
10+
# pytest -n auto --cov=./ --cov-report=xml
11+
pytest -v --full-trace -c pytest-windows.ini
12+
if ($LASTEXITCODE -ne 0) {
13+
Write-Host "Pytest invocation was unsuccessful. Exit code: $LASTEXITCODE."
14+
exit $LASTEXITCODE
15+
}

.github/workflows/_unittest.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ on:
1919
required: false
2020
type: string
2121
description: Install ExecuTorch in editable mode or not.
22+
default: 'false'
2223
python-version:
2324
required: false
2425
type: string
@@ -52,3 +53,23 @@ jobs:
5253
# This is needed to get the prebuilt PyTorch wheel from S3
5354
${CONDA_RUN} --no-capture-output pip install awscli==1.37.21
5455
.ci/scripts/unittest-macos.sh --build-tool "${{ inputs.build-tool }}" --build-mode "${{ inputs.build-mode }}" --editable "${{ inputs.editable }}"
56+
57+
windows:
58+
if: ${{ inputs.build-tool == 'cmake' }}
59+
uses: pytorch/test-infra/.github/workflows/windows_job.yml@main
60+
with:
61+
submodules: 'recursive'
62+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
63+
timeout: 120
64+
script: |
65+
conda init powershell
66+
67+
powershell -Command "& {
68+
Set-PSDebug -Trace 1
69+
\$ErrorActionPreference = 'Stop'
70+
\$PSNativeCommandUseErrorActionPreference = \$true
71+
72+
.ci/scripts/setup-windows.ps1
73+
74+
powershell .ci/scripts/unittest-windows.ps1 -editable "${{ inputs.editable }}"
75+
}"

.github/workflows/android-perf.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
# Separate default values from the workflow dispatch. To ensure defaults are accessible
7373
# during scheduled runs and to provide flexibility for different defaults between
7474
# on-demand and periodic benchmarking.
75-
CRON_DEFAULT_MODELS: ${{ github.event_name == 'schedule' && 'mv3,mv2,ic4,ic3,resnet50,edsr,mobilebert,w2l,meta-llama/Llama-3.2-1B,meta-llama/Llama-3.2-1B-Instruct-SpinQuant_INT4_EO8,meta-llama/Llama-3.2-1B-Instruct-QLORA_INT4_EO8,Qwen/Qwen3-0.6B,HuggingFaceTB/SmolLM2-135M,allenai/OLMo-1B-hf,google/gemma-3-1b-it' || 'Qwen/Qwen3-0.6B' }}
75+
CRON_DEFAULT_MODELS: ${{ github.event_name == 'schedule' && 'mv3,mv2,ic4,ic3,resnet50,mobilebert,w2l,meta-llama/Llama-3.2-1B,meta-llama/Llama-3.2-1B-Instruct-SpinQuant_INT4_EO8,meta-llama/Llama-3.2-1B-Instruct-QLORA_INT4_EO8,Qwen/Qwen3-0.6B,HuggingFaceTB/SmolLM2-135M,allenai/OLMo-1B-hf,google/gemma-3-1b-it' || 'Qwen/Qwen3-0.6B' }}
7676
CRON_DEFAULT_DEVICES: samsung_galaxy_s22+public
7777
run: |
7878
set -eux
@@ -292,7 +292,7 @@ jobs:
292292
export.output_name="${OUT_ET_MODEL_NAME}.pte"
293293
ls -lh "${OUT_ET_MODEL_NAME}.pte"
294294
elif [[ ${{ matrix.config }} == "llama3_qnn_htp" ]]; then
295-
export QNN_SDK_ROOT=/tmp/qnn/2.28.0.241029
295+
export QNN_SDK_ROOT=/tmp/qnn/2.37.0.25072
296296
export LD_LIBRARY_PATH=$QNN_SDK_ROOT/lib/x86_64-linux-clang/
297297
export PYTHONPATH=$(pwd)/..
298298
@@ -432,7 +432,7 @@ jobs:
432432
PYTHON_EXECUTABLE=python bash .ci/scripts/build-qnn-sdk.sh
433433
434434
mkdir -p aar-out
435-
PYTHON_EXECUTABLE=python ANDROID_ABIS="arm64-v8a" BUILD_AAR_DIR=aar-out EXECUTORCH_BUILD_QNN=ON QNN_SDK_ROOT=/tmp/qnn/2.28.0.241029 EXECUTORCH_ANDROID_PROFILING=ON bash scripts/build_android_library.sh
435+
PYTHON_EXECUTABLE=python ANDROID_ABIS="arm64-v8a" BUILD_AAR_DIR=aar-out EXECUTORCH_BUILD_QNN=ON QNN_SDK_ROOT=/tmp/qnn/2.37.0.25072 EXECUTORCH_ANDROID_PROFILING=ON bash scripts/build_android_library.sh
436436
mkdir -p extension/benchmark/android/benchmark/app/libs
437437
cp aar-out/executorch.aar extension/benchmark/android/benchmark/app/libs
438438
pushd extension/benchmark/android/benchmark

0 commit comments

Comments
 (0)