diff --git a/examples/kernels/relu/build.toml b/examples/kernels/relu/build.toml index e6741d3cb..6b9f4d099 100644 --- a/examples/kernels/relu/build.toml +++ b/examples/kernels/relu/build.toml @@ -40,12 +40,13 @@ rocm-archs = [ "gfx906", "gfx908", "gfx90a", - "gfx940", - "gfx941", "gfx942", + "gfx950", "gfx1030", "gfx1100", "gfx1101", + "gfx1200", + "gfx1201", ] src = ["relu_cuda/relu.cu"] diff --git a/kernel-builder/src/pyproject/kernel.rs b/kernel-builder/src/pyproject/kernel.rs index 2e7063e1f..6bf78f50f 100644 --- a/kernel-builder/src/pyproject/kernel.rs +++ b/kernel-builder/src/pyproject/kernel.rs @@ -37,9 +37,12 @@ fn render_kernel_component( Kernel::Cpu { .. } => { render_kernel_component_cpu(env, kernel_name, kernel, sources, write)? } - Kernel::Cuda { .. } | Kernel::Rocm { .. } => { + Kernel::Cuda { .. } => { render_kernel_component_cuda(env, kernel_name, kernel, sources, write)? } + Kernel::Rocm { .. } => { + render_kernel_component_hip(env, kernel_name, kernel, sources, write)? + } Kernel::Metal { .. } => { render_kernel_component_metal(env, kernel_name, kernel, sources, write)? } @@ -83,7 +86,7 @@ fn render_kernel_component_cuda( sources: String, write: &mut impl Write, ) -> Result<()> { - let (cuda_capabilities, rocm_archs, cuda_flags, hip_flags, cuda_minver) = match kernel { + let (cuda_capabilities, cuda_flags, cuda_minver) = match kernel { Kernel::Cuda { cuda_capabilities, cuda_flags, @@ -91,22 +94,9 @@ fn render_kernel_component_cuda( .. } => ( cuda_capabilities.as_deref(), - None, cuda_flags.as_deref(), - None, cuda_minver.as_ref(), ), - Kernel::Rocm { - rocm_archs, - hip_flags, - .. - } => ( - None, - rocm_archs.as_deref(), - None, - hip_flags.as_deref(), - None, - ), _ => unreachable!("Unsupported kernel type for CUDA rendering"), }; @@ -114,15 +104,49 @@ fn render_kernel_component_cuda( .wrap_err("Cannot get kernel template")? .render_captured_to( context! { + name => kernel_name, cuda_capabilities => cuda_capabilities, cuda_flags => cuda_flags.map(|flags| flags.join(";")), cuda_minver => cuda_minver.map(ToString::to_string), + cxx_flags => kernel.cxx_flags().map(|flags| flags.join(";")), + includes => kernel.include().map(prefix_and_join_includes), + kernel_name => kernel_name, + sources => sources, + }, + &mut *write, + ) + .wrap_err("Cannot render kernel template")?; + + write.write_all(b"\n")?; + + Ok(()) +} + +fn render_kernel_component_hip( + env: &Environment, + kernel_name: &str, + kernel: &Kernel, + sources: String, + write: &mut impl Write, +) -> Result<()> { + let (rocm_archs, hip_flags) = match kernel { + Kernel::Rocm { + rocm_archs, + hip_flags, + .. + } => (rocm_archs.as_deref(), hip_flags.as_deref()), + _ => unreachable!("Unsupported kernel type for ROCm rendering"), + }; + + env.get_template("kernel-component/hip.cmake") + .wrap_err("Cannot get kernel template")? + .render_captured_to( + context! { cxx_flags => kernel.cxx_flags().map(|flags| flags.join(";")), rocm_archs => rocm_archs, hip_flags => hip_flags.map(|flags| flags.join(";")), includes => kernel.include().map(prefix_and_join_includes), - kernel_name => kernel_name, - supports_hipify => matches!(kernel, Kernel::Rocm{ .. }), + name => kernel_name, sources => sources, }, &mut *write, diff --git a/kernel-builder/src/pyproject/templates/kernel-component/cuda.cmake b/kernel-builder/src/pyproject/templates/kernel-component/cuda.cmake index 21fb4a77c..62f849951 100644 --- a/kernel-builder/src/pyproject/templates/kernel-component/cuda.cmake +++ b/kernel-builder/src/pyproject/templates/kernel-component/cuda.cmake @@ -1,11 +1,11 @@ +if(GPU_LANG STREQUAL "CUDA") cuda_kernel_component(SRC + NAME {{ name }} SOURCES {{ sources }} {% if cuda_minver %}CUDA_MINVER {{ cuda_minver }}{% endif %} {% if includes %}INCLUDES "{{ includes }}"{% endif %} {% if cuda_capabilities %}CUDA_CAPABILITIES {{ cuda_capabilities|join(" ") }}{% endif %} {% if cuda_flags %}CUDA_FLAGS "{{ cuda_flags }}"{% endif %} {% if cxx_flags %}CXX_FLAGS "{{ cxx_flags }}"{% endif %} - {% if supports_hipify %}SUPPORTS_HIPIFY{% endif %} - {% if hip_flags %}HIP_FLAGS "{{ hip_flags }}"{% endif %} - {% if rocm_archs %}ROCM_ARCHS {{ rocm_archs|join(" ") }}{% endif %} ) +endif() diff --git a/kernel-builder/src/pyproject/templates/kernel-component/hip.cmake b/kernel-builder/src/pyproject/templates/kernel-component/hip.cmake new file mode 100644 index 000000000..cee3523ee --- /dev/null +++ b/kernel-builder/src/pyproject/templates/kernel-component/hip.cmake @@ -0,0 +1,10 @@ +if(GPU_LANG STREQUAL "HIP") +hip_kernel_component(SRC + NAME {{ name }} + SOURCES {{ sources }} + {% if includes %}INCLUDES "{{ includes }}"{% endif %} + {% if cxx_flags %}CXX_FLAGS "{{ cxx_flags }}"{% endif %} + {% if hip_flags %}HIP_FLAGS "{{ hip_flags }}"{% endif %} + {% if rocm_archs %}ROCM_ARCHS {{ rocm_archs|join(" ") }}{% endif %} +) +endif() diff --git a/kernel-builder/src/pyproject/templates/kernel.cmake b/kernel-builder/src/pyproject/templates/kernel.cmake index 1f81f334d..4d4ffa640 100644 --- a/kernel-builder/src/pyproject/templates/kernel.cmake +++ b/kernel-builder/src/pyproject/templates/kernel.cmake @@ -6,9 +6,8 @@ function(accumulate_gpu_archs OUT_ACC ACC EXTRA_ARCHS) endfunction() function(cuda_kernel_component SRC_VAR) - set(options SUPPORTS_HIPIFY) - set(oneValueArgs CUDA_MINVER) - set(multiValueArgs SOURCES INCLUDES CUDA_CAPABILITIES CUDA_FLAGS CXX_FLAGS HIP_FLAGS ROCM_ARCHS) + set(oneValueArgs CUDA_MINVER NAME) + set(multiValueArgs SOURCES INCLUDES CUDA_CAPABILITIES CUDA_FLAGS CXX_FLAGS) cmake_parse_arguments(KERNEL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) if(NOT KERNEL_SOURCES) @@ -32,97 +31,116 @@ function(cuda_kernel_component SRC_VAR) PROPERTIES INCLUDE_DIRECTORIES "${KERNEL_INCLUDES}") endif() - if(GPU_LANG STREQUAL "CUDA") - # Determine CUDA architectures - if(KERNEL_CUDA_CAPABILITIES) - cuda_archs_loose_intersection(_KERNEL_ARCHS "${KERNEL_CUDA_CAPABILITIES}" "${CUDA_ARCHS}") - else() - set(_KERNEL_ARCHS "${CUDA_KERNEL_ARCHS}") + # Determine CUDA architectures + if(KERNEL_CUDA_CAPABILITIES) + cuda_archs_loose_intersection(_KERNEL_ARCHS "${KERNEL_CUDA_CAPABILITIES}" "${CUDA_ARCHS}") + else() + set(_KERNEL_ARCHS "${CUDA_KERNEL_ARCHS}") + endif() + message(STATUS "CUDA kernel: ${KERNEL_NAME}, capabilities: ${_KERNEL_ARCHS}") + set_gencode_flags_for_srcs(SRCS "${_KERNEL_SRC}" CUDA_ARCHS "${_KERNEL_ARCHS}") + + accumulate_gpu_archs(_ALL_GPU_ARCHS "${ALL_GPU_ARCHS}" "${_KERNEL_ARCHS}") + set(ALL_GPU_ARCHS ${_ALL_GPU_ARCHS} PARENT_SCOPE) + + # Apply CUDA-specific compile flags + if(KERNEL_CUDA_FLAGS) + set(_CUDA_FLAGS "${KERNEL_CUDA_FLAGS}") + # -static-global-template-stub is not supported on CUDA < 12.8. Remove this + # once we don't support CUDA 12.6 anymore. + if(CUDA_VERSION VERSION_LESS 12.8) + string(REGEX REPLACE "-static-global-template-stub=(true|false)" "" _CUDA_FLAGS "${_CUDA_FLAGS}") endif() - message(STATUS "CUDA kernel capabilities: ${_KERNEL_ARCHS}") - set_gencode_flags_for_srcs(SRCS "${_KERNEL_SRC}" CUDA_ARCHS "${_KERNEL_ARCHS}") - - accumulate_gpu_archs(_ALL_GPU_ARCHS "${ALL_GPU_ARCHS}" "${_KERNEL_ARCHS}") - set(ALL_GPU_ARCHS ${_ALL_GPU_ARCHS} PARENT_SCOPE) - - # Apply CUDA-specific compile flags - if(KERNEL_CUDA_FLAGS) - set(_CUDA_FLAGS "${KERNEL_CUDA_FLAGS}") - # -static-global-template-stub is not supported on CUDA < 12.8. Remove this - # once we don't support CUDA 12.6 anymore. - if(CUDA_VERSION VERSION_LESS 12.8) - string(REGEX REPLACE "-static-global-template-stub=(true|false)" "" _CUDA_FLAGS "${_CUDA_FLAGS}") + + foreach(_SRC ${_KERNEL_SRC}) + if(_SRC MATCHES ".*\\.cu$") + set_property( + SOURCE ${_SRC} + APPEND PROPERTY + COMPILE_OPTIONS "$<$:${_CUDA_FLAGS}>" + ) endif() + endforeach() + endif() - foreach(_SRC ${_KERNEL_SRC}) - if(_SRC MATCHES ".*\\.cu$") - set_property( - SOURCE ${_SRC} - APPEND PROPERTY - COMPILE_OPTIONS "$<$:${_CUDA_FLAGS}>" - ) - endif() - endforeach() - endif() + # Apply CXX-specific compile flags + if(KERNEL_CXX_FLAGS) + foreach(_SRC ${_KERNEL_SRC}) + set_property( + SOURCE ${_SRC} + APPEND PROPERTY + COMPILE_OPTIONS "$<$:${KERNEL_CXX_FLAGS}>" + ) + endforeach() + endif() - # Apply CXX-specific compile flags - if(KERNEL_CXX_FLAGS) - foreach(_SRC ${_KERNEL_SRC}) - set_property( - SOURCE ${_SRC} - APPEND PROPERTY - COMPILE_OPTIONS "$<$:${KERNEL_CXX_FLAGS}>" - ) - endforeach() - endif() + set(_TMP_SRC ${${SRC_VAR}}) + list(APPEND _TMP_SRC ${_KERNEL_SRC}) + set(${SRC_VAR} ${_TMP_SRC} PARENT_SCOPE) +endfunction() - set(_TMP_SRC ${${SRC_VAR}}) - list(APPEND _TMP_SRC ${_KERNEL_SRC}) - set(${SRC_VAR} ${_TMP_SRC} PARENT_SCOPE) +function(hip_kernel_component SRC_VAR) + set(options SUPPORTS_HIPIFY) + set(oneValueArgs CUDA_MINVER NAME) + set(multiValueArgs SOURCES INCLUDES CXX_FLAGS HIP_FLAGS ROCM_ARCHS) + cmake_parse_arguments(KERNEL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - elseif(GPU_LANG STREQUAL "HIP") - # Apply HIP-specific compile flags - if(KERNEL_HIP_FLAGS) - foreach(_SRC ${_KERNEL_SRC}) - if(_SRC MATCHES ".*\\.(cu|hip)$") - set_property( - SOURCE ${_SRC} - APPEND PROPERTY - COMPILE_OPTIONS "$<$:${KERNEL_HIP_FLAGS}>" - ) - endif() - endforeach() - endif() + if(NOT KERNEL_SOURCES) + message(FATAL_ERROR "hip_kernel_component: SOURCES argument is required") + endif() - # Determine ROCm architectures - if(KERNEL_ROCM_ARCHS) - hip_archs_loose_intersection(_KERNEL_ARCHS "${KERNEL_ROCM_ARCHS}" "${ROCM_ARCHS}") - else() - set(_KERNEL_ARCHS "${ROCM_ARCHS}") - endif() - message(STATUS "HIP kernel archs: ${_KERNEL_ARCHS}") + set(_KERNEL_SRC ${KERNEL_SOURCES}) - accumulate_gpu_archs(_ALL_GPU_ARCHS "${ALL_GPU_ARCHS}" "${_KERNEL_ARCHS}") - set(ALL_GPU_ARCHS ${_ALL_GPU_ARCHS} PARENT_SCOPE) + if(KERNEL_INCLUDES) + # TODO: check if CLion support this: + # https://youtrack.jetbrains.com/issue/CPP-16510/CLion-does-not-handle-per-file-include-directories + set_source_files_properties( + ${_KERNEL_SRC} + PROPERTIES INCLUDE_DIRECTORIES "${KERNEL_INCLUDES}") + endif() + # Apply HIP-specific compile flags + if(KERNEL_HIP_FLAGS) foreach(_SRC ${_KERNEL_SRC}) if(_SRC MATCHES ".*\\.(cu|hip)$") - foreach(_ARCH ${_KERNEL_ARCHS}) - set_property( - SOURCE ${_SRC} - APPEND PROPERTY - COMPILE_OPTIONS "$<$:--offload-arch=${_ARCH}>" - ) - endforeach() + set_property( + SOURCE ${_SRC} + APPEND PROPERTY + COMPILE_OPTIONS "$<$:${KERNEL_HIP_FLAGS}>" + ) endif() endforeach() + endif() - set(_TMP_SRC ${${SRC_VAR}}) - list(APPEND _TMP_SRC ${_KERNEL_SRC}) - set(${SRC_VAR} ${_TMP_SRC} PARENT_SCOPE) + # Determine ROCm architectures + if(KERNEL_ROCM_ARCHS) + hip_archs_loose_intersection(_KERNEL_ARCHS "${KERNEL_ROCM_ARCHS}" "${ROCM_ARCHS}") + else() + set(_KERNEL_ARCHS "${ROCM_ARCHS}") endif() + message(STATUS "ROCm kernel: ${KERNEL_NAME}, archs: ${_KERNEL_ARCHS}") + + accumulate_gpu_archs(_ALL_GPU_ARCHS "${ALL_GPU_ARCHS}" "${_KERNEL_ARCHS}") + set(ALL_GPU_ARCHS ${_ALL_GPU_ARCHS} PARENT_SCOPE) + + foreach(_SRC ${_KERNEL_SRC}) + if(_SRC MATCHES ".*\\.(cu|hip)$") + foreach(_ARCH ${_KERNEL_ARCHS}) + set_property( + SOURCE ${_SRC} + APPEND PROPERTY + COMPILE_OPTIONS "$<$:--offload-arch=${_ARCH}>" + ) + endforeach() + endif() + endforeach() + + set(_TMP_SRC ${${SRC_VAR}}) + list(APPEND _TMP_SRC ${_KERNEL_SRC}) + set(${SRC_VAR} ${_TMP_SRC} PARENT_SCOPE) endfunction() + function(xpu_kernel_component SRC_VAR) set(options) set(oneValueArgs) diff --git a/kernel-builder/src/pyproject/templates/torch/preamble.cmake b/kernel-builder/src/pyproject/templates/torch/preamble.cmake index 9cfbc51e4..58da26f87 100644 --- a/kernel-builder/src/pyproject/templates/torch/preamble.cmake +++ b/kernel-builder/src/pyproject/templates/torch/preamble.cmake @@ -24,6 +24,10 @@ message(STATUS "FetchContent base directory: ${FETCHCONTENT_BASE_DIR}") set(HIP_SUPPORTED_ARCHS "gfx906;gfx908;gfx90a;gfx942;gfx950;gfx1030;gfx1100;gfx1101;gfx1200;gfx1201") +# Make Torch CMake machinery happy. Whatever we use does not matter, since +# we set the arches per-file later anyway. +set(ENV{PYTORCH_ROCM_ARCH} "${HIP_SUPPORTED_ARCHS}") + include(${CMAKE_CURRENT_LIST_DIR}/cmake/utils.cmake) include(${CMAKE_CURRENT_LIST_DIR}/cmake/kernel.cmake) include(${CMAKE_CURRENT_LIST_DIR}/cmake/get_gpu_lang.cmake) @@ -136,8 +140,7 @@ elseif(GPU_LANG STREQUAL "HIP") # .hip extension automatically, HIP must be enabled explicitly. enable_language(HIP) - override_gpu_arches(GPU_ARCHES HIP ${HIP_SUPPORTED_ARCHS}) - set(ROCM_ARCHS ${GPU_ARCHES}) + set(ROCM_ARCHS ${HIP_SUPPORTED_ARCHS}) message(STATUS "ROCM supported target architectures: ${ROCM_ARCHS}") # TODO: deprecate one of these settings. diff --git a/kernel-builder/src/pyproject/templates/utils.cmake b/kernel-builder/src/pyproject/templates/utils.cmake index 13e220050..eb96150d2 100644 --- a/kernel-builder/src/pyproject/templates/utils.cmake +++ b/kernel-builder/src/pyproject/templates/utils.cmake @@ -500,53 +500,6 @@ function(cuda_remove_ptx_suffixes OUT_CUDA_ARCHS CUDA_ARCHS) set(${OUT_CUDA_ARCHS} ${_CUDA_ARCHS} PARENT_SCOPE) endfunction() - - -# -# Override the GPU architectures detected by cmake/torch and filter them by -# `GPU_SUPPORTED_ARCHES`. Sets the final set of architectures in -# `GPU_ARCHES`. This only applies to the HIP language since for CUDA we set -# the architectures on a per file basis. -# -# Note: this is defined as a macro since it updates `CMAKE_CUDA_FLAGS`. -# -macro(override_gpu_arches GPU_ARCHES GPU_LANG GPU_SUPPORTED_ARCHES) - set(_GPU_SUPPORTED_ARCHES_LIST ${GPU_SUPPORTED_ARCHES} ${ARGN}) - message(STATUS "${GPU_LANG} supported arches: ${_GPU_SUPPORTED_ARCHES_LIST}") - - if (${GPU_LANG} STREQUAL "HIP") - # - # `GPU_ARCHES` controls the `--offload-arch` flags. - # - # If PYTORCH_ROCM_ARCH env variable exists, then we take it as a list, - # if not, then we use CMAKE_HIP_ARCHITECTURES which was generated by calling - # "rocm_agent_enumerator" in "enable_language(HIP)" - # (in file Modules/CMakeDetermineHIPCompiler.cmake) - # - if(DEFINED ENV{PYTORCH_ROCM_ARCH}) - set(HIP_ARCHITECTURES $ENV{PYTORCH_ROCM_ARCH}) - else() - set(HIP_ARCHITECTURES ${CMAKE_HIP_ARCHITECTURES}) - endif() - # - # Find the intersection of the supported + detected architectures to - # set the module architecture flags. - # - set(${GPU_ARCHES}) - foreach (_ARCH ${HIP_ARCHITECTURES}) - if (_ARCH IN_LIST _GPU_SUPPORTED_ARCHES_LIST) - list(APPEND ${GPU_ARCHES} ${_ARCH}) - endif() - endforeach() - - if(NOT ${GPU_ARCHES}) - message(FATAL_ERROR - "None of the detected ROCm architectures: ${HIP_ARCHITECTURES} is" - " supported. Supported ROCm architectures are: ${_GPU_SUPPORTED_ARCHES_LIST}.") - endif() - endif() -endmacro() - # # Define a target named `GPU_MOD_NAME` for a single extension. The # arguments are: diff --git a/nix-builder/lib/extension/torch/arch.nix b/nix-builder/lib/extension/torch/arch.nix index eca46a6c8..8c2a8c0f2 100644 --- a/nix-builder/lib/extension/torch/arch.nix +++ b/nix-builder/lib/extension/torch/arch.nix @@ -224,10 +224,6 @@ stdenv.mkDerivation (prevAttrs: { env = lib.optionalAttrs cudaSupport { CUDAToolkit_ROOT = "${lib.getDev cudaPackages.cuda_nvcc}"; - TORCH_CUDA_ARCH_LIST = lib.concatStringsSep ";" torch.cudaCapabilities; - } - // lib.optionalAttrs rocmSupport { - PYTORCH_ROCM_ARCH = lib.concatStringsSep ";" torch.rocmArchs; } // lib.optionalAttrs xpuSupport { MKLROOT = oneapi-torch-dev; diff --git a/nix-builder/pkgs/python-modules/torch/archs.nix b/nix-builder/pkgs/python-modules/torch/archs.nix deleted file mode 100644 index b4c924583..000000000 --- a/nix-builder/pkgs/python-modules/torch/archs.nix +++ /dev/null @@ -1,249 +0,0 @@ -{ - "2.8" = { - # https://github.com/pytorch/pytorch/blob/release/2.8/.ci/manywheel/build_cuda.sh - capsPerCudaVersion = { - "12.9" = [ - "7.0" - "7.5" - "8.0" - "8.6" - "9.0" - "10.0" - "12.0" - ]; - "12.8" = [ - "7.0" - "7.5" - "8.0" - "8.6" - "9.0" - "10.0" - "12.0" - ]; - "12.6" = [ - "5.0" - "6.0" - "7.0" - "7.5" - "8.0" - "8.6" - "9.0" - ]; - # Not a supported upstream configuration, but keep it around for - # builds that fail on newer CUDA versions. - "12.4" = [ - "5.0" - "6.0" - "7.0" - "7.5" - "8.0" - "8.6" - "9.0" - ]; - }; - # https://github.com/pytorch/pytorch/blob/ba56102387ef21a3b04b357e5b183d48f0afefc7/.ci/docker/manywheel/build.sh#L82 - supportedTorchRocmArchs = [ - "gfx900" - "gfx906" - "gfx908" - "gfx90a" - "gfx942" - "gfx1030" - "gfx1100" - "gfx1101" - "gfx1102" - "gfx1200" - "gfx1201" - ]; - }; - - "2.9" = { - # https://github.com/pytorch/pytorch/blob/release/2.9/.ci/manywheel/build_cuda.sh - capsPerCudaVersion = { - "13.0" = [ - "7.5" - "8.0" - "8.6" - "9.0" - "10.0" - "12.0" - ]; - # NOTE: 12.9 does not seem to be in RC builds, check if needed for final release. - # https://download.pytorch.org/whl/test/torch/ - "12.9" = [ - "7.0" - "7.5" - "8.0" - "8.6" - "9.0" - "10.0" - "12.0" - ]; - "12.8" = [ - "7.0" - "7.5" - "8.0" - "8.6" - "9.0" - "10.0" - "12.0" - ]; - "12.6" = [ - "5.0" - "6.0" - "7.0" - "7.5" - "8.0" - "8.6" - "9.0" - ]; - }; - - supportedTorchRocmArchs = [ - # https://github.com/pytorch/pytorch/blob/21fec65781bebe867faf209f89bb687ffd236ca4/.ci/docker/manywheel/build.sh#L92 - "gfx900" - "gfx906" - "gfx908" - "gfx90a" - "gfx942" - "gfx1030" - "gfx1100" - "gfx1101" - "gfx1102" - "gfx1200" - "gfx1201" - ]; - }; - - "2.11" = { - # https://github.com/pytorch/pytorch/blob/release/2.11/.ci/manywheel/build_cuda.sh - capsPerCudaVersion = { - "13.0" = [ - "7.5" - "8.0" - "8.6" - "9.0" - "10.0" - "11.0" - "12.0" - ]; - # NOTE: 12.9 does not seem to be in RC builds, check if needed for final release. - # https://download.pytorch.org/whl/test/torch/ - "12.9" = [ - "7.0" - "7.5" - "8.0" - "9.0" - "10.0" - "12.0" - ]; - "12.8" = [ - "7.0" - "7.5" - "8.0" - "8.6" - "9.0" - "10.0" - "12.0" - ]; - "12.6" = [ - "5.0" - "6.0" - "7.0" - "7.5" - "8.0" - "8.6" - "9.0" - ]; - }; - - supportedTorchRocmArchs = [ - # https://github.com/pytorch/pytorch/blob/release/2.11/.ci/docker/almalinux/build.sh - "gfx900" - "gfx906" - "gfx908" - "gfx90a" - "gfx942" - "gfx950" - "gfx1030" - "gfx1100" - "gfx1101" - "gfx1102" - "gfx1150" - "gfx1151" - "gfx1200" - "gfx1201" - ]; - }; - - "2.12" = { - # https://github.com/pytorch/pytorch/blob/release/2.12/.ci/manywheel/build_cuda.sh - capsPerCudaVersion = { - "13.2" = [ - "7.5" - "8.0" - "8.6" - "9.0" - "10.0" - "11.0" - "12.0" - ]; - "13.0" = [ - "7.5" - "8.0" - "8.6" - "9.0" - "10.0" - "11.0" - "12.0" - ]; - # NOTE: 12.9 does not seem to be in RC builds, check if needed for final release. - # https://download.pytorch.org/whl/test/torch/ - "12.9" = [ - "7.0" - "7.5" - "8.0" - "9.0" - "10.0" - "12.0" - ]; - "12.8" = [ - "7.0" - "7.5" - "8.0" - "8.6" - "9.0" - "10.0" - "12.0" - ]; - "12.6" = [ - "5.0" - "6.0" - "7.0" - "7.5" - "8.0" - "8.6" - "9.0" - ]; - }; - - supportedTorchRocmArchs = [ - # https://github.com/pytorch/pytorch/blob/release/2.12/.ci/docker/almalinux/build.sh - "gfx900" - "gfx906" - "gfx908" - "gfx90a" - "gfx942" - "gfx950" - "gfx1030" - "gfx1100" - "gfx1101" - "gfx1102" - "gfx1150" - "gfx1151" - "gfx1200" - "gfx1201" - ]; - }; - -} diff --git a/nix-builder/pkgs/python-modules/torch/binary/generic.nix b/nix-builder/pkgs/python-modules/torch/binary/generic.nix index 4f7e6c158..217cc3eaf 100644 --- a/nix-builder/pkgs/python-modules/torch/binary/generic.nix +++ b/nix-builder/pkgs/python-modules/torch/binary/generic.nix @@ -58,18 +58,6 @@ let else triton; - archs = (import ../archs.nix).${lib.versions.majorMinor version}; - - supportedTorchCudaCapabilities = - let - inherit (archs) capsPerCudaVersion; - real = capsPerCudaVersion."${lib.versions.majorMinor cudaPackages.cudaMajorMinorVersion}"; - ptx = lib.map (x: "${x}+PTX") real; - in - real ++ ptx; - supportedCudaCapabilities = lib.intersectLists cudaPackages.flags.cudaCapabilities supportedTorchCudaCapabilities; - inherit (archs) supportedTorchRocmArchs; - aotritonVersions = with rocmPackages; { "2.11" = aotriton_0_11_2; "2.12" = aotriton_0_11_2; @@ -374,9 +362,6 @@ buildPythonPackage.override { stdenv = effectiveStdenv; } { ; inherit (python) pkgs; - - cudaCapabilities = if cudaSupport then supportedCudaCapabilities else [ ]; - rocmArchs = if rocmSupport then supportedTorchRocmArchs else [ ]; }; meta = with lib; {