#!/bin/bash
# Run ON the Colab G4 VM after setup_vm.sh has printed SETUP_DONE.
# Keeps the server bound to 127.0.0.1; reach it through an SSH local forward.
#
#   nohup bash /content/start_vllm.sh > /content/vllm.log 2>&1 &
#
# Startup lines worth waiting for (observed: ~6.6 min model load):
#   Resolved architecture: Qwen4ExpForConditionalGeneration
#   Initialized PLE embedding ... weight_device=cpu, pinned=True
#   Model loading took 73.6 GiB memory and 396.6 seconds
#   Available KV cache memory: 14.76 GiB
#   GPU KV cache size: 560,931 tokens, Maximum concurrency for 131,072 tokens per request: 4.28x
#   Application startup complete.
set -euo pipefail

MODEL_DIR="/content/models/Qwen3.8-Flash-Next-NVFP4"

exec env MAX_JOBS=1 vllm serve "$MODEL_DIR" \
  --host 127.0.0.1 --port 8000 \
  --served-model-name qwen3.8-flash-next \
  --quantization modelopt \
  --max-model-len 131072 \
  --gpu-memory-utilization 0.95 \
  --language-model-only \
  --enforce-eager \
  --max-num-seqs 1 \
  --no-enable-flashinfer-autotune \
  --reasoning-parser qwen3 \
  --trust-remote-code
