Fixed model path resolution

This commit is contained in:
Donato Capitella
2025-11-17 08:57:42 +00:00
parent a50adb0c15
commit ecbe5c14c3
+38 -8
View File
@@ -16,7 +16,7 @@ LLAMA_BENCH_BIN="${LLAMA_BENCH_BIN:-llama-bench}"
# Explicit list of models to test - edit as needed. # Explicit list of models to test - edit as needed.
MODELS=( MODELS=(
"models/GLM-4.6-UD-Q4_K_XL-00001-of-00005.gguf" "/mnt/storage/MiniMax-M2-GGUF/UD-Q6_K_XL/MiniMax-M2-UD-Q6_K_XL-00001-of-00004.gguf"
) )
if (( ${#MODELS[@]} == 0 )); then if (( ${#MODELS[@]} == 0 )); then
@@ -55,6 +55,7 @@ ENVIRONMENTS=(
CURRENT_REMOTE_PID="" CURRENT_REMOTE_PID=""
CURRENT_REMOTE_ENV="" CURRENT_REMOTE_ENV=""
RESOLVED_MODELS=()
cleanup_remote() { cleanup_remote() {
if [[ -n "${CURRENT_REMOTE_PID:-}" && -n "${CURRENT_REMOTE_ENV:-}" ]]; then if [[ -n "${CURRENT_REMOTE_PID:-}" && -n "${CURRENT_REMOTE_ENV:-}" ]]; then
@@ -63,6 +64,29 @@ cleanup_remote() {
} }
trap cleanup_remote EXIT trap cleanup_remote EXIT
resolve_model_path() {
local raw="$1"
local expanded="$raw"
if [[ "$expanded" == ~* ]]; then
expanded="${expanded/#\~/$HOME}"
fi
local -a candidates=("$expanded")
if [[ "$expanded" != /* ]]; then
candidates+=("$SCRIPT_DIR/$expanded")
fi
for candidate in "${candidates[@]}"; do
if [[ -f "$candidate" ]]; then
printf '%s\n' "$candidate"
return 0
fi
done
return 1
}
get_hblt_modes() { get_hblt_modes() {
local env="$1" local env="$1"
if [[ "$env" == rocm* ]]; then if [[ "$env" == rocm* ]]; then
@@ -73,19 +97,25 @@ get_hblt_modes() {
} }
ensure_models_exist() { ensure_models_exist() {
local available=0 RESOLVED_MODELS=()
for m in "${MODELS[@]}"; do for m in "${MODELS[@]}"; do
if [[ -f "$m" ]]; then local resolved
((available++)) if resolved="$(resolve_model_path "$m")"; then
RESOLVED_MODELS+=("$resolved")
else else
echo "[WARN] Missing model file: $m" >&2 echo "[WARN] Missing model file: $m" >&2
fi fi
done done
if (( available == 0 )); then if (( ${#RESOLVED_MODELS[@]} == 0 )); then
echo "[ERROR] None of the listed models exist - adjust MODELS array." >&2 echo "[ERROR] None of the listed models exist - adjust MODELS array." >&2
exit 1 exit 1
fi fi
echo "Models to bench:"
for resolved in "${RESOLVED_MODELS[@]}"; do
echo " - $resolved"
done
} }
start_remote_rpc() { start_remote_rpc() {
@@ -229,9 +259,9 @@ run_all() {
continue continue
fi fi
for model in "${MODELS[@]}"; do for model in "${RESOLVED_MODELS[@]}"; do
run_llama_bench_rpc "$model" "$env" "$suffix" run_llama_bench_rpc "$model" "$env" "$suffix"
done done
stop_remote_rpc "$env" "$remote_pid" || true stop_remote_rpc "$env" "$remote_pid" || true
CURRENT_REMOTE_PID="" CURRENT_REMOTE_PID=""