Upload merge_full_gguf_hf_job.sh with huggingface_hub
Browse files- merge_full_gguf_hf_job.sh +52 -0
merge_full_gguf_hf_job.sh
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -euo pipefail
|
| 3 |
+
|
| 4 |
+
REPO_ID="${REPO_ID:-Hashhasapi/Gemopus-v1-e2b}"
|
| 5 |
+
BASE_REPO="${BASE_REPO:-lmstudio-community/gemma-4-E2B-it-GGUF}"
|
| 6 |
+
BASE_FILE="${BASE_FILE:-gemma-4-E2B-it-Q4_K_M.gguf}"
|
| 7 |
+
LORA_FILE="${LORA_FILE:-Gemopus-v1-e2b-lora.gguf}"
|
| 8 |
+
MERGED_FILE="${MERGED_FILE:-Gemopus-v1-e2b-Q4_K_M-merged.gguf}"
|
| 9 |
+
|
| 10 |
+
echo "Installing build and Python tools..."
|
| 11 |
+
apt-get update
|
| 12 |
+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
| 13 |
+
git cmake build-essential ca-certificates python3 python3-pip
|
| 14 |
+
python3 -m pip install --break-system-packages -U huggingface_hub
|
| 15 |
+
|
| 16 |
+
echo "Downloading base GGUF..."
|
| 17 |
+
hf download "$BASE_REPO" "$BASE_FILE" --local-dir /workspace/base --token "$HF_TOKEN"
|
| 18 |
+
|
| 19 |
+
echo "Downloading Gemopus LoRA GGUF..."
|
| 20 |
+
hf download "$REPO_ID" "$LORA_FILE" --local-dir /workspace/lora --token "$HF_TOKEN"
|
| 21 |
+
|
| 22 |
+
echo "Building llama.cpp export-lora..."
|
| 23 |
+
git clone --depth 1 https://github.com/ggml-org/llama.cpp /workspace/llama.cpp
|
| 24 |
+
cmake -S /workspace/llama.cpp -B /workspace/llama.cpp/build \
|
| 25 |
+
-DGGML_CUDA=OFF \
|
| 26 |
+
-DLLAMA_CURL=OFF \
|
| 27 |
+
-DLLAMA_BUILD_TESTS=OFF \
|
| 28 |
+
-DLLAMA_BUILD_EXAMPLES=OFF \
|
| 29 |
+
-DLLAMA_BUILD_TOOLS=ON
|
| 30 |
+
cmake --build /workspace/llama.cpp/build --config Release -j "$(nproc)" --target llama-export-lora
|
| 31 |
+
|
| 32 |
+
EXPORT_BIN="/workspace/llama.cpp/build/bin/llama-export-lora"
|
| 33 |
+
if [ ! -x "$EXPORT_BIN" ]; then
|
| 34 |
+
EXPORT_BIN="$(find /workspace/llama.cpp/build -name 'llama-export-lora*' -type f | head -n 1)"
|
| 35 |
+
fi
|
| 36 |
+
echo "Using export tool: $EXPORT_BIN"
|
| 37 |
+
|
| 38 |
+
echo "Merging LoRA into base GGUF..."
|
| 39 |
+
"$EXPORT_BIN" \
|
| 40 |
+
-m "/workspace/base/$BASE_FILE" \
|
| 41 |
+
--lora "/workspace/lora/$LORA_FILE" \
|
| 42 |
+
-o "/workspace/$MERGED_FILE" \
|
| 43 |
+
-t "$(nproc)"
|
| 44 |
+
|
| 45 |
+
echo "Merged file:"
|
| 46 |
+
ls -lh "/workspace/$MERGED_FILE"
|
| 47 |
+
|
| 48 |
+
echo "Uploading merged standalone GGUF..."
|
| 49 |
+
hf upload "$REPO_ID" "/workspace/$MERGED_FILE" "$MERGED_FILE" --repo-type model --token "$HF_TOKEN" \
|
| 50 |
+
--commit-message "Add merged standalone Gemopus v1 E2B GGUF"
|
| 51 |
+
|
| 52 |
+
echo "Done: https://huggingface.co/$REPO_ID/blob/main/$MERGED_FILE"
|