From 2d9b5647c30ff5f2f6fe073130b49e03e56093a6 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Sat, 20 Jul 2024 06:16:21 -0600 Subject: [PATCH] Use fbgemm on 2.4 Signed-off-by: Tom Rix --- ...1-Add-cmake-option-USE_SYSTEM_FBGEMM.patch | 47 +++++++++++++++++++ python-torch.spec | 31 ++++++++++-- 2 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 next/0001-Add-cmake-option-USE_SYSTEM_FBGEMM.patch diff --git a/next/0001-Add-cmake-option-USE_SYSTEM_FBGEMM.patch b/next/0001-Add-cmake-option-USE_SYSTEM_FBGEMM.patch new file mode 100644 index 0000000..413c60d --- /dev/null +++ b/next/0001-Add-cmake-option-USE_SYSTEM_FBGEMM.patch @@ -0,0 +1,47 @@ +From 091b7fe1ccbb5e4ff4ac6017d42bacb869f61a27 Mon Sep 17 00:00:00 2001 +From: Tom Rix +Date: Sat, 20 Jul 2024 05:37:15 -0600 +Subject: [PATCH] Add cmake option USE_SYSTEM_FBGEMM + +Signed-off-by: Tom Rix +--- + CMakeLists.txt | 1 + + cmake/Dependencies.cmake | 3 ++- + 2 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c4cd4b2c2a98..2068f7c6c4f2 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -253,6 +253,7 @@ cmake_dependent_option(USE_STATIC_CUDNN "Use cuDNN static libraries" OFF + "USE_CUDNN" OFF) + cmake_dependent_option(USE_CUSPARSELT "Use cuSPARSELt" ON "USE_CUDA" OFF) + option(USE_FBGEMM "Use FBGEMM (quantized 8-bit server operators)" ON) ++option(USE_SYSTEM_FBGEMM "Use system-wide FBGEMM" OFF) + option(USE_KINETO "Use Kineto profiling library" ON) + option(USE_CUPTI_SO "Use CUPTI as a shared library" ON) + option(USE_FAKELOWP "Use FakeLowp operators" OFF) +diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake +index f1f2eb7cec31..192dac46f13b 100644 +--- a/cmake/Dependencies.cmake ++++ b/cmake/Dependencies.cmake +@@ -706,6 +706,7 @@ endif() + + # ---[ FBGEMM + if(USE_FBGEMM) ++ if (NOT USE_SYSTEM_FBGEMM) + set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party") + if(NOT DEFINED FBGEMM_SOURCE_DIR) + set(FBGEMM_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/fbgemm" CACHE STRING "FBGEMM source directory") +@@ -746,7 +747,7 @@ if(USE_FBGEMM) + target_compile_options_if_supported(asmjit -Wno-unused-but-set-variable) + endif() + endif() +- ++ endif() + if(USE_FBGEMM) + list(APPEND Caffe2_DEPENDENCY_LIBS fbgemm) + endif() +-- +2.45.1 + diff --git a/python-torch.spec b/python-torch.spec index f27f099..3e74505 100644 --- a/python-torch.spec +++ b/python-torch.spec @@ -32,14 +32,14 @@ %endif # hipblaslt is in development %bcond_with hipblaslt -# magma is in development -%bcond_with magma # Which families gpu build for %if 0%{?fedora} > 40 %global rocm_gpu_list gfx8 gfx9 gfx10 gfx11 gfx90a gfx942 gfx1100 +%bcond_without magma %else # F40 %global rocm_gpu_list gfx8 gfx9 gfx10 gfx11 +%bcond_with magma %endif %global rocm_default_gpu default %bcond_without rocm_loop @@ -94,6 +94,16 @@ %bcond_with pocketfft %endif +%if 0%{?fedora} > 40 +%if %{with gitcommit} +%bcond_without fbgemm +%else +%bcond_with fbgemm +%endif +%else +%bcond_with fbgemm +%endif + # For testing cuda %ifarch x86_64 %bcond_with cuda @@ -230,6 +240,10 @@ Source80: https://github.com/pytorch/kineto/archive/%{ki_commit}/kineto-%{ %endif Patch0: 0001-no-third_party-foxi.patch +%if %{with gitcommit} +# https://github.com/pytorch/pytorch/pull/131282 +Patch1: 0001-Add-cmake-option-USE_SYSTEM_FBGEMM.patch +%endif %if %{without gitcommit} Patch3: 0001-Stub-in-kineto-ActivityType.patch @@ -265,7 +279,6 @@ Patch9: 0001-Enable-x86-CPU-vectorization-on-windows-submodule-sl.patch # For Python 3.13 # https://github.com/pytorch/pytorch/pull/126033 Patch10: 0001-Changes-to-compile-with-3.13-126033.patch - %endif # ROCm patches @@ -281,7 +294,6 @@ Patch102: 0001-silence-an-assert.patch %if %{without gitcommit} Patch103: 0001-can-not-use-with-c-files.patch %endif -# Patch104: 0001-use-any-hip.patch Patch105: 0001-disable-use-of-aotriton.patch %endif Patch106: 0001-include-fmt-ranges.h-for-using-fmt-join.patch @@ -292,6 +304,10 @@ ExclusiveArch: x86_64 aarch64 BuildRequires: cmake BuildRequires: eigen3-devel +%if %{with fbgemm} +BuildRequires: asmjit-devel +BuildRequires: fbgemm-devel +%endif BuildRequires: flexiblas-devel BuildRequires: fmt-devel %if %{with caffe2} @@ -885,9 +901,14 @@ export INTERN_BUILD_MOBILE=OFF export USE_DISTRIBUTED=OFF export USE_CUDA=OFF export USE_FAKELOWP=OFF +%if %{with fbgemm} +export USE_FBGEMM=ON +export USE_SYSTEM_FBGEMM=ON +%else export USE_FBGEMM=OFF +%endif export USE_FLASH_ATTENTION=OFF -export USE_GOLD_LINKER=OFF +export USE_GOLD_LINKER=ON export USE_GLOO=OFF export USE_ITT=OFF export USE_KINETO=OFF