From e53e7419c0ed524f92a6627ef31e83b6b6afd76b Mon Sep 17 00:00:00 2001 From: i0ntempest Date: Tue, 28 Jan 2025 01:08:26 +0800 Subject: [PATCH] llama.cpp: 4600, add model_converters variant Closes: https://trac.macports.org/ticket/71927 --- llm/llama.cpp/Portfile | 43 +++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/llm/llama.cpp/Portfile b/llm/llama.cpp/Portfile index 6707b31268b54..7f393c8769d0f 100644 --- a/llm/llama.cpp/Portfile +++ b/llm/llama.cpp/Portfile @@ -5,9 +5,9 @@ PortGroup github 1.0 PortGroup cmake 1.1 PortGroup legacysupport 1.1 -github.setup ggerganov llama.cpp 4534 b +github.setup ggerganov llama.cpp 4600 b github.tarball_from archive -set git-commit 955a6c2 +set git-commit 553f1e4 # This line is for displaying commit in CLI only revision 0 categories llm @@ -19,9 +19,9 @@ long_description The main goal of ${name} is to enable LLM inference with setup and state-of-the-art performance on a wide variety of hardware\ - locally and in the cloud. -checksums rmd160 771fa15d2c7b6a3ef9114fd3c0afb676e0ba6559 \ - sha256 f4b57daa8d6bfe957f08a79f02ea9d24018ce9e73663c35a5c21f31ed3ccfcb8 \ - size 20496342 +checksums rmd160 6ac30312f82228103cddfcf37f589abfd0cec94d \ + sha256 317efa87cfd06fcf016eeb9b366a0e8dfda36d42449710dd5e3bde2d3d3ee996 \ + size 20554559 # error: 'filesystem' file not found on 10.14 legacysupport.newest_darwin_requires_legacy \ @@ -41,8 +41,7 @@ post-patch { compiler.cxx_standard 2017 -configure.args-append -LAH \ - -DGGML_LTO=ON \ +configure.args-append -DGGML_LTO=ON \ -DGGML_CCACHE=OFF \ -DGGML_OPENMP=OFF \ -DLLAMA_CURL=ON @@ -60,6 +59,10 @@ if {${os.platform} eq "darwin" && ${os.subplatform} eq "macosx" && \ -DGGML_METAL_EMBED_LIBRARY=OFF } +post-destroot { + delete {*}[glob -directory ${destroot}${prefix}/bin/ convert*.py] +} + variant blas description {Uses BLAS, improves performance} { configure.args-append \ -DGGML_BLAS=ON @@ -90,6 +93,32 @@ variant openmp description {enable parallelism support using OpenMP} { } } +variant model_converters description {install extra model conversion Python scripts} { + set ::python_branch 3.12 + set ::python_version [string map {. ""} ${::python_branch}] + depends_run-append port:python${::python_version} \ + port:py${::python_version}-numpy \ + port:py${::python_version}-pytorch \ + port:py${::python_version}-transformers \ + port:py${::python_version}-gguf + + post-patch { + reinplace "s|#!/usr/bin/env python3|#!${prefix}/bin/python${::python_branch}|" {*}[glob ${worksrcpath}/convert*.py] + } + + post-destroot { + xinstall -d ${destroot}${prefix}/libexec/${name} + xinstall -m 755 {*}[glob ${worksrcpath}/convert*.py] ${destroot}${prefix}/libexec/${name} + foreach file [glob -directory ${destroot}${prefix}/libexec/${name} *.py] { + set filebasename [file rootname [file tail $file]] + set link ${destroot}${prefix}/bin/[lindex [split ${name} .] 0]-[string map {_ -} ${filebasename}] + set target [string replace ${file} 0 [string length ${destroot}]-1] + ui_debug "Creating symlink: ${link} => ${target}" + ln -s ${target} ${link} + } + } +} + variant native description "Force local build and optimize for CPU" { configure.args-append \ -DGGML_NATIVE=ON