Skip to content

Commit 7c2f165

Browse files
committed
[ET-VK][CI] Add macOS MoltenVK Vulkan model tests
Summary: Add a `test-vulkan-models-macos` job to the pull CI workflow that tests the Vulkan backend on macOS Apple Silicon using MoltenVK. This mirrors the existing `test-vulkan-models-linux` job (which uses SwiftShader) but runs on a macOS M1 runner with the LunarG Vulkan SDK providing MoltenVK as the Vulkan ICD. The new `setup-vulkan-macos-deps.sh` script downloads the macOS Vulkan SDK and configures `VK_ICD_FILENAMES` to point at MoltenVK. Generated with Claude.
1 parent 3d2c853 commit 7c2f165

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
#!/bin/bash
3+
# Copyright (c) Meta Platforms, Inc. and affiliates.
4+
# All rights reserved.
5+
#
6+
# This source code is licensed under the BSD-style license found in the
7+
# LICENSE file in the root directory of this source tree.
8+
9+
set -ex
10+
11+
install_vulkan_sdk() {
12+
VULKAN_SDK_VERSION=$1
13+
_vulkan_sdk_url="https://sdk.lunarg.com/sdk/download/${VULKAN_SDK_VERSION}/mac/vulkansdk-macos-${VULKAN_SDK_VERSION}.zip"
14+
15+
_vulkan_sdk_dir=/tmp/vulkansdk
16+
mkdir -p $_vulkan_sdk_dir
17+
18+
_tmp_archive="/tmp/vulkansdk.zip"
19+
20+
curl --silent --show-error --location --fail --retry 3 \
21+
--output "${_tmp_archive}" "${_vulkan_sdk_url}"
22+
23+
unzip -q -o "${_tmp_archive}" -d "${_vulkan_sdk_dir}"
24+
25+
export VULKAN_SDK="${_vulkan_sdk_dir}/VulkanSDK/${VULKAN_SDK_VERSION}/macOS"
26+
export PATH="${VULKAN_SDK}/bin:${PATH}"
27+
export VK_ICD_FILENAMES="${VULKAN_SDK}/share/vulkan/icd.d/MoltenVK_icd.json"
28+
export VK_LAYER_PATH="${VULKAN_SDK}/share/vulkan/explicit_layer.d"
29+
export DYLD_LIBRARY_PATH="${VULKAN_SDK}/lib:${DYLD_LIBRARY_PATH:-}"
30+
}
31+
32+
VULKAN_SDK_VERSION="1.4.321.1"
33+
34+
install_vulkan_sdk "${VULKAN_SDK_VERSION}"

.github/workflows/pull.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,46 @@ jobs:
13391339
python -m unittest backends/vulkan/test/test_vulkan_delegate.py -k "*pt2e*"
13401340
python -m unittest backends/vulkan/test/test_vulkan_delegate.py -k "*torchao*"
13411341
1342+
test-vulkan-models-macos:
1343+
name: test-vulkan-models-macos
1344+
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
1345+
permissions:
1346+
id-token: write
1347+
contents: read
1348+
with:
1349+
runner: macos-m1-stable
1350+
python-version: '3.11'
1351+
submodules: 'recursive'
1352+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
1353+
timeout: 90
1354+
script: |
1355+
set -eux
1356+
1357+
# Setup MoltenVK and Vulkan SDK which are required to build the Vulkan delegate
1358+
source .ci/scripts/setup-vulkan-macos-deps.sh
1359+
1360+
bash .ci/scripts/setup-conda.sh
1361+
1362+
# Setup MacOS dependencies and build ExecuTorch with Vulkan enabled
1363+
PYTHON_EXECUTABLE=python \
1364+
CMAKE_ARGS="-DEXECUTORCH_BUILD_VULKAN=ON" \
1365+
${CONDA_RUN} bash .ci/scripts/setup-macos.sh --build-tool "cmake"
1366+
1367+
# Build Vulkan test libraries
1368+
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash backends/vulkan/test/scripts/test_model.sh --build
1369+
1370+
# Test models with static shapes
1371+
models="mv2 mv3 edsr resnet18 resnet50 dl3 w2l ic3 ic4"
1372+
for model in $models; do
1373+
${CONDA_RUN} python -m examples.vulkan.export --model_name=$model --test
1374+
done
1375+
1376+
# Test selected models with dynamic shapes
1377+
models="mv2 resnet18 resnet50 ic3 densenet161"
1378+
for model in $models; do
1379+
${CONDA_RUN} python -m examples.vulkan.export --model_name=$model --test -d
1380+
done
1381+
13421382
test-coreml-bc-macos:
13431383
name: test-coreml-bc-macos (${{ matrix.runner }})
13441384
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main

0 commit comments

Comments
 (0)