From 48153c72b27df2d552bd67519476d53f174438cb Mon Sep 17 00:00:00 2001 From: Xu Han Date: Tue, 7 Jan 2025 01:11:25 +0000 Subject: [PATCH] [Intel XPU] enable kineto for XPU Windows. (#144034) This PR will turn on `kineto` on Windowx XPU wheel build. For `kineto` on Windows XPU, the build time dependencies list: 1. Intel PTI, it contained by oneAPI 2025+. 2. Level zero SDK: https://github.com/oneapi-src/level-zero/releases/download/v1.14.0/level-zero-sdk_1.14.0.zip **Note:** We need to manual setup level zero SDK on build time, so we will turn off kineto build on Windows XPU by default. It is in order to avoid developer occurred build issue. After add level zero SDK include path to `INCLUDE` env_var path. We can add an env_var `XPU_ENABLE_KINETO` to turn on it. For runtime dependency: 1. Intel-pti pipy package. @chuanqi129 will follow up on further PR. Local tested the nightly binary: image TODO: @chuanqi129 will submit a following PR to add `intel-pti` as dependency and turn on env_var `XPU_ENABLE_KINETO` for nightly build. Pull Request resolved: https://github.com/pytorch/pytorch/pull/144034 Approved by: https://github.com/chuanqi129, https://github.com/zejun-chen, https://github.com/EikanWang, https://github.com/sraikund16 --- .ci/pytorch/windows/internal/xpu_install.bat | 11 +++++++++++ cmake/Dependencies.cmake | 2 +- cmake/public/xpu.cmake | 10 ++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.ci/pytorch/windows/internal/xpu_install.bat b/.ci/pytorch/windows/internal/xpu_install.bat index 4d86d6ab193..2f02e475bb6 100644 --- a/.ci/pytorch/windows/internal/xpu_install.bat +++ b/.ci/pytorch/windows/internal/xpu_install.bat @@ -7,6 +7,9 @@ if not "%CUDA_VERSION%" == "xpu" ( exit /b 0 ) +set SRC_DIR=%NIGHTLIES_PYTORCH_ROOT% +if not exist "%SRC_DIR%\temp_build" mkdir "%SRC_DIR%\temp_build" + set XPU_INSTALL_MODE=%~1 if "%XPU_INSTALL_MODE%"=="" goto xpu_bundle_install_start if "%XPU_INSTALL_MODE%"=="bundle" goto xpu_bundle_install_start @@ -101,6 +104,14 @@ goto xpu_install_end :xpu_bundle_install +:: Install Level Zero SDK +set XPU_EXTRA_LZ_URL=https://github.com/oneapi-src/level-zero/releases/download/v1.14.0/level-zero-sdk_1.14.0.zip +curl -k -L %XPU_EXTRA_LZ_URL% --output "%SRC_DIR%\temp_build\level_zero_sdk.zip" +echo "Installing level zero SDK..." +7z x "%SRC_DIR%\temp_build\level_zero_sdk.zip" -o"%SRC_DIR%\temp_build\level_zero" +set "INCLUDE=%SRC_DIR%\temp_build\level_zero\include;%INCLUDE%" + +:: Install Bundle curl -o xpu_bundle.exe --retry 3 --retry-all-errors -k %XPU_BUNDLE_URL% echo "XPU Bundle installing..." start /wait "Intel Pytorch Bundle Installer" "xpu_bundle.exe" --action=install --eula=accept --silent --log-dir install_bundle diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index 602e0bd0a01..1653ae16381 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -1573,7 +1573,7 @@ if(USE_KINETO) message(STATUS "Using Kineto with Roctracer support") endif() - if((NOT USE_XPU) OR WIN32) + if((NOT USE_XPU) OR (NOT XPU_ENABLE_KINETO)) set(LIBKINETO_NOXPUPTI ON CACHE STRING "" FORCE) else() set(LIBKINETO_NOXPUPTI OFF CACHE STRING "") diff --git a/cmake/public/xpu.cmake b/cmake/public/xpu.cmake index eb4b723da37..5025da53b5b 100644 --- a/cmake/public/xpu.cmake +++ b/cmake/public/xpu.cmake @@ -44,3 +44,13 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND SYCL_COMPILER_VERSION VERSION_LESS_EQUA endif() string(APPEND XPU_HOST_CXX_FLAGS " -DSYCL_COMPILER_VERSION=${SYCL_COMPILER_VERSION}") + +if(DEFINED ENV{XPU_ENABLE_KINETO}) + set(XPU_ENABLE_KINETO TRUE) +else() + set(XPU_ENABLE_KINETO FALSE) +endif() + +if(NOT WIN32) + set(XPU_ENABLE_KINETO TRUE) +endif() \ No newline at end of file