From 4857faec4e69310843b6270e50e72c73c6b86005 Mon Sep 17 00:00:00 2001 From: xiejiahao Date: Mon, 26 Oct 2026 17:01:28 +0800 Subject: [PATCH] Improve verify auto-detection without docker --- verify.sh | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/verify.sh b/verify.sh index 6886400..3c73b90 100755 --- a/verify.sh +++ b/verify.sh @@ -106,17 +106,45 @@ for m in mounts: fi # ---------------------------------------------------------------- model dir -if [[ -z "${MODEL_DIR}" ]]; then - for candidate in \ - "/mnt/disk0/models/LLM-Research/Llama-4-Scout-17B-16E-Instruct" \ - "/mnt/disk0/models/LLM-Research/Llama-4-Maverick-17B-128E-Instruct-FP8"; do - if [[ -f "${candidate}/config.json" ]]; then - MODEL_DIR="${candidate}" +SCOUT_DEFAULT="/mnt/disk0/models/LLM-Research/Llama-4-Scout-17B-16E-Instruct" +MAVERICK_DEFAULT="/mnt/disk0/models/LLM-Research/Llama-4-Maverick-17B-128E-Instruct-FP8" + +# 没有 docker 时(例如在 ugly_hopper 内运行),按端口探测正在运行的服务。 +if [[ -z "${CONTAINER}" && -z "${PORT}" && -z "${MODEL_DIR}" && -z "${BASE_URL}" ]]; then + for candidate_port in 8091 8092; do + if curl -fsS --max-time 2 "http://127.0.0.1:${candidate_port}/health" >/dev/null 2>&1; then + PORT="${candidate_port}" break fi done fi +# 从 served name 反推模型目录(方便 --base-url + --served-name 的用法)。 +if [[ -z "${MODEL_DIR}" && -n "${SERVED_NAME}" ]]; then + case "${SERVED_NAME}" in + *maverick*) + if [[ -f "${MAVERICK_DEFAULT}/config.json" ]]; then + MODEL_DIR="${MAVERICK_DEFAULT}" + fi + ;; + *scout*) + if [[ -f "${SCOUT_DEFAULT}/config.json" ]]; then + MODEL_DIR="${SCOUT_DEFAULT}" + fi + ;; + esac +fi + +if [[ -z "${MODEL_DIR}" && -z "${BASE_URL}" ]]; then + if [[ "${PORT}" == "8092" && -f "${MAVERICK_DEFAULT}/config.json" ]]; then + MODEL_DIR="${MAVERICK_DEFAULT}" + elif [[ -f "${SCOUT_DEFAULT}/config.json" ]]; then + MODEL_DIR="${SCOUT_DEFAULT}" + elif [[ -f "${MAVERICK_DEFAULT}/config.json" ]]; then + MODEL_DIR="${MAVERICK_DEFAULT}" + fi +fi + DETECT_JSON="" if [[ -n "${MODEL_DIR}" ]]; then if [[ -f "${MODEL_DIR}/config.json" ]]; then