agg.sh 2.86 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
#
# Aggregated serving: single worker handles both prefill and decode.
# GPUs: 1
7
8
9
10
11
12
13
14
15
16

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

17
18
# Default values
MODEL="Qwen/Qwen3-0.6B"
19
ENABLE_OTEL=false
20
21
22

# Parse command line arguments
EXTRA_ARGS=()
23
24
while [[ $# -gt 0 ]]; do
    case $1 in
25
26
27
28
        --model-path)
            MODEL="$2"
            shift 2
            ;;
29
30
31
32
33
34
35
        --enable-otel)
            ENABLE_OTEL=true
            shift
            ;;
        -h|--help)
            echo "Usage: $0 [OPTIONS]"
            echo "Options:"
36
            echo "  --model-path <name>  Specify model (default: $MODEL)"
37
38
39
            echo "  --enable-otel        Enable OpenTelemetry tracing"
            echo "  -h, --help           Show this help message"
            echo ""
40
            echo "Additional SGLang/Dynamo flags can be passed and will be forwarded"
41
42
43
44
            echo "Note: System metrics are enabled by default on port 8081 (worker)"
            exit 0
            ;;
        *)
45
46
            EXTRA_ARGS+=("$1")
            shift
47
48
49
50
51
            ;;
    esac
done

# Enable tracing if requested
52
TRACE_ARGS=()
53
54
55
56
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}
57
    TRACE_ARGS+=(--enable-trace --otlp-traces-endpoint localhost:4317)
58
fi
59

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
HTTP_PORT="${DYN_HTTP_PORT:-8000}"
echo "=========================================="
echo "Launching Aggregated LLM Worker"
echo "=========================================="
echo "Model:       $MODEL"
echo "Frontend:    http://localhost:$HTTP_PORT"
echo "=========================================="
echo ""
echo "Example test command:"
echo ""
echo "  curl http://localhost:${HTTP_PORT}/v1/chat/completions \\"
echo "    -H 'Content-Type: application/json' \\"
echo "    -d '{"
echo "      \"model\": \"${MODEL}\","
echo "      \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}],"
echo "      \"max_tokens\": 32"
echo "    }'"
echo ""
echo "=========================================="

80
# run ingress
81
# dynamo.frontend accepts either --http-port flag or DYN_HTTP_PORT env var (defaults to 8000)
82
OTEL_SERVICE_NAME=dynamo-frontend \
83
python3 -m dynamo.frontend &
84
85
DYNAMO_PID=$!

86
# run worker with metrics enabled
87
OTEL_SERVICE_NAME=dynamo-worker DYN_SYSTEM_PORT=${DYN_SYSTEM_PORT:-8081} \
88
python3 -m dynamo.sglang \
89
90
  --model-path "$MODEL" \
  --served-model-name "$MODEL" \
91
92
  --page-size 16 \
  --tp 1 \
93
94
  --trust-remote-code \
  --skip-tokenizer-init \
95
  --enable-metrics \
96
  "${TRACE_ARGS[@]}" \
97
  "${EXTRA_ARGS[@]}"