Trial GPU-resident Qwen3.5-9B with verified 4B rollback

This commit is contained in:
admin committed 2026-10-27 17:14:38 +01:00
1 parent 0929cdb555
commit dec534cc88
10 files changed
+307 -93

No files matched your search

+39 -4
View File
@@ -4,7 +4,7 @@ set -Eeuo pipefail
umask 077
config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/hermes-stack-maintenance"
usage() {
printf 'Aufruf: %s [status|routine|large] (Modellwechsel beendet laufende Anfragen)\n' "$0"
printf 'Aufruf: %s [status|routine|fallback|large] (Modellwechsel beendet laufende Anfragen)\n' "$0"
}
case "${1:-}" in
''|status)
@@ -13,7 +13,7 @@ case "${1:-}" in
printf 'Aktives Modell: %s\nKonfiguration: %s/llama.env\n' "$LLAMA_MODEL" "$config_dir"
exit 0 ;;
-h|--help) usage; exit 0 ;;
routine|large) selected="$1" ;;
routine|fallback|large) selected="$1" ;;
*) usage >&2; exit 2 ;;
esac
[[ $# -eq 1 ]] || exit 2
@@ -24,12 +24,20 @@ candidate="$config_dir/llama-$selected.env"
HERMES_LLAMA_CONFIG="$candidate" "$runner" --check
backup="$(mktemp "$config_dir/llama.env.before-model-switch.XXXXXX")"
cp -p -- "$config_dir/llama.env" "$backup"
systemctl --user stop hermes-gateway.service
hermes_config="${HERMES_HOME:-$HOME/.hermes}/config.yaml"
hermes_backup=""
if [[ -f "$hermes_config" ]]; then
hermes_backup="$(mktemp "$config_dir/hermes.yaml.before-model-switch.XXXXXX")"
cp -p -- "$hermes_config" "$hermes_backup"
fi
rollback() {
local rc=$?
trap - EXIT
if ((rc != 0)); then
install -m 0600 "$backup" "$config_dir/llama.env" || true
if [[ -n "$hermes_backup" ]]; then
install -m 0600 "$hermes_backup" "$hermes_config" || true
fi
systemctl --user restart llama-qwen.service || true
systemctl --user start hermes-gateway.service || true
printf 'Modellwechsel fehlgeschlagen; vorherige Konfiguration zurückkopiert. Dienststatus prüfen.\n' >&2
@@ -37,11 +45,38 @@ rollback() {
exit "$rc"
}
trap rollback EXIT
systemctl --user stop hermes-gateway.service
install -m 0600 "$candidate" "$config_dir/llama.env"
# Keep Hermes' actual context and compression trigger paired with the model.
# Legacy profiles without metadata use the original 64K window.
LLAMA_CONTEXT_TOKENS=65536
# shellcheck disable=SC1090
source "$candidate"
if [[ -n "$hermes_backup" ]]; then
python3 - "$hermes_config" "$LLAMA_CONTEXT_TOKENS" <<'PY'
import os
from pathlib import Path
import sys
import tempfile
import yaml
path = Path(sys.argv[1])
context = int(sys.argv[2])
if context < 64000:
raise ValueError("Hermes requires at least 64000 context tokens")
config = yaml.safe_load(path.read_text())
config.setdefault("model", {})["context_length"] = context
config.setdefault("compression", {})["threshold_tokens"] = min(24000, context * 3 // 8)
with tempfile.NamedTemporaryFile(mode="w", dir=path.parent, delete=False) as out:
yaml.safe_dump(config, out, allow_unicode=True, sort_keys=False, width=1000)
temporary = Path(out.name)
os.chmod(temporary, 0o600)
temporary.replace(path)
PY
fi
ready=0
if systemctl --user restart llama-qwen.service; then
for ((i=0; i<90; i++)); do
if curl -fsS --max-time 2 http://127.0.0.1:8080/health | jq -e '.status == "ok"' >/dev/null 2>&1; then
if curl -fsS --max-time 2 http://127.0.0.1:8080/health 2>/dev/null | jq -e '.status == "ok"' >/dev/null 2>&1; then
ready=1; break
fi
sleep 2