diff options
| author | Morgan Smith <Morgan.J.Smith@outlook.com> | 2025-04-07 19:19:39 -0400 |
|---|---|---|
| committer | Danny Milosavljevic <dannym@friendly-machines.com> | 2025-04-25 11:33:26 +0200 |
| commit | f22424d4fddb6f6c3b1158dc6267cfa8b3423600 (patch) | |
| tree | 23fa950e8343627de421f7b6bb43e2cbd14958f1 /gnu | |
| parent | 9407c6370e212cf60e19cd846fb4313290287553 (diff) | |
gnu: llama-cpp: Update to 0.0.0-b5013.
* gnu/packages/machine-learning.scm (llama-cpp): Update to 0.0.0-b5013.
[inputs]: Add curl, glslang, and python-gguf.
[native-inputs]: bash -> bash-minimal.
[source, homepage]: Update URL.
[python-scripts]: Rely on upstream to install them. Delete phase.
[fix-tests]: Fix an additional test.
(python-gguf): Switch to llama-cpp's version.
* gnu/packages/patches/llama-cpp-vulkan-optional.patch: Delete.
* gnu/local.mk: Unregister patch.
Change-Id: Ic297534cd142cb83e3964eae21b4eb807b74e9bc
Signed-off-by: Danny Milosavljevic <dannym@friendly-machines.com>
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/local.mk | 1 | ||||
| -rw-r--r-- | gnu/packages/machine-learning.scm | 62 | ||||
| -rw-r--r-- | gnu/packages/patches/llama-cpp-vulkan-optional.patch | 38 |
3 files changed, 17 insertions, 84 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index 4aa84f8ef96..fafe69f609d 100644 --- a/gnu/local.mk +++ b/gnu/local.mk | |||
| @@ -1845,7 +1845,6 @@ dist_patch_DATA = \ | |||
| 1845 | %D%/packages/patches/libmhash-hmac-fix-uaf.patch \ | 1845 | %D%/packages/patches/libmhash-hmac-fix-uaf.patch \ |
| 1846 | %D%/packages/patches/libmodbus-disable-networking-test.patch \ | 1846 | %D%/packages/patches/libmodbus-disable-networking-test.patch \ |
| 1847 | %D%/packages/patches/lib-tl-for-telegram-memcpy.patch \ | 1847 | %D%/packages/patches/lib-tl-for-telegram-memcpy.patch \ |
| 1848 | %D%/packages/patches/llama-cpp-vulkan-optional.patch \ | ||
| 1849 | %D%/packages/patches/llhttp-ponyfill-object-fromentries.patch \ | 1848 | %D%/packages/patches/llhttp-ponyfill-object-fromentries.patch \ |
| 1850 | %D%/packages/patches/lvm2-no-systemd.patch \ | 1849 | %D%/packages/patches/lvm2-no-systemd.patch \ |
| 1851 | %D%/packages/patches/maturin-no-cross-compile.patch \ | 1850 | %D%/packages/patches/maturin-no-cross-compile.patch \ |
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm index 9b2eaed17f6..a88dfa7567d 100644 --- a/gnu/packages/machine-learning.scm +++ b/gnu/packages/machine-learning.scm | |||
| @@ -85,6 +85,7 @@ | |||
| 85 | #:use-module (gnu packages crates-io) | 85 | #:use-module (gnu packages crates-io) |
| 86 | #:use-module (gnu packages crates-tls) | 86 | #:use-module (gnu packages crates-tls) |
| 87 | #:use-module (gnu packages crates-web) | 87 | #:use-module (gnu packages crates-web) |
| 88 | #:use-module (gnu packages curl) | ||
| 88 | #:use-module (gnu packages databases) | 89 | #:use-module (gnu packages databases) |
| 89 | #:use-module (gnu packages dejagnu) | 90 | #:use-module (gnu packages dejagnu) |
| 90 | #:use-module (gnu packages documentation) | 91 | #:use-module (gnu packages documentation) |
| @@ -642,7 +643,7 @@ Performance is achieved by using the LLVM JIT compiler.") | |||
| 642 | (deprecated-package "guile-aiscm-next" guile-aiscm)) | 643 | (deprecated-package "guile-aiscm-next" guile-aiscm)) |
| 643 | 644 | ||
| 644 | (define-public llama-cpp | 645 | (define-public llama-cpp |
| 645 | (let ((tag "b4549")) | 646 | (let ((tag "b5013")) |
| 646 | (package | 647 | (package |
| 647 | (name "llama-cpp") | 648 | (name "llama-cpp") |
| 648 | (version (string-append "0.0.0-" tag)) | 649 | (version (string-append "0.0.0-" tag)) |
| @@ -650,19 +651,19 @@ Performance is achieved by using the LLVM JIT compiler.") | |||
| 650 | (origin | 651 | (origin |
| 651 | (method git-fetch) | 652 | (method git-fetch) |
| 652 | (uri (git-reference | 653 | (uri (git-reference |
| 653 | (url "https://github.com/ggerganov/llama.cpp") | 654 | (url "https://github.com/ggml-org/llama.cpp") |
| 654 | (commit tag))) | 655 | (commit tag))) |
| 655 | (file-name (git-file-name name tag)) | 656 | (file-name (git-file-name name tag)) |
| 656 | (sha256 | 657 | (sha256 |
| 657 | (base32 "1xf2579q0r8nv06kj8padi6w9cv30w58vdys65nq8yzm3dy452a1")) | 658 | (base32 "0s73dz871x53dr366lkzq19f677bwgma2ri8m5vhbfa9p8yp4p3r")))) |
| 658 | (patches | ||
| 659 | (search-patches "llama-cpp-vulkan-optional.patch")))) | ||
| 660 | (build-system cmake-build-system) | 659 | (build-system cmake-build-system) |
| 661 | (arguments | 660 | (arguments |
| 662 | (list | 661 | (list |
| 663 | #:configure-flags | 662 | #:configure-flags |
| 664 | #~(list "-DBUILD_SHARED_LIBS=ON" | 663 | #~(list #$(string-append "-DGGML_BUILD_NUMBER=" tag) |
| 664 | "-DBUILD_SHARED_LIBS=ON" | ||
| 665 | "-DGGML_VULKAN=ON" | 665 | "-DGGML_VULKAN=ON" |
| 666 | "-DLLAMA_CURL=ON" | ||
| 666 | "-DGGML_BLAS=ON" | 667 | "-DGGML_BLAS=ON" |
| 667 | "-DGGML_BLAS_VENDOR=OpenBLAS" | 668 | "-DGGML_BLAS_VENDOR=OpenBLAS" |
| 668 | (string-append "-DBLAS_INCLUDE_DIRS=" | 669 | (string-append "-DBLAS_INCLUDE_DIRS=" |
| @@ -692,32 +693,17 @@ Performance is achieved by using the LLVM JIT compiler.") | |||
| 692 | (substitute* "ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp" | 693 | (substitute* "ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp" |
| 693 | (("\"/bin/sh\"") | 694 | (("\"/bin/sh\"") |
| 694 | (string-append "\"" (search-input-file inputs "/bin/sh") "\""))))) | 695 | (string-append "\"" (search-input-file inputs "/bin/sh") "\""))))) |
| 695 | (add-after 'unpack 'disable-unrunable-tests | 696 | (add-after 'unpack 'fix-tests |
| 696 | (lambda _ | 697 | (lambda _ |
| 697 | ;; test-eval-callback downloads ML model from network, cannot | 698 | ;; test-eval-callback downloads ML model from network, cannot |
| 698 | ;; run in Guix build environment | 699 | ;; run in Guix build environment |
| 699 | (substitute* '("examples/eval-callback/CMakeLists.txt") | 700 | (substitute* '("examples/eval-callback/CMakeLists.txt") |
| 700 | (("COMMAND llama-eval-callback") | 701 | (("COMMAND llama-eval-callback") |
| 701 | "COMMAND true llama-eval-callback")))) | 702 | "COMMAND true llama-eval-callback")) |
| 702 | (add-before 'install 'install-python-scripts | 703 | ;; Help it find the test files it needs |
| 703 | (lambda _ | 704 | (substitute* "tests/test-chat.cpp" |
| 704 | (let ((bin (string-append #$output "/bin/"))) | 705 | (("\"\\.\\./\"") "\"../source/\"")))) |
| 705 | (define (make-script script) | 706 | (add-after 'install 'wrap-python-scripts |
| 706 | (let ((suffix (if (string-suffix? ".py" script) "" ".py"))) | ||
| 707 | (call-with-input-file | ||
| 708 | (string-append "../source/" script suffix) | ||
| 709 | (lambda (input) | ||
| 710 | (call-with-output-file (string-append bin script) | ||
| 711 | (lambda (output) | ||
| 712 | (format output "#!~a/bin/python3\n~a" | ||
| 713 | #$(this-package-input "python") | ||
| 714 | (get-string-all input)))))) | ||
| 715 | (chmod (string-append bin script) #o555))) | ||
| 716 | (mkdir-p bin) | ||
| 717 | (make-script "convert_hf_to_gguf") | ||
| 718 | (make-script "convert_llama_ggml_to_gguf") | ||
| 719 | (make-script "convert_hf_to_gguf_update.py")))) | ||
| 720 | (add-after 'install-python-scripts 'wrap-python-scripts | ||
| 721 | (assoc-ref python:%standard-phases 'wrap)) | 707 | (assoc-ref python:%standard-phases 'wrap)) |
| 722 | (add-after 'install 'remove-tests | 708 | (add-after 'install 'remove-tests |
| 723 | (lambda* (#:key outputs #:allow-other-keys) | 709 | (lambda* (#:key outputs #:allow-other-keys) |
| @@ -725,12 +711,13 @@ Performance is achieved by using the LLVM JIT compiler.") | |||
| 725 | (string-append (assoc-ref outputs "out") | 711 | (string-append (assoc-ref outputs "out") |
| 726 | "/bin") | 712 | "/bin") |
| 727 | "^test-"))))))) | 713 | "^test-"))))))) |
| 728 | (inputs (list python vulkan-headers vulkan-loader)) | 714 | (inputs (list curl glslang python python-gguf |
| 729 | (native-inputs (list pkg-config shaderc bash)) | 715 | vulkan-headers vulkan-loader)) |
| 716 | (native-inputs (list pkg-config shaderc bash-minimal)) | ||
| 730 | (propagated-inputs | 717 | (propagated-inputs |
| 731 | (list python-numpy python-pytorch python-sentencepiece openblas)) | 718 | (list python-numpy python-pytorch python-sentencepiece openblas)) |
| 732 | (properties '((tunable? . #true))) ;use AVX512, FMA, etc. when available | 719 | (properties '((tunable? . #true))) ;use AVX512, FMA, etc. when available |
| 733 | (home-page "https://github.com/ggerganov/llama.cpp") | 720 | (home-page "https://github.com/ggml-org/llama.cpp") |
| 734 | (synopsis "Port of Facebook's LLaMA model in C/C++") | 721 | (synopsis "Port of Facebook's LLaMA model in C/C++") |
| 735 | (description "This package provides a port to Facebook's LLaMA collection | 722 | (description "This package provides a port to Facebook's LLaMA collection |
| 736 | of foundation language models. It requires models parameters to be downloaded | 723 | of foundation language models. It requires models parameters to be downloaded |
| @@ -7116,21 +7103,6 @@ performance library of basic building blocks for deep learning applications.") | |||
| 7116 | (description "A Python library for reading and writing GGUF & GGML format ML models.") | 7103 | (description "A Python library for reading and writing GGUF & GGML format ML models.") |
| 7117 | (license license:expat))) | 7104 | (license license:expat))) |
| 7118 | 7105 | ||
| 7119 | (define-public python-gguf-llama-cpp | ||
| 7120 | (package/inherit python-gguf | ||
| 7121 | (version "0.16.0") | ||
| 7122 | (source (package-source llama-cpp)) | ||
| 7123 | (propagated-inputs (list python-numpy python-pyyaml python-sentencepiece | ||
| 7124 | python-tqdm)) | ||
| 7125 | (native-inputs (list python-poetry-core)) | ||
| 7126 | (arguments | ||
| 7127 | (substitute-keyword-arguments (package-arguments python-gguf) | ||
| 7128 | ((#:phases phases #~%standard-phases) | ||
| 7129 | #~(modify-phases #$phases | ||
| 7130 | (add-after 'unpack 'chdir | ||
| 7131 | (lambda _ | ||
| 7132 | (chdir "gguf-py"))))))))) | ||
| 7133 | |||
| 7134 | (define-public python-gymnasium | 7106 | (define-public python-gymnasium |
| 7135 | (package | 7107 | (package |
| 7136 | (name "python-gymnasium") | 7108 | (name "python-gymnasium") |
diff --git a/gnu/packages/patches/llama-cpp-vulkan-optional.patch b/gnu/packages/patches/llama-cpp-vulkan-optional.patch deleted file mode 100644 index 43a49b6a023..00000000000 --- a/gnu/packages/patches/llama-cpp-vulkan-optional.patch +++ /dev/null | |||
| @@ -1,38 +0,0 @@ | |||
| 1 | Author: Danny Milosavljevic <dannym@friendly-machines.com> | ||
| 2 | Date: 2025-01-29 | ||
| 3 | License: Expat | ||
| 4 | Subject: Make Vulkan optional | ||
| 5 | |||
| 6 | See also: <https://github.com/ggerganov/llama.cpp/pull/11494> | ||
| 7 | |||
| 8 | diff -ru orig/llama.cpp/ggml/include/ggml-vulkan.h llama.cpp/ggml/include/ggml-vulkan.h | ||
| 9 | --- orig/llama.cpp/ggml/include/ggml-vulkan.h 2025-01-29 10:24:10.894476682 +0100 | ||
| 10 | +++ llama.cpp/ggml/include/ggml-vulkan.h 2025-02-07 18:28:34.509509638 +0100 | ||
| 11 | @@ -10,8 +10,6 @@ | ||
| 12 | #define GGML_VK_NAME "Vulkan" | ||
| 13 | #define GGML_VK_MAX_DEVICES 16 | ||
| 14 | |||
| 15 | -GGML_BACKEND_API void ggml_vk_instance_init(void); | ||
| 16 | - | ||
| 17 | // backend API | ||
| 18 | GGML_BACKEND_API ggml_backend_t ggml_backend_vk_init(size_t dev_num); | ||
| 19 | |||
| 20 | diff -ru orig/llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp | ||
| 21 | --- orig/llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp 2025-01-29 10:24:10.922476480 +0100 | ||
| 22 | +++ llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp 2025-01-29 22:33:19.955087552 +0100 | ||
| 23 | @@ -8174,8 +8174,13 @@ | ||
| 24 | /* .iface = */ ggml_backend_vk_reg_i, | ||
| 25 | /* .context = */ nullptr, | ||
| 26 | }; | ||
| 27 | - | ||
| 28 | - return ® | ||
| 29 | + try { | ||
| 30 | + ggml_vk_instance_init(); | ||
| 31 | + return ® | ||
| 32 | + } catch (const vk::SystemError& e) { | ||
| 33 | + VK_LOG_DEBUG("ggml_vk_get_device_count() -> Error: System error: " << e.what()); | ||
| 34 | + return nullptr; | ||
| 35 | + } | ||
| 36 | } | ||
| 37 | |||
| 38 | // Extension availability | ||
