%define debug_package %{nil} # llama-CPP 1.0.0 is the Kunpeng CPU optimisation patch set for upstream # llama.cpp. The patches (0001..0011) are documented (docs/zh/quick_start.md) # to be applied on top of upstream llama.cpp commit 3ac67535c86, therefore the # source tarball shipped here is the pristine upstream tree at exactly that # commit and the patches are applied in %prep. # topdir: llama-cpp-1.0.0 %global llama_commitid 3ac67535c86 Name: llama.cpp Version: 1.0.0 Release: 1%{?dist} Summary: LLaMA/GGUF inference engine in C/C++ with Kunpeng CPU optimisations License: MIT AND Apache-2.0 URL: https://gitcode.com/boostkit/llama-CPP # upstream llama.cpp at commit 3ac67535c86 (MIT) repacked as llama-cpp-1.0.0 Source0: llama-cpp-1.0.0.tar.gz # license of the llama-CPP patch set itself Source1: LICENSE.apache-2.0 # llama-CPP 1.0.0 optimisation / bug-fix patch series Patch0001: 0001-fix-common-fix-baseline-embedding-regex-serv-bugs-ad.patch Patch0002: 0002-feat-cpu-add-ARM-SVE-NEON-FP16-FP32-matmul-kernels.patch Patch0003: 0003-feat-cpu-add-Q8_0-MMLA-spack-matmul-kernels.patch Patch0004: 0004-feat-cpu-add-fused-SDPA-microkernels-neon-cache-QK-p.patch Patch0005: 0005-feat-cpu-add-fused-SDPA-flash2-L3KV-implementation.patch Patch0006: 0006-feat-cpu-add-fused-SDPA-fp32-packqkv-front-end.patch Patch0007: 0007-feat-llama-add-GGML-fused-SDPA-op-and-integrate-into.patch Patch0008: 0008-feat-cpu-wire-optimized-matmul-fused-SDPA-kernels-in.patch Patch0009: 0009-build-add-compile.sh-helper-for-ARM-builds.patch Patch0010: 0010-update-compile.sh.patch Patch0011: 0011-add-f16-q80-unit-test.patch # build fix: keep the ARM-only includes/helpers out of non-ARM builds Patch0012: 0012-fix-guard-arm-only-code-for-non-arm-builds.patch BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: cmake BuildRequires: make %description Port of the LLaMA/GGUF large language model inference engine implemented in C/C++. This build is based on upstream llama.cpp at commit %{llama_commitid} with the llama-CPP 1.0.0 patch set applied, which adds ARM (Kunpeng 950 / Kunpeng 920) CPU kernels for FP16/FP32/Q8_0 matrix multiplication and a fused SDPA (FlashAttention v2 NEON) operator, together with several functional fixes. %prep %autosetup -p1 -n llama-cpp-%{version} cp -p %{SOURCE1} LICENSE.apache-2.0 %build # Cap the job count by the memory actually available to us. Several ggml / # llama translation units (ggml-cpu/amx/mmq.cpp, ops.cpp, ...) need a few # hundred MB up to ~1 GiB of compiler RSS each; building with -j$(nproc) on a # memory-constrained builder gets cc1plus OOM-killed (observed locally with a # 2 GiB cgroup limit and nproc=16). Use one job per 2 GiB of RAM and honour a # cgroup memory limit when the kernel exposes one (containers usually do). JOBS="$(nproc 2>/dev/null || echo 1)" MEM_MB="$(awk '/^MemTotal:/{print int($2/1024)}' /proc/meminfo 2>/dev/null || echo 0)" for limit in /sys/fs/cgroup/memory.max /sys/fs/cgroup/memory/memory.limit_in_bytes; do if [ -r "$limit" ]; then limit_bytes="$(cat "$limit" 2>/dev/null || true)" case "$limit_bytes" in ''|max|*[!0-9]*) ;; *) limit_mb=$((limit_bytes / 1024 / 1024)) if [ "$limit_mb" -gt 0 ] && { [ "$MEM_MB" -le 0 ] || [ "$limit_mb" -lt "$MEM_MB" ]; }; then MEM_MB="$limit_mb" fi ;; esac fi done if [ "${MEM_MB:-0}" -gt 0 ]; then MEM_JOBS=$((MEM_MB / 2048)) if [ "$MEM_JOBS" -lt 1 ]; then MEM_JOBS=1; fi if [ "$JOBS" -gt "$MEM_JOBS" ]; then JOBS="$MEM_JOBS"; fi fi if [ "$JOBS" -lt 1 ]; then JOBS=1; fi echo "llama.cpp: building with -j${JOBS} (nproc=$(nproc), memory=${MEM_MB}MB)" EXTRA_CMAKE_ARGS="" %ifarch aarch64 # Enable the NEON/i8mm/dotprod feature set documented for the optimisation # profile of this patch set (see compile.sh, build-fused-sdpa profile). EXTRA_CMAKE_ARGS="-DGGML_CPU_ARM_ARCH=armv8.6-a+dotprod+i8mm" %endif cmake -S . -B build \ -G "Unix Makefiles" \ -DCMAKE_INSTALL_PREFIX=%{_prefix} \ -DCMAKE_INSTALL_BINDIR=%{_bindir} \ -DCMAKE_INSTALL_LIBDIR=%{_libdir} \ -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir} \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_C_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \ -DBUILD_SHARED_LIBS=ON \ -DLLAMA_CURL=OFF \ -DGGML_NATIVE=OFF \ -DGGML_CCACHE=OFF \ -DGGML_BUILD_NUMBER=0 \ -DLLAMA_BUILD_NUMBER=0 \ -DLLAMA_BUILD_TESTS=OFF \ -DLLAMA_BUILD_EXAMPLES=OFF \ -DLLAMA_BUILD_TOOLS=ON \ -DLLAMA_BUILD_SERVER=ON \ ${EXTRA_CMAKE_ARGS} cmake --build build --parallel "$JOBS" %install DESTDIR=%{buildroot} cmake --install build %files %license LICENSE LICENSE.apache-2.0 %doc README.md %{_bindir}/* %{_includedir}/*.h %{_libdir}/*.so* %{_libdir}/cmake/* %{_libdir}/pkgconfig/* %changelog * Fri Nov 27 2026 AI Package Importer - 1.0.0-1 - Initial package: upstream llama.cpp %{llama_commitid} + llama-CPP 1.0.0 patches