machine-learning.scm (4036B)
1 (define-module (epistemia packages machine-learning) 2 #:use-module (guix packages) 3 #:use-module (guix build-system go) 4 #:use-module (guix download) 5 #:use-module (guix utils) 6 #:use-module (guix git-download) 7 #:use-module (guix gexp) 8 #:use-module ((guix licenses) #:prefix license:) 9 #:use-module (gnu packages base) 10 #:use-module (gnu packages golang-check) 11 #:use-module (gnu packages golang-web) 12 #:use-module (gnu packages golang-xyz) 13 #:use-module (gnu packages llvm) 14 #:use-module (gnu packages machine-learning) 15 #:use-module (gnu packages rocm) 16 #:use-module (gnu packages rocm-libs)) 17 18 (define-public llama-cpp-rocm 19 (let ((tag "b9515")) 20 (package 21 (inherit llama-cpp) 22 (name "llama-cpp-rocm") 23 (version (string-append "0.0.0-" tag)) 24 (source 25 (origin 26 (method git-fetch) 27 (uri (git-reference 28 (url "https://github.com/ggml-org/llama.cpp") 29 (commit tag))) 30 (file-name (git-file-name name tag)) 31 (sha256 32 (base32 "1wfwan6x22dajpzl2hcavxy5q0wwrf142qrapy998cc0zkzn771c")))) 33 (arguments 34 (substitute-keyword-arguments (package-arguments llama-cpp) 35 ((#:configure-flags flags #~'()) 36 #~(append #$flags 37 '(;; CMAKE_HIP_FLAGS is to workaround regression in ROCm 7.2 38 "-DCMAKE_HIP_FLAGS=\"-mllvm --amdgpu-unroll-threshold-local=600\"" 39 #$(string-append "-DGPU_TARGETS=" (current-amd-gpu-targets-string)) 40 ;; temporarily disable webui building until I figure out how to add second source for hf bucket 41 "-DLLAMA_USE_PREBUILT_UI=OFF" "-DLLAMA_BUILD_UI=OFF"))) 42 ((#:phases phases) 43 #~(modify-phases #$phases 44 ;; mtp added test that also needs internet for downloading its model 45 (add-after 'fix-tests 'fix-tests-new 46 (lambda _ 47 (substitute* "tests/CMakeLists.txt" 48 (("llama_build_and_test\\(test-state-restore-fragmented\\.cpp .*") 49 "") 50 (("set_tests_properties\\(test-state-restore-fragmented PROPERTIES.*") 51 "")) 52 (substitute* "tests/CMakeLists.txt" 53 (("llama_build_and_test\\(test-recurrent-state-rollback\\.cpp .*") 54 "") 55 (("set_tests_properties\\(test-recurrent-state-rollback PROPERTIES.*") 56 "")) 57 (substitute* "tests/CMakeLists.txt" 58 (("llama_build_and_test\\(test-save-load-state\\.cpp .*") 59 "") 60 (("set_tests_properties\\(test-save-load-state PROPERTIES.*") 61 "")))) 62 (delete 'fix-python-shebang))))) 63 (inputs 64 (modify-inputs (package-inputs llama-cpp) 65 (replace "ggml" ggml-rocm)))))) 66 67 (define-public ggml-rocm 68 (package 69 (inherit ggml) 70 (name "ggml-rocm") 71 ;; (version "0.13.1") 72 (version "9ca88e98e6d9e84cf77959931130d38c5b56c19b") 73 (source 74 (origin 75 (method git-fetch) 76 (uri (git-reference 77 ;; (url "https://github.com/ggml-org/ggml") 78 (url "https://git.vineetk.net/ggml") 79 ;; (commit (string-append "v" version)) 80 (commit version))) 81 (file-name (git-file-name name version)) 82 (sha256 83 (base32 "0llmlnkcg8zrdj6v2wpl018iw6j0sp1fsg2if3w3zd91hv66jq5r")))) 84 (arguments 85 (substitute-keyword-arguments (package-arguments (@@ (gnu packages machine-learning) ggml)) 86 ((#:configure-flags flags #~'()) 87 #~(append #$flags (list (string-append "-DCMAKE_HIP_COMPILER_ROCM_ROOT=" #$rocm-hip-runtime) 88 (string-append "-DCMAKE_HIP_FLAGS=--rocm-path=" #$rocm-hip-runtime 89 " --rocm-device-lib-path=" #$rocm-device-libs "/amdgcn/bitcode") 90 #$(string-append "-DGPU_TARGETS=" (current-amd-gpu-targets-string)) 91 "-DGGML_CPU=ON" 92 "-DGGML_HIP=ON" 93 "-DGGML_HIP_ROCWMMA_FATTN=OFF" 94 "-DGGML_CUDA_FA_ALL_QUANTS=ON" 95 ;; for stable-diffusion.cpp 96 "-DGGML_CPU_ALL_VARIANTS=ON" 97 "-DGGML_MAX_NAME=128"))))) 98 (inputs 99 (modify-inputs (package-inputs ggml) 100 (append clang-rocm 101 lld-rocm 102 rocm-cmake 103 rocm-device-libs 104 rocm-hipcc 105 rocm-hip-runtime 106 rocr-runtime 107 hipblas 108 hipblas-common 109 rocblas)))))