Files
LLM-Server/scripts/switch-model.sh
T
haylanandClaude-Bot 4b47a1769d feat: downloader for Qwen-Image weights, switch-model.sh script
Two frontier tickets from the ComfyUI map (#38), both unblocked now
that their blockers (#39 model choice, #40 lazytainer research) are
resolved.

- downloader-comfyui service (docker-compose.yml) + COMFYUI_* vars
  (.env.example): fetches Qwen-Image FP8 diffusion/text-encoder/VAE
  weights from Comfy-Org/Qwen-Image_ComfyUI, same test -f guard
  pattern as the existing downloaders. Closes #42.
- scripts/switch-model.sh: swaps GPU residency between llama-server
  and comfyui via direct `docker compose stop`/`up -d`, bypassing
  lazytainer per docs/research/lazytainer-omniroute-idle-stop.md
  (its packet-threshold detector can't distinguish OmniRoute's health
  checks from real traffic, so idle-stop can't be relied on for a
  deliberate swap). llama-server-fast stays resident throughout —
  not part of this swap. Closes #43.
- scripts/update.sh: runs the new downloader profile.

docker compose config -q validated clean.

Refs #38, #42, #43

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MrnMEdzeQzqZE5soVEXPCx
2026-09-06 20:57:38 +02:00

57 lines
1.8 KiB
Bash

#!/usr/bin/env bash
# Swap GPU residency between llama-server (Qwen) and comfyui — they never
# run concurrently, VRAM doesn't fit both (see issue #38's map). Manual
# invocation only, no auto-switching.
#
# Bypasses lazytainer entirely and drives docker compose directly — its
# idle-stop can't be used for this. Root cause (see
# docs/research/lazytainer-omniroute-idle-stop.md, issue #40): lazytainer's
# packet-threshold detector is source-blind and can't tell OmniRoute's
# periodic health-check pings apart from real traffic on the same port, so
# it never reliably sleeps a service on its own. A scripted swap always
# knows which service should go up/down, so it doesn't need that heuristic.
#
# llama-server-fast (the small classifier model, issue #44) is NOT part of
# this swap — it's meant to stay always-resident. Worst case with comfyui up
# is comfyui (~25GB, Qwen-Image FP8) + llama-server-fast (~5GB) ≈ 30GB,
# still under the 32GB card but tight — unverified on real hardware, check
# `docker compose ps` / VRAM usage after the first real swap.
#
# OmniRoute may show the just-stopped provider as errored/offline in its
# dashboard for up to CREDENTIAL_HEALTH_CHECK_INTERVAL (default 5 min) after
# a swap — cosmetic, not a functional problem (see the research doc above).
set -euo pipefail
cd "$(dirname "$0")/.."
usage() {
echo "Usage: $0 {qwen|comfyui}" >&2
echo " qwen - stop comfyui, start llama-server" >&2
echo " comfyui - stop llama-server, start comfyui" >&2
exit 1
}
[ $# -eq 1 ] || usage
case "$1" in
qwen)
from=comfyui
to=llama-server
;;
comfyui)
from=llama-server
to=comfyui
;;
*)
usage
;;
esac
echo "==> stopping $from"
docker compose stop "$from"
echo "==> starting $to"
docker compose up -d "$to"
echo "==> status"
docker compose ps