Guida dell'utente dei modelli Mistral con vLLM su GDC con air gap

Questo documento fornisce istruzioni passo passo per il deployment di modelli con pesi aperti di Mistral AI in ambienti Google Distributed Cloud (GDC) con air gap. Viene trattato l'utilizzo di vLLM per la distribuzione con throughput elevato, utilizzando le funzionalità della piattaforma GDC, tra cui Kubernetes, Harbor e le risorse GPU. Seleziona il modello e l'opzione GPU nella sezione Modello. Tutti gli altri passaggi sono uguali per tutti i modelli.

Modelli supportati

Modello Repository Hugging Face Parametri Licenza Opzioni GPU
Mistral 7B Instruct mistralai/Mistral-7B-Instruct-v0.2 7,2 miliardi (dense) Apache 2.0 1 x qualsiasi GPU
Mistral NeMo 12B Instruct mistralai/Mistral-Nemo-Instruct-2407 12B (dense) Apache 2.0 1 x qualsiasi GPU
Mistral Small 3.2 24B Instruct mistralai/Mistral-Small-3.2-24B-Instruct-2506 24B (dense, con codificatore di visione artificiale) Apache 2.0 1 x NVIDIA A100 80 GB
1 x NVIDIA H100 94 GB
1 x NVIDIA H200 141 GB o B300 288 GB
Ministral 8B Instruct mistralai/Ministral-8B-Instruct-2410 8B (dense) Licenza di ricerca Mistral AI (solo per uso di ricerca e non commerciale) 1 x qualsiasi GPU
Mixtral 8x7B Instruct mistralai/Mixtral-8x7B-Instruct-v0.1 46,7 miliardi totali / 12,9 miliardi attivi (Mixture of Experts, 8x7B) Apache 2.0 2 NVIDIA A100 da 80 GB
2 NVIDIA H100 da 94 GB
1 NVIDIA A100 da 80 GB o H100 da 94 GB con --quantization=fp8
1 NVIDIA H200 da 141 GB o B300 da 288 GB
Magistral Small 1.2 24B mistralai/Magistral-Small-2509 24B (denso, ragionamento, con codificatore di visione) Apache 2.0 1 x NVIDIA A100 80 GB
1 x NVIDIA H100 94 GB
1 x NVIDIA H200 141 GB o B300 288 GB

Architettura

La soluzione prevede il deployment di un backend di gestione containerizzato (vLLM) come deployment all'interno di un cluster standard. I pesi del modello sono archiviati su volumi permanenti, compilati da file scaricati localmente e caricati utilizzando un pod del caricatore. Un Service Kubernetes di tipo LoadBalancer espone l'API di backend e gli oggetti NetworkPolicy / ProjectNetworkPolicy ne proteggono l'accesso.

Prima di iniziare

Completa l'implementazione di riferimento dei modelli open weight con vLLM sulla workstation e assicurati di avere accesso alla directory ${HOME}/gdcag-solutions.

Identity and Access Management

Assicurati che gli account, i ruoli e le autorizzazioni IAM necessari siano configurati correttamente.

Ruoli Utente GDC nell'organizzazione:

  • (Facoltativo) Amministratore cluster standard (visualizza i cluster dalla console)

Ruoli GDC User sul progetto:

  • Standard Cluster Admin (standard-cluster-admin)

Ruolo GDC User sul cluster standard:

  • StandardClusterRoleBinding al cluster-admin StandardClusterRole (creato da un Project IAM Admin, consulta la sezione Identity and Access Management dell'implementazione di riferimento)

Workstation

Esegui tutti i comandi di questa guida da una workstation con gli strumenti e la connettività necessari per l'ambiente e internet, se non diversamente indicato in un passaggio.

La configurazione dell'ambiente è strutturata su più livelli:

  • ${HOME}/gdcag-solutions/env.sh carica le impostazioni della piattaforma e del registry.
  • ${HOME}/gdcag-solutions/open-weight-models/vllm/env.sh aggiunge le impostazioni vLLM.

  • Questa guida dell'utente aggiunge env.d/model.sh (il modello) e env.d/accelerator.sh (l'opzione GPU e le impostazioni di runtime), che scrivi nella sezione Modello, e env.d/model-common.sh (i valori derivati).

  1. Crea la struttura di directory della guida dell'utente:

    mkdir -p ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d
    
  2. Crea il file di configurazione dell'ambiente del modello comune. Deriva ogni percorso e nome della risorsa da GDCS_HF_MODEL, quindi è uguale per tutti i modelli:

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/model-common.sh && echo "Successfully created." || echo "Failed to create!"
    # Model (derived from env.d/model.sh)
    export GDCS_HF_DOWNLOAD_PATH="${GDCS_USER_GUIDE_HOME}/hf-models"
    export GDCS_HF_MODEL_LOWERCASE="${GDCS_HF_MODEL,,}"
    export GDCS_HF_MODEL_DOWNLOAD_DIR="${GDCS_HF_DOWNLOAD_PATH}/${GDCS_HF_MODEL_LOWERCASE}"
    export GDCS_HF_PV_MOUNT_PATH="/mnt/hf-model"
    
    GDCS_HF_MODEL_KUBERNETES="${GDCS_HF_MODEL_LOWERCASE//\//-}"
    export GDCS_HF_MODEL_KUBERNETES="${GDCS_HF_MODEL_KUBERNETES//./-}"
    
    # Workload
    export GDCS_WORKLOAD_NAMESPACE="vllm-mistral"
    export GDCS_WORKLOAD_NAME="${GDCS_HF_MODEL_KUBERNETES}"
    export GDCS_MODEL_LOADER_POD_NAME="loader-${GDCS_HF_MODEL_KUBERNETES}"
    EOF
    
  3. Crea il file del caricatore dell'ambiente della guida dell'utente:

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.sh && echo "Successfully created." || echo "Failed to create!"
    source "${HOME}/gdcag-solutions/open-weight-models/vllm/env.sh"
    
    export GDCS_USER_GUIDE_HOME="${HOME}/gdcag-solutions/open-weight-models/vllm/mistral"
    echo "GDCS_USER_GUIDE_HOME=${GDCS_USER_GUIDE_HOME}"
    
    # Sourced in dependency order: the model selection, the accelerator and runtime settings, then the values derived from them
    source "${GDCS_USER_GUIDE_HOME}/env.d/model.sh"
    source "${GDCS_USER_GUIDE_HOME}/env.d/accelerator.sh"
    source "${GDCS_USER_GUIDE_HOME}/env.d/model-common.sh"
    echo "GDCS_HF_MODEL=${GDCS_HF_MODEL} (${GDCS_WORKLOAD_ACCELERATOR_COUNT} x ${GDCS_WORKLOAD_ACCELERATOR_TYPE:-unset})"
    EOF
    

Modello

Seleziona il modello e l'opzione GPU corrispondenti ai nodi GPU del tuo cluster standard. GDC con air gap offre le seguenti GPU (consulta Tipi di macchine dei nodi del cluster); il tipo di risorsa dell'acceleratore è il nome con cui i nodi espongono la GPU a Kubernetes.

GPU Memoria Tipi di macchina Tipo di risorsa acceleratore
NVIDIA A100 40 GB a2-highgpu-1g-gdc nvidia.com/gpu-pod-NVIDIA_A100_PCIE_40GB
NVIDIA A100 80 GB a2-ultragpu-1g-gdc, a2-ultragpu-2g-gdc nvidia.com/gpu-pod-NVIDIA_A100_80GB_PCIE
NVIDIA H100 94 GB a3-highgpu-1g-gdc (anteprima), a3-highgpu-2g-gdc (anteprima), a3-highgpu-4g-gdc nvidia.com/gpu-pod-NVIDIA_H100_NVL
NVIDIA H200 141 GB a3-ultragpu-8g-gdc nvidia.com/gpu-pod-NVIDIA_H200
NVIDIA B300 288 GB a4-ultragpu-8g-gdc nvidia.com/gpu-pod-NVIDIA_B300_SXM6_AC

Ogni scheda elenca i dati del modello, il comando che scrive il file dell'ambiente del modello env.d/model.sh e le schede nidificate che scrivono il file dell'ambiente dell'acceleratore env.d/accelerator.sh per l'opzione GPU scelta con tipi di risorse e impostazioni vLLM precompilati. Per cambiare modelli o opzioni GPU in un secondo momento, scrivi file di ambiente diversi, esegui nuovamente il sourcing dell'ambiente e ripeti la sezione Implementazione. I workload di diversi modelli possono essere eseguiti contemporaneamente nello stesso spazio dei nomi perché ogni nome di risorsa deriva dal nome del modello.

  1. Crea i file dell'ambiente del modello e dell'acceleratore per l'opzione del modello e della GPU di cui vuoi eseguire il deployment.

    Mistral 7B Instruct

    Attributo Valore
    Repository Hugging Face mistralai/Mistral-7B-Instruct-v0.2
    Parametri 7,2 miliardi (dense)
    Licenza Apache 2.0
    Pesi utilizzati da vLLM Formato Hugging Face (model-*.safetensors), circa 14,5 GB
    Finestra contestuale 32.000 token; questa guida utilizza --max-model-len 32768

    Crea il file di ambiente del modello:

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/model.sh && echo "Successfully created." || echo "Failed to create!"
    # Model: Mistral 7B Instruct
    export GDCS_HF_MODEL="mistralai/Mistral-7B-Instruct-v0.2"
    export GDCS_HF_MODEL_REVISION="main"  # Hugging Face branch, tag, or commit to download
    export GDCS_HF_DOWNLOAD_EXCLUDE="consolidated* *.bin"
    EOF
    

    Crea il file dell'ambiente dell'acceleratore per l'opzione GPU:

    NVIDIA A100 da 40 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA A100 40 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_A100_PCIE_40GB"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="60"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA A100 da 80 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA A100 80 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_A100_80GB_PCIE"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="60"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA H100 da 94 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA H100 94 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_H100_NVL"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="60"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA H200 141 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA H200 141 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_H200"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="60"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA B300 288 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA B300 288 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_B300_SXM6_AC"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="60"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    Mistral NeMo 12B Instruct

    Attributo Valore
    Repository Hugging Face mistralai/Mistral-Nemo-Instruct-2407
    Parametri 12B (dense)
    Licenza Apache 2.0
    Pesi utilizzati da vLLM Formato Mistral (consolidated.safetensors, params.json, tekken.json), circa 24,5 GB
    Finestra contestuale 128.000 token; questa guida utilizza --max-model-len 32768

    Crea il file di ambiente del modello:

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/model.sh && echo "Successfully created." || echo "Failed to create!"
    # Model: Mistral NeMo 12B Instruct
    export GDCS_HF_MODEL="mistralai/Mistral-Nemo-Instruct-2407"
    export GDCS_HF_MODEL_REVISION="main"  # Hugging Face branch, tag, or commit to download
    export GDCS_HF_DOWNLOAD_EXCLUDE="model-*.safetensors *.bin"
    EOF
    

    Crea il file dell'ambiente dell'acceleratore per l'opzione GPU:

    NVIDIA A100 da 40 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA A100 40 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_A100_PCIE_40GB"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="180"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA A100 da 80 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA A100 80 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_A100_80GB_PCIE"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="180"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA H100 da 94 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA H100 94 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_H100_NVL"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="180"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA H200 141 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA H200 141 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_H200"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="180"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA B300 288 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA B300 288 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_B300_SXM6_AC"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="180"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    Mistral Small 3.2 24B Instruct

    Attributo Valore
    Repository Hugging Face mistralai/Mistral-Small-3.2-24B-Instruct-2506
    Parametri 24B (dense, con codificatore di visione artificiale)
    Licenza Apache 2.0
    Pesi utilizzati da vLLM Formato Mistral (consolidated.safetensors, params.json, tekken.json), circa 48 GB
    Finestra contestuale 128.000 token; questa guida utilizza --max-model-len 32768

    Crea il file di ambiente del modello:

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/model.sh && echo "Successfully created." || echo "Failed to create!"
    # Model: Mistral Small 3.2 24B Instruct
    export GDCS_HF_MODEL="mistralai/Mistral-Small-3.2-24B-Instruct-2506"
    export GDCS_HF_MODEL_REVISION="main"  # Hugging Face branch, tag, or commit to download
    export GDCS_HF_DOWNLOAD_EXCLUDE="model-*.safetensors *.bin"
    EOF
    

    Crea il file dell'ambiente dell'acceleratore per l'opzione GPU:

    NVIDIA A100 da 80 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA A100 80 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_A100_80GB_PCIE"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="300"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA H100 da 94 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA H100 94 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_H100_NVL"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="300"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA H200 141 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA H200 141 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_H200"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="300"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA B300 288 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA B300 288 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_B300_SXM6_AC"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="300"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    Ministral 8B Instruct

    Attributo Valore
    Repository Hugging Face mistralai/Ministral-8B-Instruct-2410
    Parametri 8B (dense)
    Licenza Licenza di ricerca Mistral AI (solo per uso di ricerca e non commerciale)
    Pesi utilizzati da vLLM Formato Mistral (consolidated.safetensors, params.json, tekken.json), circa 16 GB
    Finestra contestuale 128.000 token; questa guida utilizza --max-model-len 32768

    Crea il file di ambiente del modello:

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/model.sh && echo "Successfully created." || echo "Failed to create!"
    # Model: Ministral 8B Instruct
    export GDCS_HF_MODEL="mistralai/Ministral-8B-Instruct-2410"
    export GDCS_HF_MODEL_REVISION="main"  # Hugging Face branch, tag, or commit to download
    export GDCS_HF_DOWNLOAD_EXCLUDE="model-*.safetensors *.bin"
    EOF
    

    Crea il file dell'ambiente dell'acceleratore per l'opzione GPU:

    NVIDIA A100 da 40 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA A100 40 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_A100_PCIE_40GB"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="120"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA A100 da 80 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA A100 80 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_A100_80GB_PCIE"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="120"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA H100 da 94 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA H100 94 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_H100_NVL"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="120"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA H200 141 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA H200 141 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_H200"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="120"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA B300 288 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA B300 288 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_B300_SXM6_AC"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="120"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    Mixtral 8x7B Instruct

    Attributo Valore
    Repository Hugging Face mistralai/Mixtral-8x7B-Instruct-v0.1
    Parametri 46,7 miliardi totali / 12,9 miliardi attivi (Mixture of Experts, 8x7B)
    Licenza Apache 2.0
    Pesi utilizzati da vLLM Formato Hugging Face (model-*.safetensors), circa 93 GB (il repository contiene anche file PyTorch consolidated.*.pt, esclusi)
    Finestra contestuale 32.000 token; questa guida utilizza --max-model-len 32768

    Crea il file di ambiente del modello:

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/model.sh && echo "Successfully created." || echo "Failed to create!"
    # Model: Mixtral 8x7B Instruct
    export GDCS_HF_MODEL="mistralai/Mixtral-8x7B-Instruct-v0.1"
    export GDCS_HF_MODEL_REVISION="main"  # Hugging Face branch, tag, or commit to download
    export GDCS_HF_DOWNLOAD_EXCLUDE="consolidated* *.bin"
    EOF
    

    Crea il file dell'ambiente dell'acceleratore per l'opzione GPU:

    NVIDIA A100 da 80 GB (2 GPU)

    Richiede un nodo con due GPU A100 da 80 GB (a2-ultragpu-2g-gdc); vLLM viene eseguito con --tensor-parallel-size 2.

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA A100 80 GB (2 GPUs)
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_A100_80GB_PCIE"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="2"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="480"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA H100 94 GB (2 GPU)

    Richiede un nodo con almeno due GPU H100 (a3-highgpu-2g-gdc o a3-highgpu-4g-gdc); vLLM viene eseguito con --tensor-parallel-size 2.

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA H100 94 GB (2 GPUs)
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_H100_NVL"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="2"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="480"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA A100 da 80 GB (FP8)

    --quantization=fp8 quantizza i pesi in FP8 durante il caricamento (circa 47 GB anziché 93 GB), con una qualità di output leggermente inferiore.

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA A100 80 GB (FP8)
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_A100_80GB_PCIE"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS="--quantization=fp8"
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="480"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA H100 94 GB (FP8)

    --quantization=fp8 quantizza i pesi in FP8 durante il caricamento (circa 47 GB anziché 93 GB), con una qualità di output leggermente inferiore.

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA H100 94 GB (FP8)
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_H100_NVL"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS="--quantization=fp8"
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="480"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA H200 141 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA H200 141 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_H200"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="480"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    NVIDIA B300 288 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA B300 288 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_B300_SXM6_AC"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="32768"
    export GDCS_VLLM_EXTRA_ARGS=""
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="480"
    export GDCS_VLLM_TEST_MAX_TOKENS="128"
    EOF
    

    Magistral Small 1.2 24B

    Attributo Valore
    Repository Hugging Face mistralai/Magistral-Small-2509
    Parametri 24B (denso, ragionamento, con codificatore di visione)
    Licenza Apache 2.0
    Pesi utilizzati da vLLM Formato Mistral (consolidated.safetensors, params.json, tekken.json), circa 48 GB
    Finestra contestuale 128.000 token (40.000 consigliati da Mistral); questa guida utilizza --max-model-len 40960

    Crea il file di ambiente del modello:

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/model.sh && echo "Successfully created." || echo "Failed to create!"
    # Model: Magistral Small 1.2 24B
    export GDCS_HF_MODEL="mistralai/Magistral-Small-2509"
    export GDCS_HF_MODEL_REVISION="main"  # Hugging Face branch, tag, or commit to download
    export GDCS_HF_DOWNLOAD_EXCLUDE="model-*.safetensors *.bin"
    EOF
    

    Crea il file dell'ambiente dell'acceleratore per l'opzione GPU:

    NVIDIA A100 da 80 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA A100 80 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_A100_80GB_PCIE"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="40960"
    export GDCS_VLLM_EXTRA_ARGS="--reasoning-parser=mistral"
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="300"
    export GDCS_VLLM_TEST_MAX_TOKENS="1024"
    EOF
    

    NVIDIA H100 da 94 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA H100 94 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_H100_NVL"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="40960"
    export GDCS_VLLM_EXTRA_ARGS="--reasoning-parser=mistral"
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="300"
    export GDCS_VLLM_TEST_MAX_TOKENS="1024"
    EOF
    

    NVIDIA H200 141 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA H200 141 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_H200"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="40960"
    export GDCS_VLLM_EXTRA_ARGS="--reasoning-parser=mistral"
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="300"
    export GDCS_VLLM_TEST_MAX_TOKENS="1024"
    EOF
    

    NVIDIA B300 288 GB

    cat << 'EOF' > ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.d/accelerator.sh && echo "Successfully created." || echo "Failed to create!"
    # Accelerator: NVIDIA B300 288 GB
    export GDCS_WORKLOAD_ACCELERATOR_TYPE="nvidia.com/gpu-pod-NVIDIA_B300_SXM6_AC"
    export GDCS_WORKLOAD_ACCELERATOR_COUNT="1"
    
    # vLLM
    export GDCS_VLLM_MAX_MODEL_LEN="40960"
    export GDCS_VLLM_EXTRA_ARGS="--reasoning-parser=mistral"
    export GDCS_VLLM_STARTUP_FAILURE_THRESHOLD="300"
    export GDCS_VLLM_TEST_MAX_TOKENS="1024"
    EOF
    
  2. Esegui il sourcing del file di ambiente:

    source ${HOME}/gdcag-solutions/open-weight-models/vllm/mistral/env.sh
    

    L'output è simile al seguente:

    GDCS_ROOT_HOME=HOME_DIRECTORY_PATH/gdcag-solutions
    GDCS_IMPLEMENTATION_HOME=HOME_DIRECTORY_PATH/gdcag-solutions/open-weight-models/vllm
    GDCS_USER_GUIDE_HOME=HOME_DIRECTORY_PATH/gdcag-solutions/open-weight-models/vllm/mistral
    GDCS_HF_MODEL=HUGGING_FACE_REPOSITORY (ACCELERATOR_COUNT x ACCELERATOR_RESOURCE_TYPE)
    

Cluster

  1. Configura gdcloud:

    gdcloud config set core/account "default-user"
    gdcloud config set core/organization_console_url "${GDC_ZONAL_CONSOLE_URL}"
    gdcloud config set core/project "${GDC_PROJECT}"
    gdcloud config set core/zone "${GDC_ZONE}"
    
  2. Esegui l'autenticazione nell'ambiente GDC:

    gdcloud auth login
    
  3. Recupera le credenziali del cluster:

    gdcloud clusters get-credentials "${GDC_STANDARD_CLUSTER_NAME}" \
    --project="${GDC_PROJECT}" \
    --standard \
    --zone="${GDC_ZONE}"
    
  4. Verifica la connettività al cluster:

    kubectl get nodes -L node.cluster.private.gdc.goog/machine-class
    
  5. Verifica che il tipo di risorsa dell'acceleratore del file dell'ambiente dell'acceleratore sia disponibile nel cluster. Il comando elenca i tipi di risorse dell'acceleratore esposti dai nodi (il nome dipende dal modello di GPU installato; è vuoto nei cluster senza nodi GPU) e il valore configurato:

    kubectl get nodes --output=json | jq -r '[.items[].status.allocatable | keys[] | select(startswith("nvidia.com/"))] | unique[]'
    echo "GDCS_WORKLOAD_ACCELERATOR_TYPE=${GDCS_WORKLOAD_ACCELERATOR_TYPE}"
    

Implementazione

Spazio dei nomi

  1. Crea lo spazio dei nomi:

    kubectl create namespace "${GDCS_WORKLOAD_NAMESPACE}" \
    --dry-run=client \
    --output=yaml | kubectl apply -f -
    
  2. Aggiungi imagePullSecret:

    kubectl create secret docker-registry "${GDCS_HARBOR_K8S_PULL_SECRET}" \
    --dry-run=client \
    --from-file=.dockerconfigjson=${GDCS_HARBOR_K8S_DOCKER_CONFIG}/config.json \
    --namespace="${GDCS_WORKLOAD_NAMESPACE}" \
    --output=yaml | kubectl apply -f -
    

Pesi del modello

  1. Scarica i pesi del modello (solo i file necessari a vLLM per il modello selezionato, GDCS_HF_DOWNLOAD_EXCLUDE salta il resto) e rimuovi la directory .cache:

    EXCLUDE_ARGS=()
    if [[ -n "${GDCS_HF_DOWNLOAD_EXCLUDE:-}" ]]; then
      read -r -a EXCLUDE_PATTERNS <<< "${GDCS_HF_DOWNLOAD_EXCLUDE}"
      EXCLUDE_ARGS=(--exclude "${EXCLUDE_PATTERNS[@]}")
    fi
    hf download "${GDCS_HF_MODEL}" --revision "${GDCS_HF_MODEL_REVISION}" --local-dir "${GDCS_HF_MODEL_DOWNLOAD_DIR}" "${EXCLUDE_ARGS[@]}" && \
    rm -rf "${GDCS_HF_MODEL_DOWNLOAD_DIR}/.cache"
    
  2. Calcola la dimensione PersistentVolumeClaim richiesta dai pesi del modello scaricati con un overhead del 25% (arrotondato per eccesso al GiB intero successivo):

    MODEL_KIB=$(du -sk "${GDCS_HF_MODEL_DOWNLOAD_DIR}" | awk '{print $1}')
    export GDCS_MODEL_PVC_SIZE="$(( (MODEL_KIB * 125 / 100 + 1048575) / 1048576 ))Gi"
    echo "GDCS_MODEL_PVC_SIZE=${GDCS_MODEL_PVC_SIZE}"
    
  3. Crea il manifest per il PersistentVolumeClaim ReadWriteOnce per i pesi del modello:

    cat <<EOF > "${GDCS_USER_GUIDE_HOME}/${GDCS_WORKLOAD_NAME}-rwo-pvc.yaml"
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: ${GDCS_WORKLOAD_NAME}-rwo
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: ${GDCS_MODEL_PVC_SIZE}
      storageClassName: standard-rwo
      volumeMode: Filesystem
    EOF
    
  4. Applica il manifest per il PersistentVolumeClaim per i pesi del modello:

    kubectl apply \
    --filename="${GDCS_USER_GUIDE_HOME}/${GDCS_WORKLOAD_NAME}-rwo-pvc.yaml" \
    --namespace="${GDCS_WORKLOAD_NAMESPACE}"
    
  5. Attendi che l'oggetto PersistentVolumeClaim esegua il binding e stampi i valori necessari all'operatore dell'infrastruttura per regolare la policy di qualità del servizio (QoS) di I/O:

    kubectl wait \
    --for=jsonpath='{.status.phase}'=Bound \
    "pvc/${GDCS_WORKLOAD_NAME}-rwo" \
    --namespace="${GDCS_WORKLOAD_NAMESPACE}" \
    --timeout=120s
    BACKING_PVC=$(kubectl get pvc "${GDCS_WORKLOAD_NAME}-rwo" \
    --namespace="${GDCS_WORKLOAD_NAMESPACE}" \
    --output=jsonpath='{.spec.volumeName}')
    echo "BACKING_PVC=${BACKING_PVC} ORG=${GDC_ORG}"
    
  6. Se performance-rwo non è disponibile nel tuo cluster, chiedi all'operatore dell'infrastruttura di applicare la policy QoS ad alte prestazioni (system-performance-<ORG>-admin, 30 IOPS per GiB con un limite minimo di 6148 IOPS) al volume che supporta PersistentVolumeClaim. Fornisci i valori BACKING_PVC e ORG stampati nel passaggio precedente. L'operatore dell'infrastruttura applica la policy come descritto in FILE-R0097; la policy ha effetto sul volume attivo, quindi puoi procedere con i passaggi successivi.

  7. Crea il manifest per il pod del caricatore del modello:

    cat <<EOF > "${GDCS_USER_GUIDE_HOME}/${GDCS_MODEL_LOADER_POD_NAME}-pod.yaml"
    apiVersion: v1
    kind: Pod
    metadata:
      name: ${GDCS_MODEL_LOADER_POD_NAME}
    spec:
      containers:
        - name: uploader
          image: ${GDCS_HARBOR_PROJECT_URI}/library/busybox:${GDCS_BUSYBOX_IMAGE_TAG}
          command: ["sleep", "infinity"]
          volumeMounts:
            - name: model-data
              mountPath: ${GDCS_HF_PV_MOUNT_PATH}
      imagePullSecrets:
        - name: ${GDCS_HARBOR_K8S_PULL_SECRET}
      volumes:
        - name: model-data
          persistentVolumeClaim:
            claimName: ${GDCS_WORKLOAD_NAME}-rwo
    EOF
    
  8. Applica il manifest per il pod del caricatore del modello:

    kubectl apply \
    --filename="${GDCS_USER_GUIDE_HOME}/${GDCS_MODEL_LOADER_POD_NAME}-pod.yaml" \
    --namespace="${GDCS_WORKLOAD_NAMESPACE}"
    
  9. Attendi che il pod del caricatore del modello sia in esecuzione:

    watch --color --interval 5 --no-title \
    "kubectl get pod/${GDCS_MODEL_LOADER_POD_NAME} \
    --namespace=${GDCS_WORKLOAD_NAMESPACE} | GREP_COLORS='mt=01;92' grep -E --color=always -e '^' -e 'Running'"
    
  10. Carica i pesi del modello in PersistentVolume (lo script ignora i file già esistenti con le stesse dimensioni, quindi può essere eseguito di nuovo):

    export LOCAL_MODEL_DIR="${GDCS_HF_MODEL_DOWNLOAD_DIR}"
    export REMOTE_MODEL_DIR="${GDCS_HF_PV_MOUNT_PATH}/${GDCS_HF_MODEL_LOWERCASE}"
    export REMOTE_MOUNT_DIR="${GDCS_HF_PV_MOUNT_PATH}"
    
    ${GDCS_IMPLEMENTATION_HOME}/model_weight_upload.sh
    
  11. Elimina il pod del caricatore del modello:

    kubectl delete pod/${GDCS_MODEL_LOADER_POD_NAME} \
    --namespace="${GDCS_WORKLOAD_NAMESPACE}"
    

Server di inferenza

  1. Crea il manifest per il deployment vLLM. ConfigMap contiene le impostazioni vLLM specifiche del modello dall'ambiente, quindi il manifest è lo stesso per ogni modello e opzione GPU:

    cat <<EOF > "${GDCS_USER_GUIDE_HOME}/${GDCS_WORKLOAD_NAME}-deployment.yaml"
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: ${GDCS_WORKLOAD_NAME}
    data:
      MAX_MODEL_LEN: "${GDCS_VLLM_MAX_MODEL_LEN}"
      MODEL: "${GDCS_HF_PV_MOUNT_PATH}/${GDCS_HF_MODEL_LOWERCASE}"
      PORT: "8000"
      TENSOR_PARALLEL_SIZE: "${GDCS_WORKLOAD_ACCELERATOR_COUNT}"
      VLLM_EXTRA_ARGS: "${GDCS_VLLM_EXTRA_ARGS}"
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: ${GDCS_WORKLOAD_NAME}
      labels:
        app: ${GDCS_WORKLOAD_NAME}
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: ${GDCS_WORKLOAD_NAME}
      strategy:
        type: Recreate
      template:
        metadata:
          labels:
            app: ${GDCS_WORKLOAD_NAME}
        spec:
          containers:
            - command:
                - /bin/sh
                - -c
              args:
                - exec vllm serve "\$MODEL" --port="\$PORT" --tensor-parallel-size="\$TENSOR_PARALLEL_SIZE" --max-model-len="\$MAX_MODEL_LEN" \$VLLM_EXTRA_ARGS
              envFrom:
                - configMapRef:
                    name: ${GDCS_WORKLOAD_NAME}
              image: ${GDCS_HARBOR_PROJECT_URI}/vllm/vllm-openai:${GDCS_VLLM_IMAGE_TAG}-fips
              livenessProbe:
                failureThreshold: 3
                httpGet:
                  path: /health
                  port: 8000
                periodSeconds: 20
                timeoutSeconds: 5
              name: vllm
              ports:
                - containerPort: 8000
              readinessProbe:
                failureThreshold: 3
                httpGet:
                  path: /health
                  port: 8000
                periodSeconds: 10
                successThreshold: 1
                timeoutSeconds: 5
              resources:
                limits:
                  ${GDCS_WORKLOAD_ACCELERATOR_TYPE}: "${GDCS_WORKLOAD_ACCELERATOR_COUNT}"
                requests:
                  ${GDCS_WORKLOAD_ACCELERATOR_TYPE}: "${GDCS_WORKLOAD_ACCELERATOR_COUNT}"
              startupProbe:
                httpGet:
                  path: /health
                  port: 8000
                failureThreshold: ${GDCS_VLLM_STARTUP_FAILURE_THRESHOLD}
                periodSeconds: 10
                timeoutSeconds: 5
              volumeMounts:
                - name: model-weights
                  mountPath: ${GDCS_HF_PV_MOUNT_PATH}
                - name: shm
                  mountPath: /dev/shm
          securityContext:
            seLinuxOptions:
              type: spc_t
          imagePullSecrets:
            - name: ${GDCS_HARBOR_K8S_PULL_SECRET}
          volumes:
            - name: model-weights
              persistentVolumeClaim:
                claimName: ${GDCS_WORKLOAD_NAME}-rwo
            - name: shm
              emptyDir:
                medium: Memory
                sizeLimit: "8Gi"
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: ${GDCS_WORKLOAD_NAME}
    spec:
      ports:
        - name: vllm-http
          port: 80
          protocol: TCP
          targetPort: 8000
      selector:
        app: ${GDCS_WORKLOAD_NAME}
      type: LoadBalancer
    EOF
    
  2. Applica il manifest per il deployment vLLM:

    kubectl apply \
    --filename="${GDCS_USER_GUIDE_HOME}/${GDCS_WORKLOAD_NAME}-deployment.yaml" \
    --namespace="${GDCS_WORKLOAD_NAMESPACE}"
    
  3. Crea il manifest per vLLM NetworkPolicy:

    cat << EOF > "${GDCS_USER_GUIDE_HOME}/vllm-networkpolicy.yaml" && echo "Successfully created." || echo "Failed to create!"
    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata:
      name: allow-vllm-ingress
      namespace: ${GDCS_WORKLOAD_NAMESPACE}
    spec:
      ingress:
      - from:
        - ipBlock:
            cidr: 0.0.0.0/0
        - namespaceSelector: {}
        ports:
        - port: 8000
          protocol: TCP
      podSelector: {}
      policyTypes:
      - Ingress
    EOF
    
  4. Applica il manifest per vLLM NetworkPolicy:

    kubectl apply \
    --filename="${GDCS_USER_GUIDE_HOME}/vllm-networkpolicy.yaml"
    
  1. Attendi che il pod sia in esecuzione:

    watch --color --interval 5 --no-title \
    "kubectl get pods --selector=app=${GDCS_WORKLOAD_NAME} \
    --namespace=${GDCS_WORKLOAD_NAMESPACE} | GREP_COLORS='mt=01;92' grep -E --color=always -e '^' -e 'Running'"
    
  2. Attendi che il deployment sia pronto:

    watch --color --interval 5 --no-title \
    "kubectl get deployment/${GDCS_WORKLOAD_NAME} \
    --namespace=${GDCS_WORKLOAD_NAMESPACE} | GREP_COLORS='mt=01;92' grep -E --color=always -e '^' -e '1/1     1            1'"
    
  3. (Facoltativo) Trasmetti in streaming i log del container per monitorare l'avanzamento dell'avvio:

    kubectl logs deployment/${GDCS_WORKLOAD_NAME} \
    --follow \
    --namespace="${GDCS_WORKLOAD_NAMESPACE}"
    

Convalida

  1. Recupera l'indirizzo IP del bilanciatore del carico per vLLM:

    export VLLM_LB_IP=$(kubectl get service/${GDCS_WORKLOAD_NAME} --namespace="${GDCS_WORKLOAD_NAMESPACE}" --output=jsonpath='{.status.loadBalancer.ingress[*].ip}')
    echo "VLLM_LB_IP=${VLLM_LB_IP}"
    
  2. Invia una richiesta di test a vLLM. Il valore max_tokens è GDCS_VLLM_TEST_MAX_TOKENS da env.d/accelerator.sh; i modelli di ragionamento richiedono un budget maggiore perché la fase di ragionamento consuma token di output:

    curl http://${VLLM_LB_IP}/v1/models
    
    curl http://${VLLM_LB_IP}/v1/chat/completions \
    -H "Content-Type: application/json" \
    -d '{
      "model": "'${GDCS_HF_PV_MOUNT_PATH}/${GDCS_HF_MODEL_LOWERCASE}'",
      "messages": [
        {"role": "user", "content": "Explain Google Distributed Cloud air-gapped briefly."}
      ],
      "max_tokens": '${GDCS_VLLM_TEST_MAX_TOKENS}'
    }'
    
  3. Se l'indirizzo IP di LoadBalancer non è raggiungibile dalla workstation, ad esempio perché nessun ProjectNetworkPolicy lo ammette ancora, invia le richieste tramite port forwarding:

    kubectl port-forward service/${GDCS_WORKLOAD_NAME} \
    --namespace="${GDCS_WORKLOAD_NAMESPACE}" 8000:80 &
    PF_PID=$!
    
    sleep 1
    
    curl http://127.0.0.1:8000/v1/models
    
    kill ${PF_PID}