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

# Setup cleanup trap
cleanup() {
    echo "Cleaning up background processes..."
    kill $DYNAMO_PID $PREFILL_PID 2>/dev/null || true
    wait $DYNAMO_PID $PREFILL_PID 2>/dev/null || true
    echo "Cleanup complete."
}
trap cleanup EXIT INT TERM

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Parse command line arguments
ENABLE_OTEL=false
while [[ $# -gt 0 ]]; do
    case $1 in
        --enable-otel)
            ENABLE_OTEL=true
            shift
            ;;
        -h|--help)
            echo "Usage: $0 [OPTIONS]"
            echo "Options:"
            echo "  --enable-otel        Enable OpenTelemetry tracing"
            echo "  -h, --help           Show this help message"
            echo ""
            echo "Note: System metrics are enabled by default on ports 8081 (prefill), 8082 (decode)"
            exit 0
            ;;
        *)
            echo "Unknown option: $1"
            echo "Use --help for usage information"
            exit 1
            ;;
    esac
done

# Enable tracing if requested
if [ "$ENABLE_OTEL" = true ]; then
    export DYN_LOGGING_JSONL=true
    export OTEL_EXPORT_ENABLED=1
    export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=${OTEL_EXPORTER_OTLP_TRACES_ENDPOINT:-http://localhost:4317}
fi
45
46

# run ingress
47
# dynamo.frontend accepts either --http-port flag or DYN_HTTP_PORT env var (defaults to 8000)
48
OTEL_SERVICE_NAME=dynamo-frontend \
49
python3 -m dynamo.frontend &
50
51
DYNAMO_PID=$!

52
53
#AssertionError: Prefill round robin balance is required when dp size > 1. Please make sure that the prefill instance is launched with `--load-balance-method round_robin` and `--prefill-round-robin-balance` is set for decode server.

54
# run prefill worker
55
OTEL_SERVICE_NAME=dynamo-worker-prefill DYN_SYSTEM_PORT=${DYN_SYSTEM_PORT_PREFILL:-8081} \
56
python3 -m dynamo.sglang \
57
58
  --model-path silence09/DeepSeek-R1-Small-2layers \
  --served-model-name silence09/DeepSeek-R1-Small-2layers \
59
  --page-size 16 \
60
61
  --tp 2 --dp-size 2 --enable-dp-attention \
  --load-balance-method round_robin \
62
63
  --trust-remote-code \
  --disaggregation-mode prefill \
64
65
  --disaggregation-bootstrap-port 12345 \
  --host 0.0.0.0 \
66
  --port 40000 \
67
  --disaggregation-transfer-backend nixl \
68
  --enable-metrics --log-level debug &
69
70
71
PREFILL_PID=$!

# run decode worker
72
OTEL_SERVICE_NAME=dynamo-worker-decode DYN_SYSTEM_PORT=${DYN_SYSTEM_PORT_DECODE:-8082} \
73
74
75
CUDA_VISIBLE_DEVICES=2,3 python3 -m dynamo.sglang \
  --model-path silence09/DeepSeek-R1-Small-2layers \
  --served-model-name silence09/DeepSeek-R1-Small-2layers \
76
  --page-size 16 \
77
78
  --prefill-round-robin-balance \
  --tp 2 --dp-size 2 --enable-dp-attention \
79
80
  --trust-remote-code \
  --disaggregation-mode decode \
81
82
  --disaggregation-bootstrap-port 12345 \
  --host 0.0.0.0 \
83
  --disaggregation-transfer-backend nixl \
84
  --enable-metrics --log-level debug