ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.
Python ai-agentsamdcomfyuidockerllama-cppllmlocal-ain8nnvidiaopen-webuiragself-hostedspeech-to-textstrix-halotext-to-speechworkflow-automation
feat(installer): run the vLLM engine where a vLLM model fits one GPU (#8299)
Mike Bradley666056e45231
diff --git a/ods/.env.schema.json b/ods/.env.schema.jsonindex 58149a7f7..c1e071424 100644--- a/ods/.env.schema.json+++ b/ods/.env.schema.json@@ -170,7 +170,7 @@},"LLM_BACKEND": {"type": "string",- "description": "Inference backend. Current installers write llama-server (every local GPU, AMD included) or external; vllm runs the vLLM engine (docker-compose.vllm.yml) instead of llama-server on a big NVIDIA GPU and is opt-in. Legacy values such as lemonade and litellm remain accepted for upgrade compatibility.",+ "description": "Inference backend. Current installers write llama-server (every local GPU, AMD included), external, or vllm: the vLLM engine (docker-compose.vllm.yml) instead of llama-server, which the Linux installer chooses when a vLLM catalog model fits one NVIDIA datacenter GPU (install.sh --llm-backend vllm|llama-server overrides the choice). Legacy values such as lemonade and litellm remain accepted for upgrade compatibility.","default": "llama-server"},"VLLM_IMAGE": {diff --git a/ods/Makefile b/ods/Makefileindex a46f8f684..2cc281a15 100644--- a/ods/Makefile+++ b/ods/Makefile@@ -190,6 +190,9 @@ test: ## Run unit and contract tests@bash tests/test-llama-cuda-cache-persisted.sh@echo "=== vLLM engine service and its compose selection ==="@bash tests/test-vllm-engine-service.sh+ @echo "=== vLLM engine choice and installer phases ==="+ @bash tests/test-vllm-installer-route.sh+ @bash tests/test-vllm-installer-phases.sh@echo ""@echo "=== macOS ods config show secret-mask ==="@bash tests/test-macos-config-show-secret-mask.shdiff --git a/ods/install-core.sh b/ods/install-core.shindex 52a773ba8..6272d254d 100755--- a/ods/install-core.sh+++ b/ods/install-core.sh@@ -123,6 +123,7 @@ source "$SCRIPT_DIR/installers/lib/lemonade-migration.sh"source "$SCRIPT_DIR/installers/lib/host-arch.sh"source "$SCRIPT_DIR/installers/lib/tier-map.sh"source "$SCRIPT_DIR/installers/lib/model-selector.sh"+source "$SCRIPT_DIR/installers/lib/llm-backend.sh"source "$SCRIPT_DIR/installers/lib/docker-images.sh"source "$SCRIPT_DIR/installers/lib/compose-images.sh"source "$SCRIPT_DIR/installers/lib/compose-select.sh"@@ -251,6 +252,9 @@ EXTERNAL_LLM_API_KEY_DISABLE=falseEXTERNAL_LLM_AUTO_REUSE="${EXTERNAL_LLM_AUTO_REUSE:-false}"EXTERNAL_LLM_DISABLE=falseODS_RESELECT_MODEL="${ODS_RESELECT_MODEL:-false}"+# The model server --llm-backend asks for: vllm, llama-server, or empty, which+# lets phase 02 choose (installers/lib/llm-backend.sh).+LLM_BACKEND_REQUESTED=""usage() {cat << EOF@@ -313,6 +317,11 @@ Options:--no-external-llmDisable a persisted external LLM selection on this rerun--reselect-model Replace a valid active local model with the current installer recommendation+ --llm-backend vllm|llama-server+ Model server. Without it, a new Linux install runs the vLLM engine+ when a vLLM catalog model fits one NVIDIA datacenter GPU, and+ llama.cpp (llama-server) otherwise; a rerun keeps its engine.+ vllm stops when no vLLM model fits; llama-server never uses vLLM--voice Enable voice services (Whisper + Kokoro)--no-voice Disable voice services--workflows Enable n8n workflow automation@@ -432,6 +441,9 @@ while [[ $# -gt 0 ]]; do--reuse-external-llm) EXTERNAL_LLM_AUTO_REUSE=true; shift ;;--no-external-llm) EXTERNAL_LLM_DISABLE=true; shift ;;--reselect-model) ODS_RESELECT_MODEL=true; shift ;;+ --llm-backend)+ case "${2:-}" in vllm|llama-server) LLM_BACKEND_REQUESTED="$2" ;; *) echo "--llm-backend requires vllm or llama-server" >&2; exit 1 ;; esac+ shift 2 ;;--voice) ENABLE_VOICE=true; shift ;;--no-voice) ENABLE_VOICE=false; shift ;;--workflows) ENABLE_WORKFLOWS=true; shift ;;diff --git a/ods/install.sh b/ods/install.shindex fe15a274a..0e9d4bb24 100755--- a/ods/install.sh+++ b/ods/install.sh@@ -8,6 +8,7 @@# --native-llm-gpu-vram-mb# (the retired --use-existing-lemonade/--lemonade-* flags map onto these or# onto --external-llm-* for one release)+# --llm-backend vllm|llama-server (Linux; macOS accepts only llama-server)# --preflight-only (environment checks only; used by get-ods.sh --force through# installers/reinstall-preflight.sh before an existing install is removed)diff --git a/ods/installers/lib/bootstrap-model.sh b/ods/installers/lib/bootstrap-model.shindex 3774a01f0..0ebb34833 100644--- a/ods/installers/lib/bootstrap-model.sh+++ b/ods/installers/lib/bootstrap-model.sh@@ -8,7 +8,7 @@# while the full tier-appropriate model downloads in the background.## Expects: TIER, GGUF_FILE, INSTALL_DIR, NO_BOOTSTRAP, OFFLINE_MODE,-# ODS_MODE, tier_rank()+# ODS_MODE, LLM_BACKEND, tier_rank()# Provides: BOOTSTRAP_* constants (incl. BOOTSTRAP_GGUF_SIZE_MB), bootstrap_needed()# ============================================================================@@ -33,6 +33,8 @@ BOOTSTRAP_MAX_CONTEXT=65536# 4. Not in offline mode (can't download anything)# 5. Not in cloud mode (no local model needed)# 6. No host-native llama-server (it serves the model chosen on Windows)+# 7. Not the vLLM engine (LLM_BACKEND=vllm): it serves its own model and+# runs no llama.cpp GGUF, so there is nothing to fast-start#bootstrap_needed() {local tier_rank@@ -53,6 +55,7 @@ bootstrap_needed() {# Cloud mode — no local model needed[[ "${ODS_MODE:-local}" == "cloud" ]] && return 1[[ -n "${NATIVE_LLM_BASE_URL:-}" ]] && return 1+ [[ "${LLM_BACKEND:-}" == "vllm" ]] && return 1return 0}diff --git a/ods/installers/lib/compose-select.sh b/ods/installers/lib/compose-select.shindex 901ddc1bc..40305c272 100755--- a/ods/installers/lib/compose-select.sh+++ b/ods/installers/lib/compose-select.sh@@ -8,7 +8,10 @@## Expects: SCRIPT_DIR, TIER, GPU_BACKEND, CAP_COMPOSE_OVERLAYS, LOG_FILE,# GPU_COUNT, log(), warn()-# Provides: resolve_compose_config() → sets COMPOSE_FILE, COMPOSE_FLAGS+# Provides: resolve_compose_config() → sets COMPOSE_FILE, COMPOSE_FLAGS;+# the service-set checks ods_gateway_assert_no_managed_inference(),+# ods_host_native_assert_no_managed_llama(),+# ods_vllm_assert_engine_stack() and ods_compose_assert_no_webui()## Modder notes:# Add new compose overlay mappings or backends here.@@ -142,6 +145,23 @@ ods_host_native_assert_no_managed_llama() {return 0}+# The vLLM engine (LLM_BACKEND=vllm) serves the model in vllm-server, and the+# in-stack llama-server must stay off: both would claim the same GPU. Check the+# effective service set, because inherited profiles can override an overlay.+ods_vllm_assert_engine_stack() {+ local services compose_root="${INSTALL_DIR:-$PWD}"+ services="$(cd "$compose_root" && $DOCKER_COMPOSE_CMD "$@" config --services)" || return 1+ if ! grep -qx 'vllm-server' <<< "$services"; then+ printf 'The vLLM Compose stack has no vllm-server service; docker-compose.vllm.yml is not selected.\n' >&2+ return 1+ fi+ if grep -qx 'llama-server' <<< "$services"; then+ printf 'The vLLM Compose stack also starts the in-stack llama-server. Clear COMPOSE_PROFILES and retry.\n' >&2+ return 1+ fi+ return 0+}+# Supply the early checks' placeholder GID to Compose. On a fresh install Phase# 05 selects "sudo docker compose" because the new docker group does not apply# to the running session yet, and sudo does not pass exported variables, so@@ -164,6 +184,11 @@ ods_host_native_assert_no_managed_llama_before_pixel_identity() (ods_host_native_assert_no_managed_llama "$@")+ods_vllm_assert_engine_stack_before_pixel_identity() (+ _ods_compose_placeholder_pixel_gid || return 1+ ods_vllm_assert_engine_stack "$@"+)+# A caller can inherit COMPOSE_PROFILES=gateway-webui. Check the effective# service set before pulling or starting a Portal-only stack.ods_compose_assert_no_webui() {diff --git a/ods/installers/lib/detection.sh b/ods/installers/lib/detection.shindex b640a1848..bd6b7e546 100755--- a/ods/installers/lib/detection.sh+++ b/ods/installers/lib/detection.sh@@ -968,6 +968,7 @@ fix_nvidia_secure_boot() {[[ -n "$TIER" ]] && resume_args="$resume_args --tier $TIER"[[ "$OFFLINE_MODE" == "true" ]] && resume_args="$resume_args --offline"[[ "${ODS_RESELECT_MODEL:-false}" == "true" ]] && resume_args="$resume_args --reselect-model"+ [[ -n "${LLM_BACKEND_REQUESTED:-}" ]] && resume_args="$resume_args --llm-backend $LLM_BACKEND_REQUESTED"local resume_command="cd \"${SCRIPT_DIR}\" && ./install.sh${resume_args}"log "Secure Boot key enrollment pending; resume with: $resume_command"diff --git a/ods/installers/lib/llm-backend.sh b/ods/installers/lib/llm-backend.shnew file mode 100644index 000000000..d04fcfdbe--- /dev/null+++ b/ods/installers/lib/llm-backend.sh@@ -0,0 +1,72 @@+#!/usr/bin/env bash+# ============================================================================+# ODS Installer -- model server choice (llama.cpp or the vLLM engine)+# ============================================================================+# Part of: installers/lib/+# Purpose: The rules phase 02 uses to choose the model server. The vLLM+# engine (docker-compose.vllm.yml) serves a vLLM catalog model on one+# NVIDIA datacenter GPU; llama.cpp (llama-server) serves a GGUF+# everywhere else. Which vLLM model fits which GPU is+# scripts/select-model.py --llm-runtime vllm's decision.+#+# Expects: nothing (arguments only)+# Provides: ods_vllm_route_blocker(), ods_vllm_auto_considered(),+# ods_vllm_image_from_lock()+#+# Modder notes:+# scripts/resolve-compose-stack.sh refuses LLM_BACKEND=vllm with the same+# routes ods_vllm_route_blocker names, so the installer never selects a+# stack the resolver rejects.+#+# This file is sourced; it must not change the caller's shell options.+# ============================================================================++# ods_vllm_route_blocker KERNEL WSL GPU_BACKEND ODS_MODE EXTERNAL_URL NATIVE_URL GATEWAY_ONLY+# Prints why this install cannot run the vLLM engine, or nothing when it can.+# KERNEL is `uname -s`; WSL and GATEWAY_ONLY are true or false; EXTERNAL_URL+# is the external model server this run uses (a flag or the installation's+# retained one), NATIVE_URL the host-native llama-server's origin. The vLLM+# engine runs in local mode only: a vLLM installation's reruns+# (scripts/preserve-active-model.py) and `ods mode` (scripts/mode-switch.sh)+# keep it local, since hybrid mode was never proven with it.+ods_vllm_route_blocker() {+ local kernel="$1" wsl="$2" gpu_backend="$3" ods_mode="$4"+ local external_url="$5" native_url="$6" gateway_only="$7"+ if [[ "$kernel" != "Linux" ]]; then+ printf 'the vLLM engine runs only on Linux, and this is %s\n' "${kernel:-an unknown system}"+ elif [[ "$wsl" == "true" ]]; then+ printf 'this is WSL, where ODS runs llama.cpp\n'+ elif [[ "$ods_mode" == "cloud" ]]; then+ printf 'ODS runs in cloud mode, which has no local model server\n'+ elif [[ "$ods_mode" != "local" ]]; then+ printf 'ODS_MODE=%s, and the vLLM engine runs only in local mode\n' "$ods_mode"+ elif [[ "$gateway_only" == "true" ]]; then+ printf '%s\n' '--gateway-only serves an external model'+ elif [[ -n "$external_url" ]]; then+ printf 'an external model server (%s) serves the model\n' "$external_url"+ elif [[ -n "$native_url" ]]; then+ printf 'a host-native llama-server (%s) serves the model\n' "$native_url"+ elif [[ "$gpu_backend" != "nvidia" ]]; then+ printf 'the GPU backend is %s, and the vLLM engine runs only on NVIDIA GPUs\n' "${gpu_backend:-unknown}"+ fi+}++# ods_vllm_auto_considered EXISTING_INSTALL RETAINED_BACKEND RESELECT+# Without --llm-backend, whether this run may choose vLLM: a fresh install,+# a rerun of a vLLM installation, or --reselect-model. A rerun of a llama.cpp+# installation keeps its active model (phase 02 preserves it), so it stays on+# llama.cpp until the owner asks for vLLM or a new recommendation.+ods_vllm_auto_considered() {+ local existing_install="$1" retained_backend="$2" reselect="$3"+ [[ "$existing_install" != "true" || "$retained_backend" == "vllm" || "$reselect" == "true" ]]+}++# ods_vllm_image_from_lock DEPENDENCY_LOCK_JSON+# Prints the digest-pinned vLLM image (config/dependency-lock.json entry+# vllm.vllm-server); fails when the lock has no such entry.+ods_vllm_image_from_lock() {+ local lock="$1" image+ image="$(jq -r '[.entries[] | select(.id == "vllm.vllm-server") | .value] | if length == 1 then .[0] else "" end' "$lock")" || return 1+ [[ "$image" =~ ^[^[:space:]@]+@sha256:[0-9a-f]{64}$ ]] || return 1+ printf '%s\n' "$image"+}diff --git a/ods/installers/lib/model-selector.sh b/ods/installers/lib/model-selector.shindex 4cd7fe205..6316094cc 100644--- a/ods/installers/lib/model-selector.sh+++ b/ods/installers/lib/model-selector.sh@@ -11,7 +11,8 @@# Expects: SCRIPT_DIR, GPU_BACKEND, GPU_MEMORY_TYPE, GPU_VRAM, RAM_GB, TIER,# HOST_ARCH, MODEL_PROFILE_EFFECTIVE (or MODEL_PROFILE)# Provides: ODS_HERMES_MIN_CONTEXT, ods_model_selector_python,-# ods_run_catalog_selector, ods_catalog_fit_check+# ods_run_catalog_selector, ods_run_vllm_selector,+# ods_catalog_fit_check## This file is sourced; it must not change the caller's shell options.# ============================================================================@@ -58,6 +59,30 @@ ods_run_catalog_selector() {--env}+# ods_run_vllm_selector PYTHON [GPU_ROW...]+# The vLLM engine's pick: one GPU_ROW per line of `nvidia-smi+# --query-gpu=uuid,compute_cap,memory.total --format=csv,noheader,nounits`.+# Chooses among the catalog's vLLM entries only, never a GGUF, and prints+# shell assignments with the VLLM_* keys. Exit 2: no vLLM model fits. The fit+# comes from the GPU rows alone, so the llama.cpp memory inputs are not passed.+ods_run_vllm_selector() {+ local python="$1" row+ shift+ local -a gpu_args=()+ for row in "$@"; do+ gpu_args+=(--gpu "$row")+ done+ "$python" "$SCRIPT_DIR/scripts/select-model.py" \+ --catalog "$SCRIPT_DIR/config/model-library.json" \+ --llm-runtime vllm \+ --backend "${GPU_BACKEND:-unknown}" \+ --host-arch "${HOST_ARCH:-unknown}" \+ --min-context "$ODS_HERMES_MIN_CONTEXT" \+ --installable-only \+ ${gpu_args[@]+"${gpu_args[@]}"} \+ --env+}+# ods_catalog_fit_check PYTHON MODEL CONTEXT [RUNTIME_PROFILE]# MODEL is a catalog id, LLM_MODEL name or GGUF file name. Exit 0: fits at# CONTEXT on this hardware; 3: does not fit; anything else: unknown (thediff --git a/ods/installers/lib/pixel-host-install.sh b/ods/installers/lib/pixel-host-install.shindex 3134aa1a8..89fabe3dc 100644--- a/ods/installers/lib/pixel-host-install.sh+++ b/ods/installers/lib/pixel-host-install.sh@@ -3698,13 +3698,36 @@ _ods_pixel_runtime_model_identity() {if [[ -n "${EXTERNAL_LLM_URL:-}" ]]; thenmodel="${EXTERNAL_LLM_MODEL:-}"[[ -n "$model" ]] || return 1+ elif [[ "${LLM_BACKEND:-}" == "vllm" ]]; then+ # The vLLM engine serves its --served-model-name, VLLM_SERVED_MODEL.+ model="${VLLM_SERVED_MODEL:-}"+ [[ -n "$model" ]] || return 1fi- # llama-server serves the GGUF file name (its --alias) on every runtime,- # the Windows Portal's host-native server included.+ # llama-server serves the GGUF file name (its --alias) on every other+ # runtime, the Windows Portal's host-native server included.[[ -n "$model" ]] || model="${GGUF_FILE:-${LLM_MODEL:-default}}"printf '%s\n' "$model"}+# The onboarding renderer's unspecified reasoning setting for the vLLM model+# LLM_MODEL: model-router gives it its catalog entry's thinking level+# ("reasoning": off, low, medium or high) in its own template arguments, so+# the Portal starts from the same default. "bootstrap" is the renderer's+# default-on value and "default" its default-off one; both keep a validated+# preference for the same route.+_ods_pixel_vllm_reasoning_default() {+ local level+ level="$(jq -r --arg model "${LLM_MODEL:-}" '+ [.models[]? | select(.runtime == "vllm" and (.llm_model_name == $model or .id == $model)) | .reasoning]+ | if length == 1 and (.[0] | type) == "string" then .[0] else "" end' \+ "${SCRIPT_DIR:?}/config/model-library.json")" || return 1+ case "$level" in+ off) printf '%s\n' default ;;+ low|medium|high) printf '%s\n' bootstrap ;;+ *) return 1 ;;+ esac+}+_ods_pixel_wait_model_gateway() {local label="$1" port="$2" api_key="$3" model="$4" attempts="${5:-120}"local body attempt@@ -4844,8 +4867,15 @@ _ods_pixel_write_onboarding() {# a local built-in Qwen3.5-2B bootstrap route defaults to reasoning on so# the Portal can complete simple tasks without tool loops; every other# route keeps the historical no-think default. The renderer preserves a- # previously validated reasoning preference for the same model route.- if [[ -n "${LLAMA_REASONING+x}" ]]; then+ # previously validated reasoning preference for the same model route. On+ # the vLLM engine the catalog entry's thinking default decides, which+ # model-router applies; LLAMA_REASONING is llama-server's setting.+ if [[ -z "${EXTERNAL_LLM_URL:-}" && "${LLM_BACKEND:-}" == "vllm" ]]; then+ reasoning="$(_ods_pixel_vllm_reasoning_default)" || {+ ai_bad "Pixel could not read the thinking default of ${LLM_MODEL:-the vLLM model} from config/model-library.json. The ODS files may be incomplete: download ODS again and rerun the installer. Need help? Ask on the ODS Discord: ${ODS_HELP_DISCORD_URL:-https://discord.gg/4ntNp9MAwC}"+ return 1+ }+ elif [[ -n "${LLAMA_REASONING+x}" ]]; then# Case-insensitive, as ods-host-agent.py reads LLAMA_REASONING.if [[ "$(printf '%s' "${LLAMA_REASONING:-off}" | tr '[:upper:]' '[:lower:]')" =~ ^(off|none|false|0)$ ]]; thenreasoning=falsediff --git a/ods/installers/lib/ui.sh b/ods/installers/lib/ui.shindex 1e3e7e784..7298c65b3 100755--- a/ods/installers/lib/ui.sh+++ b/ods/installers/lib/ui.sh@@ -353,15 +353,29 @@ ods_hud_columns() {fi}+# The live counter spin_task shows: the reader function's text when one is+# given, else the .part file's bytes against the expected size.+_ods_spin_counter() {+ local progress_part="$1" progress_total_mb="$2" progress_reader="$3"+ if [[ -n "$progress_reader" ]]; then+ "$progress_reader"+ else+ format_download_progress "$(download_part_bytes "$progress_part")" "$progress_total_mb"+ fi+}+# Spinner with mm:ss timer + lore messages every 8 seconds.# Optional args 3/4 turn the label into a live download counter: pass the .part# file the task is writing and the expected size in MB (0 when unknown). Without-# them a long download is indistinguishable from a stalled one.+# them a long download is indistinguishable from a stalled one. Optional arg 5+# names a function that prints a short live status instead (a download of many+# files, a model loading); pass "" and 0 for args 3/4 with it.spin_task() {local pid=$1local msg=$2local progress_part="${3:-}"local progress_total_mb="${4:-0}"+ local progress_reader="${5:-}"local spin='⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'local i=0local elapsed=0@@ -372,11 +386,11 @@ spin_task() {ods_select_lore_messagesif ! ods_ui_cinematic; thenlocal plain_label="$msg"- if [[ -n "$progress_part" ]]; then- plain_label="$msg — $(format_download_progress "$(download_part_bytes "$progress_part")" "$progress_total_mb")"+ if [[ -n "$progress_part" || -n "$progress_reader" ]]; then+ plain_label="$msg — $(_ods_spin_counter "$progress_part" "$progress_total_mb" "$progress_reader")"fiprintf " ... %s\n" "$plain_label"- if [[ -n "$progress_part" ]]; then+ if [[ -n "$progress_part" || -n "$progress_reader" ]]; then# Plain/redirected installs have no spinner: retain a bounded heartbeat# for large downloads instead of leaving the initial byte count frozen.while kill -0 "$pid" 2>/dev/null; do@@ -385,7 +399,7 @@ spin_task() {if (( elapsed % 30 == 0 )); thenprintf " ... [%02d:%02d] %s — %s\n" \"$((elapsed / 60))" "$((elapsed % 60))" "$msg" \- "$(format_download_progress "$(download_part_bytes "$progress_part")" "$progress_total_mb")"+ "$(_ods_spin_counter "$progress_part" "$progress_total_mb" "$progress_reader")"fidonefi@@ -402,8 +416,8 @@ spin_task() {local ss=$((elapsed % 60))local label="$msg"counter=''- if [[ -n "$progress_part" ]]; then- counter="$(format_download_progress "$(download_part_bytes "$progress_part")" "$progress_total_mb")"+ if [[ -n "$progress_part" || -n "$progress_reader" ]]; then+ counter="$(_ods_spin_counter "$progress_part" "$progress_total_mb" "$progress_reader")"fiods_hud_columnsprintf -v timer '[%02d:%02d]' "$mm" "$ss"diff --git a/ods/installers/macos/install-macos.sh b/ods/installers/macos/install-macos.shindex 32a55fabb..8b11fc22f 100755--- a/ods/installers/macos/install-macos.sh+++ b/ods/installers/macos/install-macos.sh@@ -164,6 +164,19 @@ while [[ $# -gt 0 ]]; do--all) ALL_FEATURES=true; shift ;;--cloud) CLOUD_MODE=true; shift ;;--no-bootstrap) NO_BOOTSTRAP=true; shift ;;+ # The vLLM engine needs Linux and an NVIDIA datacenter GPU. macOS+ # always runs llama.cpp, so llama-server is accepted and changes+ # nothing (get-ods.sh passes the same options to every installer).+ --llm-backend)+ case "${2:-}" in+ llama-server) shift 2 ;;+ vllm)+ echo "--llm-backend vllm needs Linux with an NVIDIA datacenter GPU; macOS runs llama.cpp. Nothing was changed." >&2+ echo "Rerun without --llm-backend, or with --llm-backend llama-server." >&2+ echo "Need help? Ask on the ODS Discord: https://discord.gg/4ntNp9MAwC" >&2+ exit 1 ;;+ *) echo "--llm-backend requires vllm or llama-server" >&2; exit 1 ;;+ esac ;;# API mode is not in this installer yet; say so and name the way# to connect an API after installing, not "Unknown option".--external-llm-url|--external-llm-provider|--external-llm-model|--external-llm-key-file|--external-llm-key-env|--no-external-llm|--reuse-external-llm)diff --git a/ods/installers/phases/02-detection.sh b/ods/installers/phases/02-detection.shindex 025f8b815..0892d2234 100755--- a/ods/installers/phases/02-detection.sh+++ b/ods/installers/phases/02-detection.sh@@ -11,7 +11,8 @@# fix_nvidia_secure_boot(), normalize_profile_tier(), tier_rank(),# resolve_tier_config(), resolve_compose_config(),# show_hardware_summary(), show_tier_recommendation(),-# chapter(), ai(), ai_ok(), log(), warn(), success()+# chapter(), ai(), ai_ok(), log(), warn(), success(),+# LLM_BACKEND_REQUESTED (--llm-backend; empty lets this phase choose)# Provides: GPU_BACKEND, GPU_NAME, GPU_VRAM, GPU_COUNT, GPU_MEMORY_TYPE,# TIER, TIER_NAME, LLM_MODEL, GGUF_FILE, GGUF_URL, MAX_CONTEXT,# COMPOSE_FILE, COMPOSE_FLAGS, RAM_KB, RAM_GB, MODEL_TIER_RAM_GB,@@ -19,7 +20,11 @@# DISK_AVAIL, BACKEND_ID,# LLM_HEALTHCHECK_URL, LLM_PUBLIC_API_PORT,# GPU_TOPOLOGY_JSON, GPU_HAS_NVLINK, GPU_TOTAL_VRAM,-# LLM_MODEL_SIZE_MB, AMD_GFX_TARGET, AMD_INFERENCE_BACKEND+# LLM_MODEL_SIZE_MB, AMD_GFX_TARGET, AMD_INFERENCE_BACKEND,+# LLM_BACKEND (llama-server or vllm; exported for vllm and when a+# run leaves vllm); with vllm also VLLM_IMAGE, VLLM_MODEL_DIR,+# VLLM_SERVED_MODEL, VLLM_ARGS, VLLM_GPU_UUID, and on a rerun that+# keeps a vLLM model the VLLM_GPU_MEMORY_UTILIZATION it was given## Modder notes:# Change tier auto-detection thresholds or add new hardware classes here.@@ -34,10 +39,48 @@ declare -F ods_native_llm_owns_host_gpu >/dev/null 2>&1 \[[ -f "${SCRIPT_DIR:-}/lib/safe-env.sh" ]] && . "$SCRIPT_DIR/lib/safe-env.sh". "$SCRIPT_DIR/installers/lib/wsl-memory.sh"+declare -F ods_vllm_route_blocker >/dev/null || . "$SCRIPT_DIR/installers/lib/llm-backend.sh"ods_progress 12 "detection" "Detecting GPU hardware"chapter "SYSTEM DETECTION"+# The model server this run uses: llama-server, or vllm when the vLLM choice+# below makes it; phase 06 writes it to .env.+LLM_BACKEND=llama-server++# --llm-backend vllm, or a rerun of a vLLM installation (_phase02_vllm_kept),+# where the vLLM engine cannot run stops before anything is changed, naming+# why.+_phase02_vllm_refused() {+ if [[ "${LLM_BACKEND_REQUESTED:-}" == "vllm" ]]; then+ error "--llm-backend vllm cannot be used here: $1. Rerun without --llm-backend to let ODS choose, or with --llm-backend llama-server. Need help? Ask on the ODS Discord: ${ODS_HELP_DISCORD_URL:-https://discord.gg/4ntNp9MAwC}"+ else+ error "This installation runs its model on the vLLM engine, which this run cannot use: $1. ODS stopped before changing anything. To run it without the vLLM engine, rerun with --llm-backend llama-server, or with --reselect-model to choose the model again. Need help? Ask on the ODS Discord: ${ODS_HELP_DISCORD_URL:-https://discord.gg/4ntNp9MAwC}"+ fi+ exit 1+}++# A rerun of a vLLM installation keeps the vLLM engine and its model, as+# --llm-backend vllm would: it never quietly becomes a llama.cpp installation+# (a GGUF download and another model). --llm-backend llama-server or+# --reselect-model chooses again.+_phase02_vllm_kept() {+ [[ "${LLM_BACKEND_REQUESTED:-}" != "llama-server" && "${ODS_RESELECT_MODEL:-false}" != "true" \+ && -f "${INSTALL_DIR:-}/.env" ]] \+ && [[ "$(external_llm_env_value "$INSTALL_DIR/.env" LLM_BACKEND)" == "vllm" ]]+}++# The Compose resolver reads LLM_BACKEND from the environment before .env.+# Export this run's choice when it is vllm, or when it leaves an installation+# that ran vLLM, so the resolver never selects from a .env that phase 06 has+# not rewritten yet. Every other run leaves the environment as it was.+_phase02_export_llm_backend() {+ if [[ "$LLM_BACKEND" == "vllm" ]] || { [[ -f "${INSTALL_DIR:-}/.env" ]] \+ && [[ "$(external_llm_env_value "$INSTALL_DIR/.env" LLM_BACKEND)" == "vllm" ]]; }; then+ export LLM_BACKEND+ fi+}+GPU_BACKEND_REQUESTED="${GPU_BACKEND:-}"GPU_BACKEND_FORCED=false[[ "${GPU_BACKEND_REQUESTED,,}" == "amd" ]] && GPU_BACKEND_FORCED=true@@ -71,6 +114,10 @@ fi# Cloud mode: skip GPU detection entirelyif [[ "${ODS_MODE:-local}" == "cloud" ]]; then+ if [[ "${LLM_BACKEND_REQUESTED:-}" == "vllm" ]] || _phase02_vllm_kept; then+ _phase02_vllm_refused "ODS runs in cloud mode, which has no local model server"+ fi+ _phase02_export_llm_backendai "Cloud mode — skipping GPU detection"GPU_BACKEND="cpu"GPU_NAME="Cloud (no local GPU)"@@ -526,6 +573,107 @@ elselog "Using specified tier: $TIER"fi+# -----------------------------------------------------------------------------+# Model server: llama.cpp (llama-server) or the vLLM engine+# -----------------------------------------------------------------------------+# The vLLM engine (docker-compose.vllm.yml) serves a vLLM catalog model,+# NVIDIA's NVFP4 builds, on one NVIDIA datacenter GPU (compute capability 10.x+# with room for the model). Only Linux (not WSL) with an NVIDIA GPU, in local+# mode and with no external, host-native or cloud model route, can run it+# (installers/lib/llm-backend.sh).+#+# Without --llm-backend, a fresh install or --reselect-model uses vLLM when a+# vLLM model fits; a rerun of a llama.cpp installation keeps the llama.cpp+# path below unchanged, without querying the GPUs for vLLM. --llm-backend vllm+# and a rerun of a vLLM installation (_phase02_vllm_kept) stop when vLLM+# cannot run or no vLLM model fits; --llm-backend llama-server never considers+# vLLM. On the vLLM path every selector failure other than "nothing fits"+# (exit 2) stops the install: there is no tier-map fallback. The pick+# (VLLM_SELECTOR_ENV) is loaded after the tier map, which it replaces; on a+# rerun of a vLLM installation it is the recommendation, and the installed+# vLLM model stays active (_phase02_keep_vllm_model).+_phase02_choose_llm_backend() {+ local requested="${LLM_BACKEND_REQUESTED:-}" external="${EXTERNAL_LLM_URL:-}"+ local existing=false retained="" required=false wsl=false blocker python rows status=0+ local env_text error_text error_file+ local -a gpu_rows=()+ VLLM_SELECTOR_ENV=""+ if [[ "$requested" == "llama-server" ]]; then+ log "Model server: llama.cpp (--llm-backend llama-server)"+ return 0+ fi+ if [[ -f "$INSTALL_DIR/.env" ]]; then+ existing=true+ retained="$(external_llm_env_value "$INSTALL_DIR/.env" LLM_BACKEND)"+ # Phase 02b keeps the installation's external model unless --no-external-llm.+ if [[ -z "$external" && "${EXTERNAL_LLM_DISABLE:-false}" != "true" ]]; then+ external="$(external_llm_env_value "$INSTALL_DIR/.env" EXTERNAL_LLM_URL)"+ fi+ fi+ if [[ "$requested" == "vllm" ]] || _phase02_vllm_kept; then+ required=true+ fi+ if ods_is_wsl_host; then+ wsl=true+ fi+ blocker="$(ods_vllm_route_blocker "$(uname -s)" "$wsl" "${GPU_BACKEND:-}" "${ODS_MODE:-local}" \+ "$external" "${NATIVE_LLM_BASE_URL:-}" "${ODS_GATEWAY_ONLY:-false}")"+ if [[ -z "$blocker" && "${ODS_DISABLE_CATALOG_MODEL_SELECTOR:-false}" == "true" ]]; then+ blocker="ODS_DISABLE_CATALOG_MODEL_SELECTOR=true turns the model catalog off"+ fi+ if [[ -n "$blocker" ]]; then+ [[ "$required" != true ]] || _phase02_vllm_refused "$blocker"+ log "Model server: llama.cpp ($blocker)"+ return 0+ fi+ if [[ "$required" != true ]] \+ && ! ods_vllm_auto_considered "$existing" "$retained" "${ODS_RESELECT_MODEL:-false}"; then+ log "Model server: llama.cpp, which this installation runs (--llm-backend vllm or --reselect-model lets ODS choose vLLM)"+ return 0+ fi+ python="$(ods_model_selector_python)"+ if [[ -z "$python" ]]; then+ [[ "$required" != true ]] || _phase02_vllm_refused "Python is unavailable for the model catalog"+ log "Model server: llama.cpp (Python is unavailable for the vLLM model catalog)"+ return 0+ fi+ if ! rows="$(nvidia-smi --query-gpu=uuid,compute_cap,memory.total --format=csv,noheader,nounits 2>>"$LOG_FILE")"; then+ [[ "$required" != true ]] || _phase02_vllm_refused "nvidia-smi could not list this host's GPUs (details in $LOG_FILE)"+ log "Model server: llama.cpp (nvidia-smi could not list the GPUs for the vLLM engine)"+ return 0+ fi+ mapfile -t gpu_rows < <(printf '%s\n' "$rows" | sed '/^[[:space:]]*$/d')+ error_file="$(mktemp "${TMPDIR:-/tmp}/ods-vllm-selector.XXXXXX")"+ env_text="$(ods_run_vllm_selector "$python" ${gpu_rows[@]+"${gpu_rows[@]}"} 2>"$error_file")" || status=$?+ error_text="$(cat "$error_file")"+ rm -f -- "$error_file"+ [[ -z "$error_text" ]] || printf '%s\n' "$error_text" >> "$LOG_FILE"+ case "$status" in+ 0)+ LLM_BACKEND=vllm+ VLLM_SELECTOR_ENV="$env_text"+ ;;+ 2)+ [[ "$required" != true ]] || _phase02_vllm_refused "${error_text#error: }"+ log "Model server: llama.cpp (${error_text#error: })"+ ;;+ *)+ error "The vLLM model selector stopped (exit $status): ${error_text:-no details}. The ODS files may be incomplete: download ODS again and rerun the installer. Need help? Ask on the ODS Discord: ${ODS_HELP_DISCORD_URL:-https://discord.gg/4ntNp9MAwC}"+ exit 1+ ;;+ esac+}+_phase02_choose_llm_backend+if [[ "$LLM_BACKEND" == "vllm" ]]; then+ # docker-compose.vllm.yml defaults to the same pin; .env records it.+ if ! VLLM_IMAGE="$(ods_vllm_image_from_lock "$SCRIPT_DIR/config/dependency-lock.json")"; then+ error "$SCRIPT_DIR/config/dependency-lock.json names no digest-pinned vLLM image (entry vllm.vllm-server), so ODS stopped before changing anything. The ODS files may be incomplete: download ODS again and rerun the installer. Need help? Ask on the ODS Discord: ${ODS_HELP_DISCORD_URL:-https://discord.gg/4ntNp9MAwC}"+ exit 1+ fi+ export VLLM_IMAGE+fi+_phase02_export_llm_backend+# Resolve compose overlay filesresolve_compose_config@@ -556,10 +704,19 @@ if [[ -z "${MODEL_PROFILE:-}" ]]; thenfiresolve_tier_config+# The vLLM pick replaces the tier map's llama.cpp model (GGUF_* empty, the+# VLLM_* keys set); the llama.cpp catalog selector below does not run. The+# choice is shown once active-model preservation below is final.+if [[ "${LLM_BACKEND:-}" == "vllm" ]]; then+ load_model_selector_env_from_output <<< "$VLLM_SELECTOR_ENV"+ export PIXEL_AGENT_MODEL_READY+ log "vLLM model selector: ${MODEL_RECOMMENDATION_REASON:-$LLM_MODEL}"+fi+# Refine the tier's model choice using the versioned catalog before any GGUF is# downloaded. This keeps install-time selection aligned with the dashboard# oracle while preserving the tier map as a no-Python fallback.-if [[ "${ODS_DISABLE_CATALOG_MODEL_SELECTOR:-false}" != "true" && "${TIER:-}" != "CLOUD" ]]; then+if [[ "${ODS_DISABLE_CATALOG_MODEL_SELECTOR:-false}" != "true" && "${TIER:-}" != "CLOUD" && "${LLM_BACKEND:-}" != "vllm" ]]; then_selector_script="$SCRIPT_DIR/scripts/select-model.py"_selector_catalog="$SCRIPT_DIR/config/model-library.json"if [[ -f "$_selector_script" && -f "$_selector_catalog" ]] \@@ -678,6 +835,55 @@ if ods_native_llm_requested && [[ "${TIER:-}" != "CLOUD" ]]; thenunset _native_args _native_model_envfi+# A rerun of a vLLM installation whose model cannot be kept stops before+# anything is changed: replacing the model would download another one.+# STATUS is scripts/preserve-active-model.py's exit status; 2 means the saved+# snapshot is incomplete or is not this release's catalog entry.+_phase02_vllm_keep_refused() {+ local status="$1" model folder+ model="$(external_llm_env_value "$INSTALL_DIR/.env" LLM_MODEL)"+ folder="$(external_llm_env_value "$INSTALL_DIR/.env" VLLM_MODEL_DIR)"+ if [[ "$status" == "2" ]]; then+ error "This installation runs ${model:-its model} on the vLLM engine, but its saved vLLM model is incomplete or is no longer this release's catalog model (details in ${LOG_FILE}). ODS stopped before changing anything. To download the catalog's vLLM model, rerun the installer with --reselect-model. If the model folder data/models/${folder:-<VLLM_MODEL_DIR>} was moved or deleted, restore it and run the same command again. Need help? Ask on the ODS Discord: ${ODS_HELP_DISCORD_URL:-https://discord.gg/4ntNp9MAwC}"+ else+ error "This installation runs ${model:-its model} on the vLLM engine, but ODS could not read its saved vLLM model (scripts/preserve-active-model.py exit ${status}; details in ${LOG_FILE}). ODS stopped before changing anything. The ODS files may be incomplete: download ODS again and run the same command. Need help? Ask on the ODS Discord: ${ODS_HELP_DISCORD_URL:-https://discord.gg/4ntNp9MAwC}"+ fi+ exit 1+}++# A rerun of a vLLM installation keeps its model: the same catalog snapshot,+# served id and GPU, which scripts/preserve-active-model.py prints from .env+# (LLM_BACKEND=vllm, the VLLM_* keys, empty GGUF_* keys). The vLLM pick above+# stays the recommendation. The VLLM_* keys are cleared first, so a key the+# loader dropped cannot leave the pick's value in place.+_phase02_keep_vllm_model() {+ local python status=0 contract+ python="$(ods_model_selector_python)"+ contract="$("$python" "$SCRIPT_DIR/scripts/preserve-active-model.py" \+ --env "$INSTALL_DIR/.env" \+ --catalog "$SCRIPT_DIR/config/model-library.json" \+ --imports "$INSTALL_DIR/data/model-imports.json" \+ --models-dir "$INSTALL_DIR/data/models" \+ --state "$INSTALL_DIR/data/model-state.json" \+ --backend "${GPU_BACKEND:-unknown}" \+ --memory-type "${GPU_MEMORY_TYPE:-discrete}" \+ --vram-mb "${GPU_VRAM:-0}" \+ --ram-gb "${RAM_GB:-0}" \+ --host-arch "${HOST_ARCH:-unknown}" \+ --chat-templates "$SCRIPT_DIR/config/chat-templates" \+ --local-model \+ 2>>"$LOG_FILE")" || status=$?+ [[ "$status" -eq 0 && -n "$contract" ]] || _phase02_vllm_keep_refused "$status"+ unset VLLM_MODEL_DIR VLLM_SERVED_MODEL VLLM_ARGS VLLM_GPU_UUID+ load_model_selector_env_from_output <<< "$contract"+ if [[ "$LLM_BACKEND" != "vllm" || -z "${VLLM_MODEL_DIR:-}" || -z "${VLLM_SERVED_MODEL:-}" \+ || -z "${VLLM_ARGS:-}" || -z "${VLLM_GPU_UUID:-}" ]]; then+ log "The saved vLLM model contract is incomplete after loading: $(printf '%s' "$contract" | tr '\n' ' ')"+ _phase02_vllm_keep_refused "0 with an incomplete contract"+ fi+ log "Kept this installation's vLLM model across installer rerun: ${LLM_MODEL} (${VLLM_MODEL_DIR}) on GPU ${VLLM_GPU_UUID}, selected by ${MODEL_SELECTION_SOURCE}"+}+# The tier/catalog result is a recommendation. A valid local model already# activated through the Dashboard is operator state and must survive routine# installer reruns. Keep those two concepts separate so updates can advertise@@ -690,7 +896,21 @@ MODEL_SELECTION_SOURCE="installer"# template. Only the preserved contract of that same model sets them below;# never the recommendation or a value exported by the caller.unset LLAMA_ARG_MMPROJ MODEL_CHAT_TEMPLATE_OVERRIDE LLAMA_ARG_CHAT_TEMPLATE_FILE-if [[ -f "$INSTALL_DIR/.env" && "${ODS_RESELECT_MODEL:-false}" != "true" && "${TIER:-}" != "CLOUD" ]]; then+_phase02_retained_backend=""+[[ ! -f "$INSTALL_DIR/.env" ]] \+ || _phase02_retained_backend="$(external_llm_env_value "$INSTALL_DIR/.env" LLM_BACKEND)"+if [[ "${LLM_BACKEND:-}" == "vllm" && "$_phase02_retained_backend" != "vllm" ]]; then+ # This run moves the installation to the vLLM engine: the vLLM pick above+ # is the active model; a retained GGUF must not replace it.+ log "Model server: vLLM; the vLLM pick is used, not a retained llama.cpp model"+elif [[ "$_phase02_retained_backend" == "vllm" && "${LLM_BACKEND:-}" != "vllm" ]]; then+ # This run leaves the vLLM engine (--llm-backend llama-server, or+ # --reselect-model where no vLLM model fits). llama.cpp cannot serve the+ # vLLM model, so the pick above is the active model.+ log "Leaving the vLLM engine: this installation's vLLM model is not carried over (its files stay in data/models)"+elif [[ "${LLM_BACKEND:-}" == "vllm" && "${ODS_RESELECT_MODEL:-false}" != "true" ]]; then+ _phase02_keep_vllm_model+elif [[ -f "$INSTALL_DIR/.env" && "${ODS_RESELECT_MODEL:-false}" != "true" && "${TIER:-}" != "CLOUD" ]]; then# The model of a host-native llama-server belongs to Windows setup, which# passes it on every run. A rerun without it must not quietly switch the# install to a model in this Linux environment. (The helper fails only@@ -790,9 +1010,15 @@ if [[ -f "$INSTALL_DIR/.env" && "${ODS_RESELECT_MODEL:-false}" != "true" && "${Telif [[ "${ODS_RESELECT_MODEL:-false}" == "true" ]]; thenlog "Active-model preservation disabled by --reselect-model"fi+unset _phase02_retained_backendunset _native_python+# The model server and the model it serves, now that preservation is final.+if [[ "${LLM_BACKEND:-}" == "vllm" ]]; then+ ai_ok "Model server: vLLM engine, serving ${VLLM_SERVED_MODEL} on GPU ${VLLM_GPU_UUID}"+fi+# Display hardware summary with nice formattingCPU_INFO=$(grep "model name" /proc/cpuinfo 2>/dev/null | head -1 | cut -d: -f2 | xargs || echo "Unknown")if [[ "$INTERACTIVE" == "true" ]]; then@@ -808,6 +1034,7 @@ if [[ "$INTERACTIVE" == "true" ]]; thenfi_shown_model="$LLM_MODEL"+ [[ "${LLM_BACKEND:-}" != "vllm" ]] || _shown_model="${VLLM_SERVED_MODEL:-$LLM_MODEL} (vLLM)"if [[ -n "${EXTERNAL_LLM_URL:-}" ]]; then# The API serves the model; the local pick is not downloaded._shown_model="${EXTERNAL_LLM_MODEL:-the API's model} (API)"@@ -827,6 +1054,7 @@ elseif [[ -n "${EXTERNAL_LLM_URL:-}" ]]; thenlog " Model: ${EXTERNAL_LLM_MODEL:-the API's model}, served by ${EXTERNAL_LLM_URL}"else+ [[ "${LLM_BACKEND:-}" != "vllm" ]] || log " Engine: vLLM on GPU ${VLLM_GPU_UUID}"log " Model: $LLM_MODEL"log " Context: ${MAX_CONTEXT} tokens"fidiff --git a/ods/installers/phases/02b-external-services.sh b/ods/installers/phases/02b-external-services.shindex 3e3c2f6d0..d3f2a3d6a 100644--- a/ods/installers/phases/02b-external-services.sh+++ b/ods/installers/phases/02b-external-services.sh@@ -53,7 +53,10 @@ if [[ "$_external_disable" == "true" ]]; thenreturn 0fi-if [[ -z "$_external_url" && "${ODS_MODE:-local}" == "local" ]] && ! ods_native_llm_requested; then+# The vLLM engine (phase 02) serves its own model: a running Ollama or LM+# Studio is not offered in its place.+if [[ -z "$_external_url" && "${ODS_MODE:-local}" == "local" && "${LLM_BACKEND:-}" != "vllm" ]] \+ && ! ods_native_llm_requested; then_detected_provider=""_detected_url=""_detected_model=""diff --git a/ods/installers/phases/03-features.sh b/ods/installers/phases/03-features.shindex ebb2c40e8..dd0a88096 100755--- a/ods/installers/phases/03-features.sh+++ b/ods/installers/phases/03-features.sh@@ -11,6 +11,7 @@# HOST_ARCH, HOST_PAGE_SIZE,# GPU_TOPOLOGY_JSON, LLM_MODEL_SIZE_MB, SCRIPT_DIR, VERBOSE, DEBUG,# GPU_INDICES, GPU_UUIDS (arrays from topology),+# LLM_BACKEND and VLLM_GPU_UUID (phase 02; vllm pins the LLM GPU),# show_phase(), show_install_menu(), chapter(), bootline(),# success(), log(), warn(), error(), signal()# Provides: ENABLE_VOICE, ENABLE_WORKFLOWS, ENABLE_RAG, ENABLE_EMBEDDINGS,@@ -229,9 +230,11 @@ if [[ "${ENABLE_HERMES:-false}" == "true" && "${ODS_MODE:-local}" != "cloud" ]];&& [[ -f "$SCRIPT_DIR/scripts/select-model.py" && -f "$SCRIPT_DIR/config/model-library.json" ]]; then_hermes_python="$(ods_model_selector_python)"fi- if ods_native_llm_requested; then+ if ods_native_llm_requested || [[ "${LLM_BACKEND:-}" == "vllm" ]]; then# llama-server on the Windows host loaded this model at this- # context; this run can neither pick another model nor resize it.+ # context, and a vLLM model serves the context its --max-model-len+ # (VLLM_ARGS) fixes; this run can neither pick another model nor+ # resize it (the llama.cpp fit check does not apply)._hermes_floor_action="cap"_hermes_python=""fi@@ -504,6 +507,9 @@ if ! $DRY_RUN; then_pixel_support_services="${ENABLE_RECOMMENDED:-false}"[[ "${ENABLE_PIXEL_RUNTIME:-false}" == "true" ]] && _pixel_support_services=true[[ -n "${EXTERNAL_LLM_URL:-}" ]] && _pixel_support_services=true+ # Services reach the vLLM engine through LiteLLM and model-router, as on+ # the host-native route (phase 06 sets LLM_API_URL to the gateway).+ [[ "${LLM_BACKEND:-}" == "vllm" ]] && _pixel_support_services=true# With the default ODS_MODEL_SWITCHBOARD=enabled, phase 06 routes Open WebUI# through the gateway (OPEN_WEBUI_LLM_BASE_URL=http://litellm:4000), so it# must run even when recommended services are off. Resolve the mode as@@ -643,6 +649,11 @@ fiif [[ "$GPU_COUNT" -le 1 ]]; thenif [[ "${GPU_BACKEND:-}" == "nvidia" ]]; then_single_gpu_uuid=$(nvidia-smi --query-gpu=uuid --format=csv,noheader,nounits 2>/dev/null | sed -n '1p' || true)+ # The vLLM engine owns the GPU its selector sized the model for.+ if [[ "${LLM_BACKEND:-}" == "vllm" && "$_single_gpu_uuid" != "${VLLM_GPU_UUID:-}" ]]; then+ error "The vLLM engine was planned for GPU ${VLLM_GPU_UUID:-unknown}, but nvidia-smi lists ${_single_gpu_uuid:-no GPU}. Rerun the installer; if it happens again, rerun with --llm-backend llama-server. Need help? Ask on the ODS Discord: ${ODS_HELP_DISCORD_URL:-https://discord.gg/4ntNp9MAwC}"+ return 1+ fiif [[ -n "$_single_gpu_uuid" ]]; thenGPU_ASSIGNMENT_JSON=$(jq -n \--arg uuid "$_single_gpu_uuid" \@@ -724,8 +735,13 @@ run_automatic() {echo ""local result+ # The vLLM engine owns exactly the GPU its selector sized the model for+ # (VLLM_GPU_UUID): a model that fits one GPU is never split across GPUs,+ # and the other services take the remaining GPUs.+ local -a pin_args=()+ [[ "${LLM_BACKEND:-}" != "vllm" ]] || pin_args=(--pin-llm-gpu "$VLLM_GPU_UUID")result=$(python3 "$ASSIGN_GPUS_SCRIPT" \- --topology "$TOPOLOGY_FILE" --model-size "$LLM_MODEL_SIZE_MB" 2>&1) || {+ --topology "$TOPOLOGY_FILE" --model-size "$LLM_MODEL_SIZE_MB" ${pin_args[@]+"${pin_args[@]}"} 2>&1) || {echo -e " ${RED}Assignment failed:${NC}\n $result"error "GPU assignment failed: $result"}@@ -935,8 +951,20 @@ _load_existing_gpu_assignment_json() {# --- Multi-GPU Config TUI ---GPU_ASSIGNMENT_JSON=""+if [[ "${LLM_BACKEND:-}" == "vllm" ]]; then+ # The vLLM engine's GPU is fixed, so there is nothing to choose. A saved+ # assignment is reused only when it gives the LLM exactly that GPU.+ if _existing_assignment=$(_load_existing_gpu_assignment_json) \+ && jq -e --arg uuid "$VLLM_GPU_UUID" '.gpu_assignment.services.llama_server.gpus == [$uuid]' \+ <<< "$_existing_assignment" >/dev/null; then+ GPU_ASSIGNMENT_JSON="$_existing_assignment"+ success "Reusing existing GPU assignment from .env"+ else+ log "vLLM runs on GPU ${VLLM_GPU_UUID}; the other services take the remaining GPUs."+ run_automatic+ fi# If it is not an interactive session, run automatic assignment with default values-if ! $INTERACTIVE || $DRY_RUN; then+elif ! $INTERACTIVE || $DRY_RUN; thenif _existing_assignment=$(_load_existing_gpu_assignment_json); thenGPU_ASSIGNMENT_JSON="$_existing_assignment"success "Reusing existing GPU assignment from .env"@@ -974,6 +1002,13 @@ if [[ "$VENDOR" == "nvidia" ]]; thenif [[ -z "$LLAMA_SERVER_GPU_UUIDS" ]]; thenerror "GPU assignment did not select any NVIDIA device for llama-server"fi+ # On the vLLM route the LLM role is the vLLM engine's one GPU. The+ # multi-GPU overlay still needs LLAMA_SERVER_GPU_UUIDS for the profiled-out+ # llama-server (Compose interpolates disabled services), so it names the+ # same GPU.+ if [[ "${LLM_BACKEND:-}" == "vllm" && "$LLAMA_SERVER_GPU_UUIDS" != "${VLLM_GPU_UUID:-}" ]]; then+ error "GPU assignment gave the LLM ${LLAMA_SERVER_GPU_UUIDS}, but the vLLM engine owns GPU ${VLLM_GPU_UUID:-unknown}"+ fiWHISPER_GPU_UUID=$(echo "$GPU_ASSIGNMENT_JSON" | jq -r '.gpu_assignment.services.whisper.gpus[0]?')COMFYUI_GPU_UUID=$(echo "$GPU_ASSIGNMENT_JSON" | jq -r '.gpu_assignment.services.comfyui.gpus[0]?')EMBEDDINGS_GPU_UUID=$(echo "$GPU_ASSIGNMENT_JSON" | jq -r '.gpu_assignment.services.embeddings.gpus[0]?')diff --git a/ods/installers/phases/06-directories.sh b/ods/installers/phases/06-directories.shindex 0b60e3f61..98dec8694 100755--- a/ods/installers/phases/06-directories.sh+++ b/ods/installers/phases/06-directories.sh@@ -13,6 +13,8 @@# GPU_ASSIGNMENT_JSON, COMFYUI_GPU_UUID, WHISPER_GPU_UUID,# EMBEDDINGS_GPU_UUID, LLAMA_SERVER_GPU_UUIDS, LLAMA_ARG_SPLIT_MODE,# LLAMA_ARG_TENSOR_SPLIT, GPU_COMPUTE_CAP (optional),+# LLM_BACKEND (phase 02; with vllm also VLLM_IMAGE, VLLM_MODEL_DIR,+# VLLM_SERVED_MODEL, VLLM_ARGS, VLLM_GPU_UUID),# chapter(), ai(), ai_ok(), ai_warn(), log(), warn(), error()# Provides: WEBUI_SECRET, N8N_PASS, LITELLM_KEY, LIVEKIT_SECRET,# DASHBOARD_API_KEY, SHIELD_API_KEY, TOKEN_SPY_API_KEY,@@ -566,6 +568,11 @@ elsemkdir -p "$INSTALL_DIR"/data/{open-webui,whisper,tts,n8n,qdrant,models,privacy-shield,ape,token-spy,hermes,persona}# llama-server's CUDA kernel cache (docker-compose.nvidia.yml).mkdir -p "$INSTALL_DIR"/data/llama-server/cuda-cache+ # The vLLM engine's compile, autotune and CUDA kernel caches+ # (docker-compose.vllm.yml), made here so Docker does not create it.+ if [[ "${LLM_BACKEND:-}" == "vllm" ]]; then+ mkdir -p "$INSTALL_DIR"/data/vllm/cache+ fi# The host agent writes extension progress as the install owner. Created# here, the Dashboard API (UID 1000, which may be another user) cannot# make it first and lock the owner's host agent out of it.@@ -1300,6 +1307,12 @@ SERVICE_PORT_DEFAULTSai_warn "External LLM reuse uses the authenticated LiteLLM gateway directly; setting ODS_MODEL_SWITCHBOARD=observe."ODS_MODEL_SWITCHBOARD_VALUE="observe"fi+ # Only model-router knows the vLLM engine's endpoint (vllm-default); the+ # legacy and observe LiteLLM maps send ods/current to llama-server.+ if [[ "${LLM_BACKEND:-}" == "vllm" && "$ODS_MODEL_SWITCHBOARD_VALUE" != "enabled" ]]; then+ ai_warn "The vLLM engine is reached through model-router; setting ODS_MODEL_SWITCHBOARD=enabled."+ ODS_MODEL_SWITCHBOARD_VALUE="enabled"+ fi# Compose inherits exported installer variables ahead of the generated# .env. Keep the live process value aligned with the effective value so an# external-model install cannot select switchboard.yaml while its router@@ -1307,8 +1320,10 @@ SERVICE_PORT_DEFAULTSODS_MODEL_SWITCHBOARD="$ODS_MODEL_SWITCHBOARD_VALUE"export ODS_MODEL_SWITCHBOARD# A host-native llama-server is reachable only through LiteLLM, which holds- # its key; the in-stack llama-server serves every other local install.- _default_llm_api_url="$(if [[ "$NATIVE_LLM_ACTIVE" == "true" ]]; then echo "http://litellm:4000"; elif [[ "${ODS_MODE:-local}" == "local" ]]; then echo "http://llama-server:8080"; else echo "http://litellm:4000"; fi)"+ # its key. The vLLM engine has no in-stack llama-server either: LiteLLM+ # sends every model name to model-router as ods/current. The in-stack+ # llama-server serves every other local install.+ _default_llm_api_url="$(if [[ "$NATIVE_LLM_ACTIVE" == "true" || "${LLM_BACKEND:-}" == "vllm" ]]; then echo "http://litellm:4000"; elif [[ "${ODS_MODE:-local}" == "local" ]]; then echo "http://llama-server:8080"; else echo "http://litellm:4000"; fi)"if [[ "$EXTERNAL_LLM_ACTIVE" == "true" ]]; thenLLM_API_URL_VALUE="http://litellm:4000"OPEN_WEBUI_LLM_BASE_URL_VALUE="http://litellm:4000/v1"@@ -1324,9 +1339,10 @@ SERVICE_PORT_DEFAULTSif [[ "${ODS_REMOTE_ROUTE_PAUSED:-false}" == "true" ]]; thenLLM_API_URL_VALUE="${ODS_REMOTE_ROUTE_PREVIOUS_API_URL:-$_default_llm_api_url}"fi- # The in-stack llama-server is off for a host-native route. Preserve- # other existing values as operator-selected endpoints.- if [[ "$NATIVE_LLM_ACTIVE" == "true" ]]; then+ # The in-stack llama-server is off for a host-native route and for the+ # vLLM engine. Preserve other existing values as operator-selected+ # endpoints.+ if [[ "$NATIVE_LLM_ACTIVE" == "true" || "${LLM_BACKEND:-}" == "vllm" ]]; thencase "$LLM_API_URL_VALUE" inhttp://llama-server:8080|http://llama-server:8080/v1)LLM_API_URL_VALUE="$_default_llm_api_url"@@ -1387,6 +1403,24 @@ SERVICE_PORT_DEFAULTSHERMES_LLM_BASE_URL_VALUE="http://model-router:9099/v1"HERMES_LLM_API_KEY_VALUE="no-key"fi+ # The vLLM engine replaces the in-stack llama-server, as the host-native+ # route does: Open WebUI reaches the model through LiteLLM and Hermes+ # through model-router. A retained URL that names llama-server, or an+ # empty one an API-mode reset left, would reach no server.+ if [[ "${LLM_BACKEND:-}" == "vllm" ]]; then+ case "$OPEN_WEBUI_LLM_BASE_URL_VALUE" in+ ""|http://llama-server:8080|http://llama-server:8080/v1)+ OPEN_WEBUI_LLM_BASE_URL_VALUE="http://litellm:4000"+ OPEN_WEBUI_LLM_API_KEY_VALUE="${LITELLM_KEY}"+ ;;+ esac+ case "$HERMES_LLM_BASE_URL_VALUE" in+ http://llama-server:8080|http://llama-server:8080/v1)+ HERMES_LLM_BASE_URL_VALUE="http://model-router:9099/v1"+ HERMES_LLM_API_KEY_VALUE="no-key"+ ;;+ esac+ fi# Owner-card gating is opt-in; a rerun must not silently turn it back off.HERMES_REQUIRE_OWNER_CARD_VALUE="$(_env_get_explicit_first HERMES_REQUIRE_OWNER_CARD false)"LLM_API_URL="$LLM_API_URL_VALUE"@@ -1588,6 +1622,33 @@ SERVICE_PORT_DEFAULTSONEAPI_DEVICE_SELECTOR_VALUE="$(_env_get ONEAPI_DEVICE_SELECTOR level_zero:gpu)"fi+ # The vLLM engine's settings (LLM_BACKEND=vllm), appended after the+ # template below so every other install writes the same bytes as before.+ # Resolved here, before the template truncates the .env _env_get reads.+ # ODS Talk image attachments reach the model through LiteLLM, as the+ # host-native overlay sets; an owner's own vision server is kept.+ VLLM_GPU_MEMORY_UTILIZATION_VALUE=""+ VLLM_TALK_VISION_URL_VALUE=""+ VLLM_TALK_VISION_KEY_VALUE=""+ if [[ "${LLM_BACKEND:-}" == "vllm" ]]; then+ for _vllm_key in VLLM_IMAGE VLLM_MODEL_DIR VLLM_SERVED_MODEL VLLM_GPU_UUID; do+ [[ -n "${!_vllm_key:-}" ]] || {+ error "The vLLM engine needs ${_vllm_key}, which this run's model choice did not set, so .env was not written. Rerun the installer; if it happens again, rerun with --llm-backend llama-server. Need help? Ask on the ODS Discord: ${ODS_HELP_DISCORD_URL:-https://discord.gg/4ntNp9MAwC}"+ return 1+ }+ done+ unset _vllm_key+ VLLM_GPU_MEMORY_UTILIZATION_VALUE="$(_env_get_explicit_first VLLM_GPU_MEMORY_UTILIZATION "")"+ VLLM_TALK_VISION_URL_VALUE="$(_env_get ODS_TALK_VISION_URL "http://litellm:4000/v1")"+ VLLM_TALK_VISION_KEY_VALUE="$(_env_get ODS_TALK_VISION_KEY "${LITELLM_KEY}")"+ case "$VLLM_TALK_VISION_URL_VALUE" in+ http://llama-server:*|http://ods-llama-server:*)+ VLLM_TALK_VISION_URL_VALUE="http://litellm:4000/v1"+ VLLM_TALK_VISION_KEY_VALUE="${LITELLM_KEY}"+ ;;+ esac+ fi+# Generate .env fileif [[ "${ENABLE_PIXEL_RUNTIME:-false}" == true ]]; then_phase06_pixel_runtime_layout || {@@ -1639,7 +1700,7 @@ LLM_API_URL=$(dotenv_value "${LLM_API_URL_VALUE}")OPEN_WEBUI_LLM_BASE_URL=$(dotenv_value "${OPEN_WEBUI_LLM_BASE_URL_VALUE}")OPEN_WEBUI_LLM_API_KEY=$(dotenv_value "${OPEN_WEBUI_LLM_API_KEY_VALUE}")OPEN_WEBUI_TASK_MODEL=$(dotenv_value "${OPEN_WEBUI_TASK_MODEL_VALUE}")-LLM_BACKEND=$(if [[ "$EXTERNAL_LLM_ACTIVE" == "true" ]]; then echo "external"; else echo "llama-server"; fi)+LLM_BACKEND=$(if [[ "$EXTERNAL_LLM_ACTIVE" == "true" ]]; then echo "external"; elif [[ "${LLM_BACKEND:-}" == "vllm" ]]; then echo "vllm"; else echo "llama-server"; fi)LLM_API_BASE_PATH=/v1EXTERNAL_LLM_URL=${EXTERNAL_LLM_URL_VALUE}EXTERNAL_LLM_CONTAINER_URL=${EXTERNAL_LLM_CONTAINER_URL_VALUE}@@ -1924,6 +1985,26 @@ fi)ENV_EOF)+ if [[ "${LLM_BACKEND:-}" == "vllm" ]]; then+ {+ printf '\n#=== vLLM engine (LLM_BACKEND=vllm, docker-compose.vllm.yml) ===\n'+ printf '# The vLLM catalog model the installer chose for one GPU, with that\n'+ printf "# entry's vLLM arguments. Installer reruns rewrite these lines.\n"+ printf 'VLLM_IMAGE=%s\n' "$(dotenv_value "$VLLM_IMAGE")"+ printf 'VLLM_MODEL_DIR=%s\n' "$(dotenv_value "$VLLM_MODEL_DIR")"+ printf 'VLLM_SERVED_MODEL=%s\n' "$(dotenv_value "$VLLM_SERVED_MODEL")"+ printf 'VLLM_ARGS=%s\n' "$(dotenv_value "${VLLM_ARGS:-}")"+ printf 'VLLM_GPU_UUID=%s\n' "$(dotenv_value "$VLLM_GPU_UUID")"+ if [[ -n "$VLLM_GPU_MEMORY_UTILIZATION_VALUE" ]]; then+ printf 'VLLM_GPU_MEMORY_UTILIZATION=%s\n' "$(dotenv_value "$VLLM_GPU_MEMORY_UTILIZATION_VALUE")"+ fi+ printf 'ODS_TALK_VISION_URL=%s\n' "$(dotenv_value "$VLLM_TALK_VISION_URL_VALUE")"+ printf 'ODS_TALK_VISION_KEY=%s\n' "$(dotenv_value "$VLLM_TALK_VISION_KEY_VALUE")"+ } >> "$INSTALL_DIR/.env"+ fi+ # Compose reads an LLM_BACKEND phase 02 exported ahead of .env; keep the+ # two equal (an API route writes external).+ [[ "$EXTERNAL_LLM_ACTIVE" != "true" ]] || LLM_BACKEND=externalchmod 600 "$INSTALL_DIR/.env" # Secure secrets fileif [[ -n "$_phase06_previous_env" ]]; then@@ -2020,12 +2101,17 @@ ENV_EOFif [[ "$NATIVE_LLM_ACTIVE" == "true" ]]; then_router_llm_base_url="$NATIVE_LLM_CONTAINER_BASE_URL_VALUE"fi+ # The vLLM engine's endpoint is vllm-default (http://vllm-server:8000);+ # every other route keeps the llama-server endpoint.+ _router_llm_backend=llama-server+ [[ "${LLM_BACKEND:-}" != "vllm" ]] || _router_llm_backend=vllm_router_common_args=(--switchboard-mode "${ODS_MODEL_SWITCHBOARD_VALUE:-enabled}"--ods-mode "$_router_ods_mode"--gpu-backend "${GPU_BACKEND:-nvidia}"--gguf-file "${GGUF_FILE:-}"--llm-base-url "$_router_llm_base_url"+ --llm-backend "$_router_llm_backend"--output-root "$INSTALL_DIR"--write)@@ -2033,6 +2119,9 @@ ENV_EOF# and the switchboard map name LLAMA_SERVER_API_KEY, as the host agent's# activation render does.[[ "$NATIVE_LLM_ACTIVE" != "true" ]] || _router_common_args+=(--llm-api-key-env LLAMA_SERVER_API_KEY)+ # The vllm-default endpoint carries the served model's thinking map, which+ # the renderer reads from the vLLM catalog entry --model names (LLM_MODEL).+ [[ "$_router_llm_backend" != "vllm" ]] || _router_common_args+=(--model "$LLM_MODEL")_router_surfaces=(model-router-endpoints)if [[ "$_router_ods_mode" != "cloud" ]]; then_router_surfaces+=(litellm-switchboard)@@ -2047,7 +2136,7 @@ ENV_EOFfidoneunset _router_renderer_py _router_surface _router_common_args- unset _router_ods_mode _router_surfaces _router_llm_base_url+ unset _router_ods_mode _router_surfaces _router_llm_base_url _router_llm_backend# Validate generated .env against schema (fails fast on missing/unknown keys)._phase06_step "validate-env"diff --git a/ods/installers/phases/08-images.sh b/ods/installers/phases/08-images.shindex 3c88b34e1..cd9f03c7a 100755--- a/ods/installers/phases/08-images.sh+++ b/ods/installers/phases/08-images.sh@@ -35,6 +35,22 @@ if [[ "${DRY_RUN:-false}" != true ]] && ods_native_llm_requested; thenfiunset _host_native_compose_flagsfi+if [[ "${DRY_RUN:-false}" != true && "${LLM_BACKEND:-}" == "vllm" ]]; then+ # Inherited profiles (COMPOSE_PROFILES=local-inference) could start the+ # in-stack llama-server beside the vLLM engine on the same GPU. Phase 11+ # rechecks before container launch.+ [[ -n "${COMPOSE_FLAGS:-}" ]] || {+ ai_bad "The vLLM engine's Compose selection is unavailable before image pulls."+ exit 1+ }+ read -ra _vllm_compose_flags <<< "$COMPOSE_FLAGS"+ if ! ods_vllm_assert_engine_stack_before_pixel_identity "${_vllm_compose_flags[@]}" \+ 2>>"$LOG_FILE"; then+ ai_bad "The vLLM engine's Compose stack is not the expected one (details in $LOG_FILE); clear COMPOSE_PROFILES and rerun the installer."+ exit 1+ fi+ unset _vllm_compose_flags+fiif [[ "${ODS_GATEWAY_ONLY:-false}" == true && "${DRY_RUN:-false}" != true ]]; then# Compose merges profile lists from overlays. A caller's inherited# COMPOSE_PROFILES=local-inference can therefore re-enable a managed model@@ -78,7 +94,12 @@ if [[ "${ODS_MODE:-local}" != "cloud" && -z "${EXTERNAL_LLM_URL:-}" ]] && ! ods_# In WSL the Linux capability probe can report CPU while Windows owns the# model, so selecting this image from GPU_BACKEND alone wastes time and# disk.- if [[ "$GPU_BACKEND" == "amd" ]]; then+ if [[ "${LLM_BACKEND:-}" == "vllm" ]]; then+ # The vLLM engine serves the model: no llama.cpp image (and no+ # bootstrap GGUF) runs on this route. Phase 02 read the pin from+ # config/dependency-lock.json.+ PULL_LIST+=("${VLLM_IMAGE}|VLLM — downloading the vLLM engine (NVIDIA)")+ elif [[ "$GPU_BACKEND" == "amd" ]]; then# The AMD overlays pin their images and ignore LLAMA_SERVER_IMAGE,# which a model profile can set to another backend's image.if [[ "${AMD_INFERENCE_BACKEND:-vulkan}" == "rocm" ]]; thendiff --git a/ods/installers/phases/11-services.sh b/ods/installers/phases/11-services.shindex 3c6326e9c..6e3f36b7f 100755--- a/ods/installers/phases/11-services.sh+++ b/ods/installers/phases/11-services.sh@@ -3,11 +3,12 @@# ODS Installer — Phase 11: Start Services# ============================================================================# Part of: installers/phases/-# Purpose: Download GGUF model, SDXL Lightning model, generate models.ini, launch-# Docker Compose stack+# Purpose: Download the GGUF model (or the vLLM engine's model snapshot),+# SDXL Lightning model, generate models.ini, launch Docker Compose stack## Expects: DRY_RUN, INSTALL_DIR, LOG_FILE, GPU_BACKEND,# GGUF_FILE, GGUF_URL, LLM_MODEL, MAX_CONTEXT,+# LLM_BACKEND (vllm: VLLM_MODEL_DIR, VLLM_SERVED_MODEL, LLM_MODEL_SIZE_MB),# DOCKER_COMPOSE_CMD, COMPOSE_FLAGS, BGRN, RED, AMB, NC,# show_phase(), bootline(), signal(), ai(), ai_ok(), ai_bad(),# ai_warn(), log(), spin_task(), ui_status_line()@@ -534,6 +535,89 @@ else[[ -n "$url" && -n "$model" && "${skip,,}" == "true" ]]}+ # The vLLM engine (vllm-server) serves the model instead of llama-server.+ _phase11_vllm_engine() {+ [[ "${LLM_BACKEND:-$(_phase11_env_get LLM_BACKEND "")}" == "vllm" ]]+ }++ # The llama-server container ids Compose still knows for this project, in+ # any state: the vLLM overlay keeps the service behind its local-inference+ # profile, where `up --remove-orphans` never removes it.+ _phase11_old_llama_containers() {+ $DOCKER_COMPOSE_CMD --profile local-inference "${COMPOSE_FLAGS_ARR[@]}" \+ ps -a -q llama-server 2>>"$LOG_FILE"+ }++ _phase11_old_llama_stuck() {+ ai_bad "The previous llama-server container could not be removed, and it would hold GPU memory the vLLM engine needs (details in $LOG_FILE)."+ ai "Remove it with: docker rm -f ods-llama-server, then run the same install command again. Its models stay in data/models."+ ai "Need help? Ask on the ODS Discord: ${ODS_HELP_DISCORD_URL:-https://discord.gg/4ntNp9MAwC}"+ exit 1+ }++ # spin_task's live status for the vLLM model download: the downloader's+ # latest "progress: N% x of y GB" line.+ _phase11_vllm_download_status() {+ awk '/^progress: / { line = substr($0, 11) } END { print (line == "" ? "checking files" : line) }' \+ "$ODS_VLLM_DOWNLOAD_LOG"+ }++ # The vLLM engine's model is a whole pinned Hugging Face snapshot: every+ # file goes to data/models/<VLLM_MODEL_DIR>/ and is verified against the+ # catalog by scripts/download-hf-manifest.py, which keeps verified files+ # and partial bytes when it stops, so another run resumes. A stop (exit 1)+ # resumes up to twice here; a checksum mismatch (3) or a full disk (4)+ # needs the owner and ends the install with what to do.+ _phase11_download_vllm_model() {+ local python_cmd="${ODS_PYTHON_CMD:-python3}" name size_gb attempt pid status=0 detail+ name="${VLLM_SERVED_MODEL:-$LLM_MODEL}"+ size_gb=$(( (${LLM_MODEL_SIZE_MB:-0} + 999) / 1000 ))+ ODS_VLLM_DOWNLOAD_LOG="$INSTALL_DIR/logs/vllm-model-download.log"+ mkdir -p "$INSTALL_DIR/logs"+ : >> "$ODS_VLLM_DOWNLOAD_LOG"+ ai "Getting ${name} for the vLLM engine (about ${size_gb} GB into data/models/${VLLM_MODEL_DIR}). Files already here are checked, not downloaded again."+ for attempt in 1 2 3; do+ printf '=== %s attempt %s of 3\n' "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" "$attempt" >> "$ODS_VLLM_DOWNLOAD_LOG"+ "$python_cmd" "$INSTALL_DIR/scripts/download-hf-manifest.py" \+ --catalog "$INSTALL_DIR/config/model-library.json" \+ --model-id "$LLM_MODEL" \+ --models-dir "$INSTALL_DIR/data/models" >> "$ODS_VLLM_DOWNLOAD_LOG" 2>&1 &+ pid=$!+ ODS_ACTIVE_DOWNLOAD_PID="$pid"+ status=0+ spin_task "$pid" "Downloading ${name}" "" 0 _phase11_vllm_download_status || status=$?+ ODS_ACTIVE_DOWNLOAD_PID=""+ if [[ "$status" -eq 0 ]]; then+ ui_status_line ok "Model downloaded and verified: ${name}"+ return 0+ fi+ [[ "$status" -eq 1 && "$attempt" -lt 3 ]] || break+ ai "The download paused (network or Hugging Face); resuming from the files kept so far (attempt $((attempt + 1)) of 3)."+ sleep "${ODS_VLLM_DOWNLOAD_RETRY_DELAY_SECONDS:-5}"+ done+ detail="$(awk '/^error: / { line = substr($0, 8) } END { print line }' "$ODS_VLLM_DOWNLOAD_LOG")"+ case "$status" in+ 1)+ ai_bad "The download of ${name} stopped before it finished${detail:+: $detail}"+ ai "Run the same install command again: it keeps the verified files and resumes. Details: $ODS_VLLM_DOWNLOAD_LOG"+ ;;+ 3)+ ai_bad "A downloaded file of ${name} did not match the catalog checksum, so it was deleted${detail:+: $detail}"+ ai "Run the same install command again to fetch that file again. Details: $ODS_VLLM_DOWNLOAD_LOG"+ ;;+ 4)+ ai_bad "There is not enough free disk space for ${name}${detail:+: $detail}"+ ai "Free up space on that disk, then run the same install command again (files already downloaded are kept). Or install with --llm-backend llama-server, which uses a smaller model."+ ;;+ *)+ ai_bad "The download of ${name} ended unexpectedly (exit ${status})${detail:+: $detail}"+ ai "Run the same install command again; files already verified are kept. Details: $ODS_VLLM_DOWNLOAD_LOG"+ ;;+ esac+ ai "Need help? Ask on the ODS Discord: ${ODS_HELP_DISCORD_URL:-https://discord.gg/4ntNp9MAwC}"+ return 1+ }+_phase11_close_inherited_fds_for_daemon() {local fd fd_dir fd_name@@ -1108,6 +1192,14 @@ elsefifi+ # The vLLM engine's model (GGUF_URL is empty on that route, so the block+ # above did nothing). vllm-server mounts the folder read-only, so it must+ # be complete before the stack starts.+ if _phase11_vllm_engine; then+ ods_progress 77 "services" "Downloading AI model"+ _phase11_download_vllm_model || exit 1+ fi+# ── SDXL Lightning model download (ComfyUI image generation) ──ods_progress 79 "services" "Checking image generation models"if [[ "$ENABLE_COMFYUI" != "true" ]]; then@@ -1205,10 +1297,12 @@ elsefifi- # Generate models.ini for llama-server (skip in cloud mode)+ # Generate models.ini for llama-server (skip in cloud mode, and where the+ # model runs outside the stack or in the vLLM engine)if [[ "${ODS_MODE:-local}" != "cloud" ]] \&& ! _phase11_host_native_llm \- && ! _phase11_external_llm; then+ && ! _phase11_external_llm \+ && ! _phase11_vllm_engine; thenmkdir -p "$INSTALL_DIR/config/llama-server"cat > "$INSTALL_DIR/config/llama-server/models.ini" << MODELS_INI_EOF[${LLM_MODEL}]@@ -1415,6 +1509,29 @@ MODELS_INI_EOFexit 1fi+ if _phase11_vllm_engine &&+ ! ods_vllm_assert_engine_stack "${COMPOSE_FLAGS_ARR[@]}" 2>>"$LOG_FILE"; then+ ai_bad "The vLLM engine's Compose stack is not the expected one (details in $LOG_FILE); clear COMPOSE_PROFILES and rerun the installer."+ exit 1+ fi++ if _phase11_vllm_engine; then+ # A rerun that moves a llama.cpp installation to the vLLM engine leaves+ # the old llama-server container, which would hold GPU memory vLLM+ # needs: stop and remove it before the launch.+ _vllm_old_llama="$(_phase11_old_llama_containers)" || _phase11_old_llama_stuck+ if [[ -n "$_vllm_old_llama" ]]; then+ if ! $DOCKER_COMPOSE_CMD --profile local-inference "${COMPOSE_FLAGS_ARR[@]}" \+ rm --stop --force llama-server >>"$LOG_FILE" 2>&1; then+ _phase11_old_llama_stuck+ fi+ _vllm_old_llama="$(_phase11_old_llama_containers)" || _phase11_old_llama_stuck+ [[ -z "$_vllm_old_llama" ]] || _phase11_old_llama_stuck+ ai_ok "Removed the previous llama-server container; its models stay in data/models"+ fi+ unset _vllm_old_llama+ fi+if [[ "${ENABLE_OPEN_WEBUI:-true}" != true ]] &&! ods_compose_assert_no_webui "${COMPOSE_FLAGS_ARR[@]}" 2>>"$LOG_FILE"; thenai_bad "No-WebUI Compose could start Open WebUI; inspect $LOG_FILE and clear COMPOSE_PROFILES."@@ -1631,6 +1748,8 @@ MODELS_INI_EOFecho ""if [[ -n "${EXTERNAL_LLM_URL:-}" ]]; thenai_ok "Services started (external model through LiteLLM)"+ elif _phase11_vllm_engine; then+ ai_ok "Services started (vLLM engine; it loads the model next)"elseai_ok "Services started (llama-server)"fidiff --git a/ods/installers/phases/12-health.sh b/ods/installers/phases/12-health.shindex cbd65dd2a..0738ff3d0 100755--- a/ods/installers/phases/12-health.sh+++ b/ods/installers/phases/12-health.sh@@ -8,6 +8,7 @@## Expects: DRY_RUN, GPU_BACKEND, ENABLE_VOICE, ENABLE_WORKFLOWS, ENABLE_RAG, ENABLE_QDRANT,# ENABLE_EMBEDDINGS, ENABLE_HERMES, LLM_MODEL,+# LLM_BACKEND and VLLM_SERVED_MODEL (vllm waits on vllm-server),# LOG_FILE, BGRN, AMB, NC,# WHISPER_PORT, TTS_PORT,# PERPLEXICA_PORT (:-3004), COMFYUI_PORT (:-8188),@@ -51,6 +52,8 @@ if $DRY_RUN; thenlog "[DRY RUN] Would verify service health:"if [[ -n "${EXTERNAL_LLM_URL:-}" ]]; thenlog "[DRY RUN] - External model through LiteLLM"+ elif [[ "${LLM_BACKEND:-}" == "vllm" ]]; then+ log "[DRY RUN] - vLLM engine (${VLLM_SERVED_MODEL:-the vLLM model}) and its route through model-router"elselog "[DRY RUN] - Managed llama-server"fi@@ -353,6 +356,174 @@ else:ai "A completed user-visible answer still requires a real Pixel turn."}+# The vLLM engine (LLM_BACKEND=vllm) runs in ods-vllm-server, which has no+# host port. Its compose healthcheck turns healthy once vLLM's /health answers+# 200; a first start reads 130-200 GB of weights and compiles kernels, so the+# wait allows as long as the healthcheck's start period (an hour).+_phase12_vllm_engine() {+ [[ "${LLM_BACKEND:-$(_phase12_env_get LLM_BACKEND "")}" == "vllm" ]]+}++# A vLLM failure ends the install with its cause, what to do next and where+# to ask. vLLM's own log is saved to the install log first.+_phase12_vllm_stop() {+ local cause="$1" recovery="$2"+ local -a docker_cmd_arr=()+ read -r -a docker_cmd_arr <<< "${DOCKER_CMD:-docker}"+ {+ printf '=== docker logs --tail 200 ods-vllm-server\n'+ "${docker_cmd_arr[@]}" logs --tail 200 ods-vllm-server 2>&1 \+ || printf '(the vLLM container log is unavailable)\n'+ } >> "$LOG_FILE"+ ai_bad "$cause"+ ai "$recovery"+ ai "Need help? Ask on the ODS Discord: ${ODS_HELP_DISCORD_URL:-https://discord.gg/4ntNp9MAwC}"+ exit 1+}++# Run in the background under spin_task: returns 0 once vllm-server is+# healthy, 1 when the engine stopped (why goes to REASON_FILE), 2 when the+# wait ran out. A restart counts only when it happens during this wait.+_phase12_poll_vllm_health() {+ local reason_file="$1" interval="${ODS_VLLM_POLL_SECONDS:-10}"+ local deadline=$((SECONDS + ${ODS_VLLM_READY_TIMEOUT_SECONDS:-3600}))+ local state restarts health first_restarts=""+ local -a docker_cmd_arr=()+ read -r -a docker_cmd_arr <<< "${DOCKER_CMD:-docker}"+ while (( SECONDS < deadline )); do+ if ! read -r state restarts health < <("${docker_cmd_arr[@]}" inspect \+ --format '{{.State.Status}} {{.RestartCount}} {{if .State.Health}}{{.State.Health.Status}}{{else}}none{{end}}' \+ ods-vllm-server 2>>"$LOG_FILE"); then+ state=missing restarts=0 health=none+ fi+ [[ "$restarts" =~ ^[0-9]+$ ]] || restarts=0+ [[ -n "$first_restarts" ]] || first_restarts="$restarts"+ if [[ "$health" == "healthy" ]]; then+ return 0+ fi+ case "$state" in+ exited|dead|missing)+ printf 'The vLLM container stopped before the model was ready (container %s)' "$state" > "$reason_file"+ return 1+ ;;+ esac+ if (( restarts > first_restarts )); then+ printf 'vLLM stopped while loading the model, and Docker restarted it' > "$reason_file"+ return 1+ fi+ if [[ "$health" == "unhealthy" ]]; then+ printf "vLLM's health check failed" > "$reason_file"+ return 1+ fi+ sleep "$interval"+ done+ return 2+}++_phase12_vllm_wait_status() {+ printf 'a first start reads the weights and compiles kernels'+}++_phase12_wait_for_vllm() {+ local model="${VLLM_SERVED_MODEL:-the vLLM model}" limit="${ODS_VLLM_READY_TIMEOUT_SECONDS:-3600}"+ local reason_file pid rc=0 reason+ reason_file="$(mktemp "${TMPDIR:-/tmp}/ods-vllm-wait.XXXXXX")"+ ai "vLLM is loading ${model}. A first start reads the whole model into GPU memory and compiles kernels before it answers; later starts are faster."+ _phase12_poll_vllm_health "$reason_file" &+ pid=$!+ spin_task "$pid" "Loading ${model} into GPU memory" "" 0 _phase12_vllm_wait_status || rc=$?+ reason="$(cat "$reason_file")"+ rm -f -- "$reason_file"+ case "$rc" in+ 0)+ ui_status_line ok "vLLM engine ready (${model})"+ ;;+ 2)+ _phase12_vllm_stop "vLLM did not finish loading ${model} within $((limit / 60)) minutes." \+ "See what it is doing with: docker logs --tail 100 ods-vllm-server. Once it reports the model loaded, run the same install command again; the downloaded model is kept."+ ;;+ *)+ _phase12_vllm_stop "${reason:-vLLM stopped before ${model} was ready}." \+ "vLLM's log says why (docker logs --tail 100 ods-vllm-server; also saved to ${LOG_FILE}). Fix that, for example by freeing the GPU's memory, then run the same install command again; the downloaded model is kept."+ ;;+ esac+}++# True when the chat completion in FILE carries text (an answer, or reasoning+# a short reply can stop in).+_phase12_completion_has_text() {+ "${ODS_PYTHON_CMD:-python3}" -c '+import json+import sys++try:+ with open(sys.argv[1], encoding="utf-8") as handle:+ body = json.load(handle)+except (OSError, ValueError):+ sys.exit(1)+choices = body.get("choices") if isinstance(body, dict) else None+first = choices[0] if isinstance(choices, list) and choices else None+message = first.get("message") if isinstance(first, dict) else None+texts = [message.get(key) for key in ("content", "reasoning_content", "reasoning")] if isinstance(message, dict) else []+sys.exit(0 if any(isinstance(text, str) and text.strip() for text in texts) else 1)+' "$1"+}++# Run in the background under spin_task: asks ods/current for a short answer+# through LiteLLM, which sends it to model-router, which routes it to the vLLM+# engine, the path every ODS service uses. Returns 0 once an answer has text,+# 2 when the wait ran out; the last HTTP status goes to STATUS_FILE and the+# last reply to the install log.+_phase12_poll_vllm_route() {+ local status_file="$1" interval="${ODS_VLLM_POLL_SECONDS:-10}"+ local deadline=$((SECONDS + ${ODS_VLLM_ROUTE_TIMEOUT_SECONDS:-900}))+ local port="${SERVICE_PORTS[litellm]:-4000}" key="${LITELLM_KEY:-$(_phase12_env_get LITELLM_KEY "")}"+ local body='{"model":"ods/current","messages":[{"role":"user","content":"Reply with exactly OK."}],"max_tokens":64,"temperature":0,"stream":false,"chat_template_kwargs":{"enable_thinking":false}}'+ local response_file http_status="000"+ response_file="$(mktemp "${TMPDIR:-/tmp}/ods-vllm-route.XXXXXX")"+ while (( SECONDS < deadline )); do+ if ! http_status="$(_phase12_curl_bearer "$key" -sS --max-time 120 -o "$response_file" -w '%{http_code}' \+ -X POST "http://127.0.0.1:${port}/v1/chat/completions" \+ -H "Content-Type: application/json" -d "$body" 2>>"$LOG_FILE")"; then+ http_status="000"+ fi+ printf '%s' "$http_status" > "$status_file"+ if [[ "$http_status" == 2?? ]] && _phase12_completion_has_text "$response_file"; then+ rm -f -- "$response_file"+ return 0+ fi+ sleep "$interval"+ done+ {+ printf 'vLLM model route check, last reply (HTTP %s):\n' "$http_status"+ head -c 4096 "$response_file"+ printf '\n'+ } >> "$LOG_FILE"+ rm -f -- "$response_file"+ return 2+}++_phase12_vllm_route_status() {+ printf 'waiting for the model route'+}++_phase12_verify_vllm_route() {+ local model="${VLLM_SERVED_MODEL:-the vLLM model}" limit="${ODS_VLLM_ROUTE_TIMEOUT_SECONDS:-900}"+ local status_file pid rc=0 http_status+ status_file="$(mktemp "${TMPDIR:-/tmp}/ods-vllm-route-status.XXXXXX")"+ _phase12_poll_vllm_route "$status_file" &+ pid=$!+ spin_task "$pid" "Asking ${model} for a first answer through model-router" "" 0 _phase12_vllm_route_status || rc=$?+ http_status="$(cat "$status_file")"+ rm -f -- "$status_file"+ if [[ "$rc" -eq 0 ]]; then+ ui_status_line ok "Model route verified: ods/current answers through model-router (vLLM)"+ return 0+ fi+ _phase12_vllm_stop "vLLM is running, but ${model} did not answer through LiteLLM and model-router within $((limit / 60)) minutes (last HTTP status ${http_status:-none})." \+ "The ODS host agent proves the vLLM route once the engine is up. Check ods status, then run the same install command again; the model stays downloaded. The last reply is saved to ${LOG_FILE}."+}+# Core service health checks with adaptive timeouts.# Cloud mode does not launch local llama-server; LiteLLM/external APIs are the# LLM surface, so do not wait on a container that intentionally is not running.@@ -370,6 +541,13 @@ elif [[ "${ODS_MODE:-local}" == "cloud" ]] || _phase12_host_native_llm; thenexit 1fifi+elif _phase12_vllm_engine; then+ # No llama-server runs here: wait for the vLLM engine, then for an answer+ # through model-router, the route every consumer uses.+ ods_progress 86 "health" "Waiting for the vLLM engine"+ _phase12_wait_for_vllm+ ods_progress 87 "health" "Verifying the model route"+ _phase12_verify_vllm_routeelse# Format: _check_health "name" "url" max_attempts timeout_per_request# llama-server: 150 attempts * adaptive backoff (2s->8s) = up to ~20 minutes (model loading can be slow)@@ -430,6 +608,8 @@ fi# llama-server doesn't hang phase 12.if [[ "${ODS_MODE:-local}" == "cloud" ]] || _phase12_host_native_llm || _phase12_external_llm; thenai "The LLM runs outside the stack - skipping local llama-server pre-warm"+elif _phase12_vllm_engine; then+ log "The vLLM engine already answered the model route check; there is no llama-server to pre-warm"elseods_progress 87 "health" "Pre-warming LLM slot"# llama-server serves the GGUF file name (--alias) under /v1 on every GPU.diff --git a/ods/installers/phases/13-summary.sh b/ods/installers/phases/13-summary.shindex 2edb1377f..85edbaa09 100755--- a/ods/installers/phases/13-summary.sh+++ b/ods/installers/phases/13-summary.sh@@ -13,7 +13,8 @@# COMPOSE_FLAGS, SUMMARY_JSON_FILE, PREFLIGHT_REPORT_FILE,# BGRN, GRN, AMB, WHT, NC, DASHBOARD_PORT (:-3001),# CAP_HARDWARE_CLASS_ID (:-unknown), CAP_HARDWARE_CLASS_LABEL (:-Unknown),-# BACKEND_SERVICE_NAME (:-llama-server),+# BACKEND_SERVICE_NAME (:-llama-server), LLM_BACKEND (vllm names the+# vLLM engine, VLLM_GPU_UUID and VLLM_SERVED_MODEL),# SDXL_CHECKPOINT_DIR, SDXL_MODEL (set by phase 11 when ComfyUI is enabled),# show_success_card(), bootline(), signal(), ai_ok(), log()# Provides: Desktop shortcut, sidebar pin, summary JSON@@ -217,6 +218,8 @@ bootlineecho " • Dashboard: http://localhost:${SERVICE_PORTS[dashboard]:-3001}"if [[ -n "${EXTERNAL_LLM_URL:-}" || "${ODS_MODE:-local}" == "cloud" || -n "${NATIVE_LLM_BASE_URL:-}" ]]; thenecho " • LLM API: http://localhost:${SERVICE_PORTS[litellm]:-4000}/v1 (managed LiteLLM gateway)"+elif [[ "${LLM_BACKEND:-}" == "vllm" ]]; then+ echo " • LLM API: http://localhost:${SERVICE_PORTS[litellm]:-4000}/v1 (LiteLLM gateway to the vLLM engine)"elseecho " • LLM API: http://localhost:${SERVICE_PORTS[llama-server]:-11434}/v1 (llama-server)"fi@@ -244,6 +247,9 @@ bootlineecho " • Tier: $TIER ($TIER_NAME)"if [[ "${ODS_GATEWAY_ONLY:-false}" == true ]]; thenecho " • External model: ${EXTERNAL_LLM_MODEL:-unknown}"+elif [[ "${LLM_BACKEND:-}" == "vllm" ]]; then+ echo " • Engine: vLLM on GPU ${VLLM_GPU_UUID:-unknown}"+ echo " • Model: ${VLLM_SERVED_MODEL:-$LLM_MODEL} (${LLM_MODEL}, ${MAX_CONTEXT:-?} tokens of context)"elseecho " • Model: $LLM_MODEL"fi@@ -549,7 +555,10 @@ if [[ -n "$SUMMARY_JSON_FILE" ]]; thenPYTHON_CMD="python"fi- "$PYTHON_CMD" - "$SUMMARY_JSON_FILE" "$VERSION" "$INSTALL_DIR" "$TIER" "$TIER_NAME" "$GPU_BACKEND" "${BACKEND_SERVICE_NAME:-llama-server}" "$LLM_MODEL" "$COMPOSE_FLAGS" "$DRY_RUN" "$PREFLIGHT_REPORT_FILE" "${CAP_HARDWARE_CLASS_ID:-unknown}" "${CAP_HARDWARE_CLASS_LABEL:-Unknown}" "${PIXEL_AGENT_MODE:-hermes}" <<'PY'+ # The model server's compose service: vllm-server for the vLLM engine.+ _summary_backend_service="${BACKEND_SERVICE_NAME:-llama-server}"+ [[ "${LLM_BACKEND:-}" != "vllm" ]] || _summary_backend_service=vllm-server+ "$PYTHON_CMD" - "$SUMMARY_JSON_FILE" "$VERSION" "$INSTALL_DIR" "$TIER" "$TIER_NAME" "$GPU_BACKEND" "$_summary_backend_service" "$LLM_MODEL" "$COMPOSE_FLAGS" "$DRY_RUN" "$PREFLIGHT_REPORT_FILE" "${CAP_HARDWARE_CLASS_ID:-unknown}" "${CAP_HARDWARE_CLASS_LABEL:-Unknown}" "${PIXEL_AGENT_MODE:-hermes}" <<'PY'import jsonimport osimport pathlibdiff --git a/ods/lib/safe-env.sh b/ods/lib/safe-env.shindex 85916563a..229be987c 100755--- a/ods/lib/safe-env.sh+++ b/ods/lib/safe-env.sh@@ -148,8 +148,12 @@ load_env_from_output_allowlist() {}# Model contracts from scripts/select-model.py and scripts/preserve-active-model.py.-# Only the preserved contract of the same active model carries the last three-# keys (its vision projector and fixed chat template; model activation owns them).+# Only the preserved contract of the same active model carries its vision+# projector and fixed chat template (LLAMA_ARG_MMPROJ through+# LLAMA_ARG_CHAT_TEMPLATE_FILE; model activation owns them). Only a vLLM pick+# (select-model.py --llm-runtime vllm) and a vLLM installation's preserved+# contract carry the VLLM_* keys; only that contract carries LLM_BACKEND+# (always vllm) and VLLM_GPU_MEMORY_UTILIZATION.load_model_selector_env_from_output() {load_env_from_output_allowlist \LLM_MODEL \@@ -189,5 +193,11 @@ load_model_selector_env_from_output() {LLAMA_ARG_TENSOR_SPLIT \LLAMA_ARG_MMPROJ \MODEL_CHAT_TEMPLATE_OVERRIDE \- LLAMA_ARG_CHAT_TEMPLATE_FILE+ LLAMA_ARG_CHAT_TEMPLATE_FILE \+ LLM_BACKEND \+ VLLM_MODEL_DIR \+ VLLM_SERVED_MODEL \+ VLLM_ARGS \+ VLLM_GPU_UUID \+ VLLM_GPU_MEMORY_UTILIZATION}diff --git a/ods/scripts/assign_gpus.py b/ods/scripts/assign_gpus.pyindex 009e391f8..d5af5ef7a 100644--- a/ods/scripts/assign_gpus.py+++ b/ods/scripts/assign_gpus.py@@ -5,6 +5,12 @@ assign_gpus.py — GPU assignment algorithm for ODSUsage:python3 assign_gpus.py --topology topo.json --model-size 70000python3 assign_gpus.py --topology topo.json --model-size 70000 --enabled-services llama_server,whisper+ python3 assign_gpus.py --topology topo.json --model-size 132735 --pin-llm-gpu GPU-<uuid>++--pin-llm-gpu gives the LLM role (llama_server) exactly that GPU, as the vLLM+engine needs: its model selector already sized the model for that one GPU, and+a model that fits one GPU is never split across GPUs. The other services take+the remaining GPUs.Output: gpu_assignment JSON to stdoutErrors: to stderr, exit code 1@@ -221,7 +227,20 @@ def span_subsets(all_gpus: list, rank_matrix: dict, model_size_mb: float, ordere)-def assign_services(all_gpus: list, llama_gpus: list, rank_matrix: dict, enabled_services: list, model_size_mb: float, vendor: str = "nvidia") -> tuple:+def pinned_llama_subset(gpus: list, rank_matrix: dict, uuid: str) -> Subset:+ """The LLM role on exactly the GPU ``uuid`` names (``--pin-llm-gpu``).++ The vLLM model selector already checked that the model fits this GPU's+ total memory, and vLLM claims its share of that memory at start, so the+ free-VRAM fit used for llama.cpp splits does not apply.+ """+ pinned = [g for g in gpus if g.uuid == uuid]+ if len(pinned) != 1:+ raise ValueError(f"--pin-llm-gpu {uuid} names {len(pinned)} GPUs in the topology, not one")+ return compute_subset(pinned, rank_matrix)+++def assign_services(all_gpus: list, llama_gpus: list, rank_matrix: dict, enabled_services: list, model_size_mb: float, vendor: str = "nvidia", grow_llama: bool = True) -> tuple:"""Assign remaining GPUs to non-llama services.Returns (service_assignments dict, final_llama_gpus list, strategy str).@@ -232,6 +251,7 @@ def assign_services(all_gpus: list, llama_gpus: list, rank_matrix: dict, enabledremaining == 2 → whisper → [0], comfyui+embeddings → [1] → colocatedremaining >= 3 → whisper → [0], comfyui → [1], emb → [2] → dedicatedremaining[3:] → back to llama if the expanded group fits+ (never with grow_llama=False, a pinned LLM GPU)AMD APU+dGPU hybrid: if mixed memory types (unified + discrete), prefer APUGPUs for auxiliary services (lower bandwidth but sufficient for whisper/embeddings).@@ -284,7 +304,7 @@ def assign_services(all_gpus: list, llama_gpus: list, rank_matrix: dict, enabledif "embeddings" in enabled_services:assignments["embeddings"] = ServiceAssignment(gpus=[remaining[2]])# Return spare devices only when the expanded LLM group still fits.- if len(remaining) > 3:+ if grow_llama and len(remaining) > 3:expanded = compute_subset(final_llama_gpus + remaining[3:], rank_matrix)# Adding a mostly occupied device can make an equal layer split fail# even though the originally selected LLM group comfortably fits.@@ -450,6 +470,9 @@ def main():parser.add_argument("--model-size", required=True, type=float, help="Model size in MB")parser.add_argument("--enabled-services", default=",".join(DEFAULT_SERVICES),help="Comma-separated list of enabled services")+ parser.add_argument("--pin-llm-gpu", default="", metavar="UUID",+ help="Give the LLM role exactly this GPU (the vLLM engine's VLLM_GPU_UUID); "+ "the other services take the remaining GPUs")args = parser.parse_args()# Load topology@@ -475,6 +498,24 @@ def main():print("ERROR: no GPUs found in topology", file=sys.stderr)sys.exit(1)+ # Pinned LLM GPU (the vLLM engine): no subset search, no split+ if args.pin_llm_gpu:+ gpus = parse_gpus(topology)+ rank_matrix = build_rank_matrix(parse_links(topology))+ try:+ llama_subset = pinned_llama_subset(gpus, rank_matrix, args.pin_llm_gpu)+ except ValueError as e:+ print(f"ERROR: {e}", file=sys.stderr)+ sys.exit(1)+ service_assignments, _, strategy = assign_services(+ gpus, llama_subset.gpus, rank_matrix, enabled_services, model_size_mb,+ vendor=topology.get("vendor", "nvidia"), grow_llama=False,+ )+ service_assignments["llama_server"].parallelism = select_parallelism(llama_subset)+ result = AssignmentResult(strategy="single" if gpu_count == 1 else strategy, services=service_assignments)+ print(json.dumps(build_output(result), indent=2))+ return+# Early exit: single GPUif gpu_count == 1:gpu = parse_gpus(topology)[0]diff --git a/ods/tests/ci-suite.txt b/ods/tests/ci-suite.txtindex 9c8c9f3a6..423c885fd 100644--- a/ods/tests/ci-suite.txt+++ b/ods/tests/ci-suite.txt@@ -63,6 +63,8 @@ tests/test-comfyui-user-dir-persisted.shtests/test-comfyui-cuda-cache-persisted.shtests/test-llama-cuda-cache-persisted.shtests/test-vllm-engine-service.sh+tests/test-vllm-installer-route.sh+tests/test-vllm-installer-phases.shtests/test-cli-vllm-engine.shtests/test-doctor-vllm-engine.shtests/test_comfyui_extension_contract.pydiff --git a/ods/tests/lib/phase06-env-harness.sh b/ods/tests/lib/phase06-env-harness.shnew file mode 100644index 000000000..38f352961--- /dev/null+++ b/ods/tests/lib/phase06-env-harness.sh@@ -0,0 +1,95 @@+#!/usr/bin/env bash+# ============================================================================+# ODS Tests -- render phase 06's .env without installing anything+# ============================================================================+# ods_phase06_render_env PHASE06 ODS_ROOT INSTALL_DIR FIXTURE+#+# Runs PHASE06's .env generation, from its "generate-env" step through the+# lines after the template (up to the chmod), in a fresh bash. The shipped+# helper libraries come from ODS_ROOT; host probes are stubbed (no Docker,+# fixed secrets, clock, host name, CPUs and IDs), so two phase 06 versions+# given the same FIXTURE write comparable bytes. FIXTURE is a file of shell+# assignments describing the route (GPU_BACKEND, TIER, LLM_MODEL, ...). An+# existing INSTALL_DIR/.env is read as the installation's previous values.+# Leaves INSTALL_DIR/.env and, in INSTALL_DIR/exported-llm-backend, the+# LLM_BACKEND it exports to later phases; stderr goes to+# INSTALL_DIR/render.err. Returns the render's status.+# ============================================================================++ods_phase06_render_env() {+ local phase06="$1" root="$2" install_dir="$3" fixture="$4" script+ local segment readers secrets+ segment="$(awk '+ /^ # ── \.env merge logic: preserve user-configured values on re-install ──$/ { emit = 1 }+ /^ chmod 600 "\$INSTALL_DIR\/\.env" # Secure secrets file$/ { exit }+ emit { print }+ ' "$phase06")"+ readers="$(awk '+ /^ _env_get\(\) \{$/ { emit = 1 }+ emit { print }+ emit && /^ _env_get_explicit_first\(\) \{$/ { last = 1 }+ last && /^ }$/ { exit }+ ' "$phase06")"+ secrets="$(awk '+ /^_phase06_generate_hex_secret\(\) \{$/ || /^_phase06_env_hex_secret\(\) \{$/ { emit = 1 }+ emit { print }+ emit && /^}$/ { emit = 0 }+ ' "$phase06")"+ [[ -n "$segment" && -n "$readers" && -n "$secrets" ]] || {+ printf 'phase 06 .env generation not found in %s\n' "$phase06" >&2+ return 2+ }+ mkdir -p "$install_dir/config/litellm"+ script="$install_dir/render.sh"+ {+ printf '%s\n' 'set -euo pipefail'+ printf 'SCRIPT_DIR=%q\nINSTALL_DIR=%q\nLOG_FILE=%q\n' "$root" "$install_dir" "$install_dir/render.log"+ cat <<'PRELUDE'+for _lib in lib/safe-env.sh lib/dotenv-quote.sh installers/lib/native-llm.sh installers/lib/amd-runtime.sh \+ installers/lib/tier-map.sh installers/lib/llama-memory-budget.sh installers/lib/external-services.sh; do+ # shellcheck source=/dev/null+ source "$SCRIPT_DIR/$_lib"+done+unset _lib+ods_progress() { :; }+_phase06_step() { :; }+log() { :; }+ai() { :; }+ai_ok() { :; }+ai_warn() { printf 'WARN %s\n' "$*" >&2; }+warn() { printf 'WARN %s\n' "$*" >&2; }+error() { printf 'ERROR %s\n' "$*" >&2; exit 1; }+# Never reach a Docker daemon from a test.+docker() { printf 'the .env harness must not run docker\n' >&2; exit 97; }+ods_docker_memory_gb() { return 1; }+calculate_llama_cpu_budget() { printf '16 2 32\n'; }+ods_physical_cpu_cores() { printf '16\n'; }+openssl() {+ case "$2" in+ -hex) printf '%0*d\n' "$(($3 * 2))" 7 ;;+ *) printf 'Zml4ZWQtc2VjcmV0LXZhbHVl\n' ;;+ esac+}+date() { printf '2026-10-27T00:00:00Z\n'; }+hostname() { printf 'ods-fixture\n'; }+id() { printf '1000\n'; }+_phase06_compose_uid=1000+_phase06_compose_gid=1000+VERSION=3.0.0-fixture+TIER_NAME=Fixture+SYSTEM_TZ=UTC+ENABLE_PIXEL_RUNTIME=false+_env_existing=""+[[ -f "$INSTALL_DIR/.env" ]] && _env_existing="$INSTALL_DIR/.env"+PRELUDE+ printf '%s\n' "$secrets" "$readers"+ cat "$fixture"+ printf '%s\n' "$segment"+ # The previous .env snapshot is carried after the chmod, outside this render.+ printf '%s\n' '[[ -z "${_phase06_previous_env:-}" ]] || rm -f -- "$_phase06_previous_env"'+ # What later phases (and Compose) see exported.+ # shellcheck disable=SC2016 # expanded by the render script+ printf '%s\n' 'bash -c '\''printf "%s\n" "${LLM_BACKEND:-<unset>}"'\'' > "$INSTALL_DIR/exported-llm-backend"'+ } > "$script"+ bash "$script" 2>"$install_dir/render.err"+}diff --git a/ods/tests/test-assign-gpus.py b/ods/tests/test-assign-gpus.pyindex 7972f0b7c..b99bab081 100755--- a/ods/tests/test-assign-gpus.py+++ b/ods/tests/test-assign-gpus.py@@ -652,3 +652,74 @@ class TestParallelismModeSelection:def test_mem_util_pipeline_is_095(self):_, out, _ = run(fixture_path("nvidia_smi_topo_matrix_4gpus_soc.json"), 100000)assert parallelism(out)["gpu_memory_utilization"] == 0.95+++# ── --pin-llm-gpu: the vLLM engine owns exactly one GPU ───────────────────────++def run_pinned(topology_path, model_size_mb, uuid):+ cmd = [sys.executable, SCRIPT, "--topology", str(topology_path),+ "--model-size", str(model_size_mb), "--pin-llm-gpu", uuid]+ result = subprocess.run(cmd, capture_output=True, text=True, timeout=10)+ output = json.loads(result.stdout)["gpu_assignment"] if result.returncode == 0 else None+ return result.returncode, output, result.stderr+++class TestPinnedLlmGpu:+ GB300 = "GPU-aaaaaaaa-gb300"+ RTX = "GPU-bbbbbbbb-rtx6000"++ def dgx_station(self, tmp_path):+ """GB300 (sm_103) beside an RTX PRO 6000 on PCIe, as on a DGX Station."""+ topology = tmp_path / "dgx-station.json"+ topology.write_text(json.dumps({+ "vendor": "nvidia", "gpu_count": 2,+ "gpus": [+ {"index": 0, "uuid": self.GB300, "name": "NVIDIA GB300", "memory_gb": 250.7, "memory_free_gb": 250.0},+ {"index": 1, "uuid": self.RTX, "name": "NVIDIA RTX PRO 6000", "memory_gb": 95.6, "memory_free_gb": 95.0},+ ],+ "links": [{"gpu_a": 0, "gpu_b": 1, "link_type": "SYS", "link_label": "SYS", "rank": 10}],+ }))+ return topology++ def test_llm_gets_exactly_the_pinned_gpu_and_services_the_other(self, tmp_path):+ code, out, err = run_pinned(self.dgx_station(tmp_path), 132735, self.GB300)+ assert code == 0, err+ assert llama(out)["gpus"] == [self.GB300]+ for service in ("whisper", "comfyui", "embeddings"):+ assert out["services"][service]["gpus"] == [self.RTX]+ p = parallelism(out)+ assert (p["mode"], p["tensor_parallel_size"], p["pipeline_parallel_size"]) == ("none", 1, 1)+ assert "tensor_split" not in p++ def test_without_the_pin_the_same_model_spans_both_gpus(self, tmp_path):+ # The case the pin exists for: the llama.cpp search splits a model+ # that fits the GB300 alone across both mismatched GPUs.+ code, out, err = run(str(self.dgx_station(tmp_path)), 132735)+ assert code == 0, err+ assert len(llama(out)["gpus"]) == 2++ def test_spare_gpus_never_join_the_pinned_gpu(self):+ topology = fixture_path("nvidia_smi_topo_matrix_5gpus_nv12_with_mlx5.json")+ pinned = "GPU-22222222-2222-2222-2222-222222222222"+ code, out, err = run_pinned(topology, 300000, pinned)+ assert code == 0, err+ assert llama(out)["gpus"] == [pinned]+ assert parallelism(out)["mode"] == "none"+ others = {out["services"][s]["gpus"][0] for s in ("whisper", "comfyui", "embeddings")}+ assert pinned not in others and len(others) == 3+ assert out["strategy"] == "dedicated"++ def test_single_gpu_uses_the_vllm_selectors_sizing(self):+ topology = fixture_path("nvidia_smi_topo_matrix_1gpu_pcie.json")+ uuid = TestSingleGpu.UUID+ # The selector sized the model against total memory; free VRAM does not apply.+ code, out, err = run_pinned(topology, 10**7, uuid)+ assert code == 0, err+ assert out["strategy"] == "single"+ assert all(service["gpus"] == [uuid] for service in out["services"].values())+ assert parallelism(out)["mode"] == "none"++ def test_unknown_gpu_is_refused(self, tmp_path):+ code, out, err = run_pinned(self.dgx_station(tmp_path), 132735, "GPU-not-here")+ assert code == 1 and out is None+ assert "--pin-llm-gpu GPU-not-here names 0 GPUs in the topology" in errdiff --git a/ods/tests/test-vllm-installer-phases.sh b/ods/tests/test-vllm-installer-phases.shnew file mode 100644index 000000000..410971f5a--- /dev/null+++ b/ods/tests/test-vllm-installer-phases.sh@@ -0,0 +1,827 @@+#!/usr/bin/env bash+# The Linux installer's phases on the vLLM route (LLM_BACKEND=vllm), each run+# from the shipped phase code with no Docker daemon, GPU or network:+#+# 03 the LLM role is exactly VLLM_GPU_UUID; whisper, ComfyUI and+# embeddings take the other GPUs; no split, no tensor split;+# 06 .env carries LLM_BACKEND=vllm and the VLLM_* keys, every URL that+# named llama-server goes through LiteLLM or model-router as on the+# host-native route, the switchboard is on, the model-router endpoint+# is vllm-default rendered for LLM_MODEL, and every other route writes+# no vLLM line;+# 08 the vLLM image is pulled instead of llama.cpp's; the stack check+# refuses a stack without vllm-server or with llama-server;+# 11 the model download's progress and every downloader exit code, and a+# rerun that moves to vLLM removes the old llama-server container;+# 12 the wait for vllm-server and the answer through model-router, with+# calm progress and a cause, a next step and the Discord link on failure;+# 13 the summary names the engine and the model;+# pixel Pixel binds vLLM's served id and the catalog's thinking default.+set -euo pipefail++ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"+PHASES="$ROOT_DIR/installers/phases"+PYTHON_CMD="${ODS_PYTHON_CMD:-python3}"+PASS=0+fail() { printf '[FAIL] %s\n' "$*" >&2; exit 1; }+pass() { printf '[PASS] %s\n' "$*"; PASS=$((PASS + 1)); }+# ODS_TEST_SECTION=NN runs only that phase's section (a quick rerun while editing).+only() { [[ -z "${ODS_TEST_SECTION:-}" || "$ODS_TEST_SECTION" == "$1" ]]; }++tmp="$(mktemp -d)"+trap 'rm -rf "$tmp"' EXIT+fakebin="$tmp/bin"+mkdir -p "$fakebin"+# No test here may reach a real Docker daemon.+printf '#!/usr/bin/env bash\necho "the test reached docker" >&2\nexit 97\n' > "$fakebin/docker"+chmod +x "$fakebin/docker"+export PATH="$fakebin:$PATH"++GB300=GPU-aaaaaaaa-gb300+RTX=GPU-bbbbbbbb-rtx6000+PINNED_IMAGE="$(jq -r '.entries[] | select(.id == "vllm.vllm-server") | .value' "$ROOT_DIR/config/dependency-lock.json")"++# ── 03: the vLLM engine owns exactly its GPU ──────────────────────────────+if only 03; then+phase03() {+ local name="$1" topology="$2" rc=0 dir="$tmp/p03-$1"+ shift 2+ mkdir -p "$dir/src/scripts" "$dir/home" "$dir/install"+ cp "$ROOT_DIR/scripts/assign_gpus.py" "$dir/src/scripts/"+ {+ printf '%s\n' 'set -euo pipefail'+ printf 'FEATURES_PHASE=%q\nSCRIPT_DIR=%q\nINSTALL_DIR=%q\nHOME=%q\n' \+ "$PHASES/03-features.sh" "$dir/src" "$dir/install" "$dir/home"+ printf 'GPU_TOPOLOGY_JSON=%q\n' "$topology"+ cat <<'EOF'+INTERACTIVE=false DRY_RUN=false TIER=NV_ULTRA ODS_MODE=local+ENABLE_VOICE=true ENABLE_WORKFLOWS=false ENABLE_RAG=true ENABLE_RECOMMENDED=false+ENABLE_HERMES=false ENABLE_PIXEL=false ENABLE_COMFYUI=true ENABLE_APE=false+ENABLE_PERPLEXICA=false ENABLE_PRIVACY_SHIELD=false ENABLE_LANGFUSE=false ENABLE_BRAVE_SEARCH=false+GPU_BACKEND=nvidia HOST_ARCH=arm64 HOST_PAGE_SIZE=4096 MAX_CONTEXT=131072 LLM_MODEL_SIZE_MB=132735+VERBOSE=false DEBUG=false AMB= BGRN= DIM= GRN= NC= RED= WHT=+GPU_COUNT="$(jq '.gpu_count' <<< "$GPU_TOPOLOGY_JSON")"+ods_progress() { :; }; show_phase() { :; }; show_install_menu() { :; }; ai() { :; }; ai_warn() { :; }+ai_bad() { :; }; log() { :; }; chapter() { :; }; bootline() { :; }; signal() { :; }+warn() { printf 'WARN %s\n' "$*"; }+success() { printf 'SUCCESS %s\n' "$*"; }+error() { printf 'ERROR %s\n' "$*" >&2; exit 1; }+nvidia-smi() { jq -r '.gpus[].uuid' <<< "$GPU_TOPOLOGY_JSON"; }+source "$(dirname "$FEATURES_PHASE")/../lib/installed-feature-state.sh"+EOF+ printf '%s\n' "$@"+ cat <<'EOF'+source "$FEATURES_PHASE"+printf 'LLAMA=%s\nWHISPER=%s\nCOMFYUI=%s\nEMBEDDINGS=%s\nSPLIT=%s\nTENSOR=%s\n' "${LLAMA_SERVER_GPU_UUIDS:-}" \+ "${WHISPER_GPU_UUID:-}" "${COMFYUI_GPU_UUID:-}" "${EMBEDDINGS_GPU_UUID:-}" "${LLAMA_ARG_SPLIT_MODE:-}" "${LLAMA_ARG_TENSOR_SPLIT:-}"+printf 'ASSIGNED=%s\n' "$(jq -c '.gpu_assignment.services.llama_server.gpus' <<< "$GPU_ASSIGNMENT_JSON")"+printf 'MAX_CONTEXT=%s\nBELOW_FLOOR=%s\n' "$MAX_CONTEXT" "${HERMES_CONTEXT_BELOW_FLOOR:-}"+EOF+ } > "$dir/run.bash"+ bash "$dir/run.bash" >"$dir/out" 2>"$dir/err" || rc=$?+ printf '%s\n' "$rc" > "$dir/rc"+}+p03() { sed -n "s/^$2=//p" "$tmp/p03-$1/out"; }+dgx_topology="$(cat <<EOF+{"vendor": "nvidia", "gpu_count": 2, "gpus": [+ {"index": 0, "uuid": "$GB300", "name": "NVIDIA GB300", "memory_gb": 250.7, "memory_free_gb": 250.0},+ {"index": 1, "uuid": "$RTX", "name": "NVIDIA RTX PRO 6000 Blackwell", "memory_gb": 95.6, "memory_free_gb": 95.0}],+ "links": [{"gpu_a": 0, "gpu_b": 1, "rank": 10, "link_type": "SYS", "link_label": "SYS"}]}+EOF+)"+phase03 dgx "$dgx_topology" 'LLM_BACKEND=vllm' "VLLM_GPU_UUID=$GB300"+[[ "$(cat "$tmp/p03-dgx/rc")" == 0 ]] || fail "phase 03 failed on the DGX Station: $(cat "$tmp/p03-dgx/err")"+[[ "$(p03 dgx LLAMA)" == "$GB300" && "$(p03 dgx ASSIGNED)" == "[\"$GB300\"]" ]] \+ || fail "the LLM role must be exactly the vLLM GPU: $(cat "$tmp/p03-dgx/out")"+[[ "$(p03 dgx WHISPER)" == "$RTX" && "$(p03 dgx COMFYUI)" == "$RTX" && "$(p03 dgx EMBEDDINGS)" == "$RTX" ]] \+ || fail "whisper, ComfyUI and embeddings must take the other GPU: $(cat "$tmp/p03-dgx/out")"+[[ "$(p03 dgx SPLIT)" == none && "$(p03 dgx TENSOR)" == 1 ]] || fail "the vLLM route must not split the model"+# The same host and model without the pin: llama.cpp would split it across both.+phase03 dgx-llama "$dgx_topology" 'LLM_BACKEND=llama-server'+[[ "$(p03 dgx-llama ASSIGNED)" == "[\"$GB300\",\"$RTX\"]" ]] \+ || fail "fixture check: the unpinned assignment was expected to span both GPUs: $(cat "$tmp/p03-dgx-llama/out" "$tmp/p03-dgx-llama/err")"+pass "phase 03 gives vLLM exactly its GPU and the other services the rest, where llama.cpp would split"++five="$(jq -c '.' <<'EOF'+{"vendor":"nvidia","gpu_count":5,"gpus":[+ {"index":0,"uuid":"GPU-0","name":"B200","memory_gb":180,"memory_free_gb":180},+ {"index":1,"uuid":"GPU-1","name":"B200","memory_gb":180,"memory_free_gb":180},+ {"index":2,"uuid":"GPU-2","name":"B200","memory_gb":180,"memory_free_gb":180},+ {"index":3,"uuid":"GPU-3","name":"B200","memory_gb":180,"memory_free_gb":180},+ {"index":4,"uuid":"GPU-4","name":"B200","memory_gb":180,"memory_free_gb":180}],+ "links":[{"gpu_a":0,"gpu_b":1,"rank":100,"link_type":"NV18","link_label":"NV18"},{"gpu_a":0,"gpu_b":2,"rank":100,"link_type":"NV18","link_label":"NV18"},+ {"gpu_a":0,"gpu_b":3,"rank":100,"link_type":"NV18","link_label":"NV18"},{"gpu_a":0,"gpu_b":4,"rank":100,"link_type":"NV18","link_label":"NV18"},+ {"gpu_a":1,"gpu_b":2,"rank":100,"link_type":"NV18","link_label":"NV18"},{"gpu_a":1,"gpu_b":3,"rank":100,"link_type":"NV18","link_label":"NV18"},+ {"gpu_a":1,"gpu_b":4,"rank":100,"link_type":"NV18","link_label":"NV18"},{"gpu_a":2,"gpu_b":3,"rank":100,"link_type":"NV18","link_label":"NV18"},+ {"gpu_a":2,"gpu_b":4,"rank":100,"link_type":"NV18","link_label":"NV18"},{"gpu_a":3,"gpu_b":4,"rank":100,"link_type":"NV18","link_label":"NV18"}]}+EOF+)"+phase03 five "$five" 'LLM_BACKEND=vllm' 'VLLM_GPU_UUID=GPU-2'+[[ "$(p03 five LLAMA)" == GPU-2 && "$(p03 five SPLIT)" == none ]] \+ || fail "spare GPUs must not join a pinned vLLM GPU: $(cat "$tmp/p03-five/out" "$tmp/p03-five/err")"+[[ "$(p03 five WHISPER)" != GPU-2 && "$(p03 five COMFYUI)" != GPU-2 && "$(p03 five EMBEDDINGS)" != GPU-2 ]] \+ || fail "with spare GPUs the other services must not share vLLM's GPU: $(cat "$tmp/p03-five/out")"+pass "on an NVLink host vLLM keeps one GPU and no spare GPU joins it"++mkdir -p "$tmp/p03-reuse/install"+saved_split="$(jq -nc --arg a "$GB300" --arg b "$RTX" '{gpu_assignment:{version:"1.0",strategy:"colocated",services:{+ llama_server:{gpus:[$a,$b],parallelism:{mode:"pipeline",tensor_parallel_size:1,pipeline_parallel_size:2,gpu_memory_utilization:0.95}},+ whisper:{gpus:[$b]},comfyui:{gpus:[$b]},embeddings:{gpus:[$b]}}}}')"+printf 'GPU_ASSIGNMENT_JSON_B64=%s\n' "$(printf '%s' "$saved_split" | base64 | tr -d '\n')" > "$tmp/p03-reuse/install/.env"+phase03 reuse "$dgx_topology" 'LLM_BACKEND=vllm' "VLLM_GPU_UUID=$GB300"+[[ "$(p03 reuse ASSIGNED)" == "[\"$GB300\"]" ]] && ! grep -q 'Reusing existing GPU assignment' "$tmp/p03-reuse/out" \+ || fail "a saved assignment that splits the LLM must not be reused for vLLM: $(cat "$tmp/p03-reuse/out")"+saved_pinned="$(jq -c --arg a "$GB300" '.gpu_assignment.services.llama_server = {gpus:[$a],parallelism:{mode:"none",tensor_parallel_size:1,pipeline_parallel_size:1,gpu_memory_utilization:0.95}}' <<< "$saved_split")"+mkdir -p "$tmp/p03-reuse2/install"+printf 'GPU_ASSIGNMENT_JSON_B64=%s\n' "$(printf '%s' "$saved_pinned" | base64 | tr -d '\n')" > "$tmp/p03-reuse2/install/.env"+phase03 reuse2 "$dgx_topology" 'LLM_BACKEND=vllm' "VLLM_GPU_UUID=$GB300"+grep -q 'SUCCESS Reusing existing GPU assignment from .env' "$tmp/p03-reuse2/out" && [[ "$(p03 reuse2 LLAMA)" == "$GB300" ]] \+ || fail "a saved assignment that already pins vLLM's GPU must be kept: $(cat "$tmp/p03-reuse2/out" "$tmp/p03-reuse2/err")"+pass "a saved GPU assignment is reused for vLLM only when it already gives the LLM exactly vLLM's GPU"++single="$(jq -nc --arg a "$GB300" '{vendor:"nvidia",gpu_count:1,gpus:[{index:0,uuid:$a,name:"NVIDIA GB300",memory_gb:250.7}],links:[]}')"+phase03 single "$single" 'LLM_BACKEND=vllm' "VLLM_GPU_UUID=$GB300"+[[ "$(cat "$tmp/p03-single/rc")" == 0 ]] && grep -q "ASSIGNED=\[\"$GB300\"\]" "$tmp/p03-single/out" \+ || fail "a single vLLM GPU must get the trivial assignment: $(cat "$tmp/p03-single/out" "$tmp/p03-single/err")"+phase03 single-mismatch "$single" 'LLM_BACKEND=vllm' 'VLLM_GPU_UUID=GPU-other'+[[ "$(cat "$tmp/p03-single-mismatch/rc")" != 0 ]] && grep -q 'The vLLM engine was planned for GPU GPU-other' "$tmp/p03-single-mismatch/err" \+ || fail "a single GPU that is not vLLM's must stop the install"+pass "a single-GPU vLLM host gets its one GPU, and a GPU mismatch stops the install"++# vLLM serves the context its --max-model-len fixes: the Hermes floor never+# raises it (llama.cpp's unverified fresh pick would be raised to 64K).+phase03 hermes-vllm "$single" 'LLM_BACKEND=vllm' "VLLM_GPU_UUID=$GB300" 'ENABLE_HERMES=true' 'MAX_CONTEXT=32768'+[[ "$(p03 hermes-vllm MAX_CONTEXT)" == 32768 && "$(p03 hermes-vllm BELOW_FLOOR)" == true ]] \+ || fail "the Hermes floor must not resize a vLLM model: $(cat "$tmp/p03-hermes-vllm/out" "$tmp/p03-hermes-vllm/err")"+phase03 hermes-llama "$single" 'LLM_BACKEND=llama-server' 'ENABLE_HERMES=true' 'MAX_CONTEXT=32768'+[[ "$(p03 hermes-llama MAX_CONTEXT)" == 65536 ]] || fail "fixture check: llama.cpp's fresh pick is raised to 64K"+pass "the Hermes 64K floor keeps a vLLM model's context instead of raising it"++fi++# ── 06: the .env the vLLM route writes ────────────────────────────────────+if only 06; then+# shellcheck source=lib/phase06-env-harness.sh+source "$ROOT_DIR/tests/lib/phase06-env-harness.sh"+PHASE06="$PHASES/06-directories.sh"+cat > "$tmp/vllm.fixture" <<EOF+TIER=NV_ULTRA+GPU_BACKEND=nvidia+GPU_COUNT=2+GPU_COMPUTE_CAP=10.3+RAM_GB=512+HOST_ARCH=arm64+ODS_MODE=local+LLM_BACKEND=vllm+export LLM_BACKEND+LLM_MODEL=qwen3.8-flash-next-nvfp4+GGUF_FILE=""+GGUF_URL=""+GGUF_SHA256=""+MAX_CONTEXT=131072+LLM_MODEL_SIZE_MB=132735+VLLM_IMAGE='$PINNED_IMAGE'+VLLM_MODEL_DIR='nvidia--Qwen3.8-Flash-Next-NVFP4@fc694b54'+VLLM_SERVED_MODEL=Qwen3.8-Flash-Next-NVFP4+VLLM_ARGS='--quantization modelopt --max-model-len 131072 --speculative-config.method=mtp'+VLLM_GPU_UUID=$GB300+LLAMA_SERVER_GPU_UUIDS=$GB300+LLAMA_ARG_SPLIT_MODE=none+LLAMA_ARG_TENSOR_SPLIT=1+EOF+render() {+ local name="$1" fixture="$2"+ mkdir -p "$tmp/p06-$name"+ ods_phase06_render_env "$PHASE06" "$ROOT_DIR" "$tmp/p06-$name" "$fixture" \+ || fail "phase 06 did not render the $name .env: $(cat "$tmp/p06-$name/render.err")"+}+envv() {+ python3 - "$tmp/p06-$1/.env" "$2" "$ROOT_DIR/extensions/services/dashboard-api" <<'PY'+import sys+sys.path.insert(0, sys.argv[3])+from env_values import parse_env_value+value = None+for line in open(sys.argv[1], encoding="utf-8").read().splitlines():+ key, separator, raw = line.partition("=")+ if separator and key == sys.argv[2]:+ value = parse_env_value(raw)+print("<absent>" if value is None else value)+PY+}+render vllm "$tmp/vllm.fixture"+for pair in "LLM_BACKEND=vllm" "VLLM_IMAGE=$PINNED_IMAGE" "VLLM_MODEL_DIR=nvidia--Qwen3.8-Flash-Next-NVFP4@fc694b54" \+ "VLLM_SERVED_MODEL=Qwen3.8-Flash-Next-NVFP4" "VLLM_GPU_UUID=$GB300" \+ "VLLM_ARGS=--quantization modelopt --max-model-len 131072 --speculative-config.method=mtp" \+ "LLM_API_URL=http://litellm:4000" "OPEN_WEBUI_LLM_BASE_URL=http://litellm:4000" \+ "HERMES_LLM_BASE_URL=http://model-router:9099/v1" "ODS_MODEL_SWITCHBOARD=enabled" \+ "ODS_TALK_VISION_URL=http://litellm:4000/v1" "GGUF_FILE=" "GGUF_URL=" "MAX_CONTEXT=131072" "CTX_SIZE=131072" \+ "LLAMA_SERVER_GPU_UUIDS=$GB300" "LLAMA_ARG_SPLIT_MODE=none" "SKIP_MODEL_DOWNLOAD=false" \+ "VLLM_GPU_MEMORY_UTILIZATION=<absent>"; do+ [[ "$(envv vllm "${pair%%=*}")" == "${pair#*=}" ]] || fail "the vLLM .env must hold ${pair}, got '$(envv vllm "${pair%%=*}")'"+done+[[ "$(envv vllm ODS_TALK_VISION_KEY)" == "$(envv vllm LITELLM_KEY)" \+ && "$(envv vllm OPEN_WEBUI_LLM_API_KEY)" == "$(envv vllm LITELLM_KEY)" ]] \+ || fail "Open WebUI and ODS Talk images must reach LiteLLM with its key"+if grep -E '^[A-Z_]+=.*llama-server:8080' "$tmp/p06-vllm/.env"; then+ fail "the vLLM .env must not point a service at the in-stack llama-server"+fi+[[ "$(grep -c '^VLLM_' "$tmp/p06-vllm/.env")" == 5 && "$(grep -c '^LLM_BACKEND=' "$tmp/p06-vllm/.env")" == 1 ]] \+ || fail "each vLLM key must appear once"+if grep -q 'WARN' "$tmp/p06-vllm/render.err"; then+ fail "a fresh vLLM install must not warn: $(cat "$tmp/p06-vllm/render.err")"+fi+bash "$ROOT_DIR/scripts/validate-env.sh" "$tmp/p06-vllm/.env" "$ROOT_DIR/.env.schema.json" >"$tmp/validate.out" 2>&1 \+ || fail "the vLLM .env must pass .env.schema.json: $(tail -20 "$tmp/validate.out")"+pass "phase 06 writes LLM_BACKEND=vllm, the VLLM_* keys and gateway URLs that pass the schema"++# A rerun over an installation that ran llama.cpp with the switchboard off.+mkdir -p "$tmp/p06-rerun"+cat > "$tmp/p06-rerun/.env" <<'EOF'+LLM_BACKEND=llama-server+ODS_MODEL_SWITCHBOARD=legacy+LLM_API_URL=http://llama-server:8080+OPEN_WEBUI_LLM_BASE_URL=+HERMES_LLM_BASE_URL=http://llama-server:8080/v1+HERMES_LLM_API_KEY=sk-ods-hermes-local+ODS_TALK_VISION_URL=http://llama-server:8080/v1+VLLM_GPU_MEMORY_UTILIZATION=0.85+LITELLM_KEY=sk-ods-kept-key+EOF+render rerun "$tmp/vllm.fixture"+for pair in "LLM_API_URL=http://litellm:4000" "OPEN_WEBUI_LLM_BASE_URL=http://litellm:4000" \+ "OPEN_WEBUI_LLM_API_KEY=sk-ods-kept-key" "HERMES_LLM_BASE_URL=http://model-router:9099/v1" \+ "HERMES_LLM_API_KEY=no-key" "ODS_MODEL_SWITCHBOARD=enabled" "ODS_TALK_VISION_URL=http://litellm:4000/v1" \+ "ODS_TALK_VISION_KEY=sk-ods-kept-key" "VLLM_GPU_MEMORY_UTILIZATION=0.85" "LLM_BACKEND=vllm"; do+ [[ "$(envv rerun "${pair%%=*}")" == "${pair#*=}" ]] || fail "the vLLM rerun must hold ${pair}, got '$(envv rerun "${pair%%=*}")'"+done+grep -q 'setting ODS_MODEL_SWITCHBOARD=enabled' "$tmp/p06-rerun/render.err" \+ || fail "turning the switchboard on must be said"+mkdir -p "$tmp/p06-owner"+printf '%s\n' 'ODS_TALK_VISION_URL=http://10.0.0.9:8000/v1' 'ODS_TALK_VISION_KEY=owner-key' > "$tmp/p06-owner/.env"+render owner "$tmp/vllm.fixture"+[[ "$(envv owner ODS_TALK_VISION_URL)" == http://10.0.0.9:8000/v1 && "$(envv owner ODS_TALK_VISION_KEY)" == owner-key ]] \+ || fail "an owner's own vision server must be kept"+pass "a rerun moves llama-server URLs to LiteLLM and model-router, turns the switchboard on and keeps owner settings"++mkdir -p "$tmp/p06-noimage"+grep -v '^VLLM_IMAGE=' "$tmp/vllm.fixture" > "$tmp/noimage.fixture"+! ods_phase06_render_env "$PHASE06" "$ROOT_DIR" "$tmp/p06-noimage" "$tmp/noimage.fixture" \+ && grep -q 'The vLLM engine needs VLLM_IMAGE' "$tmp/p06-noimage/render.err" \+ || fail "phase 06 must refuse to write a vLLM .env without VLLM_IMAGE"+pass "phase 06 refuses a vLLM .env with a missing VLLM_* value"++# Other routes: no vLLM line, and an exported llama-server writes the same bytes as none.+for route in \+ "llama|TIER=NV_ULTRA GPU_BACKEND=nvidia GPU_COUNT=1 RAM_GB=512 ODS_MODE=local LLM_MODEL=qwen3.6-35b-a3b GGUF_FILE=Q.gguf MAX_CONTEXT=65536" \+ "amd|TIER=SH_LARGE GPU_BACKEND=amd GPU_COUNT=1 RAM_GB=128 ODS_MODE=local LLM_MODEL=qwen3.6-35b-a3b GGUF_FILE=Q.gguf MAX_CONTEXT=65536" \+ "cloud|TIER=CLOUD GPU_BACKEND=cpu GPU_COUNT=0 RAM_GB=8 ODS_MODE=cloud LLM_MODEL=anthropic/claude-sonnet-4-6 GGUF_FILE= MAX_CONTEXT=200000" \+ "external|TIER=3 GPU_BACKEND=nvidia GPU_COUNT=1 RAM_GB=32 ODS_MODE=local LLM_MODEL=m GGUF_FILE=Q.gguf MAX_CONTEXT=65536 EXTERNAL_LLM_URL=http://127.0.0.1:11434 EXTERNAL_LLM_CONTAINER_URL=http://host.docker.internal:11434 EXTERNAL_LLM_PROVIDER=ollama EXTERNAL_LLM_MODEL=qwen3:32b"; do+ IFS='|' read -r name assignments <<< "$route"+ read -r -a items <<< "$assignments"+ printf '%s\n' "${items[@]}" > "$tmp/$name.fixture"+ { cat "$tmp/$name.fixture"; printf 'LLM_BACKEND=llama-server\nexport LLM_BACKEND\n'; } > "$tmp/$name-exported.fixture"+ render "$name" "$tmp/$name.fixture"+ render "$name-exported" "$tmp/$name-exported.fixture"+ cmp -s "$tmp/p06-$name/.env" "$tmp/p06-$name-exported/.env" \+ || fail "$name: an exported LLM_BACKEND=llama-server changed .env: $(diff "$tmp/p06-$name/.env" "$tmp/p06-$name-exported/.env")"+ if grep -E '^(VLLM_[A-Z_]+|ODS_TALK_VISION_[A-Z]+)=|vLLM engine' "$tmp/p06-$name/.env"; then+ fail "$name: a route without vLLM must write no vLLM line"+ fi+done+[[ "$(envv llama LLM_BACKEND)" == llama-server && "$(envv external LLM_BACKEND)" == external \+ && "$(envv llama LLM_API_URL)" == http://llama-server:8080 ]] || fail "the llama.cpp and API routes keep their values"+pass "every other route writes no vLLM line and the same bytes whether or not LLM_BACKEND is exported"++# Compose reads the exported LLM_BACKEND ahead of .env, so the two must agree.+[[ "$(cat "$tmp/p06-vllm/exported-llm-backend")" == vllm \+ && "$(cat "$tmp/p06-external-exported/exported-llm-backend")" == external \+ && "$(cat "$tmp/p06-llama-exported/exported-llm-backend")" == llama-server ]] \+ || fail "phase 06 must export the LLM_BACKEND it writes to .env"+cache_block="$(awk '/^ if \[\[ "\$\{LLM_BACKEND:-\}" == "vllm" \]\]; then$/ { emit = 1 } emit { print } emit && /^ fi$/ { exit }' "$PHASE06")"+[[ "$cache_block" == *'mkdir -p "$INSTALL_DIR"/data/vllm/cache'* ]] || fail "phase 06 must create data/vllm/cache"+( INSTALL_DIR="$tmp/cache-vllm" LLM_BACKEND=vllm; eval "$cache_block" )+( INSTALL_DIR="$tmp/cache-llama" LLM_BACKEND=llama-server; eval "$cache_block" )+[[ -d "$tmp/cache-vllm/data/vllm/cache" && ! -e "$tmp/cache-llama" ]] \+ || fail "data/vllm/cache must be created for the vLLM engine only"+pass "phase 06 exports the LLM_BACKEND it writes and creates data/vllm/cache only for vLLM"++# The runtime-config renders phase 06 runs: vllm-default only for vLLM.+router_args="$(awk '/^ _router_llm_backend=llama-server$/ { emit = 1 } /^ _router_surfaces=\(model-router-endpoints\)$/ { exit } emit { print }' "$PHASE06")"+[[ "$router_args" == *'--llm-backend "$_router_llm_backend"'* ]] || fail "phase 06 must pass --llm-backend to the router renders"+# router_arg ASSIGNMENTS FLAG: the value phase 06 passes the router renders for FLAG.+router_arg() (+ ODS_MODEL_SWITCHBOARD_VALUE=enabled _router_ods_mode=local GPU_BACKEND=nvidia GGUF_FILE=""+ _router_llm_base_url=http://llama-server:8080/v1 INSTALL_DIR="$tmp" NATIVE_LLM_ACTIVE=false+ LLM_MODEL=qwen3.8-flash-next-nvfp4+ eval "$1"+ eval "$router_args"+ printf '%s\n' "${_router_common_args[@]}" | sed -n "/^$2\$/{n;p;}"+)+[[ "$(router_arg 'LLM_BACKEND=vllm' --llm-backend)" == vllm && "$(router_arg 'LLM_BACKEND=llama-server' --llm-backend)" == llama-server \+ && "$(router_arg 'unset LLM_BACKEND' --llm-backend)" == llama-server ]] \+ || fail "phase 06 must render the router for vllm only on the vLLM route"+# The vllm-default endpoint carries the model's thinking map, read from the+# catalog entry --model names; every other route renders without --model.+[[ "$(router_arg 'LLM_BACKEND=vllm' --model)" == qwen3.8-flash-next-nvfp4 \+ && -z "$(router_arg 'LLM_BACKEND=llama-server' --model)" && -z "$(router_arg 'unset LLM_BACKEND' --model)" ]] \+ || fail "phase 06 must name LLM_MODEL with --model on the vLLM route only"+endpoints() {+ rm -rf "$tmp/render" && mkdir -p "$tmp/render"+ ODS_RENDER_LITELLM_KEY=sk-ods-test env -u LLM_BACKEND "$PYTHON_CMD" "$ROOT_DIR/scripts/render-runtime-configs.py" \+ --surface model-router-endpoints --switchboard-mode enabled --ods-mode local --gpu-backend nvidia \+ --gguf-file Q.gguf --llm-base-url http://llama-server:8080 --output-root "$tmp/render" --write "$@" >/dev/null+ cat "$tmp/render/config/model-router/endpoints.json"+}+[[ "$(endpoints)" == "$(endpoints --llm-backend llama-server)" ]] || fail "--llm-backend llama-server must render the endpoints as before"+vllm_endpoints="$(endpoints --llm-backend vllm --model qwen3.8-flash-next-nvfp4)"+grep -q '"id": "vllm-default"' <<< "$vllm_endpoints" && grep -q 'http://vllm-server:8000' <<< "$vllm_endpoints" \+ || fail "--llm-backend vllm must route model-router to vllm-server: $vllm_endpoints"+pass "model-router's endpoint is vllm-default, rendered for LLM_MODEL, on vLLM and unchanged elsewhere"++fi++# ── 08: images ─────────────────────────────────────────────────────────────+if only 08; then+pull_plan() (+ SCRIPT_DIR="$ROOT_DIR" INSTALL_DIR="$tmp/p08" LOG_FILE="$tmp/p08.log" DRY_RUN=true+ GPU_BACKEND=nvidia ODS_MODE=local EXTERNAL_LLM_URL="" COMPOSE_FLAGS="" ENABLE_VOICE=false+ ENABLE_WORKFLOWS=false ENABLE_RAG=false ENABLE_HERMES=false ENABLE_OPEN_WEBUI=true+ HOST_ARCH=arm64+ eval "$1"+ ods_progress() { :; }; show_phase() { :; }; ai() { :; }; ai_ok() { :; }; ai_warn() { :; }+ bootline() { :; }; signal() { :; }+ source "$ROOT_DIR/installers/lib/native-llm.sh"+ source "$PHASES/08-images.sh"+ printf '%s\n' "${PULL_LIST[@]}"+)+plan="$(pull_plan "LLM_BACKEND=vllm VLLM_IMAGE='$PINNED_IMAGE'")"+grep -qxF "$PINNED_IMAGE|VLLM — downloading the vLLM engine (NVIDIA)" <<< "$plan" \+ || fail "phase 08 must pull the pinned vLLM image: $plan"+! grep -q 'LLAMA-SERVER' <<< "$plan" || fail "phase 08 must not pull a llama.cpp image for vLLM: $plan"+grep -q 'LLAMA-SERVER' <<< "$(pull_plan 'LLM_BACKEND=llama-server')" || fail "the llama.cpp route still pulls llama-server"+pass "phase 08 pulls the vLLM image and no llama.cpp image on the vLLM route"++(+ source "$ROOT_DIR/installers/lib/compose-select.sh"+ INSTALL_DIR="$tmp"+ fake_compose() { printf '%s\n' $FAKE_SERVICES; }+ DOCKER_COMPOSE_CMD=fake_compose+ FAKE_SERVICES="dashboard model-router vllm-server litellm"+ ods_vllm_assert_engine_stack -f docker-compose.base.yml || exit 11+ FAKE_SERVICES="dashboard model-router vllm-server llama-server"+ ! ods_vllm_assert_engine_stack 2>"$tmp/assert.err" || exit 12+ grep -q 'also starts the in-stack llama-server' "$tmp/assert.err" || exit 13+ FAKE_SERVICES="dashboard llama-server"+ ! ods_vllm_assert_engine_stack 2>"$tmp/assert.err" || exit 14+ grep -q 'no vllm-server service' "$tmp/assert.err" || exit 15+) || fail "the vLLM stack check must refuse a stack with llama-server or without vllm-server (exit $?)"+for phase in 08-images.sh 11-services.sh; do+ grep -q 'ods_vllm_assert_engine_stack' "$PHASES/$phase" || fail "$phase must check the vLLM stack before using it"+done+pass "phases 08 and 11 check that the vLLM stack runs vllm-server and not llama-server"++fi++# ── 11: the vLLM model download ───────────────────────────────────────────+if only 11; then+download_fns="$(awk '+ /^ _phase11_vllm_download_status\(\) \{$/ { emit = 1 }+ emit { print }+ emit && /^ _phase11_download_vllm_model\(\) \{$/ { last = 1 }+ last && /^ }$/ { exit }+' "$PHASES/11-services.sh")"+[[ "$download_fns" == *'_phase11_download_vllm_model() {'* ]] || fail "phase 11's vLLM download was not found"+download() {+ local name="$1" exits="$2" rc=0 dir="$tmp/p11-$1"+ mkdir -p "$dir/install/scripts"+ cat > "$dir/install/scripts/download-hf-manifest.py" <<'PY'+import os+import sys+from pathlib import Path++state = Path(os.environ["FAKE_STATE"])+calls = int(state.read_text()) if state.exists() else 0+state.write_text(str(calls + 1))+codes = os.environ["FAKE_EXITS"].split(",")+code = int(codes[min(calls, len(codes) - 1)])+with open(os.environ["FAKE_ARGS"], "a", encoding="utf-8") as handle:+ handle.write(" ".join(sys.argv[1:]) + "\n")+print("plan: nvidia/Qwen3.8-Flash-Next-NVFP4@fc694b54, 25 files, 132.7 GB, into x", flush=True)+print("progress: 40% 53.1 of 132.7 GB", flush=True)+messages = {1: "the download stopped: timed out. Its bytes are kept: run this again to resume.",+ 3: "model.safetensors does not match the catalog (sha256 1, expected 2), so its download was deleted.",+ 4: "/models has 12.0 GB free, but this model needs 120.6 GB more plus a 2.1 GB safety margin."}+if code:+ print(f"error: {messages.get(code, 'unexpected')}\nNeed help? Ask on the ODS Discord: x", file=sys.stderr)+else:+ print("done: 25 files verified in x", flush=True)+sys.exit(code)+PY+ {+ printf '%s\n' 'set -euo pipefail'+ printf 'INSTALL_DIR=%q\nODS_PYTHON_CMD=%q\n' "$dir/install" "$PYTHON_CMD"+ printf 'export FAKE_STATE=%q FAKE_ARGS=%q FAKE_EXITS=%q\n' "$dir/state" "$dir/args" "$exits"+ cat <<'EOF'+LLM_MODEL=qwen3.8-flash-next-nvfp4 VLLM_SERVED_MODEL=Qwen3.8-Flash-Next-NVFP4+VLLM_MODEL_DIR='nvidia--Qwen3.8-Flash-Next-NVFP4@fc694b54' LLM_MODEL_SIZE_MB=132735+ODS_VLLM_DOWNLOAD_RETRY_DELAY_SECONDS=0+ai() { printf 'AI %s\n' "$*"; }+ai_bad() { printf 'BAD %s\n' "$*"; }+ui_status_line() { printf 'STATUS %s %s\n' "$1" "$2"; }+spin_task() { local rc=0; wait "$1" || rc=$?; printf 'SPIN %s | %s\n' "$2" "$("$5")"; return "$rc"; }+EOF+ printf '%s\n' "$download_fns"+ printf '%s\n' '_phase11_download_vllm_model'+ } > "$dir/run.bash"+ bash "$dir/run.bash" >"$dir/out" 2>"$dir/err" || rc=$?+ printf '%s\n' "$rc" > "$dir/rc"+}+download ok 0+[[ "$(cat "$tmp/p11-ok/rc")" == 0 ]] && grep -q '^STATUS ok Model downloaded and verified: Qwen3.8-Flash-Next-NVFP4$' "$tmp/p11-ok/out" \+ || fail "a verified download must be reported: $(cat "$tmp/p11-ok/out" "$tmp/p11-ok/err")"+# (Windows Python sees the same paths spelled C:/...; compare their ends.)+grep -Eqx -- '--catalog .*/p11-ok/install/config/model-library\.json --model-id qwen3\.8-flash-next-nvfp4 --models-dir .*/p11-ok/install/data/models' "$tmp/p11-ok/args" \+ || fail "the downloader must get the catalog, the model and data/models: $(cat "$tmp/p11-ok/args")"+grep -q '^SPIN Downloading Qwen3.8-Flash-Next-NVFP4 | 40% 53.1 of 132.7 GB$' "$tmp/p11-ok/out" \+ || fail "the download must show the downloader's progress: $(cat "$tmp/p11-ok/out")"+grep -q 'about 133 GB into data/models/nvidia--Qwen3.8-Flash-Next-NVFP4@fc694b54' "$tmp/p11-ok/out" \+ || fail "the download must say how big it is and where it goes"+if grep -qi 'fail\|error' "$tmp/p11-ok/out"; then+ fail "a successful download must not show error-looking text: $(cat "$tmp/p11-ok/out")"+fi+download resumed 1,0+[[ "$(cat "$tmp/p11-resumed/rc")" == 0 && "$(wc -l < "$tmp/p11-resumed/args" | tr -d ' ')" == 2 ]] \+ && grep -q 'resuming from the files kept so far (attempt 2 of 3)' "$tmp/p11-resumed/out" \+ || fail "a stopped download must resume: $(cat "$tmp/p11-resumed/out")"+if grep -qi 'fail\|error' "$tmp/p11-resumed/out"; then+ fail "a resumed download must stay calm: $(cat "$tmp/p11-resumed/out")"+fi+download stopped 1+[[ "$(cat "$tmp/p11-stopped/rc")" != 0 && "$(wc -l < "$tmp/p11-stopped/args" | tr -d ' ')" == 3 ]] \+ && grep -q '^BAD The download of Qwen3.8-Flash-Next-NVFP4 stopped before it finished: the download stopped: timed out' "$tmp/p11-stopped/out" \+ && grep -q 'Run the same install command again: it keeps the verified files and resumes' "$tmp/p11-stopped/out" \+ || fail "three stops must end with the cause and the resume step: $(cat "$tmp/p11-stopped/out")"+download mismatch 3+[[ "$(cat "$tmp/p11-mismatch/rc")" != 0 && "$(wc -l < "$tmp/p11-mismatch/args" | tr -d ' ')" == 1 ]] \+ && grep -q '^BAD A downloaded file of Qwen3.8-Flash-Next-NVFP4 did not match the catalog checksum' "$tmp/p11-mismatch/out" \+ || fail "a checksum mismatch must stop at once with its cause: $(cat "$tmp/p11-mismatch/out")"+download disk 4+[[ "$(cat "$tmp/p11-disk/rc")" != 0 ]] \+ && grep -q '^BAD There is not enough free disk space for Qwen3.8-Flash-Next-NVFP4: /models has 12.0 GB free' "$tmp/p11-disk/out" \+ && grep -q 'Free up space on that disk' "$tmp/p11-disk/out" \+ || fail "a full disk must say how much is free and what to do: $(cat "$tmp/p11-disk/out")"+for name in stopped mismatch disk; do+ grep -q '^AI Need help? Ask on the ODS Discord: https://discord.gg/4ntNp9MAwC$' "$tmp/p11-$name/out" \+ || fail "$name: a download failure must name the Discord help link"+done+grep -q 'vllm-model-download.log' "$tmp/p11-stopped/out" || fail "a download failure must name its log"+grep -q '_phase11_download_vllm_model || exit 1' "$PHASES/11-services.sh" || fail "phase 11 must stop on a failed vLLM download"+pass "phase 11 shows the vLLM download's progress, resumes a stop and explains exits 1, 3 and 4"++# A rerun that moves a llama.cpp installation to vLLM: the old llama-server+# container, which the vLLM overlay keeps behind a profile, goes first.+p11_helpers="$(sed -n '/^ _phase11_old_llama_containers() {$/,/^ }$/p; /^ _phase11_old_llama_stuck() {$/,/^ }$/p' "$PHASES/11-services.sh")"+p11_removal="$(awk '+ /^ # A rerun that moves a llama.cpp installation to the vLLM engine leaves$/ { print previous; emit = 1 }+ emit { print }+ emit && /^ fi$/ { exit }+ { previous = $0 }+' "$PHASES/11-services.sh")"+[[ "$p11_helpers" == *'_phase11_old_llama_stuck() {'* && "$p11_removal" == ' if _phase11_vllm_engine; then'* ]] \+ || fail "phase 11's removal of the old llama-server was not found"+removal_line="$(grep -n '^ # A rerun that moves a llama.cpp installation to the vLLM engine leaves$' "$PHASES/11-services.sh" | cut -d: -f1)"+launch_line="$(grep -n 'up -d --remove-orphans --no-build --pull never >> "$LOG_FILE" 2>&1 &$' "$PHASES/11-services.sh" | head -1 | cut -d: -f1)"+(( removal_line < launch_line )) || fail "the old llama-server must be removed before the containers launch"+remove_old() {+ local name="$1" rc=0 dir="$tmp/p11c-$1"+ shift+ mkdir -p "$dir"+ : > "$dir/calls"+ {+ printf '%s\n' 'set -euo pipefail'+ printf 'LOG_FILE=%q\nSTATE=%q\n' "$dir/install.log" "$dir"+ cat <<'EOF'+ai() { printf 'AI %s\n' "$*"; }+ai_ok() { printf 'OK %s\n' "$*"; }+ai_bad() { printf 'BAD %s\n' "$*"; }+fake_compose() {+ printf '%s\n' "$*" >> "$STATE/calls"+ case " $* " in+ *" ps -a -q llama-server "*) [[ ! -f "$STATE/container" ]] || cat "$STATE/container" ;;+ *" rm --stop --force llama-server "*)+ [[ "${FAKE_RM:-ok}" != fail ]] || return 1+ [[ "${FAKE_RM:-ok}" == keeps ]] || rm -f "$STATE/container"+ ;;+ *) return 97 ;;+ esac+}+DOCKER_COMPOSE_CMD=fake_compose+COMPOSE_FLAGS_ARR=(-f docker-compose.base.yml -f docker-compose.vllm.yml)+_phase11_vllm_engine() { [[ "$LLM_BACKEND" == vllm ]]; }+EOF+ printf '%s\n' "$@" "$p11_helpers" "$p11_removal" 'printf "LAUNCH\n"'+ } > "$dir/run.bash"+ bash "$dir/run.bash" > "$dir/out" 2>&1 || rc=$?+ printf '%s\n' "$rc" > "$dir/rc"+}+old_container='printf "%s\n" 0123abcd4567 > "$STATE/container"'+remove_old present 'LLM_BACKEND=vllm' "$old_container"+[[ "$(cat "$tmp/p11c-present/rc")" == 0 ]] && grep -qx 'LAUNCH' "$tmp/p11c-present/out" \+ && grep -qx -- '--profile local-inference -f docker-compose.base.yml -f docker-compose.vllm.yml rm --stop --force llama-server' \+ "$tmp/p11c-present/calls" \+ && grep -qx 'OK Removed the previous llama-server container; its models stay in data/models' "$tmp/p11c-present/out" \+ || fail "a rerun moving to vLLM must stop and remove the old llama-server: $(cat "$tmp/p11c-present/out" "$tmp/p11c-present/calls")"+remove_old absent 'LLM_BACKEND=vllm'+[[ "$(cat "$tmp/p11c-absent/rc")" == 0 ]] && grep -qx 'LAUNCH' "$tmp/p11c-absent/out" \+ && ! grep -q ' rm ' "$tmp/p11c-absent/calls" && ! grep -q '^OK' "$tmp/p11c-absent/out" \+ || fail "a fresh vLLM install has no llama-server to remove and says nothing: $(cat "$tmp/p11c-absent/out")"+remove_old rm-fails 'LLM_BACKEND=vllm' "$old_container" 'export FAKE_RM=fail'+remove_old rm-keeps 'LLM_BACKEND=vllm' "$old_container" 'export FAKE_RM=keeps'+for name in rm-fails rm-keeps; do+ [[ "$(cat "$tmp/p11c-$name/rc")" != 0 ]] && ! grep -qx 'LAUNCH' "$tmp/p11c-$name/out" \+ && grep -q '^BAD The previous llama-server container could not be removed' "$tmp/p11c-$name/out" \+ && grep -q 'docker rm -f ods-llama-server, then run the same install command again' "$tmp/p11c-$name/out" \+ && grep -q 'discord.gg' "$tmp/p11c-$name/out" \+ || fail "$name: a llama-server that stays must stop the install with what to do: $(cat "$tmp/p11c-$name/out")"+done+remove_old llama 'LLM_BACKEND=llama-server' "$old_container"+[[ "$(cat "$tmp/p11c-llama/rc")" == 0 && ! -s "$tmp/p11c-llama/calls" ]] \+ || fail "the llama.cpp route must leave its llama-server alone: $(cat "$tmp/p11c-llama/calls")"+pass "a rerun that moves to vLLM stops and removes the old llama-server before the launch, and stops when it stays"++fi++# ── 12: the wait for vllm-server and the model route ──────────────────────+if only 12; then+phase12_fns="$(awk '+ /^_phase12_env_get\(\) \{$/ || /^_phase12_curl_bearer\(\) \{$/ { emit = 1 }+ /^# The vLLM engine \(LLM_BACKEND=vllm\) runs in ods-vllm-server/ { emit = 1 }+ /^# Core service health checks/ { exit }+ emit { print }+ emit && /^}$/ && !vllm { emit = 0 }+ /^# The vLLM engine \(LLM_BACKEND=vllm\) runs in ods-vllm-server/ { vllm = 1 }+' "$PHASES/12-health.sh")"+[[ "$phase12_fns" == *'_phase12_verify_vllm_route() {'* && "$phase12_fns" == *'_phase12_curl_bearer() {'* ]] \+ || fail "phase 12's vLLM functions were not found"+cat > "$fakebin/fake-docker" <<'EOF'+#!/usr/bin/env bash+case "$1" in+ inspect)+ count=$(( $(cat "$FAKE_DOCKER_COUNT") + 1 ))+ printf '%s' "$count" > "$FAKE_DOCKER_COUNT"+ state="$(sed -n "${count}p" "$FAKE_DOCKER_STATES")"+ [[ -n "$state" ]] || state="$(tail -n 1 "$FAKE_DOCKER_STATES")"+ [[ "$state" == missing ]] && { echo "Error: No such object: ods-vllm-server" >&2; exit 1; }+ printf '%s\n' "$state"+ ;;+ logs) printf 'vLLM: torch.OutOfMemoryError: CUDA out of memory\n' ;;+ *) exit 97 ;;+esac+EOF+cat > "$fakebin/curl" <<'EOF'+#!/usr/bin/env bash+out="" header=""+while (( $# > 0 )); do+ case "$1" in+ -o) out="$2"; shift 2 ;;+ -H) [[ "$2" == @* ]] && header="$(cat "${2#@}")"; shift 2 ;;+ -w|-X|-d|--max-time) shift 2 ;;+ *) shift ;;+ esac+done+printf '%s\n' "$header" >> "$FAKE_CURL_HEADERS"+count=$(( $(cat "$FAKE_CURL_COUNT") + 1 ))+printf '%s' "$count" > "$FAKE_CURL_COUNT"+reply="$(sed -n "${count}p" "$FAKE_CURL_REPLIES")"+[[ -n "$reply" ]] || reply="$(tail -n 1 "$FAKE_CURL_REPLIES")"+printf '%s' "${reply#*|}" > "$out"+printf '%s' "${reply%%|*}"+EOF+chmod +x "$fakebin/fake-docker" "$fakebin/curl"+health() {+ local name="$1" call="$2" rc=0 dir="$tmp/p12-$1"+ mkdir -p "$dir"+ cat > "$dir/states"+ {+ printf '%s\n' 'set -euo pipefail'+ printf 'INSTALL_DIR=%q\nLOG_FILE=%q\nDOCKER_CMD=%q\n' "$dir" "$dir/install.log" "$fakebin/fake-docker"+ printf 'export FAKE_DOCKER_STATES=%q FAKE_DOCKER_COUNT=%q\n' "$dir/states" "$dir/docker-count"+ printf 'export FAKE_CURL_REPLIES=%q FAKE_CURL_COUNT=%q FAKE_CURL_HEADERS=%q\n' "$dir/replies" "$dir/curl-count" "$dir/headers"+ printf 'ODS_PYTHON_CMD=%q\n' "$PYTHON_CMD"+ cat <<'EOF'+declare -A SERVICE_PORTS=([litellm]=4000)+LLM_BACKEND=vllm VLLM_SERVED_MODEL=Qwen3.8-Flash-Next-NVFP4 LITELLM_KEY=sk-ods-route-key+ODS_VLLM_POLL_SECONDS=0 ODS_VLLM_READY_TIMEOUT_SECONDS=3 ODS_VLLM_ROUTE_TIMEOUT_SECONDS=3+RED='' BGRN='' NC=''+ai() { printf 'AI %s\n' "$*"; }+ai_bad() { printf 'BAD %s\n' "$*"; }+ui_status_line() { printf 'STATUS %s %s\n' "$1" "$2"; }+spin_task() { local rc=0; wait "$1" || rc=$?; printf 'SPIN %s | %s\n' "$2" "$("$5")"; return "$rc"; }+EOF+ printf '%s\n' "$phase12_fns" "$call" 'printf "RETURNED\n"'+ } > "$dir/run.bash"+ : > "$dir/replies"+ printf '0' > "$dir/docker-count"+ printf '0' > "$dir/curl-count"+ [[ -z "${REPLIES:-}" ]] || printf '%b' "$REPLIES" > "$dir/replies"+ bash "$dir/run.bash" >"$dir/out" 2>"$dir/err" || rc=$?+ printf '%s\n' "$rc" > "$dir/rc"+}+p12_ok() { [[ "$(cat "$tmp/p12-$1/rc")" == 0 ]] && grep -q '^RETURNED$' "$tmp/p12-$1/out"; }+p12_stopped() {+ local name="$1" cause="$2"+ [[ "$(cat "$tmp/p12-$name/rc")" != 0 ]] && ! grep -q '^RETURNED$' "$tmp/p12-$name/out" \+ && grep -qF "BAD $cause" "$tmp/p12-$name/out" \+ && grep -q '^AI Need help? Ask on the ODS Discord: https://discord.gg/4ntNp9MAwC$' "$tmp/p12-$name/out" \+ || fail "$name: expected a stop with '$cause' and the Discord link: $(cat "$tmp/p12-$name/out" "$tmp/p12-$name/err")"+}++printf '%s\n' 'running 0 starting' 'running 0 starting' 'running 0 healthy' | health healthy _phase12_wait_for_vllm+p12_ok healthy && grep -q '^STATUS ok vLLM engine ready (Qwen3.8-Flash-Next-NVFP4)$' "$tmp/p12-healthy/out" \+ || fail "a healthy vllm-server must be reported ready: $(cat "$tmp/p12-healthy/out" "$tmp/p12-healthy/err")"+grep -q '^SPIN Loading Qwen3.8-Flash-Next-NVFP4 into GPU memory | a first start reads the weights and compiles kernels$' "$tmp/p12-healthy/out" \+ && grep -q 'compiles kernels before it answers; later starts are faster' "$tmp/p12-healthy/out" \+ || fail "the wait must explain the first start calmly: $(cat "$tmp/p12-healthy/out")"+if grep -qi 'fail\|error' "$tmp/p12-healthy/out"; then+ fail "waiting must not show error-looking text: $(cat "$tmp/p12-healthy/out")"+fi+printf '%s\n' 'running 3 starting' 'running 3 healthy' | health old-restarts _phase12_wait_for_vllm+p12_ok old-restarts || fail "restarts from before this wait must not count: $(cat "$tmp/p12-old-restarts/out")"+pass "phase 12 waits calmly for vllm-server's health check"++printf '%s\n' 'running 0 starting' 'exited 0 unhealthy' | health exited _phase12_wait_for_vllm+p12_stopped exited 'The vLLM container stopped before the model was ready (container exited).'+grep -q 'docker logs --tail 100 ods-vllm-server' "$tmp/p12-exited/out" \+ && grep -q 'CUDA out of memory' "$tmp/p12-exited/install.log" \+ || fail "a stopped engine must say how to read its log and save the log to the install log"+printf '%s\n' 'running 0 starting' 'restarting 1 starting' | health restarted _phase12_wait_for_vllm+p12_stopped restarted 'vLLM stopped while loading the model, and Docker restarted it.'+printf '%s\n' 'running 0 unhealthy' | health unhealthy _phase12_wait_for_vllm+p12_stopped unhealthy "vLLM's health check failed."+printf '%s\n' 'missing' | health missing _phase12_wait_for_vllm+p12_stopped missing 'The vLLM container stopped before the model was ready (container missing).'+printf '%s\n' 'running 0 starting' | health slow _phase12_wait_for_vllm+p12_stopped slow 'vLLM did not finish loading Qwen3.8-Flash-Next-NVFP4 within'+pass "phase 12 stops with the cause, the next step and the Discord link when vLLM exits, restarts, fails or is slow"++REPLIES='503|{"error":"no verified route"}\n503|{"error":"no verified route"}\n200|{"choices":[{"message":{"role":"assistant","content":"OK"}}]}\n'+printf 'running 0 healthy\n' | health route _phase12_verify_vllm_route+p12_ok route && grep -q '^STATUS ok Model route verified: ods/current answers through model-router (vLLM)$' "$tmp/p12-route/out" \+ || fail "an answer through model-router must verify the route: $(cat "$tmp/p12-route/out" "$tmp/p12-route/err")"+[[ "$(cat "$tmp/p12-route/curl-count")" == 3 ]] && grep -qx 'Authorization: Bearer sk-ods-route-key' "$tmp/p12-route/headers" \+ || fail "the route check must retry until an answer, with LiteLLM's key"+if grep -qi 'fail\|error' "$tmp/p12-route/out"; then+ fail "the route check must stay calm while it waits: $(cat "$tmp/p12-route/out")"+fi+REPLIES='200|{"choices":[{"message":{"role":"assistant","content":null,"reasoning_content":"The user wants OK."},"finish_reason":"length"}]}\n'+printf 'running 0 healthy\n' | health reasoning _phase12_verify_vllm_route+p12_ok reasoning || fail "a reasoning-only first answer still proves the route: $(cat "$tmp/p12-reasoning/out")"+REPLIES='200|{"choices":[{"message":{"role":"assistant","content":""}}]}\n'+printf 'running 0 healthy\n' | health empty _phase12_verify_vllm_route+p12_stopped empty 'vLLM is running, but Qwen3.8-Flash-Next-NVFP4 did not answer through LiteLLM and model-router within 0 minutes (last HTTP status 200).'+grep -q 'vLLM model route check, last reply (HTTP 200)' "$tmp/p12-empty/install.log" || fail "the last reply must be saved to the install log"+REPLIES='503|{"error":"no verified route"}\n'+printf 'running 0 healthy\n' | health no-route _phase12_verify_vllm_route+p12_stopped no-route 'vLLM is running, but Qwen3.8-Flash-Next-NVFP4 did not answer through LiteLLM and model-router'+grep -qF '(last HTTP status 503).' "$tmp/p12-no-route/out" || fail "a route that never answers must name its last HTTP status"+unset REPLIES+pass "phase 12 confirms the model answers through model-router, and explains a route that never answers"++# Phase 12's model-server dispatch and llama-server pre-warm, run with stubs.+dispatch_block="$(awk '/^if _phase12_external_llm; then$/ { emit = 1 } emit { print } emit && /^fi$/ { exit }' "$PHASES/12-health.sh")"+prewarm_block="$(awk '/^if \[\[ "\$\{ODS_MODE:-local\}" == "cloud" \]\] \|\| _phase12_host_native_llm \|\| _phase12_external_llm; then$/ { emit = 1 } emit { print } emit && /^fi$/ { exit }' "$PHASES/12-health.sh")"+[[ -n "$dispatch_block" && -n "$prewarm_block" ]] || fail "phase 12's model-server checks were not found"+dispatch() (+ exec 3>&1 # the pre-warm sends curl's output to /dev/null; the stub reports on fd 3+ ods_progress() { :; }; ai() { :; }; ai_ok() { :; }; ai_warn() { :; }; log() { :; }+ sr_container() { printf 'ods-x\n'; }+ _phase12_external_llm() { return 1; }+ _phase12_host_native_llm() { return 1; }+ _phase12_vllm_engine() { [[ "$route" == vllm ]]; }+ _phase12_wait_for_vllm() { printf 'WAIT_VLLM\n'; }+ _phase12_verify_vllm_route() { printf 'ROUTE_VLLM\n'; }+ _check_health() { printf 'CHECK %s\n' "$1"; }+ curl() { printf 'PREWARM\n' >&3; }+ declare -A SERVICE_PORTS=() SERVICE_HEALTH=()+ ODS_MODE=local INSTALL_DIR="$tmp/p12-dispatch" GGUF_FILE=Q.gguf LLM_MODEL=q route="$1"+ eval "$dispatch_block"+ eval "$prewarm_block"+)+[[ "$(dispatch vllm)" == "$(printf '%s\n' WAIT_VLLM ROUTE_VLLM)" ]] \+ || fail "the vLLM route must wait on vllm-server and its model route, not llama-server: $(dispatch vllm)"+[[ "$(dispatch llama)" == "$(printf '%s\n' 'CHECK llama-server' PREWARM)" ]] \+ || fail "the llama.cpp route must keep its llama-server wait and pre-warm: $(dispatch llama)"+pass "phase 12 waits on vllm-server and its route instead of llama-server on the vLLM route"++fi++# ── 13: the summary names the engine and the model ────────────────────────+if only 13; then+summary_api="$(awk '/^if \[\[ -n "\$\{EXTERNAL_LLM_URL:-\}" \|\| "\$\{ODS_MODE:-local\}" == "cloud"/ { emit = 1 } emit { print } emit && /^fi$/ { exit }' "$PHASES/13-summary.sh")"+summary_model="$(awk '/^if \[\[ "\$\{ODS_GATEWAY_ONLY:-false\}" == true \]\]; then$/ { emit = 1 } emit { print } emit && /^fi$/ { exit }' "$PHASES/13-summary.sh")"+summary_json="$(awk '/^if \[\[ -n "\$SUMMARY_JSON_FILE" \]\]; then$/ { emit = 1 } emit { print }' "$PHASES/13-summary.sh")"+[[ -n "$summary_api" && -n "$summary_model" && -n "$summary_json" ]] || fail "phase 13's summary blocks were not found"+shown="$(+ declare -A SERVICE_PORTS=([litellm]=4000 [llama-server]=11434)+ LLM_BACKEND=vllm VLLM_GPU_UUID="$GB300" VLLM_SERVED_MODEL=Qwen3.8-Flash-Next-NVFP4+ LLM_MODEL=qwen3.8-flash-next-nvfp4 MAX_CONTEXT=131072+ eval "$summary_api"+ eval "$summary_model"+)"+grep -qF ' • LLM API: http://localhost:4000/v1 (LiteLLM gateway to the vLLM engine)' <<< "$shown" \+ && grep -qF " • Engine: vLLM on GPU $GB300" <<< "$shown" \+ && grep -qF ' • Model: Qwen3.8-Flash-Next-NVFP4 (qwen3.8-flash-next-nvfp4, 131072 tokens of context)' <<< "$shown" \+ || fail "the summary must name the vLLM engine and its model: $shown"+shown="$(+ declare -A SERVICE_PORTS=([litellm]=4000 [llama-server]=11434)+ LLM_BACKEND=llama-server LLM_MODEL=qwen3.6-27b+ eval "$summary_api"+ eval "$summary_model"+)"+[[ "$shown" == "$(printf '%s\n' ' • LLM API: http://localhost:11434/v1 (llama-server)' ' • Model: qwen3.6-27b')" ]] \+ || fail "the llama.cpp summary must stay as it was: $shown"+(+ SCRIPT_DIR="$ROOT_DIR" SUMMARY_JSON_FILE="$tmp/summary.json" VERSION=3.0.0 INSTALL_DIR="$tmp" TIER=NV_ULTRA+ TIER_NAME=Ultra GPU_BACKEND=nvidia LLM_MODEL=qwen3.8-flash-next-nvfp4 COMPOSE_FLAGS="" DRY_RUN=false+ PREFLIGHT_REPORT_FILE="" LLM_BACKEND=vllm+ eval "$summary_json" >/dev/null+)+[[ "$(jq -r '.runtime.backend_service' "$tmp/summary.json")" == vllm-server ]] \+ || fail "the summary JSON must name vllm-server as the model server"+pass "phase 13 names the vLLM engine, its GPU and its model, and the llama.cpp summary is unchanged"+fi++# ── pixel: the model the Portal binds and its thinking default ────────────+if only pixel; then+# pixel_case NAME [ASSIGNMENT...]: write Pixel's onboarding contract with the+# renderer replaced by a recorder; NAME/render-args holds its arguments.+pixel_case() {+ local name="$1" rc=0 dir="$tmp/pixel-$1"+ shift+ mkdir -p "$dir/home"+ {+ printf '%s\n' 'set -euo pipefail'+ printf 'ROOT_DIR=%q\nSTATE=%q\n' "$ROOT_DIR" "$dir"+ cat <<'EOF'+source "$ROOT_DIR/installers/lib/pixel-host-install.sh"+SCRIPT_DIR="$ROOT_DIR"+ai_bad() { printf 'BAD %s\n' "$*"; }+ods_pixel_run_as_owner() {+ shift 2+ case "$1" in+ python3) printf '%s\n' "$@" > "$STATE/render-args" ;;+ mktemp) printf '%s\n' "$STATE/relay-key" ;;+ tee) cat > "$STATE/relay-key" ;;+ esac+}+PIXEL_MODEL_RELAY_KEY=sk-ods-relay MAX_CONTEXT=131072 ODS_MODEL_SWITCHBOARD=enabled EXTERNAL_LLM_URL=""+EOF+ printf '%s\n' "$@"+ printf '%s\n' '_ods_pixel_write_onboarding owner "$STATE/home" "$STATE/home/onboarding.json" /usr/bin/openclaw /opt/ods/pixel-plugin digest'+ } > "$dir/run.bash"+ bash "$dir/run.bash" > "$dir/out" 2>&1 || rc=$?+ printf '%s\n' "$rc" > "$dir/rc"+}+# The renderer's arguments after python3: 2 renderer ... 6 model, 9 reasoning.+rendered() {+ [[ "$(cat "$tmp/pixel-$1/rc")" == 0 ]] || fail "$1: Pixel onboarding failed: $(cat "$tmp/pixel-$1/out")"+ sed -n "$2p" "$tmp/pixel-$1/render-args"+}+qwen_vllm='LLM_BACKEND=vllm LLM_MODEL=qwen3.8-flash-next-nvfp4 VLLM_SERVED_MODEL=Qwen3.8-Flash-Next-NVFP4 GGUF_FILE=""'+pixel_case vllm "$qwen_vllm"+[[ "$(rendered vllm 6)" == Qwen3.8-Flash-Next-NVFP4 && "$(rendered vllm 9)" == bootstrap ]] \+ || fail "on vLLM Pixel must bind the served id and start thinking on (medium): $(cat "$tmp/pixel-vllm/render-args")"+pixel_case vllm-llama-off "$qwen_vllm" 'export LLAMA_REASONING=off'+[[ "$(rendered vllm-llama-off 9)" == bootstrap ]] || fail "llama-server's LLAMA_REASONING must not decide vLLM's thinking"+pixel_case vllm-glm 'LLM_BACKEND=vllm LLM_MODEL=glm-5.3-flash-nvfp4 VLLM_SERVED_MODEL=GLM-5.3-Flash-NVFP4 GGUF_FILE=""'+[[ "$(rendered vllm-glm 6)" == GLM-5.3-Flash-NVFP4 && "$(rendered vllm-glm 9)" == bootstrap ]] \+ || fail "GLM-5.3 on vLLM must bind its served id with thinking on"+mkdir -p "$tmp/pixel-off-root/config"+python3 - "$ROOT_DIR/config/model-library.json" "$tmp/pixel-off-root/config/model-library.json" <<'PY'+import json, sys+data = json.load(open(sys.argv[1], encoding="utf-8"))+for model in data["models"]:+ if model.get("id") == "qwen3.8-flash-next-nvfp4-vllm":+ model["reasoning"] = "off"+json.dump(data, open(sys.argv[2], "w", encoding="utf-8"))+PY+pixel_case vllm-off "$qwen_vllm" "SCRIPT_DIR='$tmp/pixel-off-root'"+[[ "$(rendered vllm-off 9)" == default ]] || fail "a vLLM model whose thinking default is off must start with thinking off"+pixel_case vllm-unknown 'LLM_BACKEND=vllm LLM_MODEL=not-a-catalog-model VLLM_SERVED_MODEL=X GGUF_FILE=""'+[[ "$(cat "$tmp/pixel-vllm-unknown/rc")" != 0 && ! -e "$tmp/pixel-vllm-unknown/render-args" ]] \+ && grep -q '^BAD Pixel could not read the thinking default of not-a-catalog-model' "$tmp/pixel-vllm-unknown/out" \+ && grep -q 'discord.gg' "$tmp/pixel-vllm-unknown/out" \+ || fail "a vLLM model outside the catalog must stop Pixel's setup with what to do: $(cat "$tmp/pixel-vllm-unknown/out")"+pixel_case vllm-unnamed 'LLM_BACKEND=vllm LLM_MODEL=qwen3.8-flash-next-nvfp4 VLLM_SERVED_MODEL="" GGUF_FILE=""'+[[ "$(cat "$tmp/pixel-vllm-unnamed/rc")" != 0 && ! -e "$tmp/pixel-vllm-unnamed/render-args" ]] \+ || fail "Pixel must not bind a vLLM route without its served id"+pixel_case llama 'LLM_BACKEND=llama-server LLM_MODEL=qwen3.6-35b GGUF_FILE=Qwen3.6-35B-A3B-UD-Q4_K_M.gguf'+[[ "$(rendered llama 6)" == Qwen3.6-35B-A3B-UD-Q4_K_M.gguf && "$(rendered llama 9)" == default ]] \+ || fail "llama.cpp must keep binding the GGUF name with the no-think default"+pixel_case llama-on 'LLM_BACKEND=llama-server LLM_MODEL=qwen3.6-35b GGUF_FILE=Qwen3.6-35B-A3B-UD-Q4_K_M.gguf' \+ 'export LLAMA_REASONING=on'+[[ "$(rendered llama-on 9)" == true ]] || fail "LLAMA_REASONING must still decide llama.cpp's thinking"+pass "Pixel binds vLLM's served id and starts from the catalog's thinking default; llama.cpp is unchanged"+fi++printf '\nResult: %d passed, 0 failed\n' "$PASS"diff --git a/ods/tests/test-vllm-installer-route.sh b/ods/tests/test-vllm-installer-route.shnew file mode 100644index 000000000..0ad2794b7--- /dev/null+++ b/ods/tests/test-vllm-installer-route.sh@@ -0,0 +1,620 @@+#!/usr/bin/env bash+# The Linux installer's model server choice (llama.cpp or the vLLM engine).+#+# - install-core parses --llm-backend vllm|llama-server;+# - installers/lib/llm-backend.sh names every route that cannot run vLLM;+# - phase 02's real decision, with the real selector and catalog and a fake+# nvidia-smi: a vLLM model that fits picks vLLM, nothing fitting keeps+# llama.cpp untouched, --llm-backend vllm stops when nothing fits,+# --llm-backend llama-server never looks, WSL, macOS, AMD, cloud, hybrid,+# external, host-native and gateway-only routes never use vLLM, a rerun of+# a llama.cpp install keeps llama.cpp, and every selector failure other+# than "nothing fits" stops the install;+# - a rerun of a vLLM install keeps the vLLM engine and its installed model+# (scripts/preserve-active-model.py's contract, faked here) and stops,+# never falling back to llama.cpp, when the model cannot be kept, vLLM+# cannot run (cloud mode included) or nothing fits; only --llm-backend+# llama-server or --reselect-model chooses again;+# - the vLLM pick replaces the tier map's GGUF and loads the VLLM_* keys;+# - exporting this run's LLM_BACKEND leaves every other resolver selection+# byte-identical, and the fast-start bootstrap GGUF is never used on vLLM.+# Needs no Docker daemon and no GPU.+set -euo pipefail++ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"+CORE="$ROOT_DIR/install-core.sh"+PHASE02="$ROOT_DIR/installers/phases/02-detection.sh"+PASS=0+fail() { printf '[FAIL] %s\n' "$*" >&2; exit 1; }+pass() { printf '[PASS] %s\n' "$*"; PASS=$((PASS + 1)); }+# ODS_TEST_SECTION=N runs only section N (a quick rerun while editing).+only() { [[ -z "${ODS_TEST_SECTION:-}" || "$ODS_TEST_SECTION" == "$1" ]]; }++tmp="$(mktemp -d)"+trap 'rm -rf "$tmp"' EXIT+# shellcheck source=../installers/lib/llm-backend.sh+source "$ROOT_DIR/installers/lib/llm-backend.sh"+pinned="$(ods_vllm_image_from_lock "$ROOT_DIR/config/dependency-lock.json")"++extract() {+ local text+ text="$(sed -n "$1" "$2")"+ [[ -n "$text" ]] || fail "installer block not found: $1 in $2"+ printf '%s\n' "$text"+}++# ── 1. install-core parses --llm-backend ───────────────────────────────────+if only 1; then+parser="$(extract '/^while \[\[ \$# -gt 0 \]\]; do$/,/^done$/p' "$CORE")"+grep -q '^LLM_BACKEND_REQUESTED=""$' "$CORE" || fail "install-core must default to the automatic choice"+parse() (+ LLM_BACKEND_REQUESTED=""+ eval "$parser"+ printf '%s\n' "$LLM_BACKEND_REQUESTED"+)+[[ "$(parse --llm-backend vllm)" == vllm ]] || fail "--llm-backend vllm was not parsed"+[[ "$(parse --llm-backend llama-server --non-interactive)" == llama-server ]] \+ || fail "--llm-backend llama-server was not parsed"+[[ "$(parse --non-interactive)" == "" ]] || fail "no flag must leave the choice to phase 02"+for bad in auto lemonade '' --pixel; do+ rc=0+ parse --llm-backend "$bad" >"$tmp/out" 2>"$tmp/err" || rc=$?+ [[ "$rc" -ne 0 ]] && grep -q -- '--llm-backend requires vllm or llama-server' "$tmp/err" \+ || fail "--llm-backend '$bad' must be refused (rc=$rc): $(cat "$tmp/out" "$tmp/err")"+done+grep -qF -- '--llm-backend vllm|llama-server' "$CORE" || fail "install-core --help must document --llm-backend"+pass "install-core parses --llm-backend vllm|llama-server and refuses anything else"++macos_parser="$(extract '/^while \[\[ \$# -gt 0 \]\]; do$/,/^done$/p' "$ROOT_DIR/installers/macos/install-macos.sh")"+macos_parse() ( eval "$macos_parser"; printf 'parsed\n' )+[[ "$(macos_parse --llm-backend llama-server)" == parsed ]] || fail "macOS must accept --llm-backend llama-server"+rc=0+macos_parse --llm-backend vllm >"$tmp/out" 2>"$tmp/err" || rc=$?+[[ "$rc" -ne 0 ]] && grep -q 'needs Linux with an NVIDIA datacenter GPU' "$tmp/err" && grep -q 'discord.gg' "$tmp/err" \+ || fail "macOS must refuse --llm-backend vllm with the reason and the Discord link"+pass "the macOS installer accepts llama-server and refuses vllm with a reason"++# The command shown after the one-time Secure Boot key reboot resumes with+# the same --llm-backend choice.+resume_block="$(extract '/^ local resume_args=""$/,/^ local resume_command=/p' "$ROOT_DIR/installers/lib/detection.sh")"+resume_command() (+ ENABLE_VOICE=false ENABLE_WORKFLOWS=false ENABLE_RAG=false ENABLE_HERMES=false TIER="" OFFLINE_MODE=false+ ODS_RESELECT_MODEL=false SCRIPT_DIR=/opt/ods LLM_BACKEND_REQUESTED=""+ eval "$1"+ eval "resume() {+$resume_block+printf '%s\n' \"\$resume_command\"+}"+ resume+)+[[ "$(resume_command 'LLM_BACKEND_REQUESTED=vllm')" == 'cd "/opt/ods" && ./install.sh --llm-backend vllm' \+ && "$(resume_command 'LLM_BACKEND_REQUESTED=llama-server ODS_RESELECT_MODEL=true')" \+ == 'cd "/opt/ods" && ./install.sh --reselect-model --llm-backend llama-server' \+ && "$(resume_command ':')" == 'cd "/opt/ods" && ./install.sh' ]] \+ || fail "the Secure Boot resume command must keep --llm-backend: $(resume_command 'LLM_BACKEND_REQUESTED=vllm')"+pass "the Secure Boot resume command keeps the --llm-backend choice"++fi++# ── 2. The route rule ───────────────────────────────────────────────────────+if only 2; then+blocker() { ods_vllm_route_blocker "$@"; }+[[ -z "$(blocker Linux false nvidia local "" "" false)" ]] || fail "Linux NVIDIA local must allow vLLM"+check_blocked() {+ local expected="$1" reason+ shift+ reason="$(blocker "$@")"+ [[ "$reason" == *"$expected"* ]] || fail "route $* must be refused with '$expected', got '$reason'"+}+check_blocked 'only on Linux' Darwin false nvidia local "" "" false+check_blocked 'WSL' Linux true nvidia local "" "" false+check_blocked 'cloud mode' Linux false nvidia cloud "" "" false+check_blocked 'ODS_MODE=hybrid, and the vLLM engine runs only in local mode' Linux false nvidia hybrid "" "" false+check_blocked 'ODS_MODE=lemonade' Linux false nvidia lemonade "" "" false+check_blocked 'external model server (http://10.0.0.5:11434)' Linux false nvidia local http://10.0.0.5:11434 "" false+check_blocked 'host-native llama-server (http://localhost:8080)' Linux false nvidia local "" http://localhost:8080 false+check_blocked 'gateway-only' Linux false nvidia local "" "" true+for backend in amd cpu apple intel sycl jetson; do+ check_blocked "GPU backend is $backend" Linux false "$backend" local "" "" false+done+pass "vLLM is refused on macOS, WSL, cloud, hybrid, external, host-native, gateway-only and every non-NVIDIA backend"++ods_vllm_auto_considered false "" false || fail "a fresh install must consider vLLM"+ods_vllm_auto_considered true vllm false || fail "a rerun of a vLLM install must consider vLLM"+ods_vllm_auto_considered true llama-server true || fail "--reselect-model must consider vLLM"+! ods_vllm_auto_considered true llama-server false || fail "a rerun of a llama.cpp install must keep llama.cpp"+! ods_vllm_auto_considered true "" false || fail "a rerun of an older install must keep llama.cpp"+pass "without --llm-backend, only fresh installs, vLLM reruns and --reselect-model consider vLLM"++[[ "$pinned" =~ ^vllm/vllm-openai:v[0-9][^@]*@sha256:[0-9a-f]{64}$ ]] || fail "the vLLM image pin was not read: $pinned"+grep -qF "\${VLLM_IMAGE:-$pinned}" "$ROOT_DIR/docker-compose.vllm.yml" \+ || fail "the installer's VLLM_IMAGE must equal docker-compose.vllm.yml's default"+printf '{"entries":[{"id":"vllm.vllm-server","value":"vllm/vllm-openai:latest"}]}\n' > "$tmp/unpinned-lock.json"+! ods_vllm_image_from_lock "$tmp/unpinned-lock.json" >/dev/null || fail "an image without a digest must be refused"+pass "VLLM_IMAGE comes from the dependency lock's digest pin, the compose default"++fi++# ── 3. Phase 02's decision with the real selector and catalog ───────────────+if only 3; then+refused_fn="$(extract '/^_phase02_vllm_refused() {$/,/^}$/p' "$PHASE02")"+kept_fn="$(extract '/^_phase02_vllm_kept() {$/,/^}$/p' "$PHASE02")"+export_fn="$(extract '/^_phase02_export_llm_backend() {$/,/^}$/p' "$PHASE02")"+decision="$(extract '/^_phase02_choose_llm_backend() {$/,/^_phase02_export_llm_backend$/p' "$PHASE02")"+load_block="$(extract '/^# The vLLM pick replaces the tier map/,/^fi$/p' "$PHASE02")"+# Keeping a vLLM installation's model, active-model preservation and the+# report of the choice, which follows it.+keep_fns="$(extract '/^# A rerun of a vLLM installation whose model cannot be kept/,/^# The tier\/catalog result is a recommendation\./p' "$PHASE02")"+preservation="$(extract '/^# The tier\/catalog result is a recommendation\./,/^unset _native_python$/p' "$PHASE02")"+shown="$(extract '/^# The model server and the model it serves, now that preservation is final\.$/,/^fi$/p' "$PHASE02")"+grep -q '^LLM_BACKEND=llama-server$' "$PHASE02" || fail "phase 02 must start every run on llama-server"+# Cloud mode returns before the decision; leaving vLLM still exports the choice.+cloud_block="$(extract '/^if \[\[ "\${ODS_MODE:-local}" == "cloud" \]\]; then$/,/^ resolve_compose_config$/p' "$PHASE02")"+[[ "$cloud_block" == *'_phase02_export_llm_backend'* ]] \+ || fail "phase 02's cloud path must export the choice before resolving Compose"++fakebin="$tmp/bin"+mkdir -p "$fakebin"+cat > "$fakebin/nvidia-smi" <<'EOF'+#!/usr/bin/env bash+printf '%s\n' "$*" >> "$FAKE_NVIDIA_SMI_CALLS"+[[ "${FAKE_NVIDIA_SMI_FAIL:-false}" != true ]] || { echo "NVIDIA-SMI has failed" >&2; exit 9; }+printf '%b' "$FAKE_GPU_ROWS"+EOF+# Python for phase 02: scripts/preserve-active-model.py answers from the+# FAKE_PRESERVE_* settings (its vLLM contract lives on the runtime side);+# everything else, the real model selector included, runs on real Python.+cat > "$fakebin/python-shim" <<'EOF'+#!/usr/bin/env bash+if [[ "${1:-}" == */scripts/preserve-active-model.py ]]; then+ printf '%s\n' "${*:2}" >> "$FAKE_PRESERVE_CALLS"+ [[ -z "${FAKE_PRESERVE_STDERR:-}" ]] || printf '%s\n' "$FAKE_PRESERVE_STDERR" >&2+ [[ -z "${FAKE_PRESERVE_OUT:-}" ]] || printf '%b' "$FAKE_PRESERVE_OUT"+ exit "${FAKE_PRESERVE_STATUS:-0}"+fi+exec "$FAKE_REAL_PYTHON" "$@"+EOF+chmod +x "$fakebin/nvidia-smi" "$fakebin/python-shim"+real_python="$(SCRIPT_DIR="$ROOT_DIR"; source "$ROOT_DIR/installers/lib/model-selector.sh"; ods_model_selector_python)"+[[ -n "$real_python" ]] || fail "the real model selector needs Python"+DGX_ROWS='GPU-aaaaaaaa-gb300, 10.3, 256703\nGPU-bbbbbbbb-rtx6000, 12.0, 97887\n'+RTX_ROWS='GPU-cccccccc-4090, 8.9, 24564\n'++# decide NAME [VAR=value...]: run phase 02's decision, active-model+# preservation and the report in a fresh shell with the given inputs;+# NAME/{out,err,rc,calls,preserve-calls,install.log} hold the evidence.+decide() {+ local name="$1" rc=0 dir="$tmp/$1"+ shift+ mkdir -p "$dir/install"+ : > "$dir/calls"+ : > "$dir/preserve-calls"+ {+ printf '%s\n' 'set -euo pipefail'+ printf 'SCRIPT_DIR=%q\nINSTALL_DIR=%q\nLOG_FILE=%q\n' "$ROOT_DIR" "$dir/install" "$dir/install.log"+ printf 'export FAKE_NVIDIA_SMI_CALLS=%q PATH=%q\n' "$dir/calls" "$fakebin:$PATH"+ printf 'export FAKE_PRESERVE_CALLS=%q FAKE_REAL_PYTHON=%q FAKE_PYTHON_SHIM=%q\n' \+ "$dir/preserve-calls" "$real_python" "$fakebin/python-shim"+ cat <<'EOF'+source "$SCRIPT_DIR/lib/safe-env.sh"+source "$SCRIPT_DIR/installers/lib/external-services.sh"+source "$SCRIPT_DIR/installers/lib/model-selector.sh"+source "$SCRIPT_DIR/installers/lib/llm-backend.sh"+ods_model_selector_python() { printf '%s' "$FAKE_PYTHON_SHIM"; }+ods_native_llm_requested() { [[ -n "${NATIVE_LLM_BASE_URL:-}" ]]; }+log() { printf 'LOG %s\n' "$*" >> "$LOG_FILE"; }+ai_ok() { printf 'OK %s\n' "$*"; }+error() { printf 'ERROR %s\n' "$*" >&2; }+ods_is_wsl_host() { [[ "${FAKE_WSL:-false}" == true ]]; }+uname() { printf '%s\n' "${FAKE_KERNEL:-Linux}"; }+GPU_BACKEND=nvidia+ODS_MODE=local+HOST_ARCH=arm64+EXTERNAL_LLM_URL=""+NATIVE_LLM_BASE_URL=""+ODS_GATEWAY_ONLY=false+ODS_RESELECT_MODEL=false+LLM_BACKEND_REQUESTED=""+# The llama.cpp selector block (not run here) leaves its Python for preservation.+_selector_python="$FAKE_PYTHON_SHIM"+export FAKE_GPU_ROWS='GPU-aaaaaaaa-gb300, 10.3, 256703\nGPU-bbbbbbbb-rtx6000, 12.0, 97887\n'+EOF+ printf '%s\n' "$@"+ printf '%s\n' 'LLM_BACKEND=llama-server'+ printf '%s\n' "$refused_fn" "$kept_fn" "$export_fn" "$decision"+ # The tier map ran before the pick is loaded.+ printf '%s\n' 'LLM_MODEL=tier-model GGUF_FILE=tier.gguf GGUF_URL=https://example.invalid/tier.gguf GGUF_SHA256=abc'+ printf '%s\n' 'MAX_CONTEXT=32768 LLM_MODEL_SIZE_MB=20000'+ printf '%s\n' "$load_block" "$keep_fns" "$preservation" "$shown"+ cat <<'EOF'+printf 'BACKEND=%s\n' "$LLM_BACKEND"+printf 'EXPORTED=%s\n' "$(bash -c 'printf %s "${LLM_BACKEND:-}"')"+printf 'MODEL=%s\nGGUF_FILE=%s\nGGUF_URL=%s\nMAX_CONTEXT=%s\nSIZE_MB=%s\n' "$LLM_MODEL" "$GGUF_FILE" "$GGUF_URL" "$MAX_CONTEXT" "$LLM_MODEL_SIZE_MB"+printf 'VLLM_MODEL_DIR=%s\nVLLM_SERVED_MODEL=%s\nVLLM_GPU_UUID=%s\nVLLM_IMAGE=%s\nVLLM_ARGS=%s\n' \+ "${VLLM_MODEL_DIR:-}" "${VLLM_SERVED_MODEL:-}" "${VLLM_GPU_UUID:-}" "${VLLM_IMAGE:-}" "${VLLM_ARGS:-}"+printf 'VLLM_SHARE=%s\nSELECTION_SOURCE=%s\nRECOMMENDED=%s\n' \+ "${VLLM_GPU_MEMORY_UTILIZATION:-}" "${MODEL_SELECTION_SOURCE:-}" "${INSTALLER_RECOMMENDED_MODEL:-}"+EOF+ } > "$dir/run.bash"+ bash "$dir/run.bash" >"$dir/out" 2>"$dir/err" || rc=$?+ printf '%s\n' "$rc" > "$dir/rc"+}+value() { sed -n "s/^$2=//p" "$tmp/$1/out"; }+rc_of() { cat "$tmp/$1/rc"; }+calls() { wc -l < "$tmp/$1/calls" | tr -d ' '; }+preserve_calls() { wc -l < "$tmp/$1/preserve-calls" | tr -d ' '; }+# expect_llama NAME [EXPORTED]: llama.cpp with the tier map untouched. The+# environment stays as it was (nothing exported) unless the run leaves vLLM.+expect_llama() {+ local name="$1" exported="${2:-}"+ [[ "$(rc_of "$name")" == 0 ]] || fail "$name: the decision failed: $(cat "$tmp/$name/err")"+ [[ "$(value "$name" BACKEND)" == llama-server ]] || fail "$name: expected llama.cpp, got $(value "$name" BACKEND)"+ [[ "$(value "$name" EXPORTED)" == "$exported" ]] \+ || fail "$name: expected LLM_BACKEND '${exported}' in the environment, got '$(value "$name" EXPORTED)'"+ [[ "$(value "$name" MODEL)" == tier-model && "$(value "$name" GGUF_FILE)" == tier.gguf \+ && "$(value "$name" MAX_CONTEXT)" == 32768 && -z "$(value "$name" VLLM_GPU_UUID)" \+ && -z "$(value "$name" VLLM_IMAGE)" ]] \+ || fail "$name: the llama.cpp path must keep the tier map's model untouched: $(cat "$tmp/$name/out")"+}+expect_refused() {+ local name="$1" reason="$2"+ [[ "$(rc_of "$name")" != 0 ]] || fail "$name: --llm-backend vllm was accepted: $(cat "$tmp/$name/out")"+ grep -qF -- "--llm-backend vllm cannot be used here: " "$tmp/$name/err" && grep -qF -- "$reason" "$tmp/$name/err" \+ || fail "$name: expected the reason '$reason', got: $(cat "$tmp/$name/err")"+ grep -q 'discord.gg' "$tmp/$name/err" || fail "$name: the refusal must name the Discord help link"+}+# expect_kept_refused NAME REASON: a rerun of a vLLM install stopped instead+# of becoming a llama.cpp install, naming why and how to choose again.+expect_kept_refused() {+ local name="$1" reason="$2"+ [[ "$(rc_of "$name")" != 0 ]] || fail "$name: a rerun of a vLLM install left vLLM: $(cat "$tmp/$name/out")"+ grep -qF 'ERROR This installation runs its model on the vLLM engine, which this run cannot use: ' "$tmp/$name/err" \+ && grep -qF -- "$reason" "$tmp/$name/err" \+ && grep -qF -- 'rerun with --llm-backend llama-server, or with --reselect-model' "$tmp/$name/err" \+ || fail "$name: expected the kept-vLLM refusal naming '$reason', got: $(cat "$tmp/$name/err")"+ grep -q 'discord.gg' "$tmp/$name/err" || fail "$name: the refusal must name the Discord help link"+ [[ "$(preserve_calls "$name")" == 0 ]] || fail "$name: the model must not be read once the route is refused"+}++decide dgx-auto+[[ "$(rc_of dgx-auto)" == 0 ]] || fail "the DGX Station decision failed: $(cat "$tmp/dgx-auto/err")"+[[ "$(value dgx-auto BACKEND)" == vllm && "$(value dgx-auto EXPORTED)" == vllm ]] \+ || fail "the DGX Station must choose vLLM: $(cat "$tmp/dgx-auto/out")"+[[ "$(value dgx-auto VLLM_GPU_UUID)" == GPU-aaaaaaaa-gb300 ]] || fail "vLLM must own the GB300, not the RTX PRO 6000"+# The expected pick is the catalog's highest-priority vLLM entry that fits the GB300+# (model_vllm.rank_entries), so a priority change in the catalog needs no edit here.+read -r want_model want_served want_dir want_size < <("$real_python" - "$ROOT_DIR" <<'PY'+import json, sys+from pathlib import Path+root = Path(sys.argv[1])+sys.path.insert(0, str(root / "extensions/services/dashboard-api"))+from model_vllm import Gpu, model_dir_name, rank_entries+models = json.loads((root / "config/model-library.json").read_text(encoding="utf-8"))["models"]+best = rank_entries(models, [Gpu("GPU-aaaaaaaa-gb300", "10.3", 256703)])[0].model+print(best["llm_model_name"], best["served_model_name"], model_dir_name(best), best["size_mb"])+PY+)+want_size="${want_size%$'\r'}" # a Windows Python ends the line with CRLF+[[ -n "$want_model" ]] || fail "the catalog must hold a vLLM model that fits the GB300"+[[ "$(value dgx-auto MODEL)" == "$want_model" \+ && "$(value dgx-auto VLLM_SERVED_MODEL)" == "$want_served" \+ && "$(value dgx-auto VLLM_MODEL_DIR)" == "$want_dir" ]] \+ || fail "the DGX Station must get the highest-priority vLLM model ($want_model): $(cat "$tmp/dgx-auto/out")"+[[ -z "$(value dgx-auto GGUF_FILE)" && -z "$(value dgx-auto GGUF_URL)" && "$(value dgx-auto MAX_CONTEXT)" == 131072 \+ && "$(value dgx-auto SIZE_MB)" == "$want_size" ]] \+ || fail "the vLLM pick must replace the tier map's GGUF: $(cat "$tmp/dgx-auto/out")"+[[ "$(value dgx-auto VLLM_IMAGE)" == "$pinned" ]] || fail "VLLM_IMAGE must be the locked pin"+[[ "$(value dgx-auto VLLM_ARGS)" == *'--max-model-len 131072'* ]] || fail "VLLM_ARGS must carry the catalog arguments"+[[ "$(calls dgx-auto)" == 1 ]] && grep -qx -- '--query-gpu=uuid,compute_cap,memory.total --format=csv,noheader,nounits' "$tmp/dgx-auto/calls" \+ || fail "the decision must read each GPU's uuid, compute capability and memory once"+grep -qx "OK Model server: vLLM engine, serving $want_served on GPU GPU-aaaaaaaa-gb300" "$tmp/dgx-auto/out" \+ || fail "the choice must be shown: $(cat "$tmp/dgx-auto/out")"+pass "a fresh DGX Station install chooses vLLM on the GB300 with the catalog's top vLLM pick ($want_served)"++decide b200 "export FAKE_GPU_ROWS='GPU-dddddddd-b200, 10.0, 183359\n'"+[[ "$(value b200 BACKEND)" == vllm && "$(value b200 VLLM_GPU_UUID)" == GPU-dddddddd-b200 ]] \+ || fail "one B200 with room for a vLLM model must choose vLLM: $(cat "$tmp/b200/out" "$tmp/b200/err")"+pass "other datacenter Blackwell GPUs choose vLLM where a model fits"++decide rtx-auto "export FAKE_GPU_ROWS='$RTX_ROWS'"+expect_llama rtx-auto+grep -q 'LOG Model server: llama.cpp (no vLLM catalog model fits this host' "$tmp/rtx-auto/install.log" \+ || fail "the reason vLLM was not chosen must reach the install log"+[[ ! -s "$tmp/rtx-auto/err" ]] || fail "a host without a vLLM fit must not print anything: $(cat "$tmp/rtx-auto/err")"+decide spark-auto "export FAKE_GPU_ROWS='GPU-eeeeeeee-gb10, 12.1, [N/A]\n'"+expect_llama spark-auto+decide pro6000-auto "export FAKE_GPU_ROWS='GPU-ffffffff-rtx6000, 12.0, 97887\n'"+expect_llama pro6000-auto+pass "without a vLLM fit (RTX 4090, DGX Spark, RTX PRO 6000) the llama.cpp path is unchanged and quiet"++decide rtx-forced "export FAKE_GPU_ROWS='$RTX_ROWS'" 'LLM_BACKEND_REQUESTED=vllm'+expect_refused rtx-forced 'no vLLM catalog model fits this host'+grep -qF 'needs one GPU with compute capability 10.0 or 10.3' "$tmp/rtx-forced/err" \+ || fail "the forced refusal must say what a vLLM model needs"+pass "--llm-backend vllm without a fit stops and says what a vLLM model needs"++decide dgx-llama 'LLM_BACKEND_REQUESTED=llama-server'+expect_llama dgx-llama+[[ "$(calls dgx-llama)" == 0 ]] || fail "--llm-backend llama-server must not query the GPUs for vLLM"+pass "--llm-backend llama-server never considers vLLM, even where it fits"++for route in \+ "wsl|FAKE_WSL=true|this is WSL" \+ "macos|FAKE_KERNEL=Darwin|only on Linux" \+ "amd|GPU_BACKEND=amd|GPU backend is amd" \+ "cpu|GPU_BACKEND=cpu|GPU backend is cpu" \+ "cloud|ODS_MODE=cloud|cloud mode" \+ "hybrid|ODS_MODE=hybrid|runs only in local mode" \+ "external|EXTERNAL_LLM_URL=http://127.0.0.1:11434|external model server" \+ "native|NATIVE_LLM_BASE_URL=http://127.0.0.1:8080|host-native llama-server" \+ "gateway|ODS_GATEWAY_ONLY=true|gateway-only" \+ "no-catalog|ODS_DISABLE_CATALOG_MODEL_SELECTOR=true|ODS_DISABLE_CATALOG_MODEL_SELECTOR"; do+ IFS='|' read -r name assignment reason <<< "$route"+ decide "$name-auto" "$assignment"+ expect_llama "$name-auto"+ [[ "$(calls "$name-auto")" == 0 ]] || fail "$name: a route that cannot run vLLM must not query the GPUs"+ decide "$name-forced" "$assignment" 'LLM_BACKEND_REQUESTED=vllm'+ expect_refused "$name-forced" "$reason"+done+pass "WSL, macOS, AMD, CPU, cloud, hybrid, external, host-native, gateway-only and a disabled catalog never use vLLM"++retained() { printf '%s\n' "$@" > "$tmp/$name/install/.env"; }+name=rerun-llama; mkdir -p "$tmp/$name/install"; retained 'LLM_BACKEND=llama-server' 'GGUF_FILE=Qwen3.6-35B-A3B-UD-Q4_K_M.gguf'+decide rerun-llama+expect_llama rerun-llama+[[ "$(calls rerun-llama)" == 0 ]] || fail "a rerun of a llama.cpp install must not query the GPUs"+[[ "$(preserve_calls rerun-llama)" == 1 ]] && grep -q -- '--local-model$' "$tmp/rerun-llama/preserve-calls" \+ || fail "a rerun of a llama.cpp install must still preserve its active model"+name=rerun-reselect; mkdir -p "$tmp/$name/install"; retained 'LLM_BACKEND=llama-server'+decide rerun-reselect 'ODS_RESELECT_MODEL=true'+[[ "$(value rerun-reselect BACKEND)" == vllm ]] || fail "--reselect-model must let a rerun choose vLLM"+name=rerun-forced; mkdir -p "$tmp/$name/install"; retained 'LLM_BACKEND=llama-server' 'GGUF_FILE=Qwen3.6-35B-A3B-UD-Q4_K_M.gguf'+decide rerun-forced 'LLM_BACKEND_REQUESTED=vllm'+[[ "$(rc_of rerun-forced)" == 0 && "$(value rerun-forced BACKEND)" == vllm \+ && "$(value rerun-forced MODEL)" == "$want_model" && "$(preserve_calls rerun-forced)" == 0 ]] \+ || fail "--llm-backend vllm must move a llama.cpp install to the vLLM pick, not keep its GGUF: $(cat "$tmp/rerun-forced/out" "$tmp/rerun-forced/err")"+name=retained-external; mkdir -p "$tmp/$name/install"; retained 'LLM_BACKEND=external' 'EXTERNAL_LLM_URL=http://127.0.0.1:1234'+decide retained-external 'ODS_RESELECT_MODEL=true'+expect_llama retained-external+name=retained-external-off; mkdir -p "$tmp/$name/install"; retained 'LLM_BACKEND=external' 'EXTERNAL_LLM_URL=http://127.0.0.1:1234'+decide retained-external-off 'ODS_RESELECT_MODEL=true' 'EXTERNAL_LLM_DISABLE=true'+[[ "$(value retained-external-off BACKEND)" == vllm ]] || fail "--no-external-llm must free the route for vLLM"+pass "a llama.cpp install's rerun keeps llama.cpp unless asked; --llm-backend vllm or --reselect-model moves it to the vLLM pick; an API route blocks vLLM"++# A rerun of a vLLM install keeps its installed model: GLM-5.3 here, while+# the fresh pick for the GB300 is Qwen 3.8, which stays the recommendation.+GLM_DIR='nvidia--GLM-5.3-Flash-NVFP4@da920bb0'+vllm_install() {+ retained 'LLM_BACKEND=vllm' 'LLM_MODEL=glm-5.3-flash-nvfp4' "VLLM_MODEL_DIR=$GLM_DIR" \+ 'VLLM_SERVED_MODEL=GLM-5.3-Flash-NVFP4' 'VLLM_GPU_UUID=GPU-aaaaaaaa-gb300' 'VLLM_GPU_MEMORY_UTILIZATION=0.85'+}+# scripts/preserve-active-model.py's vLLM contract for that .env: every key,+# in its order, as its shell_value() quotes them.+GLM_CONTRACT='LLM_BACKEND="vllm"\nLLM_MODEL="glm-5.3-flash-nvfp4"\nGGUF_FILE=""\nGGUF_URL=""\nGGUF_SHA256=""\nMAX_CONTEXT="131072"\nLLM_MODEL_SIZE_MB="204476"\nMODEL_SELECTION_SOURCE="dashboard"\nVLLM_MODEL_DIR="'"$GLM_DIR"'"\nVLLM_SERVED_MODEL="GLM-5.3-Flash-NVFP4"\nVLLM_ARGS="--max-model-len 131072 --kv-cache-dtype fp8"\nVLLM_GPU_UUID="GPU-aaaaaaaa-gb300"\nVLLM_GPU_MEMORY_UTILIZATION="0.85"\n'+name=rerun-vllm; mkdir -p "$tmp/$name/install"; vllm_install+decide rerun-vllm "export FAKE_PRESERVE_OUT='$GLM_CONTRACT'"+[[ "$(rc_of rerun-vllm)" == 0 ]] || fail "a rerun of a vLLM install failed: $(cat "$tmp/rerun-vllm/err")"+[[ "$(value rerun-vllm BACKEND)" == vllm && "$(value rerun-vllm EXPORTED)" == vllm ]] \+ || fail "a rerun of a vLLM install must stay on vLLM: $(cat "$tmp/rerun-vllm/out")"+[[ "$(value rerun-vllm MODEL)" == glm-5.3-flash-nvfp4 && "$(value rerun-vllm VLLM_MODEL_DIR)" == "$GLM_DIR" \+ && "$(value rerun-vllm VLLM_SERVED_MODEL)" == GLM-5.3-Flash-NVFP4 \+ && "$(value rerun-vllm VLLM_GPU_UUID)" == GPU-aaaaaaaa-gb300 && "$(value rerun-vllm VLLM_SHARE)" == 0.85 \+ && "$(value rerun-vllm VLLM_ARGS)" == '--max-model-len 131072 --kv-cache-dtype fp8' \+ && -z "$(value rerun-vllm GGUF_FILE)" && "$(value rerun-vllm MAX_CONTEXT)" == 131072 \+ && "$(value rerun-vllm SIZE_MB)" == 204476 && "$(value rerun-vllm SELECTION_SOURCE)" == dashboard ]] \+ || fail "a rerun must keep the installed vLLM model, folder, served id, GPU and memory share: $(cat "$tmp/rerun-vllm/out")"+[[ "$(value rerun-vllm RECOMMENDED)" == "$want_model" ]] \+ || fail "the fresh vLLM pick must stay the recommendation, not the active model: $(cat "$tmp/rerun-vllm/out")"+[[ "$(preserve_calls rerun-vllm)" == 1 ]] \+ && grep -qF -- "--env $tmp/rerun-vllm/install/.env " "$tmp/rerun-vllm/preserve-calls" \+ && grep -qF -- "--models-dir $tmp/rerun-vllm/install/data/models " "$tmp/rerun-vllm/preserve-calls" \+ && grep -q -- '--local-model$' "$tmp/rerun-vllm/preserve-calls" \+ || fail "the vLLM model must be read once from the installation's .env and models: $(cat "$tmp/rerun-vllm/preserve-calls")"+grep -qx 'OK Model server: vLLM engine, serving GLM-5.3-Flash-NVFP4 on GPU GPU-aaaaaaaa-gb300' "$tmp/rerun-vllm/out" \+ || fail "the report must name the kept model and GPU: $(cat "$tmp/rerun-vllm/out")"+grep -qF "LOG Kept this installation's vLLM model across installer rerun: glm-5.3-flash-nvfp4 ($GLM_DIR) on GPU GPU-aaaaaaaa-gb300, selected by dashboard" \+ "$tmp/rerun-vllm/install.log" || fail "keeping the vLLM model must reach the install log"+pass "a rerun of a vLLM install keeps its model, folder, GPU and memory share; the fresh pick stays the recommendation"++name=rerun-vllm-incomplete; mkdir -p "$tmp/$name/install"; vllm_install+decide rerun-vllm-incomplete 'export FAKE_PRESERVE_STATUS=2' \+ "export FAKE_PRESERVE_STDERR='This installation runs its model on the vLLM engine, but its saved model is not a complete vLLM catalog snapshot for the GPU it names; refusing to replace it.'"+[[ "$(rc_of rerun-vllm-incomplete)" != 0 ]] \+ || fail "exit 2 from the model helper must stop the rerun: $(cat "$tmp/rerun-vllm-incomplete/out")"+grep -qF "ERROR This installation runs glm-5.3-flash-nvfp4 on the vLLM engine, but its saved vLLM model is incomplete or is no longer this release's catalog model" \+ "$tmp/rerun-vllm-incomplete/err" \+ && grep -qF -- 'rerun the installer with --reselect-model' "$tmp/rerun-vllm-incomplete/err" \+ && grep -qF "data/models/$GLM_DIR was moved or deleted, restore it" "$tmp/rerun-vllm-incomplete/err" \+ && grep -q 'discord.gg' "$tmp/rerun-vllm-incomplete/err" \+ || fail "exit 2 must stop with the cause, --reselect-model, the model folder and the Discord link: $(cat "$tmp/rerun-vllm-incomplete/err")"+grep -qF 'refusing to replace it' "$tmp/rerun-vllm-incomplete/install.log" \+ || fail "the helper's own reason must reach the install log"+! grep -q '^OK Model server' "$tmp/rerun-vllm-incomplete/out" || fail "a stopped rerun must not report a model server"+name=rerun-vllm-old-helper; mkdir -p "$tmp/$name/install"; vllm_install+decide rerun-vllm-old-helper+[[ "$(rc_of rerun-vllm-old-helper)" != 0 ]] \+ && grep -qF 'but ODS could not read its saved vLLM model (scripts/preserve-active-model.py exit 0;' "$tmp/rerun-vllm-old-helper/err" \+ || fail "a helper without a vLLM contract must stop the rerun: $(cat "$tmp/rerun-vllm-old-helper/out" "$tmp/rerun-vllm-old-helper/err")"+name=rerun-vllm-partial; mkdir -p "$tmp/$name/install"; vllm_install+decide rerun-vllm-partial "export FAKE_PRESERVE_OUT='${GLM_CONTRACT%VLLM_GPU_UUID=*}'"+[[ "$(rc_of rerun-vllm-partial)" != 0 ]] && grep -qF 'exit 0 with an incomplete contract' "$tmp/rerun-vllm-partial/err" \+ || fail "a contract without VLLM_GPU_UUID must stop, not keep the pick's GPU: $(cat "$tmp/rerun-vllm-partial/out" "$tmp/rerun-vllm-partial/err")"+pass "a vLLM model that cannot be kept (helper exit 2, no contract, a missing key) stops the rerun with the cause and how to recover"++name=rerun-vllm-gone; mkdir -p "$tmp/$name/install"; vllm_install+decide rerun-vllm-gone "export FAKE_GPU_ROWS='$RTX_ROWS'"+expect_kept_refused rerun-vllm-gone 'no vLLM catalog model fits this host'+name=rerun-vllm-cpu; mkdir -p "$tmp/$name/install"; vllm_install+decide rerun-vllm-cpu 'GPU_BACKEND=cpu'+expect_kept_refused rerun-vllm-cpu 'the GPU backend is cpu'+name=rerun-vllm-smi; mkdir -p "$tmp/$name/install"; vllm_install+decide rerun-vllm-smi 'export FAKE_NVIDIA_SMI_FAIL=true'+expect_kept_refused rerun-vllm-smi 'nvidia-smi could not list'+name=rerun-vllm-hybrid; mkdir -p "$tmp/$name/install"; vllm_install+decide rerun-vllm-hybrid 'ODS_MODE=hybrid'+expect_kept_refused rerun-vllm-hybrid 'runs only in local mode'+name=rerun-vllm-cloud; mkdir -p "$tmp/$name/install"; vllm_install+decide rerun-vllm-cloud 'ODS_MODE=cloud'+expect_kept_refused rerun-vllm-cloud 'cloud mode'+pass "a vLLM install's rerun stops instead of becoming llama.cpp when nothing fits, the NVIDIA GPU or nvidia-smi is gone, or the mode is not local"++name=rerun-vllm-forced-off; mkdir -p "$tmp/$name/install"; vllm_install+decide rerun-vllm-forced-off 'LLM_BACKEND_REQUESTED=llama-server' "export FAKE_PRESERVE_OUT='$GLM_CONTRACT'"+expect_llama rerun-vllm-forced-off llama-server+[[ "$(preserve_calls rerun-vllm-forced-off)" == 0 ]] || fail "leaving vLLM must not load the vLLM model's contract"+grep -qF 'LOG Leaving the vLLM engine' "$tmp/rerun-vllm-forced-off/install.log" || fail "leaving vLLM must be logged"+name=rerun-vllm-reselect; mkdir -p "$tmp/$name/install"; vllm_install+decide rerun-vllm-reselect 'ODS_RESELECT_MODEL=true' "export FAKE_PRESERVE_OUT='$GLM_CONTRACT'"+[[ "$(value rerun-vllm-reselect BACKEND)" == vllm && "$(value rerun-vllm-reselect MODEL)" == "$want_model" \+ && "$(preserve_calls rerun-vllm-reselect)" == 0 ]] \+ || fail "--reselect-model must replace the installed vLLM model with the fresh pick: $(cat "$tmp/rerun-vllm-reselect/out")"+name=rerun-vllm-reselect-gone; mkdir -p "$tmp/$name/install"; vllm_install+decide rerun-vllm-reselect-gone 'ODS_RESELECT_MODEL=true' "export FAKE_GPU_ROWS='$RTX_ROWS'"+expect_llama rerun-vllm-reselect-gone llama-server+pass "--llm-backend llama-server or --reselect-model chooses again without the vLLM model's contract; leaving vLLM exports llama-server"++# Cloud mode returns before the decision; it refuses a vLLM install's rerun+# the same way, and leaving vLLM still exports llama-server.+cloud_run() {+ local name="$1" rc=0 dir="$tmp/$1"+ shift+ mkdir -p "$dir/install"+ {+ printf '%s\n' 'set -euo pipefail'+ printf 'SCRIPT_DIR=%q\nINSTALL_DIR=%q\nLOG_FILE=%q\n' "$ROOT_DIR" "$dir/install" "$dir/install.log"+ cat <<'EOF'+source "$SCRIPT_DIR/lib/safe-env.sh"+source "$SCRIPT_DIR/installers/lib/external-services.sh"+ai() { :; }+error() { printf 'ERROR %s\n' "$*" >&2; }+df() { printf 'Filesystem 1024-blocks Used Available Capacity Mounted\nfake 209715200 0 104857600 0%% /\n'; }+resolve_compose_config() { printf 'EXPORTED=%s\n' "$(bash -c 'printf %s "${LLM_BACKEND:-}"')"; }+ODS_MODE=cloud+ODS_RESELECT_MODEL=false+LLM_BACKEND_REQUESTED=""+LLM_BACKEND=llama-server+EOF+ printf '%s\n' "$@" "$refused_fn" "$kept_fn" "$export_fn" "$cloud_block" 'fi'+ } > "$dir/run.bash"+ bash "$dir/run.bash" >"$dir/out" 2>"$dir/err" || rc=$?+ printf '%s\n' "$rc" > "$dir/rc"+}+name=cloud-vllm; mkdir -p "$tmp/$name/install"; vllm_install+cloud_run cloud-vllm+[[ "$(rc_of cloud-vllm)" != 0 ]] \+ && grep -qF 'ERROR This installation runs its model on the vLLM engine, which this run cannot use: ODS runs in cloud mode' "$tmp/cloud-vllm/err" \+ || fail "cloud mode must refuse a vLLM install's rerun: $(cat "$tmp/cloud-vllm/out" "$tmp/cloud-vllm/err")"+name=cloud-vllm-off; mkdir -p "$tmp/$name/install"; vllm_install+cloud_run cloud-vllm-off 'LLM_BACKEND_REQUESTED=llama-server'+name=cloud-vllm-reselect; mkdir -p "$tmp/$name/install"; vllm_install+cloud_run cloud-vllm-reselect 'ODS_RESELECT_MODEL=true'+for name in cloud-vllm-off cloud-vllm-reselect; do+ [[ "$(rc_of "$name")" == 0 && "$(value "$name" EXPORTED)" == llama-server ]] \+ || fail "$name: leaving vLLM for cloud mode must export llama-server: $(cat "$tmp/$name/out" "$tmp/$name/err")"+done+cloud_run cloud-fresh+[[ "$(rc_of cloud-fresh)" == 0 && -z "$(value cloud-fresh EXPORTED)" ]] \+ || fail "a fresh cloud install must leave LLM_BACKEND unexported: $(cat "$tmp/cloud-fresh/out" "$tmp/cloud-fresh/err")"+cloud_run cloud-forced 'LLM_BACKEND_REQUESTED=vllm'+[[ "$(rc_of cloud-forced)" != 0 ]] && grep -qF -- '--llm-backend vllm cannot be used here: ODS runs in cloud mode' "$tmp/cloud-forced/err" \+ || fail "cloud mode must refuse --llm-backend vllm: $(cat "$tmp/cloud-forced/err")"+pass "cloud mode refuses --llm-backend vllm and a vLLM install's rerun; --llm-backend llama-server or --reselect-model leaves vLLM"++decide smi-auto 'export FAKE_NVIDIA_SMI_FAIL=true'+expect_llama smi-auto+decide smi-forced 'export FAKE_NVIDIA_SMI_FAIL=true' 'LLM_BACKEND_REQUESTED=vllm'+expect_refused smi-forced 'nvidia-smi could not list'+decide crash-auto 'ods_run_vllm_selector() { echo "Traceback: broken catalog" >&2; return 1; }'+[[ "$(rc_of crash-auto)" != 0 ]] && grep -q 'ERROR The vLLM model selector stopped (exit 1): Traceback: broken catalog' "$tmp/crash-auto/err" \+ || fail "a selector failure other than exit 2 must stop the install: $(cat "$tmp/crash-auto/out" "$tmp/crash-auto/err")"+grep -q 'discord.gg' "$tmp/crash-auto/err" || fail "a selector failure must name the Discord help link"+decide bad-lock 'ods_vllm_image_from_lock() { return 1; }'+[[ "$(rc_of bad-lock)" != 0 ]] && grep -q 'names no digest-pinned vLLM image' "$tmp/bad-lock/err" \+ || fail "a missing vLLM image pin must stop the install"+pass "a failed GPU query keeps llama.cpp (or refuses --llm-backend vllm); a selector crash or a missing pin stops"++fi++# ── 4. The loader keeps the vLLM contract ──────────────────────────────────+if only 4; then+(+ # shellcheck source=../lib/safe-env.sh+ source "$ROOT_DIR/lib/safe-env.sh"+ unset LLM_BACKEND VLLM_MODEL_DIR VLLM_SERVED_MODEL VLLM_ARGS VLLM_GPU_UUID VLLM_GPU_MEMORY_UTILIZATION+ load_model_selector_env_from_output < <(printf '%s\n' 'LLM_BACKEND="vllm"' 'VLLM_MODEL_DIR="nvidia--X@01234567"' \+ 'VLLM_SERVED_MODEL="X"' 'VLLM_ARGS="--max-model-len 131072 --speculative-config.method=mtp"' \+ 'VLLM_GPU_UUID="GPU-1"' 'VLLM_GPU_MEMORY_UTILIZATION="0.85"' 'VLLM_UNKNOWN="no"')+ [[ "$LLM_BACKEND" == vllm && "$VLLM_MODEL_DIR" == 'nvidia--X@01234567' && "$VLLM_SERVED_MODEL" == X \+ && "$VLLM_GPU_UUID" == GPU-1 && "$VLLM_GPU_MEMORY_UTILIZATION" == 0.85 \+ && "$VLLM_ARGS" == '--max-model-len 131072 --speculative-config.method=mtp' && -z "${VLLM_UNKNOWN:-}" ]]+) || fail "load_model_selector_env_from_output must load the vLLM contract keys and no other VLLM_* key"+pass "the selector env loader carries a vLLM contract: LLM_BACKEND and the five VLLM_* keys"++fi++# ── 5. Exporting this run's LLM_BACKEND leaves other selections unchanged ──+if only 5; then+# A run that leaves vLLM exports llama-server (phase 02), and phase 06 then+# exports external for an API: the resolver must select exactly the same files+# as with nothing exported, which is what every other install does.+resolve() {+ (+ cd "$ROOT_DIR"+ env -u LLM_BACKEND -u NATIVE_LLM_BASE_URL -u EXTERNAL_LLM_URL -u ODS_EXTERNAL_LLM_SELECTED \+ -u AMD_INFERENCE_BACKEND -u ODS_GATEWAY_ONLY "$@"+ )+}+compared=0+for fixture in \+ "--tier 1 --gpu-backend nvidia --gpu-count 1 --ods-mode local" \+ "--tier NV_ULTRA --gpu-backend nvidia --gpu-count 2 --ods-mode local" \+ "--tier 4 --gpu-backend nvidia --gpu-count 4 --ods-mode hybrid" \+ "--tier SH_LARGE --gpu-backend amd --gpu-count 1 --ods-mode local" \+ "--tier 2 --gpu-backend amd --gpu-count 2 --ods-mode local" \+ "--tier 1 --gpu-backend cpu --gpu-count 0 --ods-mode local" \+ "--tier 0 --gpu-backend cpu --gpu-count 0 --ods-mode local" \+ "--tier CLOUD --gpu-backend cpu --gpu-count 0 --ods-mode cloud" \+ "--tier AP_PRO --gpu-backend apple --gpu-count 1 --ods-mode local" \+ "--tier ARC --gpu-backend intel --gpu-count 1 --ods-mode local"; do+ read -r -a args <<< "$fixture"+ for mode in files env; do+ [[ "$mode" == files ]] || args+=(--env)+ baseline="$(resolve bash scripts/resolve-compose-stack.sh --script-dir "$ROOT_DIR" "${args[@]}")"+ for exported in llama-server external; do+ got="$(resolve LLM_BACKEND="$exported" bash scripts/resolve-compose-stack.sh --script-dir "$ROOT_DIR" "${args[@]}")"+ [[ "$got" == "$baseline" ]] || fail "LLM_BACKEND=$exported changed the resolver output for $fixture ($mode)"+ compared=$((compared + 1))+ done+ done+done+external_baseline="$(resolve EXTERNAL_LLM_URL=http://127.0.0.1:11434 bash scripts/resolve-compose-stack.sh \+ --script-dir "$ROOT_DIR" --tier 3 --gpu-backend nvidia --ods-mode local)"+[[ "$(resolve EXTERNAL_LLM_URL=http://127.0.0.1:11434 LLM_BACKEND=external bash scripts/resolve-compose-stack.sh \+ --script-dir "$ROOT_DIR" --tier 3 --gpu-backend nvidia --ods-mode local)" == "$external_baseline" ]] \+ || fail "an exported LLM_BACKEND=external changed the external route's stack"+pass "an exported llama-server or external LLM_BACKEND leaves $compared resolver selections byte-identical"++fi++# ── 6. No fast-start GGUF on the vLLM route ────────────────────────────────+if only 6; then+(+ # shellcheck source=../installers/lib/bootstrap-model.sh+ source "$ROOT_DIR/installers/lib/bootstrap-model.sh"+ tier_rank() { printf '4\n'; }+ TIER=NV_ULTRA INSTALL_DIR="$tmp/bootstrap" GGUF_FILE=""+ mkdir -p "$INSTALL_DIR/data/models"+ LLM_BACKEND=llama-server+ bootstrap_needed || exit 1+ LLM_BACKEND=vllm+ ! bootstrap_needed+) || fail "bootstrap_needed must stay true for llama.cpp and false for the vLLM engine"+pass "the bootstrap model is never downloaded for the vLLM engine"++# Phase 02b offers no running Ollama or LM Studio in vLLM's place.+grep -q '"${LLM_BACKEND:-}" != "vllm"' "$ROOT_DIR/installers/phases/02b-external-services.sh" \+ || fail "phase 02b must not offer a detected external model on the vLLM route"+pass "phase 02b does not offer a detected Ollama or LM Studio on the vLLM route"+fi++printf '\nResult: %d passed, 0 failed\n' "$PASS"