From b6852778ffd4db1c507aeb098f0c2493a03816de Mon Sep 17 00:00:00 2001 From: Ting Lu Date: Tue, 19 Aug 2025 01:10:00 +0000 Subject: [PATCH] Add Magma build for CUDA 13.0 (#160770) Add magma build for CUDA 13.0 after almalinux docker is available https://github.com/pytorch/pytorch/issues/159779 Pull Request resolved: https://github.com/pytorch/pytorch/pull/160770 Approved by: https://github.com/atalman Co-authored-by: Andrey Talman Co-authored-by: Wei Wang --- .ci/magma/Makefile | 7 +++++++ .ci/magma/build_magma.sh | 2 ++ .ci/magma/package_files/cuda13.patch | 26 +++++++++++++++++++++++++ .github/workflows/build-magma-linux.yml | 2 +- 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .ci/magma/package_files/cuda13.patch diff --git a/.ci/magma/Makefile b/.ci/magma/Makefile index 5035e1ee3b2c..4169aedd03fa 100644 --- a/.ci/magma/Makefile +++ b/.ci/magma/Makefile @@ -16,6 +16,7 @@ DOCKER_RUN = set -eou pipefail; ${DOCKER_CMD} run --rm -i \ magma/build_magma.sh .PHONY: all +all: magma-cuda130 all: magma-cuda129 all: magma-cuda128 all: magma-cuda126 @@ -25,6 +26,12 @@ clean: $(RM) -r magma-* $(RM) -r output +.PHONY: magma-cuda130 +magma-cuda130: DESIRED_CUDA := 13.0 +magma-cuda130: CUDA_ARCH_LIST := -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_90,code=sm_90 -gencode arch=compute_100,code=sm_100 -gencode arch=compute_120,code=sm_120 +magma-cuda130: + $(DOCKER_RUN) + .PHONY: magma-cuda129 magma-cuda129: DESIRED_CUDA := 12.9 magma-cuda129: CUDA_ARCH_LIST += -gencode arch=compute_100,code=sm_100 -gencode arch=compute_120,code=sm_120 diff --git a/.ci/magma/build_magma.sh b/.ci/magma/build_magma.sh index 3ac0bcaf1d5b..6f1924fa4596 100755 --- a/.ci/magma/build_magma.sh +++ b/.ci/magma/build_magma.sh @@ -28,6 +28,7 @@ pushd ${PACKAGE_DIR}/magma-${MAGMA_VERSION} patch < ${PACKAGE_FILES}/CMake.patch patch < ${PACKAGE_FILES}/cmakelists.patch patch -p0 < ${PACKAGE_FILES}/thread_queue.patch +patch -p1 < ${PACKAGE_FILES}/cuda13.patch patch -p1 < ${PACKAGE_FILES}/getrf_shfl.patch patch -p1 < ${PACKAGE_FILES}/getrf_nbparam.patch # The build.sh script expects to be executed from the sources root folder @@ -37,6 +38,7 @@ popd # Package recipe, license and tarball # Folder and package name are backward compatible for the build workflow cp ${PACKAGE_FILES}/build.sh ${PACKAGE_RECIPE}/build.sh +cp ${PACKAGE_FILES}/cuda13.patch ${PACKAGE_RECIPE}/cuda13.patch cp ${PACKAGE_FILES}/thread_queue.patch ${PACKAGE_RECIPE}/thread_queue.patch cp ${PACKAGE_FILES}/cmakelists.patch ${PACKAGE_RECIPE}/cmakelists.patch cp ${PACKAGE_FILES}/getrf_shfl.patch ${PACKAGE_RECIPE}/getrf_shfl.patch diff --git a/.ci/magma/package_files/cuda13.patch b/.ci/magma/package_files/cuda13.patch new file mode 100644 index 000000000000..d6ebaf9dfaae --- /dev/null +++ b/.ci/magma/package_files/cuda13.patch @@ -0,0 +1,26 @@ +diff --git a/interface_cuda/interface.cpp b/interface_cuda/interface.cpp +index 73fed1b20..e77519bfe 100644 +--- a/interface_cuda/interface.cpp ++++ b/interface_cuda/interface.cpp +@@ -438,14 +438,20 @@ magma_print_environment() + cudaDeviceProp prop; + err = cudaGetDeviceProperties( &prop, dev ); + check_error( err ); ++ #ifdef MAGMA_HAVE_CUDA ++#if CUDA_VERSION < 13000 + printf( "%% device %d: %s, %.1f MHz clock, %.1f MiB memory, capability %d.%d\n", + dev, + prop.name, + prop.clockRate / 1000., ++#else ++ printf( "%% device %d: %s, ??? MHz clock, %.1f MiB memory, capability %d.%d\n", ++ dev, ++ prop.name, ++#endif + prop.totalGlobalMem / (1024.*1024.), + prop.major, + prop.minor ); +- #ifdef MAGMA_HAVE_CUDA + int arch = prop.major*100 + prop.minor*10; + if ( arch < MAGMA_CUDA_ARCH_MIN ) { + printf("\n" diff --git a/.github/workflows/build-magma-linux.yml b/.github/workflows/build-magma-linux.yml index e13de48b2408..be8f613169e8 100644 --- a/.github/workflows/build-magma-linux.yml +++ b/.github/workflows/build-magma-linux.yml @@ -34,7 +34,7 @@ jobs: id-token: write strategy: matrix: - cuda_version: ["129", "128", "126"] + cuda_version: ["130", "129", "128", "126"] steps: - name: Checkout PyTorch uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2