Provide an optimized systemd service template with dynamic per-model GGUF optimization
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- bash
- Lĩnh vực
- devops
Hướng nghiên cứu
The proposal is a systemd unit whose ExecStartPre bash script generates a preset .ini for llama-server --models-preset; check the repo's server docs and examples to confirm the preset keys and flags it uses. Before any file is added, the maintainer needs to agree on whether this belongs in the examples folder, and the script's gguf-parser/jq field names and cache-type choices need verifying. Done means a reviewed unit file and a README note that run cleanly on a sample models directory.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Prerequisites
- I am running the latest code. Mention the version if possible as well.
- I carefully followed the README.md.
- I searched using keywords relevant to my issue to make sure that I am creating a new issue that is not already open (or closed).
- I reviewed the Discussions, and have a new and useful enhancement to share.
Feature Description
Hello! I would like to share and propose a production-ready systemd service file for beellama.cpp that automatically generates optimal presets and handles dynamic per-model configurations at startup.
This configuration uses gguf-parser and jq to parse local models dynamically, matching them with multimodal projectors (mmproj) and configuring layers, context sizes, and KV cache types automatically.
Features of this Systemd Unit:
Inline Dynamic Preset Generation: Automatically scans the models directory before starting the server and writes an optimized configuration file (beellama_auto.ini).
Smart Architecture Detection: Extracts block counts (gpu-layers), maximum context lengths, and architecture types using gguf-parser and jq.
Automatic Multimodal Mapping: Automatically detects and pairs mmproj files with their corresponding base models based on filename matching.
LoRA & KV Cache Tuning: Automatically adjusts cache types (e.g., switches to q4_0 if LoRA ranks are detected, otherwise uses kvarn4).
Proposed Systemd Unit File:
[Unit]
Description=beellama.cpp Server with Dynamic Per-Model Optimization
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
Environment="MODELS_DIR=/run/media/user/Data/LLM"
Environment="PRESET_FILE=/etc/conf.d/beellama_auto.ini"
ExecStartPre=/bin/bash -c ' \
set -Eeuo pipefail; \
echo "=== beellama: inline dynamic preset generator ==="; \
echo "# Auto-generated optimal preset" > "$PRESET_FILE"; \
echo "" >> "$PRESET_FILE"; \
echo "[*]" >> "$PRESET_FILE"; \
echo "threads = 8" >> "$PRESET_FILE"; \
echo "threads-batch = 8" >> "$PRESET_FILE"; \
echo "flash-attn = on" >> "$PRESET_FILE"; \
echo "" >> "$PRESET_FILE"; \
while IFS= read -r -d "" MODEL_FILE; do \
MODEL_NAME=$(basename "$MODEL_FILE" .gguf); \
MODEL_DIR=$(dirname "$MODEL_FILE"); \
MMPROJ_FILE=""; \
CANDIDATE=$(find "$MODEL_DIR" -type f -iname "*mmproj*.gguf" -print -quit || true); \
if [ -n "$CANDIDATE" ]; then \
CLEAN_MODEL_NAME=$(echo "$MODEL_NAME" | sed "s/-Q[0-9].*//i" | sed "s/-IQ.*//i"); \
if echo "$CANDIDATE" | grep -qi "$CLEAN_MODEL_NAME"; then \
MMPROJ_FILE="$CANDIDATE"; \
fi; \
fi; \
LAYERS="auto"; \
CTX_SIZE="32768"; \
CACHE_TYPE="kvarn4"; \
ARCH_DETECTED="unknown"; \
if command -v gguf-parser >/dev/null 2>&1 && command -v jq >/dev/null 2>&1; then \
JSON_OUT=$(gguf-parser --model "$MODEL_FILE" --json 2>/dev/null || true); \
if [ -n "$JSON_OUT" ]; then \
DETECTED_LAYERS=$(echo "$JSON_OUT" | jq -r ".architecture.blockCount // empty" 2>/dev/null || true); \
if [ -n "$DETECTED_LAYERS" ] && [ "$DETECTED_LAYERS" != "null" ]; then \
LAYERS="$DETECTED_LAYERS"; \
fi; \
DETECTED_CTX=$(echo "$JSON_OUT" | jq -r ".architecture.maximumContextLength // empty" 2>/dev/null || true); \
if [ -n "$DETECTED_CTX" ] && [ "$DETECTED_CTX" != "null" ]; then \
if [ "$DETECTED_CTX" -lt 32768 ]; then \
CTX_SIZE="$DETECTED_CTX"; \
else \
CTX_SIZE="32768"; \
fi; \
fi; \
ARCH_DETECTED=$(echo "$JSON_OUT" | jq -r ".architecture.architecture // \"unknown\"" 2>/dev/null || true); \
LORARANK=$(echo "$JSON_OUT" | jq -r ".architecture.attentionKeyValueLORARank // 0" 2>/dev/null || true); \
if [ "$LORARANK" -gt 0 ] 2>/dev/null; then \
CACHE_TYPE="q4_0"; \
fi; \
fi; \
fi; \
echo "Model: $MODEL_NAME [Arch: $ARCH_DETECTED] -> Layers: $LAYERS, Ctx: $CTX_SIZE, Cache: $CACHE_TYPE"; \
echo "[$MODEL_NAME]" >> "$PRESET_FILE"; \
echo "model = $MODEL_FILE" >> "$PRESET_FILE"; \
echo "gpu-layers = $LAYERS" >> "$PRESET_FILE"; \
echo "ctx-size = $CTX_SIZE" >> "$PRESET_FILE"; \
echo "cache-type-k = $CACHE_TYPE" >> "$PRESET_FILE"; \
echo "cache-type-v = $CACHE_TYPE" >> "$PRESET_FILE"; \
if [ -n "$MMPROJ_FILE" ]; then \
echo "mmproj = $MMPROJ_FILE" >> "$PRESET_FILE"; \
fi; \
echo "" >> "$PRESET_FILE"; \
done < <(find "$MODELS_DIR" -type f -name "*.gguf" ! -iname "*mmproj*" -print0); \
echo "Preset generation complete."'
ExecStart=/usr/bin/llama-server --models-preset /etc/conf.d/beellama_auto.ini --host 0.0.0.0 --port 8080 --models-max 1 --cache-reuse 1024 --cache-ram 16384
ExecReload=/bin/kill -s HUP $MAINPID
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
Feel free to adapt or integrate this into the documentation or examples folder if others might find it useful!
Motivation
Key benefits for users:
- Zero-Touch Configuration: Automatically scans the designated models directory, eliminating the need to manually write or update .ini preset files whenever new models are added or removed.
- Smart Resource Optimization: Leverages gguf-parser and jq to dynamically extract hardware-friendly metrics per model (such as exact architecture block counts for optimal GPU layer offloading and context limits).
- Seamless Multimodal Support: Automatically detects and pairs mmproj files with their respective base models based on filename structure.
- Production Reliability: Standardizes deployment using standard systemd patterns (Restart=on-failure, graceful HUP reloading, and proper environment separation) making it ideal for self-hosted LLM setups.
Possible Implementation
No response
- Ngôn ngữ chính
- C++
- Star
- 1.2k
- Fork
- 80
- Merge trung bình
- 4 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Anbeeld/beellama.cpp
-
[BUG] KVarN assertion failure in build_inp_mem_hybrid_iswa() due to uninitialized self_kvarn_rotĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Anbeeld/beellama.cpp#205 ·
-
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 58/100
Anbeeld/beellama.cpp#206 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 57/100
Anbeeld/beellama.cpp#204 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Anbeeld/beellama.cpp#203 · 2 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Anbeeld/beellama.cpp#202 · 1 bình luận ·
Tất cả issue của Anbeeld/beellama.cpp
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
CachyOS/packageinstaller#144 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
TomerAberbach/profiler-md#951 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] Default key routing (JavaStringHash) picks a different partition than the Java client for about half of keysCó thể đã có người làm @0z5a đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
apache/pulsar-client-go#1575 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
pocoproject/poco#5764 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug cpp-core-guidelines low-priority
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
NatronGitHub/openfx-supportext#164 ·
Maintainer thường phản hồi trong vòng 1 ngày