Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions .devops/nix/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@
useMpi ? false,
useRocm ? config.rocmSupport,
rocmGpuTargets ? builtins.concatStringsSep ";" rocmPackages.clr.gpuTargets,
rocmUseWmma ? true,
enableCurl ? true,
useVulkan ? false,
buildAllCudaFaQuants ? false,
enableUma ? false,
llamaVersion ? "0.0.0", # Arbitrary version, substituted by the flake

# It's necessary to consistently use backendStdenv when building with CUDA support,
Expand Down Expand Up @@ -91,11 +94,16 @@ let
libcublas
];

rocmBuildInputs = with rocmPackages; [
clr
hipblas
rocblas
];
rocmBuildInputs =
with rocmPackages;
[
clr
hipblas
rocblas
llvm.lld
llvm.bintools
]
++ optionals rocmUseWmma [ rocmPackages.rocwmma ];

vulkanBuildInputs = [
vulkan-headers
Expand Down Expand Up @@ -160,7 +168,8 @@ effectiveStdenv.mkDerivation (finalAttrs: {
buildInputs =
optionals effectiveStdenv.isDarwin darwinBuildInputs
++ optionals useCuda cudaBuildInputs
++ optionals useMpi [ mpi ]
++ optionals (useMpi && !useRocm) [ mpi ]
++ optionals (useMpi && useRocm) [ rocmPackages.mpi ]
++ optionals useRocm rocmBuildInputs
++ optionals useBlas [ blas ]
++ optionals useVulkan vulkanBuildInputs
Expand All @@ -187,10 +196,18 @@ effectiveStdenv.mkDerivation (finalAttrs: {
builtins.concatStringsSep ";" (map dropDot cudaCapabilities)
)
)
(cmakeBool "GGML_CUDA_FA_ALL_QUANTS" buildAllCudaFaQuants)
(cmakeBool "GGML_CUDA_ENABLE_UNIFIED_MEMORY" enableUma)
]
++ optionals useRocm [
(cmakeFeature "CMAKE_HIP_COMPILER" "${rocmPackages.llvm.clang}/bin/clang")
(cmakeFeature "CMAKE_HIP_ARCHITECTURES" rocmGpuTargets)
(cmakeFeature "AMDGPU_TARGETS" rocmGpuTargets)
(cmakeBool "GGML_CUDA_FA_ALL_QUANTS" buildAllCudaFaQuants)
(cmakeBool "GGML_CUDA_ENABLE_UNIFIED_MEMORY" enableUma)
]
++ optionals rocmUseWmma [
(cmakeBool "GGML_HIP_ROCWMMA_FATTN" rocmUseWmma)
(cmakeFeature "GGML_HIP_ROCWMMA_PATH" "${rocmPackages.rocwmma}")
]
++ optionals useMetalKit [
(lib.cmakeFeature "CMAKE_C_FLAGS" "-D__ARM_FEATURE_DOTPROD=1")
Expand Down
5 changes: 4 additions & 1 deletion ggml/src/ggml-hip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ endif()
find_package(hip REQUIRED)
find_package(hipblas REQUIRED)
find_package(rocblas REQUIRED)
if (GGML_HIP_ROCWMMA_FATTN)
if (GGML_HIP_ROCWMMA_FATTN AND NOT GGML_HIP_ROCWMMA_PATH)
CHECK_INCLUDE_FILE_CXX("rocwmma/rocwmma.hpp" FOUND_ROCWMMA)
if (NOT ${FOUND_ROCWMMA})
message(FATAL_ERROR "rocwmma has not been found")
Expand Down Expand Up @@ -111,6 +111,9 @@ endif()

if (GGML_HIP_ROCWMMA_FATTN)
add_compile_definitions(GGML_HIP_ROCWMMA_FATTN)
if (GGML_HIP_ROCWMMA_PATH)
target_include_directories(ggml-hip PRIVATE ${GGML_HIP_ROCWMMA_PATH}/include)
endif()
endif()

if (NOT GGML_HIP_MMQ_MFMA)
Expand Down