mirror of
https://github.com/gentoo-mirror/guru.git
synced 2026-11-27 19:57:58 -05:00
sci-misc/llama-cpp: version bump
Signed-off-by: Adam Pimentel <adam.pimentel@protonmail.com>
This commit is contained in:
2 files changed
+272
No files matched your search
@@ -3,3 +3,4 @@ DIST llama-b11429-ui.tar.gz 3099802 BLAKE2B ede327bab6068c0443ab19e9f4565a5ced30
|
||||
DIST llama-b11960-ui.tar.gz 3244974 BLAKE2B 1ff4569442140d7aa0afed0911b3e5acdcb95d798e1d66f004f81de4416d16a714bc4be140e248f72e8de24ad662e0d144604a3bca91018fe342c09a2e473e39 SHA512 aa5ddf5ab10ca66bb82c0263c358b809baa30ee7ddfefcc9165c35f3a65b27e56537ad445fb2227cd9e9e7b824b786ce27efd44f8fb76b6140d4f3e42e6995bc
|
||||
DIST llama-cpp-0.7.0.tar.gz 38183379 BLAKE2B 8673743e112bbb9e96e5560f71c714f7f080d28341df299938536b13371f370361ee9d7b93382d03f2cdbde018697c4c17e5bcbf07ba7be632ed3a3a9262d399 SHA512 88cd464c20370ecca12b174e36fa4f21b271f42851f474dd83b03191dd444dcc96543849a56aaa16a35368d09e5be9c3481bebe66c2d614a0965d882f530ca91
|
||||
DIST llama-cpp-0.8.0.tar.gz 38680037 BLAKE2B e07a0f59d3d548b4b3ee85500f7aed70edb583e35a7acd9ae8252be2e45ae0d48a818737b6b7dc1337b00909f728fcdeca16696a590899bae7d250245a27c61b SHA512 0c09fa70644513a098a529748f6c02d8706f22d572e80222f1766549c0f94cc97037cdaf214ef7bd09ffea987df0cd5ecf933df7d5b05647b50ced6a05b564b3
|
||||
DIST llama-cpp-1.0.0.tar.gz 38889520 BLAKE2B eff50fd94e3b468f7004d6adbcbc74c705e19b3eb444bb9644f626156d96b37fd719560435d216ed3890892d6c6e0169d95c8e66b5c3d2ab485ddb4b0f02b840 SHA512 d5e204e7983280001e4fba1c4cba2d6b82eca3a628867dcf9c3ff3333fff93d2d416535edeb4baad546979967d0b04c9b35d9728e0ab200d49d832b137cc4a56
|
||||
@@ -0,0 +1,271 @@
|
||||
# Copyright 2026 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=8
|
||||
|
||||
PYTHON_COMPAT=( python3_{13..15} )
|
||||
ROCM_VERSION="6.1"
|
||||
|
||||
inherit cmake cuda rocm linux-info python-any-r1 toolchain-funcs
|
||||
|
||||
MY_PN="${PN/-/.}"
|
||||
TINY_LLAMAS_COMMIT="99dd1a73db5a37100bd4ae633f4cfce6560e1567"
|
||||
|
||||
DESCRIPTION="Port of Facebook's LLaMA model in C/C++"
|
||||
HOMEPAGE="https://github.com/ggml-org/llama.cpp"
|
||||
|
||||
if [[ ${PV} == *9999* ]]; then
|
||||
inherit git-r3
|
||||
EGIT_REPO_URI="https://github.com/ggml-org/llama.cpp.git"
|
||||
LLAMA_BUILD_IS_DEV=ON
|
||||
LLAMA_BUILD_NUMBER="b0000"
|
||||
LLAMA_UI_VERSION="b11960"
|
||||
MY_PV="${PV}"
|
||||
else
|
||||
if [[ $(ver_cut 4) == "p" ]]; then
|
||||
LLAMA_BUILD_IS_DEV=ON
|
||||
LLAMA_BUILD_NUMBER="b$(ver_cut 5)"
|
||||
MY_PV="${LLAMA_BUILD_NUMBER}"
|
||||
S="${WORKDIR}/${MY_PN}-${MY_PV}"
|
||||
else
|
||||
LLAMA_BUILD_IS_DEV=OFF
|
||||
# Set from https://github.com/ggml-org/llama.cpp/releases/download/v${PV}/nightly-tag.txt
|
||||
LLAMA_BUILD_NUMBER="b11960"
|
||||
MY_PV="v${PV}"
|
||||
S="${WORKDIR}/${MY_PN}-${PV}"
|
||||
fi
|
||||
LLAMA_UI_VERSION="${LLAMA_BUILD_NUMBER}"
|
||||
SRC_URI="https://github.com/ggml-org/llama.cpp/archive/refs/tags/${MY_PV}.tar.gz -> ${P}.tar.gz"
|
||||
KEYWORDS="~amd64"
|
||||
fi
|
||||
|
||||
MODEL_STORIES15M_URI="
|
||||
https://huggingface.co/ggml-org/tiny-llamas/resolve/${TINY_LLAMAS_COMMIT}/stories15M-q4_0.gguf
|
||||
-> ggml-org_models_tinyllamas_stories15M-q4_0-${TINY_LLAMAS_COMMIT}.gguf
|
||||
"
|
||||
|
||||
SRC_URI+="
|
||||
https://github.com/ggml-org/llama.cpp/releases/download/${LLAMA_UI_VERSION}/llama-${LLAMA_UI_VERSION}-ui.tar.gz
|
||||
examples? ( ${MODEL_STORIES15M_URI} )
|
||||
test? ( ${MODEL_STORIES15M_URI} )
|
||||
"
|
||||
|
||||
LICENSE="MIT"
|
||||
SLOT="0"
|
||||
|
||||
# GGML CPU flags
|
||||
X86_CPU_FLAGS=(
|
||||
amx_bf16
|
||||
amx_int8
|
||||
amx_tile
|
||||
avx
|
||||
avx2
|
||||
avx512_bf16
|
||||
avx512_vnni
|
||||
avx512f
|
||||
avx512vbmi
|
||||
avx_vnni
|
||||
bmi2
|
||||
f16c
|
||||
fma3
|
||||
sse4_2
|
||||
)
|
||||
CPU_FLAGS=( "${X86_CPU_FLAGS[@]/#/cpu_flags_x86_}" )
|
||||
|
||||
# GGML BLAS backends
|
||||
BLAS_BACKENDS="blis openblas"
|
||||
|
||||
GGML_IUSE="blas flexiblas ${BLAS_BACKENDS} ${CPU_FLAGS[*]} cuda opencl +openmp rocm vulkan"
|
||||
|
||||
IUSE="${GGML_IUSE} examples openssl test"
|
||||
REQUIRED_USE="
|
||||
blas? ( ?? ( ${BLAS_BACKENDS} ) )
|
||||
rocm? ( ${ROCM_REQUIRED_USE} )
|
||||
"
|
||||
|
||||
unset BLAS_BACKENDS GGML_IUSE X86_CPU_FLAGS CPU_FLAGS
|
||||
|
||||
RESTRICT="!test? ( test )"
|
||||
|
||||
COMMON_DEPEND="
|
||||
openmp? ( llvm-runtimes/openmp:= )
|
||||
blas? (
|
||||
virtual/blas[flexiblas=]
|
||||
flexiblas? ( sci-libs/flexiblas:=[blis?,openblas?,openmp?] )
|
||||
!flexiblas? (
|
||||
blis? ( sci-libs/blis:=[openmp?] )
|
||||
openblas? ( sci-libs/openblas:=[openmp?] )
|
||||
)
|
||||
)
|
||||
rocm? (
|
||||
>=dev-util/hip-${ROCM_VERSION}:=
|
||||
>=sci-libs/hipBLAS-${ROCM_VERSION}:=
|
||||
>=sci-libs/rocBLAS-${ROCM_VERSION}:=
|
||||
)
|
||||
cuda? ( dev-util/nvidia-cuda-toolkit:= )
|
||||
openssl? ( dev-libs/openssl:= )
|
||||
"
|
||||
DEPEND="${COMMON_DEPEND}
|
||||
opencl? ( dev-util/opencl-headers )
|
||||
vulkan? (
|
||||
dev-util/spirv-headers
|
||||
dev-util/vulkan-headers
|
||||
)
|
||||
"
|
||||
RDEPEND="${COMMON_DEPEND}
|
||||
opencl? ( dev-libs/opencl-icd-loader )
|
||||
vulkan? ( media-libs/vulkan-loader )
|
||||
"
|
||||
BDEPEND="
|
||||
opencl? ( ${PYTHON_DEPS} )
|
||||
vulkan? ( media-libs/shaderc )
|
||||
test? ( $(python_gen_any_dep 'dev-python/jinja2[${PYTHON_USEDEP}]') )
|
||||
"
|
||||
|
||||
python_check_deps() {
|
||||
if use test; then
|
||||
python_has_version "dev-python/jinja2[${PYTHON_USEDEP}]"
|
||||
fi
|
||||
}
|
||||
|
||||
pkg_pretend() {
|
||||
[[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
|
||||
}
|
||||
|
||||
pkg_setup() {
|
||||
if use rocm; then
|
||||
linux-info_pkg_setup
|
||||
if linux-info_get_any_version && linux_config_exists; then
|
||||
if ! linux_chkconfig_present HSA_AMD_SVM; then
|
||||
ewarn "To use ROCm/HIP, you need to have HSA_AMD_SVM option enabled in your kernel."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if use opencl || use test; then
|
||||
python-any-r1_pkg_setup
|
||||
fi
|
||||
|
||||
[[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
|
||||
}
|
||||
|
||||
src_unpack() {
|
||||
[[ ${PV} == *9999* ]] && git-r3_src_unpack
|
||||
default
|
||||
}
|
||||
|
||||
src_prepare() {
|
||||
use cuda && cuda_src_prepare
|
||||
cmake_src_prepare
|
||||
if use examples || use test; then
|
||||
mkdir -p "${BUILD_DIR}/tinyllamas" || die
|
||||
cp "${DISTDIR}/ggml-org_models_tinyllamas_stories15M-q4_0-${TINY_LLAMAS_COMMIT}.gguf" \
|
||||
"${BUILD_DIR}/tinyllamas/stories15M-q4_0.gguf" || die
|
||||
fi
|
||||
|
||||
# Move web UI assets where they belong, bug #979245
|
||||
mkdir -p "${S}"/tools/ui || die
|
||||
cp -a "${WORKDIR}"/llama-${LLAMA_UI_VERSION} "${S}"/tools/ui/dist || die
|
||||
}
|
||||
|
||||
src_configure() {
|
||||
local mycmakeargs=(
|
||||
-DLLAMA_BUILD_IS_DEV=${LLAMA_BUILD_IS_DEV}
|
||||
-DLLAMA_BUILD_TESTS=$(usex test)
|
||||
-DLLAMA_BUILD_EXAMPLES=$(usex examples)
|
||||
-DLLAMA_BUILD_SERVER=ON
|
||||
-DLLAMA_TESTS_INSTALL=OFF
|
||||
-DBUILD_NUMBER="${LLAMA_BUILD_NUMBER}"
|
||||
-DLLAMA_OPENSSL=$(usex openssl)
|
||||
|
||||
# avoid clashing with sci-ml/ggml
|
||||
-DCMAKE_INSTALL_INCLUDEDIR="include/${MY_PN}"
|
||||
-DCMAKE_INSTALL_LIBDIR="$(get_libdir)/${MY_PN}"
|
||||
-DCMAKE_INSTALL_RPATH="\$ORIGIN/../$(get_libdir)/${MY_PN};\$ORIGIN"
|
||||
)
|
||||
|
||||
# GGML backends
|
||||
mycmakeargs+=(
|
||||
-DGGML_NATIVE=OFF # don't set march
|
||||
-DGGML_CCACHE=OFF
|
||||
-DGGML_LTO="$(tc-is-lto)"
|
||||
|
||||
# CPU Flags
|
||||
-DGGML_SSE42=$(usex cpu_flags_x86_sse4_2)
|
||||
-DGGML_AVX=$(usex cpu_flags_x86_avx)
|
||||
-DGGML_AVX_VNNI=$(usex cpu_flags_x86_avx_vnni)
|
||||
-DGGML_AVX2=$(usex cpu_flags_x86_avx2)
|
||||
-DGGML_BMI2=$(usex cpu_flags_x86_bmi2)
|
||||
-DGGML_AVX512=$(usex cpu_flags_x86_avx512f)
|
||||
-DGGML_AVX512_VBMI=$(usex cpu_flags_x86_avx512vbmi)
|
||||
-DGGML_AVX512_VNNI=$(usex cpu_flags_x86_avx512_vnni)
|
||||
-DGGML_AVX512_BF16=$(usex cpu_flags_x86_avx512_bf16)
|
||||
-DGGML_FMA=$(usex cpu_flags_x86_fma3)
|
||||
-DGGML_F16C=$(usex cpu_flags_x86_f16c)
|
||||
-DGGML_AMX_TILE=$(usex cpu_flags_x86_amx_tile)
|
||||
-DGGML_AMX_INT8=$(usex cpu_flags_x86_amx_int8)
|
||||
-DGGML_AMX_BF16=$(usex cpu_flags_x86_amx_bf16)
|
||||
|
||||
-DGGML_BLAS=$(usex blas)
|
||||
-DGGML_CUDA=$(usex cuda)
|
||||
-DGGML_VULKAN=$(usex vulkan)
|
||||
-DGGML_OPENMP=$(usex openmp)
|
||||
-DGGML_RPC=ON
|
||||
-DGGML_OPENCL=$(usex opencl)
|
||||
)
|
||||
|
||||
if use blas; then
|
||||
if use flexiblas ; then
|
||||
mycmakeargs+=(
|
||||
-DGGML_BLAS_VENDOR="FlexiBLAS"
|
||||
)
|
||||
elif use blis ; then
|
||||
mycmakeargs+=(
|
||||
-DGGML_BLAS_VENDOR="FLAME"
|
||||
)
|
||||
elif use openblas ; then
|
||||
mycmakeargs+=(
|
||||
-DGGML_BLAS_VENDOR="OpenBLAS"
|
||||
)
|
||||
else
|
||||
mycmakeargs+=(
|
||||
-DGGML_BLAS_VENDOR="Generic"
|
||||
)
|
||||
fi
|
||||
fi
|
||||
|
||||
if use cuda; then
|
||||
local -x CUDAHOSTCXX="$(cuda_gccdir)"
|
||||
# tries to recreate dev symlinks
|
||||
cuda_add_sandbox
|
||||
addpredict "/dev/char/"
|
||||
fi
|
||||
|
||||
if use rocm; then
|
||||
rocm_use_clang
|
||||
mycmakeargs+=(
|
||||
-DGGML_HIP=ON
|
||||
-DGPU_TARGETS=$(get_amdgpu_flags)
|
||||
-DCMAKE_HIP_FLAGS="${CXXFLAGS}"
|
||||
# cmake.eclass clears per-build-type flags for C/CXX only; drop CMake's "-O2 -g -DNDEBUG" for HIP
|
||||
"-DCMAKE_HIP_FLAGS_${CMAKE_BUILD_TYPE^^}="
|
||||
)
|
||||
fi
|
||||
|
||||
cmake_src_configure
|
||||
}
|
||||
|
||||
src_test() {
|
||||
local CMAKE_SKIP_TESTS=(
|
||||
test-download-model # due to network sandbox
|
||||
test-arg-parser # due to network sandbox in download functions test
|
||||
)
|
||||
cmake_src_test
|
||||
}
|
||||
|
||||
src_install() {
|
||||
cmake_src_install
|
||||
|
||||
dodoc -r "${S}"/docs
|
||||
dodoc "${S}"/tools/*/README.md
|
||||
}
|
||||
Reference in new issue
Block a user