disagg_multimodal_llama.sh 2.34 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set -ex

# Default values
HEAD_NODE=0

# Parse command line arguments
while [[ $# -gt 0 ]]; do
    case $1 in
        --head-node)
            HEAD_NODE=1
            shift 1
            ;;
        -h|--help)
            echo "Usage: $0 [OPTIONS]"
18
19
20
            echo ""
            echo "Disaggregated multimodal serving with separate Prefill/Decode workers for Llama 4"
            echo ""
21
22
23
            echo "Options:"
            echo "  --head-node          Run as head node. Head node will run the HTTP server, processor and prefill worker."
            echo "  -h, --help           Show this help message"
24
25
26
27
28
29
30
31
            echo ""
            echo "Examples:"
            echo "  # On head node:"
            echo "  $0 --head-node"
            echo ""
            echo "  # On worker node (requires NATS_SERVER and ETCD_ENDPOINTS pointing to head node):"
            echo "  $0"
            echo ""
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
            exit 0
            ;;
        *)
            echo "Unknown option: $1"
            echo "Use --help for usage information"
            exit 1
            ;;
    esac
done

trap 'echo Cleaning up...; kill 0' EXIT

MODEL_NAME="meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8"

if [[ $HEAD_NODE -eq 1 ]]; then
    # run ingress
48
    python -m dynamo.frontend --http-port=8000 &
49
50

    # run processor
51
52
53
54
55
    python -m dynamo.vllm --multimodal-processor --model $MODEL_NAME --mm-prompt-template "<|image|>\n<prompt>" &

    # Llama 4 doesn't support image embedding input, so the prefill worker will also
    # handle image encoding inline.
    # run prefill worker
56
    VLLM_NIXL_SIDE_CHANNEL_PORT=20097 python -m dynamo.vllm --multimodal-encode-prefill-worker --is-prefill-worker --model $MODEL_NAME --tensor-parallel-size=8 --max-model-len=208960 --gpu-memory-utilization 0.80 --kv-events-config '{"publisher":"zmq","topic":"kv-events","endpoint":"tcp://*:20080"}' &
57
58
else
    # run decode worker on non-head node
59
    VLLM_NIXL_SIDE_CHANNEL_PORT=20098 python -m dynamo.vllm --multimodal-decode-worker --model $MODEL_NAME --tensor-parallel-size=8 --max-model-len=208960 --gpu-memory-utilization 0.80 --kv-events-config '{"publisher":"zmq","topic":"kv-events","endpoint":"tcp://*:20081"}' &
60
61
62
63
fi

# Wait for all background processes to complete
wait