Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .ci/scripts/setup-vulkan-macos-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# Copyright 2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

set -ex

install_vulkan_sdk() {
VULKAN_SDK_VERSION=$1
_vulkan_sdk_url="https://sdk.lunarg.com/sdk/download/${VULKAN_SDK_VERSION}/mac/vulkansdk-macos-${VULKAN_SDK_VERSION}.zip"
_vulkan_sdk_dir=/tmp/vulkansdk
_vulkan_sdk_extract_dir=/tmp/vulkansdk-installer

mkdir -p "${_vulkan_sdk_dir}"
rm -rf "${_vulkan_sdk_extract_dir}"
mkdir -p "${_vulkan_sdk_extract_dir}"

_tmp_archive="/tmp/vulkansdk-macos.zip"

curl --silent --show-error --location --fail --retry 3 \
--output "${_tmp_archive}" "${_vulkan_sdk_url}"

unzip -q -o "${_tmp_archive}" -d "${_vulkan_sdk_extract_dir}"

_vulkan_sdk_app_path="$(
find "${_vulkan_sdk_extract_dir}" -maxdepth 3 -type d \
\( -name "vulkansdk-macOS-${VULKAN_SDK_VERSION}.app" \
-o -name "vulkansdk-macos-${VULKAN_SDK_VERSION}.app" \) \
-print -quit
)"
if [[ -z "${_vulkan_sdk_app_path}" ]]; then
echo "Failed to find Vulkan SDK installer app"
exit 1
fi
_vulkan_sdk_installer="${_vulkan_sdk_app_path}/Contents/MacOS/$(basename "${_vulkan_sdk_app_path}" .app)"
if [[ ! -x "${_vulkan_sdk_installer}" ]]; then
echo "Failed to find Vulkan SDK installer binary at ${_vulkan_sdk_installer}"
exit 1
fi

"${_vulkan_sdk_installer}" \
--root "${_vulkan_sdk_dir}/${VULKAN_SDK_VERSION}" \
--accept-licenses \
--default-answer \
--confirm-command install

export PATH="${PATH}:${_vulkan_sdk_dir}/${VULKAN_SDK_VERSION}/macOS/bin/"
export VULKAN_SDK="${_vulkan_sdk_dir}/${VULKAN_SDK_VERSION}/macOS"
export DYLD_LIBRARY_PATH="${_vulkan_sdk_dir}/${VULKAN_SDK_VERSION}/macOS/lib${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}"

_moltenvk_icd="${VULKAN_SDK}/share/vulkan/icd.d/MoltenVK_icd.json"
if [[ -f "${_moltenvk_icd}" ]]; then
export VK_DRIVER_FILES="${_moltenvk_icd}"
fi
}

VULKAN_SDK_VERSION="1.4.321.0"

install_vulkan_sdk "${VULKAN_SDK_VERSION}"
38 changes: 38 additions & 0 deletions .ci/scripts/wheel/pre_build_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# Copyright 2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

Expand Down Expand Up @@ -57,6 +59,42 @@ fi

"${GITHUB_WORKSPACE}/${REPOSITORY}/install_requirements.sh" --example

setup_vulkan_for_vgf() {
if [[ "$UNAME_S" == "Linux" && "$(uname -m)" == "x86_64" ]]; then
source "${GITHUB_WORKSPACE}/${REPOSITORY}/.ci/scripts/setup-vulkan-linux-deps.sh"
elif [[ "$UNAME_S" == "Darwin" ]]; then
source "${GITHUB_WORKSPACE}/${REPOSITORY}/.ci/scripts/setup-vulkan-macos-deps.sh"
fi

if ! command -v glslc >/dev/null 2>&1; then
return 1
fi

for _var in PATH VULKAN_SDK LD_LIBRARY_PATH DYLD_LIBRARY_PATH VK_ICD_FILENAMES VK_DRIVER_FILES ETVK_USING_SWIFTSHADER; do
if [[ -n "${!_var:-}" ]]; then
echo "${_var}=${!_var}" >> "${GITHUB_ENV}"
fi
done

return 0
}

# Enable VGF in pybind wheel builds when the platform-specific build input is
# available from pip.
if [[ "$UNAME_S" == "Linux" || "$UNAME_S" == "Darwin" ]]; then
if python3 -m pip install -r \
"${GITHUB_WORKSPACE}/${REPOSITORY}/backends/arm/requirements-arm-vgf-runtime.txt"; then
if setup_vulkan_for_vgf; then
export EXECUTORCH_PYBIND_ENABLE_VGF=ON
echo "EXECUTORCH_PYBIND_ENABLE_VGF=ON" >> "${GITHUB_ENV}"
else
echo "glslc unavailable after VGF build dependency install; building without VGF"
Comment thread
robell marked this conversation as resolved.
fi
else
echo "VGF build dependency unavailable on this platform; building without VGF"
fi
fi

# Download Qualcomm QNN SDK on Linux x86_64 so the wheel build can include the
# QNN backend. The SDK is large, so we download it here (outside CMake) rather
# than during cmake configure.
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,10 @@ if(EXECUTORCH_BUILD_PYBIND)
list(APPEND _dep_libs coremldelegate)
endif()

if(EXECUTORCH_BUILD_VGF)
list(APPEND _dep_libs vgf_backend)
endif()

if(EXECUTORCH_BUILD_MPS)
list(APPEND _dep_libs mpsdelegate)
endif()
Expand Down
8 changes: 8 additions & 0 deletions backends/arm/requirements-arm-vgf-runtime.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# These dependencies need to match pyproject.toml
Comment thread
robell marked this conversation as resolved.

ai_ml_sdk_vgf_library == 0.9.0
1 change: 0 additions & 1 deletion backends/arm/requirements-arm-vgf.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@

ai_ml_emulation_layer_for_vulkan == 0.9.0
ai_ml_sdk_model_converter == 0.9.0
ai_ml_sdk_vgf_library == 0.9.0
2 changes: 1 addition & 1 deletion backends/arm/scripts/setup-mlsdk-from-source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ root_dir="${et_dir}/examples/arm/arm-scratch"
setup_path_script=""
mlsdk_manifest_dir="ml-sdk-for-vulkan-manifest"
mlsdk_manifest_url="${MLSDK_MANIFEST_URL:-https://github.com/arm/ai-ml-sdk-manifest.git}"
mlsdk_manifest_tag="${MLSDK_MANIFEST_TAG:-refs/tags/v2026.03.0}" # Keep this in sync with what is mentioned in requirements-arm-vgf.txt
mlsdk_manifest_tag="${MLSDK_MANIFEST_TAG:-refs/tags/v2026.03.0}" # Keep this in sync with backends/arm/requirements-arm-vgf.txt and backends/arm/requirements-arm-vgf-runtime.txt

enable_model_converter=0
enable_vgf_lib=0
Expand Down
8 changes: 7 additions & 1 deletion examples/arm/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,13 @@ function setup_ethos_u_tools() {

function setup_mlsdk_dependencies() {
log_step "mlsdk" "Installing MLSDK dependencies"
pip install -r $et_dir/backends/arm/requirements-arm-vgf.txt
if [[ "${enable_model_converter}" -eq 1 || "${enable_emulation_layer}" -eq 1 ]]; then
pip install -r $et_dir/backends/arm/requirements-arm-vgf.txt
fi

if [[ "${enable_vgf_lib}" -eq 1 ]]; then
pip install -r $et_dir/backends/arm/requirements-arm-vgf-runtime.txt
fi
}

function validate_mlsdk_pip_compatibility() {
Expand Down
23 changes: 23 additions & 0 deletions tools/cmake/preset/pybind.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# Copyright 2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
Expand All @@ -25,9 +26,26 @@ set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE ON)
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_NAMED_DATA_MAP ON)
set_overridable_option(EXECUTORCH_BUILD_WHEEL_DO_NOT_USE ON)

# Optional VGF enable for the default pybind/install flow. This is intentionally
# scoped to this preset rather than acting as a general environment-to-CMake
# override mechanism.
set(_executorch_pybind_enable_vgf OFF)
if(DEFINED ENV{EXECUTORCH_PYBIND_ENABLE_VGF})
if("$ENV{EXECUTORCH_PYBIND_ENABLE_VGF}" STREQUAL "ON")
set(_executorch_pybind_enable_vgf ON)
else()
set(_executorch_pybind_enable_vgf OFF)
endif()
endif()

# TODO(larryliu0820): Temporarily disable building llm_runner for Windows wheel
# due to the issue of tokenizer file path length limitation.
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# VGF depends on Vulkan in the pybind flow.
set_overridable_option(
EXECUTORCH_BUILD_VULKAN ${_executorch_pybind_enable_vgf}
)
Comment thread
robell marked this conversation as resolved.
set_overridable_option(EXECUTORCH_BUILD_VGF ${_executorch_pybind_enable_vgf})
set_overridable_option(EXECUTORCH_BUILD_COREML ON)
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TRAINING ON)
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_LLM_RUNNER ON)
Expand All @@ -51,6 +69,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
endif()
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
# VGF depends on Vulkan in the pybind flow.
set_overridable_option(
EXECUTORCH_BUILD_VULKAN ${_executorch_pybind_enable_vgf}
)
set_overridable_option(EXECUTORCH_BUILD_VGF ${_executorch_pybind_enable_vgf})
set_overridable_option(EXECUTORCH_BUILD_COREML ON)
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TRAINING ON)
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_LLM_RUNNER ON)
Expand Down
Loading