Commit ·
46def5b
0
Parent(s):
openPangu-2.0-Flash support for llama.cpp v0.7.0 (diff + patch.sh)
Browse files- llama.cpp-openpangu-v0.7.0.diff +0 -0
- patch.sh +73 -0
llama.cpp-openpangu-v0.7.0.diff
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
patch.sh
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# ----------------------------------------------------------------------------
|
| 3 |
+
# openPangu-2.0-Flash support + speed optimizations for llama.cpp v0.7.0
|
| 4 |
+
#
|
| 5 |
+
# Downloads the pinned upstream llama.cpp commit, applies the patch and
|
| 6 |
+
# prints build/run instructions.
|
| 7 |
+
#
|
| 8 |
+
# Usage: ./patch.sh
|
| 9 |
+
# ----------------------------------------------------------------------------
|
| 10 |
+
set -euo pipefail
|
| 11 |
+
|
| 12 |
+
LLAMA_COMMIT="620d2225cc436ab0b001e3200e590e3b286ef9ab" # llama.cpp release v0.7.0
|
| 13 |
+
SRC_DIR="llama.cpp-${LLAMA_COMMIT}"
|
| 14 |
+
|
| 15 |
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
| 16 |
+
PATCH_FILE="${SCRIPT_DIR}/llama.cpp-openpangu-v0.7.0.diff"
|
| 17 |
+
|
| 18 |
+
if [ ! -f "${PATCH_FILE}" ]; then
|
| 19 |
+
echo "error: ${PATCH_FILE} not found (keep it next to this script)" >&2
|
| 20 |
+
exit 1
|
| 21 |
+
fi
|
| 22 |
+
|
| 23 |
+
cd "${SCRIPT_DIR}"
|
| 24 |
+
|
| 25 |
+
if [ ! -d "${SRC_DIR}" ]; then
|
| 26 |
+
echo "==> downloading llama.cpp @ ${LLAMA_COMMIT} (v0.7.0)"
|
| 27 |
+
if command -v curl >/dev/null 2>&1; then
|
| 28 |
+
curl -L --fail -o llama.tar.gz \
|
| 29 |
+
"https://codeload.github.com/ggml-org/llama.cpp/tar.gz/${LLAMA_COMMIT}"
|
| 30 |
+
elif command -v wget >/dev/null 2>&1; then
|
| 31 |
+
wget -O llama.tar.gz \
|
| 32 |
+
"https://codeload.github.com/ggml-org/llama.cpp/tar.gz/${LLAMA_COMMIT}"
|
| 33 |
+
else
|
| 34 |
+
echo "error: need curl or wget" >&2
|
| 35 |
+
exit 1
|
| 36 |
+
fi
|
| 37 |
+
echo "==> extracting"
|
| 38 |
+
tar xzf llama.tar.gz
|
| 39 |
+
rm -f llama.tar.gz
|
| 40 |
+
fi
|
| 41 |
+
|
| 42 |
+
cd "${SRC_DIR}"
|
| 43 |
+
|
| 44 |
+
echo "==> applying $(basename "${PATCH_FILE}")"
|
| 45 |
+
if command -v git >/dev/null 2>&1 && git apply --check "${PATCH_FILE}" 2>/dev/null; then
|
| 46 |
+
git apply "${PATCH_FILE}"
|
| 47 |
+
elif command -v patch >/dev/null 2>&1; then
|
| 48 |
+
patch -p1 --forward < "${PATCH_FILE}"
|
| 49 |
+
else
|
| 50 |
+
echo "error: need git or patch to apply the diff" >&2
|
| 51 |
+
exit 1
|
| 52 |
+
fi
|
| 53 |
+
|
| 54 |
+
echo
|
| 55 |
+
echo "==> done. build with:"
|
| 56 |
+
echo
|
| 57 |
+
echo " cd ${SRC_DIR}"
|
| 58 |
+
echo " cmake -B build -S . -DCMAKE_BUILD_TYPE=Release"
|
| 59 |
+
echo " cmake --build build -j --target llama-cli llama-server"
|
| 60 |
+
echo
|
| 61 |
+
echo " # CPU only (no GPU):"
|
| 62 |
+
echo " cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DGGML_NATIVE=ON"
|
| 63 |
+
echo " # CUDA:"
|
| 64 |
+
echo " cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DGGML_CUDA=ON"
|
| 65 |
+
echo
|
| 66 |
+
echo "==> run (get the GGUF models at https://huggingface.co/mrexodia/openPangu-2.0-Flash-GGUF):"
|
| 67 |
+
echo
|
| 68 |
+
echo " ./build/bin/llama-cli -m openPangu-2.0-Flash-base-Q3_K_M.gguf -c 65536 --jinja -t \$(nproc)"
|
| 69 |
+
echo " ./build/bin/llama-server -m openPangu-2.0-Flash-base-Q3_K_M.gguf -c 65536 --jinja --host 0.0.0.0 --port 8080"
|
| 70 |
+
echo
|
| 71 |
+
echo " # optional multi-token-prediction self-speculative decoding (needs the split MTP head):"
|
| 72 |
+
echo " ./build/bin/llama-cli -m openPangu-2.0-Flash-base-Q3_K_M.gguf \\"
|
| 73 |
+
echo " --spec-draft-model openPangu-2.0-Flash-mtp-Q8_0.gguf --spec-type draft-mtp -c 65536 --jinja"
|