SPB Git

spb/wp25_uqo

Public
1.3 KB · 24 lines shellscript
1#!/usr/bin/env bash2# Start (or check) local OpenAI-compatible inference servers for the LLM laboratory.3# Models are small open-weight instruction models served by mlx_lm on MacLustr nodes.4# No credentials involved.  Usage:  scripts/llm_serve.sh start|status|stop5# Laptop access goes through SSH port-forwards (see scripts/llm_tunnel.sh).6set -u7declare -a SPECS=(8  "M3U96a 8081 mlx-community/Qwen2.5-7B-Instruct-4bit"9  "M3U96b 8082 mlx-community/Mistral-7B-Instruct-v0.3-4bit"10  "M3U96a 8083 mlx-community/Llama-3.2-3B-Instruct-4bit"11)12cmd=${1:-status}13for spec in "${SPECS[@]}"; do14  set -- $spec; node=$1; port=$2; model=$3; tag=$(echo "$model" | tr '/' '_')15  case $cmd in16    start)17      ssh -o ConnectTimeout=8 "$node" "mkdir -p ~/age-llm; if curl -s -m 2 localhost:$port/v1/models >/dev/null; then echo '$node:$port already up'; else nohup python3 -m mlx_lm.server --model '$model' --host 0.0.0.0 --port $port --max-tokens 1024 > ~/age-llm/server_$port.log 2>&1 & echo '$node:$port starting $model'; fi";;18    status)19      ssh -o ConnectTimeout=8 "$node" "curl -s -m 3 localhost:$port/v1/models | head -c 200; echo; tail -n 2 ~/age-llm/server_$port.log 2>/dev/null";;20    stop)21      ssh -o ConnectTimeout=8 "$node" "pkill -f 'mlx_lm.server.*--port $port' && echo '$node:$port stopped'";;22  esac23done24
Files · main
Menu

Theme