Remove torch XPU ABI=0 build logic for old compiler (#150095)

# Motivation
Follow https://github.com/pytorch/pytorch/pull/149888, this PR intends to remove ABI=0 build logic for PyTorch XPU build with old compiler (< 2025.0). For newer compilers >= 2025.0, the ABI is neutral by default without requiring additional compilation options (`-fpreview-breaking-changes`).

# Additional Context
This PR depends on XPU CI pass, which will be fixed by  https://github.com/pytorch/pytorch/pull/149843 and https://github.com/intel/torch-xpu-ops/pull/1515

Pull Request resolved: https://github.com/pytorch/pytorch/pull/150095
Approved by: https://github.com/EikanWang, https://github.com/malfet
This commit is contained in:
Yu, Guangye
2025-06-03 07:54:31 +00:00
committed by PyTorch MergeBot
parent 58e5d20c57
commit 10cef1e25d
4 changed files with 4 additions and 24 deletions

View File

@ -45,11 +45,6 @@ IF(NOT MKLDNN_FOUND)
list(APPEND DNNL_MAKE_COMMAND "--" "-l" "$ENV{MAX_JOBS}")
endif()
endif()
if(XPU_DEVICE_CXX_FLAGS)
set(DNNL_CXX_FLAGS "-DCMAKE_CXX_FLAGS=${XPU_DEVICE_CXX_FLAGS}")
else()
set(DNNL_CXX_FLAGS "")
endif()
ExternalProject_Add(xpu_mkldnn_proj
GIT_REPOSITORY https://github.com/oneapi-src/oneDNN
GIT_TAG v3.8.1
@ -57,7 +52,6 @@ IF(NOT MKLDNN_FOUND)
BUILD_IN_SOURCE 0
CMAKE_ARGS -DCMAKE_C_COMPILER=icx
-DCMAKE_CXX_COMPILER=${SYCL_CXX_DRIVER}
${DNNL_CXX_FLAGS}
-DDNNL_GPU_RUNTIME=SYCL
-DDNNL_CPU_RUNTIME=THREADPOOL
-DDNNL_BUILD_TESTS=OFF

View File

@ -99,12 +99,10 @@ set(PYTORCH_2_5_SYCL_TOOLKIT_VERSION 20249999)
# By default, we use libsycl.so on Linux and sycl.lib on Windows as the SYCL library name.
if (SYCL_COMPILER_VERSION VERSION_LESS_EQUAL PYTORCH_2_5_SYCL_TOOLKIT_VERSION)
# Don't use if(LINUX) here since this requires cmake>=3.25 and file is installed
# Don't use if(WIN32) here since this requires cmake>=3.25 and file is installed
# and used by other projects.
# See: https://cmake.org/cmake/help/v3.25/variable/LINUX.html
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(sycl_lib_suffix "-preview")
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
# On Windows, the SYCL library is named sycl7.lib until PYTORCH_2_5_SYCL_TOOLKIT_VERSION.
# sycl.lib is supported in the later version.
set(sycl_lib_suffix "7")

View File

@ -6,7 +6,6 @@ if(TARGET torch::xpurt)
endif()
set(XPU_HOST_CXX_FLAGS)
set(XPU_DEVICE_CXX_FLAGS)
# Find SYCL library.
find_package(SYCLToolkit REQUIRED)
@ -37,12 +36,6 @@ torch_xpu_get_arch_list(XPU_ARCH_FLAGS)
# propagate to torch-xpu-ops
set(TORCH_XPU_ARCH_LIST ${XPU_ARCH_FLAGS})
if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND SYCL_COMPILER_VERSION VERSION_LESS_EQUAL PYTORCH_2_5_SYCL_TOOLKIT_VERSION)
# for ABI compatibility on Linux
string(APPEND XPU_HOST_CXX_FLAGS " -D__INTEL_PREVIEW_BREAKING_CHANGES")
string(APPEND XPU_DEVICE_CXX_FLAGS " -fpreview-breaking-changes")
endif()
string(APPEND XPU_HOST_CXX_FLAGS " -DSYCL_COMPILER_VERSION=${SYCL_COMPILER_VERSION}")
if(DEFINED ENV{XPU_ENABLE_KINETO})

View File

@ -551,15 +551,10 @@ if __name__ == "__main__":
library = find_library_location("libtorch_xpu.so")
cmd = f"ldd {library} | grep libsycl"
results = subprocess.check_output(cmd, shell=True).strip().split(b"\n")
# There should be only one libsycl.so or libsycl-preview.so
# There should be only one libsycl.so
self.assertEqual(len(results), 1)
for result in results:
if b"libsycl.so" in result:
self.assertGreaterEqual(compiler_version, 20250000)
elif b"libsycl-preview.so" in result:
self.assertLess(compiler_version, 20250000)
else:
self.fail("Unexpected libsycl library")
self.assertTrue(b"libsycl.so" in result)
def test_dlpack_conversion(self):
x = make_tensor((5,), dtype=torch.float32, device="xpu")