agg_multimodal.sh 3.18 KB
Newer Older
1
#!/bin/bash
2
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3
# SPDX-License-Identifier: Apache-2.0
4
5
6
7
8
9
10
11
12
13
#
# Aggregated multimodal serving with standard Dynamo preprocessing
#
# Architecture: Single-worker PD (Prefill-Decode)
# - Frontend: Rust OpenAIPreprocessor handles image URLs (HTTP and data:// base64)
# - Worker: Standard vLLM worker with vision model support
#
# For EPD (Encode-Prefill-Decode) architecture with dedicated encoding worker,
# see agg_multimodal_epd.sh

14
15
16
set -e
trap 'echo Cleaning up...; kill 0' EXIT

17
18
19
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../../../common/launch_utils.sh"

20
# Default values
21
MODEL_NAME="Qwen/Qwen3-VL-30B-A3B-Instruct-FP8"
22
23

# Parse command line arguments
24
25
# Extra arguments are passed through to the vLLM worker
EXTRA_ARGS=()
26
27
28
29
30
31
32
while [[ $# -gt 0 ]]; do
    case $1 in
        --model)
            MODEL_NAME=$2
            shift 2
            ;;
        -h|--help)
33
            echo "Usage: $0 [OPTIONS] [-- EXTRA_VLLM_ARGS]"
34
            echo "Options:"
35
36
37
38
39
            echo "  --model <model_name>   Specify the VLM model to use (default: $MODEL_NAME)"
            echo "  -h, --help             Show this help message"
            echo ""
            echo "Any additional arguments are passed through to the vLLM worker."
            echo "Example: $0 --model Qwen/Qwen3-VL-30B-A3B-Instruct-FP8 --dyn-tool-call-parser hermes"
40
41
42
            exit 0
            ;;
        *)
43
44
            EXTRA_ARGS+=("$1")
            shift
45
46
47
48
            ;;
    esac
done

49
HTTP_PORT="${DYN_HTTP_PORT:-8000}"
50
print_launch_banner --multimodal "Launching Aggregated Multimodal Serving" "$MODEL_NAME" "$HTTP_PORT"
51

52
53
54
55
56
# Use TCP transport (instead of default NATS)
# TCP is preferred for multimodal workloads because it overcomes:
# - NATS default 1MB max payload limit (multimodal base64 images can exceed this)
export DYN_REQUEST_PLANE=tcp

57
# Start frontend with Rust OpenAIPreprocessor
58
59
# dynamo.frontend accepts either --http-port flag or DYN_HTTP_PORT env var (defaults to 8000)
python -m dynamo.frontend &
60

61
# Configure GPU memory optimization for specific models (if no extra args override)
62
MODEL_SPECIFIC_ARGS="--gpu-memory-utilization 0.85 --max-model-len 16384"
63
if [[ "$MODEL_NAME" == "Qwen/Qwen2.5-VL-7B-Instruct" ]]; then
64
    MODEL_SPECIFIC_ARGS="--gpu-memory-utilization 0.85 --max-model-len 4096"
65
elif [[ "$MODEL_NAME" == "llava-hf/llava-1.5-7b-hf" ]]; then
66
    MODEL_SPECIFIC_ARGS="--gpu-memory-utilization 0.85 --max-model-len 4096"
67
68
elif [[ "$MODEL_NAME" == "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8" ]]; then
    MODEL_SPECIFIC_ARGS="--tensor-parallel-size=8 --gpu-memory-utilization 0.85 --max-model-len=108960"
69
70
fi

71
72
73
# Start vLLM worker with vision model
# Multimodal data (images) are decoded in the backend worker using ImageLoader
# --enforce-eager: Quick deployment (remove for production)
74
# Extra args from command line come last to allow overrides
75
CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES:-0} \
76
DYN_SYSTEM_PORT=${DYN_SYSTEM_PORT:-8081} \
77
    python -m dynamo.vllm --enable-multimodal --model $MODEL_NAME $MODEL_SPECIFIC_ARGS "${EXTRA_ARGS[@]}"
78

79
80
# Exit on first worker failure; kill 0 in the EXIT trap tears down the rest
wait_any_exit