diff options
| author | Nigko Yerden <nigko.yerden@gmail.com> | 2026-03-22 09:12:42 +0500 |
|---|---|---|
| committer | Cayetano Santos <csantosb@inventati.org> | 2026-03-24 11:28:48 +0100 |
| commit | ff3accfef4cb462251b5fabf9dfc3c9d53d51e70 (patch) | |
| tree | 440db9a5d64d9ea722d8eb3544fb976a09c75b75 | |
| parent | 642382f87564a0959a95ebabd197842334751601 (diff) | |
gnu: llama-cpp: Further debloat and improve.
Reduces closure size from ~700 downto 291 MiB.
Note that coreutils is required by 'env' program referensed in
'bin/convert_hf_to_gguf.py'.
* gnu/packages/machine-learning.scm (llama-cpp)[arguments]:
Delete #:modules and #:imported-modules.
<#:phases>{patch-paths}: Delete.
{fix-tests}: Delete string substitutions for "tests/CMakeLists.txt"
that do nothing.
{wrap-python-scripts}: Delete.
{fix-python-shebang}: Add.
[inputs]: Delete all inputs except 'ggml and 'openssl; add 'coreutils.
[native-inputs]: Replace with 'python and 'python-jinja2 inputs.
[propatated-inputs]: Delete.
Merges guix/guix!7396
Change-Id: I64229d6cfa096e32926672bed55125f22c9ca7eb
Signed-off-by: Cayetano Santos <csantosb@inventati.org>
Modified-by: Cayetano Santos <csantosb@inventati.org>
| -rw-r--r-- | gnu/packages/machine-learning.scm | 46 |
1 files changed, 13 insertions, 33 deletions
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm index 1dd5a6d70da..91682458a3e 100644 --- a/gnu/packages/machine-learning.scm +++ b/gnu/packages/machine-learning.scm | |||
| @@ -852,22 +852,8 @@ NumPy @code{dtype} extensions used in machine learning libraries, including: | |||
| 852 | #:configure-flags | 852 | #:configure-flags |
| 853 | #~(list "-DBUILD_SHARED_LIBS=ON" | 853 | #~(list "-DBUILD_SHARED_LIBS=ON" |
| 854 | "-DLLAMA_USE_SYSTEM_GGML=ON") | 854 | "-DLLAMA_USE_SYSTEM_GGML=ON") |
| 855 | #:modules '((ice-9 textual-ports) | ||
| 856 | (guix build utils) | ||
| 857 | ((guix build python-build-system) #:prefix python:) | ||
| 858 | (guix build cmake-build-system)) | ||
| 859 | #:imported-modules `(,@%cmake-build-system-modules | ||
| 860 | (guix build python-build-system)) | ||
| 861 | #:phases | 855 | #:phases |
| 862 | #~(modify-phases %standard-phases | 856 | #~(modify-phases %standard-phases |
| 863 | (add-after 'unpack 'patch-paths | ||
| 864 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 865 | (substitute* (format #f "~a~a" | ||
| 866 | "ggml/src/ggml-vulkan/vulkan-shaders/" | ||
| 867 | "vulkan-shaders-gen.cpp") | ||
| 868 | (("\"/bin/sh\"") | ||
| 869 | (string-append "\"" (search-input-file inputs "/bin/sh") | ||
| 870 | "\""))))) | ||
| 871 | (add-after 'unpack 'fix-tests | 857 | (add-after 'unpack 'fix-tests |
| 872 | (lambda _ | 858 | (lambda _ |
| 873 | ;; test-thread-safety downloads ML model from network, | 859 | ;; test-thread-safety downloads ML model from network, |
| @@ -882,16 +868,6 @@ NumPy @code{dtype} extensions used in machine learning libraries, including: | |||
| 882 | "") | 868 | "") |
| 883 | (("set_tests_properties\\(test-state-restore-fragmented.*") | 869 | (("set_tests_properties\\(test-state-restore-fragmented.*") |
| 884 | "") | 870 | "") |
| 885 | (((string-append "llama_build_and_test\\" | ||
| 886 | "(test-eval-callback-download-model.cpp.*")) | ||
| 887 | "") | ||
| 888 | (((string-append "set_tests_properties\\" | ||
| 889 | "(test-eval-callback-download-model.*")) | ||
| 890 | "") | ||
| 891 | (("llama_build_and_test\\(test-eval-callback.cpp.*") | ||
| 892 | "") | ||
| 893 | (("set_tests_properties\\(test-eval-callback.*") | ||
| 894 | "") | ||
| 895 | (("llama_build_and_test\\(test-llama-archs.cpp.*") | 871 | (("llama_build_and_test\\(test-llama-archs.cpp.*") |
| 896 | "") | 872 | "") |
| 897 | (("set_tests_properties\\(test-download-model.*") | 873 | (("set_tests_properties\\(test-download-model.*") |
| @@ -913,20 +889,24 @@ NumPy @code{dtype} extensions used in machine learning libraries, including: | |||
| 913 | ;; Help it find the test files it needs | 889 | ;; Help it find the test files it needs |
| 914 | (substitute* "tests/test-chat.cpp" | 890 | (substitute* "tests/test-chat.cpp" |
| 915 | (("\"\\.\\./\"") "\"../source/\"")))) | 891 | (("\"\\.\\./\"") "\"../source/\"")))) |
| 916 | (add-after 'install 'wrap-python-scripts | ||
| 917 | (assoc-ref python:%standard-phases 'wrap)) | ||
| 918 | (add-after 'install 'remove-tests | 892 | (add-after 'install 'remove-tests |
| 919 | (lambda _ | 893 | (lambda _ |
| 920 | (for-each delete-file | 894 | (for-each delete-file |
| 921 | (find-files (string-append #$output "/bin") | 895 | (find-files (string-append #$output "/bin") |
| 922 | "^test-"))))))) | 896 | "^test-")))) |
| 923 | (inputs | 897 | ;; This phase and coreutils are needed to reduce the closure size |
| 924 | (list curl ggml glslang python-minimal spirv-headers | 898 | ;; of this package. Remove them when not needed anymore. |
| 925 | spirv-tools vulkan-headers vulkan-loader openssl)) | 899 | (add-after 'patch-shebangs 'fix-python-shebang |
| 900 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 901 | (substitute* (string-append #$output | ||
| 902 | "/bin/convert_hf_to_gguf.py") | ||
| 903 | (("^#!.*/bin/python3") | ||
| 904 | (string-append "#!" (search-input-file inputs "bin/env") | ||
| 905 | " python3")))))))) | ||
| 906 | (inputs (list coreutils ggml openssl)) | ||
| 926 | (native-inputs | 907 | (native-inputs |
| 927 | (list bash-minimal pkg-config python-minimal-wrapper shaderc)) | 908 | ;; These are only used in the check phase for test-jinja-py |
| 928 | (propagated-inputs | 909 | (list python python-jinja2)) |
| 929 | (list python-numpy python-jinja2 python-sentencepiece)) | ||
| 930 | (properties '((tunable? . #true))) ;use AVX512, FMA, etc. when available | 910 | (properties '((tunable? . #true))) ;use AVX512, FMA, etc. when available |
| 931 | (home-page "https://github.com/ggml-org/llama.cpp") | 911 | (home-page "https://github.com/ggml-org/llama.cpp") |
| 932 | (synopsis "Port of Facebook's LLaMA model in C/C++") | 912 | (synopsis "Port of Facebook's LLaMA model in C/C++") |
