File size: 1,428 Bytes
5713d13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
# One GPU, one HF backend, one Decision API. Keep this supervisor running.
set -euo pipefail

ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
cd "$ROOT"
PYTHON="$ROOT/.venv/bin/python"
MODEL=${MODEL:-"$ROOT"}
GPU=${GPU:-0}
HOST=${HOST:-127.0.0.1}
BACKEND_PORT=${BACKEND_PORT:-29100}
API_PORT=${API_PORT:-30100}
export TOKENIZERS_PARALLELISM=false
export OMP_NUM_THREADS=8
export PYTHONDONTWRITEBYTECODE=1
export JEV_HF_FAILURE_DIR="$ROOT/logs/hf-failures"

cleanup() {
  trap - EXIT INT TERM
  kill "$BACKEND_PID" "${API_PID:-}" 2>/dev/null || true
  wait "$BACKEND_PID" "${API_PID:-}" 2>/dev/null || true
}

CUDA_VISIBLE_DEVICES="$GPU" "$PYTHON" -u serving/hf_direct_backend.py \
  --model "$MODEL" --port "$BACKEND_PORT" \
  --attention bidirectional_prompt --max-context 65536 \
  --batch-size 8 --batch-tokens 16384 &
BACKEND_PID=$!
trap cleanup EXIT
trap 'exit 130' INT
trap 'exit 143' TERM

"$PYTHON" -u serving/decision_server.py \
  --model-path "$MODEL" --model-name jev-policy \
  --backend "http://127.0.0.1:$BACKEND_PORT" \
  --port "$API_PORT" --host "$HOST" --concurrency 64 \
  --max-context 65536 \
  --attention-mode bidirectional_prompt --backend-kind hf \
  --error-dir "$ROOT/logs/readout-errors" &
API_PID=$!

echo "Starting GPU=$GPU model=$MODEL API=$HOST:$API_PORT; wait for /health."
# If either service exits, release the other one too.
wait -n "$BACKEND_PID" "$API_PID"