agg_embed.sh 2.15 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 embedding model serving.
# 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
19
20
21
22
23
24
25
# Parse command line arguments
while [[ $# -gt 0 ]]; do
    case $1 in
        -h|--help)
            echo "Usage: $0 [OPTIONS]"
            echo "Options:"
            echo "  -h, --help           Show this help message"
            echo ""
            echo "Note: System metrics are enabled by default on port 8081 (worker)"
26
            echo "Note: OpenTelemetry tracing is not yet supported for embedding models"
27
28
29
30
31
32
33
34
35
36
            exit 0
            ;;
        *)
            echo "Unknown option: $1"
            echo "Use --help for usage information"
            exit 1
            ;;
    esac
done

37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
MODEL="Qwen/Qwen3-Embedding-4B"
HTTP_PORT="${DYN_HTTP_PORT:-8000}"
echo "=========================================="
echo "Launching Embedding 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/embeddings \\"
echo "    -H 'Content-Type: application/json' \\"
echo "    -d '{"
echo "      \"model\": \"${MODEL}\","
52
echo "      \"input\": \"Explain why Roger Federer is considered one of the greatest tennis players of all time\""
53
54
55
56
echo "    }'"
echo ""
echo "=========================================="

57
# run ingress
58
59
# dynamo.frontend accepts either --http-port flag or DYN_HTTP_PORT env var (defaults to 8000)
python3 -m dynamo.frontend &
60
61
62
DYNAMO_PID=$!

# run worker
63
DYN_SYSTEM_PORT=${DYN_SYSTEM_PORT:-8081} \
64
65
66
67
68
69
70
python3 -m dynamo.sglang \
  --embedding-worker \
  --model-path Qwen/Qwen3-Embedding-4B \
  --served-model-name Qwen/Qwen3-Embedding-4B \
  --page-size 16 \
  --tp 1 \
  --trust-remote-code \
71
  --use-sglang-tokenizer \
72
  --enable-metrics