Skip to content

Commit cfc6ecd

Browse files
authored
Qualcomm AI Engine Direct - Enable QNN Windows ARM64 build in CI (pytorch#22438)
Follow up on pytorch#20802. With Windows ARM64 build CI enabled in pytorch#21817, add Qualcomm Windows ARM64 build validation to the CI pipeline. ### Summary - Adds a `build-qnn-windows-arm64` job to `qnn-windows-msvc.yml`, running on the native windows-11-arm, to build the QNN backend for Windows ARM64. - Switches Python environment setup from `conda` to `venv` (`py -3.12 -m venv et`) for both architectures, since `conda` isn't available on the windows-11-arm image. - Verifies build artifacts (pybind module, backend DLL, executor runner) per architecture after each build. ### Test plan - Passing .github/workflows/qnn-windows-msvc.yml on both `build-qnn-windows-x64` and `build-qnn-windows-arm64` jobs.
1 parent 067c74b commit cfc6ecd

2 files changed

Lines changed: 75 additions & 24 deletions

File tree

‎.ci/scripts/build-qnn-windows-msvc.ps1‎

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,35 @@
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
66

7+
param(
8+
[switch]$SkipX86Windows,
9+
[switch]$SkipArm64Windows
10+
)
11+
712
$ErrorActionPreference = "Stop"
813

9-
conda create --yes --quiet -n et python=3.12
10-
conda activate et
14+
if ($SkipX86Windows -eq $SkipArm64Windows) {
15+
Write-Error "Specify exactly one of -SkipArm64Windows (to build x86_64) or -SkipX86Windows (to build arm64)."
16+
exit 1
17+
}
1118

12-
# Install CI requirements
13-
pip install -r .ci/docker/requirements-ci.txt
19+
if ($SkipX86Windows) {
20+
$ArchLabel = "arm64"
21+
py -3.12 -m venv et
22+
.\et\Scripts\Activate.ps1
23+
# ARM64 prebuilt wheels are not available for some Python modules.
24+
# To unblock the build process, only a minimal set of dependencies
25+
# is installed via pip. `PyYAML`/`torch` for ExecuTorch's codegen,
26+
# `requests` for download_qnn_sdk.py.
27+
pip install pyyaml requests
28+
pip install torch --index-url https://download.pytorch.org/whl/cpu
29+
} else {
30+
$ArchLabel = "x86_64"
31+
conda create --yes --quiet -n et python=3.12
32+
conda activate et
33+
# Install CI requirements
34+
pip install -r .ci/docker/requirements-ci.txt
35+
}
1436

1537
# Provision the QNN SDK
1638
if ($env:QNN_SDK_ROOT -and (Test-Path -Path $env:QNN_SDK_ROOT)) {
@@ -44,27 +66,26 @@ if (-not (Test-Path -Path (Join-Path $env:QNN_SDK_ROOT "include\QNN"))) {
4466
exit 1
4567
}
4668

47-
# Test x86_64 Windows host build
48-
.\backends\qualcomm\scripts\build.ps1 -SkipArm64Windows -Release
69+
if ($SkipArm64Windows) {
70+
.\backends\qualcomm\scripts\build.ps1 -SkipArm64Windows -Release
71+
} else {
72+
.\backends\qualcomm\scripts\build.ps1 -SkipX86Windows -Release
73+
}
4974

50-
$x86Artifacts = @(
51-
"build-x86_64-windows\backends\qualcomm\Release\PyQnnManagerAdaptor*.pyd",
52-
"build-x86_64-windows\backends\qualcomm\Release\qnn_executorch_backend.dll",
53-
"build-x86_64-windows\examples\qualcomm\executor_runner\Release\qnn_executor_runner.exe"
75+
$Artifacts = @(
76+
"build-$ArchLabel-windows\backends\qualcomm\Release\qnn_executorch_backend.dll",
77+
"build-$ArchLabel-windows\examples\qualcomm\executor_runner\Release\qnn_executor_runner.exe"
5478
)
55-
foreach ($artifact in $x86Artifacts) {
79+
if ($SkipArm64Windows) {
80+
# Only run PyQnnManagerAdaptor validation for x86_64 Windows artifacts,
81+
# since AOT is not fully supported on native ARM64 Windows.
82+
$Artifacts += "build-x86_64-windows\backends\qualcomm\Release\PyQnnManagerAdaptor*.pyd"
83+
}
84+
foreach ($artifact in $Artifacts) {
5685
if (-not (Get-ChildItem -Path $artifact -ErrorAction SilentlyContinue)) {
57-
Write-Error "ERROR: x86_64 artifact not found: $artifact"
86+
Write-Error "ERROR: $ArchLabel artifact not found: $artifact"
5887
exit 1
5988
}
6089
}
6190

62-
# The ARM64 MSVC toolchain is currently not installed in the Windows CI
63-
# environment. Enabling this build configuration results in build failures
64-
# due to the missing ARM64 platform definition.
65-
# `.\backends\qualcomm\scripts\build.ps1 -SkipX86Windows -Release`
66-
#
67-
# Temporarily disable this build option until ARM64 MSVC support is available
68-
# in CI. The configuration can be re-enabled in a future update.
69-
70-
Write-Host "PASSED: QNN backend Windows MSVC build completed"
91+
Write-Host "PASSED: QNN backend Windows MSVC build ($ArchLabel) completed"

‎.github/workflows/qnn-windows-msvc.yml‎

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ permissions:
5656
contents: read
5757

5858
jobs:
59-
build-qnn-windows-msvc:
60-
name: build-qnn-windows-msvc
59+
build-qnn-windows-x64:
60+
name: build-qnn-windows-x64
6161
uses: pytorch/test-infra/.github/workflows/windows_job.yml@main
6262
with:
6363
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
@@ -70,5 +70,35 @@ jobs:
7070
Set-PSDebug -Trace 1
7171
\$ErrorActionPreference = 'Stop'
7272
\$PSNativeCommandUseErrorActionPreference = \$true
73-
.ci/scripts/build-qnn-windows-msvc.ps1
73+
.ci/scripts/build-qnn-windows-msvc.ps1 -SkipArm64Windows
7474
}"
75+
76+
build-qnn-windows-arm64:
77+
name: build-qnn-windows-arm64
78+
runs-on: windows-11-arm
79+
timeout-minutes: 90
80+
steps:
81+
- name: Enable long paths
82+
shell: cmd
83+
run: |
84+
git config --system --get core.longpaths || echo "core.longpaths is not set, setting it now"
85+
git config --system core.longpaths true
86+
87+
- name: Checkout ExecuTorch
88+
uses: actions/checkout@v4
89+
with:
90+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
91+
92+
- name: Initialize submodules
93+
shell: pwsh
94+
run: |
95+
git config --global http.sslBackend openssl
96+
git submodule update --init --recursive
97+
98+
- name: Build QNN backend (arm64)
99+
shell: pwsh
100+
run: |
101+
Set-PSDebug -Trace 1
102+
$ErrorActionPreference = 'Stop'
103+
$PSNativeCommandUseErrorActionPreference = $true
104+
.ci/scripts/build-qnn-windows-msvc.ps1 -SkipX86Windows

0 commit comments

Comments
 (0)