Skip to content

Commit c7a0b68

Browse files
authored
Enable Arm VGF delegate in pybind builds (#19290)
- Enable VGF in pybind build if directed by env var. - Use VGF pybind in the wheel builds, based on package availability. ### Summary This adds VGF runtime delegate to end pip installs, and gives the option for ./install_executorch.sh to include it for developer side. This tidies up vgf with runtime installation further to the following: 1. developer flows: ./examples/arm/setup.sh --enable-mlsdk-deps; export EXECUTORCH_PYBIND_ENABLE_VGF=ON; ./install_executorch.sh --editable --optional-dependency vgf 3. wheel builds: # will invoke .ci/scripts/wheel/pre_build_script.sh which installs the build dependency # suitable platforms have EXECUTORCH_PYBIND_ENABLE_VGF=ON set 4. end users: pip install executorch[vgf] # published wheels contain runtime delegate on supported platforms cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @rascani --------- Signed-off-by: Rob Elliott <Robert.Elliott@arm.com>
1 parent f07ddec commit c7a0b68

10 files changed

Lines changed: 76 additions & 9 deletions

File tree

.ci/scripts/wheel/pre_build_script.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Copyright (c) Meta Platforms, Inc. and affiliates.
33
# All rights reserved.
44
#
5+
# Copyright 2026 Arm Limited and/or its affiliates.
6+
#
57
# This source code is licensed under the BSD-style license found in the
68
# LICENSE file in the root directory of this source tree.
79

@@ -57,6 +59,18 @@ fi
5759

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

62+
# Enable VGF in pybind wheel builds when the platform-specific build input is
63+
# available from pip.
64+
if [[ "$UNAME_S" == "Linux" || "$UNAME_S" == "Darwin" ]]; then
65+
if python3 -m pip install -r \
66+
"${GITHUB_WORKSPACE}/${REPOSITORY}/backends/arm/requirements-arm-vgf-runtime.txt"; then
67+
export EXECUTORCH_PYBIND_ENABLE_VGF=ON
68+
echo "EXECUTORCH_PYBIND_ENABLE_VGF=ON" >> "${GITHUB_ENV}"
69+
else
70+
echo "VGF build dependency unavailable on this platform; building without VGF"
71+
fi
72+
fi
73+
6074
# Download Qualcomm QNN SDK on Linux x86_64 so the wheel build can include the
6175
# QNN backend. The SDK is large, so we download it here (outside CMake) rather
6276
# than during cmake configure.

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,10 @@ if(EXECUTORCH_BUILD_PYBIND)
10401040
list(APPEND _dep_libs coremldelegate)
10411041
endif()
10421042

1043+
if(EXECUTORCH_BUILD_VGF)
1044+
list(APPEND _dep_libs vgf_backend)
1045+
endif()
1046+
10431047
if(EXECUTORCH_BUILD_MPS)
10441048
list(APPEND _dep_libs mpsdelegate)
10451049
endif()

backends/arm/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ if(EXECUTORCH_BUILD_VGF)
197197
set(_vgf_backend_sources backends/arm/runtime/VGFBackend.cpp
198198
backends/arm/runtime/VGFSetup.cpp
199199
)
200+
if(NOT EXECUTORCH_BUILD_VULKAN)
201+
list(APPEND _vgf_backend_sources backends/vulkan/third-party/volk/volk.c)
202+
endif()
200203

201204
# vgf backend
202205
list(TRANSFORM _vgf_backend_sources PREPEND "${EXECUTORCH_ROOT}/")
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright 2026 Arm Limited and/or its affiliates.
2+
#
3+
# This source code is licensed under the BSD-style license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
# Runtime build dependencies for the Arm VGF backend.
7+
8+
ai_ml_sdk_vgf_library == 0.9.0

backends/arm/requirements-arm-vgf.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@
77

88
ai_ml_emulation_layer_for_vulkan == 0.9.0
99
ai_ml_sdk_model_converter == 0.9.0
10-
ai_ml_sdk_vgf_library == 0.9.0

backends/arm/scripts/setup-mlsdk-from-source.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ root_dir="${et_dir}/examples/arm/arm-scratch"
1515
setup_path_script=""
1616
mlsdk_manifest_dir="ml-sdk-for-vulkan-manifest"
1717
mlsdk_manifest_url="${MLSDK_MANIFEST_URL:-https://github.com/arm/ai-ml-sdk-manifest.git}"
18-
mlsdk_manifest_tag="${MLSDK_MANIFEST_TAG:-refs/tags/v2026.03.0}" # Keep this in sync with what is mentioned in requirements-arm-vgf.txt
18+
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
1919

2020
enable_model_converter=0
2121
enable_vgf_lib=0

backends/arm/test/misc/test_vgf_check_env.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,22 @@ def test_cmake_build_flags_pass(tmp_path):
223223
assert "EXECUTORCH_BUILD_VULKAN=TRUE" in result.detail
224224

225225

226+
def test_cmake_build_flags_pass_when_vulkan_disabled(tmp_path):
227+
(tmp_path / "CMakeCache.txt").write_text(
228+
"EXECUTORCH_BUILD_VGF:BOOL=ON\n" "EXECUTORCH_BUILD_VULKAN:BOOL=OFF\n",
229+
encoding="utf-8",
230+
)
231+
232+
result = check_env._check_cmake_build_flags(
233+
build_dir=tmp_path,
234+
require_runtime_build=True,
235+
)
236+
237+
assert result.status == check_env.STATUS_OK
238+
assert "EXECUTORCH_BUILD_VGF=ON" in result.detail
239+
assert "EXECUTORCH_BUILD_VULKAN=OFF" in result.detail
240+
241+
226242
def test_cmake_build_flags_fail_when_vgf_disabled(tmp_path):
227243
(tmp_path / "CMakeCache.txt").write_text(
228244
"EXECUTORCH_BUILD_VGF:BOOL=OFF\n" "EXECUTORCH_BUILD_VULKAN:BOOL=ON\n",

backends/arm/vgf/check_env.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,8 @@ def _check_cmake_build_flags(
704704
"VGF source-build CMake flags",
705705
STATUS_FAIL,
706706
f"No CMakeCache.txt found for build_dir={build_dir!s}.",
707-
"Configure the runtime build with -DEXECUTORCH_BUILD_VGF=ON "
708-
"-DEXECUTORCH_BUILD_VULKAN=ON, then pass --build-dir <dir>.",
707+
"Configure the runtime build with -DEXECUTORCH_BUILD_VGF=ON, "
708+
"then pass --build-dir <dir>.",
709709
)
710710

711711
status = STATUS_FAIL if require_runtime_build else STATUS_WARN
@@ -720,12 +720,15 @@ def _check_cmake_build_flags(
720720
values = _parse_cmake_cache(cache)
721721
required = {
722722
"EXECUTORCH_BUILD_VGF": values.get("EXECUTORCH_BUILD_VGF"),
723+
}
724+
observed = {
725+
**required,
723726
"EXECUTORCH_BUILD_VULKAN": values.get("EXECUTORCH_BUILD_VULKAN"),
724727
}
725728
bad = [key for key, value in required.items() if not _is_cmake_truthy(value)]
726729
rendered = ", ".join(
727730
f"{key}={value if value is not None else '<missing>'}"
728-
for key, value in required.items()
731+
for key, value in observed.items()
729732
)
730733

731734
if bad:
@@ -734,8 +737,7 @@ def _check_cmake_build_flags(
734737
STATUS_FAIL,
735738
f"{cache}: required runtime flag(s) are disabled or missing: "
736739
f"{', '.join(bad)}. Current values: {rendered}",
737-
"Reconfigure CMake with -DEXECUTORCH_BUILD_VGF=ON "
738-
"-DEXECUTORCH_BUILD_VULKAN=ON.",
740+
"Reconfigure CMake with -DEXECUTORCH_BUILD_VGF=ON.",
739741
)
740742

741743
return VgfEnvironmentCheck(

examples/arm/setup.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ function setup_root_dir() {
209209

210210
function setup_ethos_u_tools() {
211211
log_step "ethos-u-tools" "Installing Ethos-U Python tooling"
212-
CMAKE_POLICY_VERSION_MINIMUM=3.5 BUILD_PYBIND=1 pip install --no-dependencies -r $et_dir/backends/arm/requirements-arm-ethos-u.txt
212+
CMAKE_POLICY_VERSION_MINIMUM=3.5 BUILD_PYBIND=1 pip install --no-dependencies -r "$et_dir/backends/arm/requirements-arm-ethos-u.txt"
213213
}
214214

215215
function setup_cortex_m_tools() {
@@ -219,7 +219,13 @@ function setup_cortex_m_tools() {
219219

220220
function setup_mlsdk_dependencies() {
221221
log_step "mlsdk" "Installing MLSDK dependencies"
222-
pip install -r $et_dir/backends/arm/requirements-arm-vgf.txt
222+
if [[ "${enable_model_converter}" -eq 1 || "${enable_emulation_layer}" -eq 1 ]]; then
223+
pip install -r "$et_dir/backends/arm/requirements-arm-vgf.txt"
224+
fi
225+
226+
if [[ "${enable_vgf_lib}" -eq 1 ]]; then
227+
pip install -r "$et_dir/backends/arm/requirements-arm-vgf-runtime.txt"
228+
fi
223229
}
224230

225231
function validate_mlsdk_pip_compatibility() {

tools/cmake/preset/pybind.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) Meta Platforms, Inc. and affiliates.
22
# All rights reserved.
3+
# Copyright 2026 Arm Limited and/or its affiliates.
34
#
45
# This source code is licensed under the BSD-style license found in the
56
# LICENSE file in the root directory of this source tree.
@@ -25,9 +26,22 @@ set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE ON)
2526
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_NAMED_DATA_MAP ON)
2627
set_overridable_option(EXECUTORCH_BUILD_WHEEL_DO_NOT_USE ON)
2728

29+
# Optional VGF enable for the default pybind/install flow. This is intentionally
30+
# scoped to this preset rather than acting as a general environment-to-CMake
31+
# override mechanism.
32+
set(_executorch_pybind_enable_vgf OFF)
33+
if(DEFINED ENV{EXECUTORCH_PYBIND_ENABLE_VGF})
34+
if("$ENV{EXECUTORCH_PYBIND_ENABLE_VGF}" STREQUAL "ON")
35+
set(_executorch_pybind_enable_vgf ON)
36+
else()
37+
set(_executorch_pybind_enable_vgf OFF)
38+
endif()
39+
endif()
40+
2841
# TODO(larryliu0820): Temporarily disable building llm_runner for Windows wheel
2942
# due to the issue of tokenizer file path length limitation.
3043
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
44+
set_overridable_option(EXECUTORCH_BUILD_VGF ${_executorch_pybind_enable_vgf})
3145
set_overridable_option(EXECUTORCH_BUILD_COREML ON)
3246
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TRAINING ON)
3347
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_LLM_RUNNER ON)
@@ -51,6 +65,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
5165
endif()
5266
endif()
5367
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
68+
set_overridable_option(EXECUTORCH_BUILD_VGF ${_executorch_pybind_enable_vgf})
5469
set_overridable_option(EXECUTORCH_BUILD_COREML ON)
5570
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TRAINING ON)
5671
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_LLM_RUNNER ON)

0 commit comments

Comments
 (0)