guix-epistemia

Personal Guix channel
Log | Files | Refs

commit 4dc1a3862f723bd8fec6164abfd8e318365a7451
parent 88701b4c01498f5bd987f71d01e34eeda4f90e62
Author: Vineet Kumar <git@vineetk.net>
Date:   Sat, 25 Apr 2026 16:34:34 -0400

packages/machine-learning: add ggml-rocm and llama-cpp-rocm

Diffstat:
Aepistemia/packages/machine-learning.scm | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 83 insertions(+), 0 deletions(-)

diff --git a/epistemia/packages/machine-learning.scm b/epistemia/packages/machine-learning.scm @@ -0,0 +1,83 @@ +(define-module (epistemia packages machine-learning) + #:use-module (guix packages) + #:use-module (guix download) + #:use-module (guix utils) + #:use-module (guix git-download) + #:use-module (guix gexp) + #:use-module (gnu packages llvm) + #:use-module (gnu packages machine-learning) + #:use-module (gnu packages rocm) + #:use-module (gnu packages rocm-libs)) + +(define-public llama-cpp-rocm + (let ((tag "b8931")) + (package + (inherit llama-cpp) + (name "llama-cpp-rocm") + (version (string-append "0.0.0-" tag)) + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/ggml-org/llama.cpp") + (commit tag))) + (file-name (git-file-name name tag)) + (sha256 + (base32 "1bjhkmgj83z5br70j4pgz1sa1jvbc4rmxm7kca2yr4f6wxk47sgx")))) + (arguments + (substitute-keyword-arguments (package-arguments llama-cpp) + ((#:configure-flags flags #~'()) + #~(append #$flags + '(;; CMAKE_HIP_FLAGS is to workaround regression in ROCm 7.2 + "-DCMAKE_HIP_FLAGS=\"-mllvm --amdgpu-unroll-threshold-local=600\"" + "-DGPU_TARGETS=gfx1100"))) + ((#:phases phases) + #~(modify-phases #$phases + ;; the test-chat test got two new extra lines that need to be removed + (add-after 'fix-tests 'fix-tests-new + (lambda _ + (substitute* "tests/CMakeLists.txt" + (("target_include_directories\\(test-chat PRIVATE.*") + "") + (("target_link_libraries\\(test-chat PRIVATE.*") + "")))))))) + (inputs + (modify-inputs (package-inputs llama-cpp) + (replace "ggml" ggml-rocm)))))) + +(define-public ggml-rocm + (package + (inherit (@@ (gnu packages machine-learning) ggml)) + (name "ggml-rocm") + (version "0.10.0") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/ggml-org/ggml") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 "0pp3zsv5rckb4rr6ddd3d1qmpmg7ifzx46v932i5dndfaa8bp2yr")))) + (arguments + (substitute-keyword-arguments (package-arguments (@@ (gnu packages machine-learning) ggml)) + ((#:configure-flags flags #~'()) + #~(append #$flags (list (string-append "-DCMAKE_HIP_COMPILER_ROCM_ROOT=" #$rocm-hip-runtime) + (string-append "-DCMAKE_HIP_FLAGS=--rocm-path=" #$rocm-hip-runtime + " --rocm-device-lib-path=" #$rocm-device-libs "/amdgcn/bitcode") + "-DGPU_TARGETS=gfx1100" + "-DGGML_HIP=ON" + "-DGGML_HIP_ROCWMMA_FATTN=OFF" + "-DGGML_CUDA_FA_ALL_QUANTS=ON"))))) + (inputs + (modify-inputs (package-inputs (@@ (gnu packages machine-learning) ggml)) + (append clang-rocm + lld-rocm + rocm-cmake + rocm-device-libs + rocm-hipcc + rocm-hip-runtime + rocr-runtime + hipblas + hipblas-common + rocblas)))))