nix: explicit mpi support

This commit is contained in:
Someone Serge 2023-12-26 22:23:30 +00:00
parent 82e48e2567
commit 7bd8d8c6d7
No known key found for this signature in database
GPG key ID: 7B0E3B1390D61DA4
2 changed files with 14 additions and 7 deletions

View file

@ -22,6 +22,7 @@
], ],
useCuda ? config.cudaSupport, useCuda ? config.cudaSupport,
useMetalKit ? stdenv.isAarch64 && stdenv.isDarwin && !useOpenCL, useMetalKit ? stdenv.isAarch64 && stdenv.isDarwin && !useOpenCL,
useMpi ? false, # Increases the runtime closure size by ~700M
useOpenCL ? false, useOpenCL ? false,
useRocm ? config.rocmSupport, useRocm ? config.rocmSupport,
llamaVersion ? "0.0.0", # Arbitrary version, substituted by the flake llamaVersion ? "0.0.0", # Arbitrary version, substituted by the flake
@ -42,11 +43,12 @@ let
effectiveStdenv = if useCuda then cudaPackages.backendStdenv else inputs.stdenv; effectiveStdenv = if useCuda then cudaPackages.backendStdenv else inputs.stdenv;
suffices = suffices =
lib.optionals useOpenCL [ "OpenCL" ] lib.optionals useBlas [ "BLAS" ]
++ lib.optionals useCuda [ "CUDA" ] ++ lib.optionals useCuda [ "CUDA" ]
++ lib.optionals useRocm [ "ROCm" ]
++ lib.optionals useMetalKit [ "MetalKit" ] ++ lib.optionals useMetalKit [ "MetalKit" ]
++ lib.optionals useBlas [ "BLAS" ]; ++ lib.optionals useMpi [ "MPI" ]
++ lib.optionals useOpenCL [ "OpenCL" ]
++ lib.optionals useRocm [ "ROCm" ];
pnameSuffix = pnameSuffix =
strings.optionalString (suffices != [ ]) strings.optionalString (suffices != [ ])
@ -149,11 +151,11 @@ effectiveStdenv.mkDerivation (
]; ];
buildInputs = buildInputs =
[ mpi ] optionals effectiveStdenv.isDarwin darwinBuildInputs
++ optionals useOpenCL [ clblast ]
++ optionals useCuda cudaBuildInputs ++ optionals useCuda cudaBuildInputs
++ optionals useRocm rocmBuildInputs ++ optionals useMpi [ mpi ]
++ optionals effectiveStdenv.isDarwin darwinBuildInputs; ++ optionals useOpenCL [ clblast ]
++ optionals useRocm rocmBuildInputs;
cmakeFlags = cmakeFlags =
[ [
@ -166,6 +168,7 @@ effectiveStdenv.mkDerivation (
(cmakeBool "LLAMA_CUBLAS" useCuda) (cmakeBool "LLAMA_CUBLAS" useCuda)
(cmakeBool "LLAMA_HIPBLAS" useRocm) (cmakeBool "LLAMA_HIPBLAS" useRocm)
(cmakeBool "LLAMA_METAL" useMetalKit) (cmakeBool "LLAMA_METAL" useMetalKit)
(cmakeBool "LLAMA_MPI" useMpi)
] ]
++ optionals useCuda [ ++ optionals useCuda [
( (
@ -203,6 +206,7 @@ effectiveStdenv.mkDerivation (
useBlas useBlas
useCuda useCuda
useMetalKit useMetalKit
useMpi
useOpenCL useOpenCL
useRocm useRocm
; ;

View file

@ -85,6 +85,9 @@
opencl = config.packages.default.override { useOpenCL = true; }; opencl = config.packages.default.override { useOpenCL = true; };
cuda = (pkgsCuda.callPackage .devops/nix/scope.nix { inherit llamaVersion; }).llama-cpp; cuda = (pkgsCuda.callPackage .devops/nix/scope.nix { inherit llamaVersion; }).llama-cpp;
rocm = (pkgsRocm.callPackage .devops/nix/scope.nix { inherit llamaVersion; }).llama-cpp; rocm = (pkgsRocm.callPackage .devops/nix/scope.nix { inherit llamaVersion; }).llama-cpp;
mpi-cpu = config.packages.default.override { useMpi = true; };
mpi-cuda = config.packages.default.override { useMpi = true; };
}; };
}; };
}; };