Skip to content

Commit

Permalink
llama.cpp: 4600, add model_converters variant
Browse files Browse the repository at this point in the history
  • Loading branch information
i0ntempest committed Jan 31, 2025
1 parent 6514650 commit e53e741
Showing 1 changed file with 36 additions and 7 deletions.
43 changes: 36 additions & 7 deletions llm/llama.cpp/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 \
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e53e741

Please sign in to comment.