diff --git a/.ci/scripts/wheel/pre_build_script.sh b/.ci/scripts/wheel/pre_build_script.sh index 365398d27a4..5ad57f3c710 100755 --- a/.ci/scripts/wheel/pre_build_script.sh +++ b/.ci/scripts/wheel/pre_build_script.sh @@ -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. @@ -57,6 +59,18 @@ fi "${GITHUB_WORKSPACE}/${REPOSITORY}/install_requirements.sh" --example +# 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 + export EXECUTORCH_PYBIND_ENABLE_VGF=ON + echo "EXECUTORCH_PYBIND_ENABLE_VGF=ON" >> "${GITHUB_ENV}" + 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. diff --git a/CMakeLists.txt b/CMakeLists.txt index ce0def6000b..a8c7edc1216 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/backends/arm/CMakeLists.txt b/backends/arm/CMakeLists.txt index 12c46107104..81a5d488c1a 100644 --- a/backends/arm/CMakeLists.txt +++ b/backends/arm/CMakeLists.txt @@ -160,6 +160,9 @@ if(EXECUTORCH_BUILD_VGF) set(_vgf_backend_sources backends/arm/runtime/VGFBackend.cpp backends/arm/runtime/VGFSetup.cpp ) + if(NOT EXECUTORCH_BUILD_VULKAN) + list(APPEND _vgf_backend_sources backends/vulkan/third-party/volk/volk.c) + endif() # vgf backend list(TRANSFORM _vgf_backend_sources PREPEND "${EXECUTORCH_ROOT}/") diff --git a/backends/arm/requirements-arm-vgf-runtime.txt b/backends/arm/requirements-arm-vgf-runtime.txt new file mode 100644 index 00000000000..e395862d0dd --- /dev/null +++ b/backends/arm/requirements-arm-vgf-runtime.txt @@ -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. + +# Runtime build dependencies for the Arm VGF backend. + +ai_ml_sdk_vgf_library == 0.9.0 diff --git a/backends/arm/requirements-arm-vgf.txt b/backends/arm/requirements-arm-vgf.txt index 5627c4f13ec..30cc48f2836 100644 --- a/backends/arm/requirements-arm-vgf.txt +++ b/backends/arm/requirements-arm-vgf.txt @@ -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 diff --git a/backends/arm/scripts/setup-mlsdk-from-source.sh b/backends/arm/scripts/setup-mlsdk-from-source.sh index 0d6b6040bf9..d8ec1795a23 100755 --- a/backends/arm/scripts/setup-mlsdk-from-source.sh +++ b/backends/arm/scripts/setup-mlsdk-from-source.sh @@ -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 diff --git a/examples/arm/setup.sh b/examples/arm/setup.sh index 323815b59a2..7d452293766 100755 --- a/examples/arm/setup.sh +++ b/examples/arm/setup.sh @@ -184,7 +184,7 @@ function check_options() { ;; --setup-test-dependency) log_step "deps" "Installing test dependency..." - source $et_dir/backends/arm/scripts/install_models_for_test.sh + source "$et_dir/backends/arm/scripts/install_models_for_test.sh" exit 0 ;; --help) @@ -208,12 +208,18 @@ function setup_root_dir() { function setup_ethos_u_tools() { log_step "ethos-u-tools" "Installing Ethos-U Python tooling" - CMAKE_POLICY_VERSION_MINIMUM=3.5 BUILD_PYBIND=1 pip install --no-dependencies -r $et_dir/backends/arm/requirements-arm-ethos-u.txt + CMAKE_POLICY_VERSION_MINIMUM=3.5 BUILD_PYBIND=1 pip install --no-dependencies -r "$et_dir/backends/arm/requirements-arm-ethos-u.txt" } 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() { diff --git a/tools/cmake/preset/pybind.cmake b/tools/cmake/preset/pybind.cmake index ecce850ab3c..0b84fb93d79 100644 --- a/tools/cmake/preset/pybind.cmake +++ b/tools/cmake/preset/pybind.cmake @@ -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. @@ -25,9 +26,22 @@ 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") + 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) @@ -51,6 +65,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + 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)