"components/backends/sglang/deploy/disagg_planner.yaml" did not exist on "5bf23d54f3e46a15ff5000773a32d8829befa919"
README.md 7.05 KB
Newer Older
1
2
3
4
5
<!--
SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: Apache-2.0
-->

6
# LLM Deployment using SGLang
7

8
This directory contains an SGLang component for Dynamo and reference implementations for deploying Large Language Models (LLMs) in various configurations using SGLang. SGLang internally uses ZMQ to communicate between the ingress and the engine processes. For Dynamo, we leverage the runtime to communicate directly with the engine processes and handle ingress and pre/post processing on our end.
9

10
11
12
13
14
15
16
17
18
19
20
21
## Use the Latest Release

We recommend using the latest stable release of dynamo to avoid breaking changes:

[![GitHub Release](https://img.shields.io/github/v/release/ai-dynamo/dynamo)](https://github.com/ai-dynamo/dynamo/releases/latest)

You can find the latest release [here](https://github.com/ai-dynamo/dynamo/releases/latest) and check out the corresponding branch with:

```bash
git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
```

22
---
23

24
25
26
27
28
29
## Table of Contents
- [Feature Support Matrix](#feature-support-matrix)
- [Quick Start](#quick-start)
- [Single Node Examples](#run-single-node-examples)
- [Multi-Node and Advanced Examples](#advanced-examples)
- [Deploy on SLURM or Kubernetes](#deployment)
30

31
## Feature Support Matrix
32

33
### Core Dynamo Features
34

35
36
| Feature | SGLang | Notes |
|---------|--------|-------|
37
38
39
40
41
42
| [**Disaggregated Serving**](../../../docs/architecture/disagg_serving.md) | ✅ |  |
| [**Conditional Disaggregation**](../../../docs/architecture/disagg_serving.md#conditional-disaggregation) | 🚧 | WIP [PR](https://github.com/sgl-project/sglang/pull/7730) |
| [**KV-Aware Routing**](../../../docs/architecture/kv_cache_routing.md) | ✅ |  |
| [**SLA-Based Planner**](../../../docs/architecture/sla_planner.md) | ❌ | Planned |
| [**Load Based Planner**](../../../docs/architecture/load_planner.md) | ❌ | Planned |
| [**KVBM**](../../../docs/architecture/kvbm_architecture.md) | ❌ | Planned |
43

44
45
### Large Scale P/D and WideEP Features

ishandhanani's avatar
ishandhanani committed
46
47
48
49
50
| Feature             | SGLang | Notes                                                        |
|---------------------|--------|--------------------------------------------------------------|
| **WideEP**          | ✅     | Full support on H100s/GB200                                  |
| **DP Rank Routing** | 🚧     | Direct routing supported. Dynamo KV router does not router to DP worker |
| **GB200 Support**   | ✅     |                                                              |
51
52
53
54
55
56
57
58


## Quick Start

Below we provide a guide that lets you run all of our the common deployment patterns on a single node. See our different [architectures](../llm/README.md#deployment-architectures) for a high level overview of each pattern and the architecture diagram for each.

### Start NATS and ETCD in the background

59
Start using [Docker Compose](../../../deploy/docker-compose.yml)
60

61
```bash
62
docker compose -f deploy/docker-compose.yml up -d
63
64
```

65
### Build container
66
67

```bash
68
69
70
# pull our pre-build sglang runtime container
docker pull nvcr.io/nvidia/ai-dynamo/sglang-runtime:0.3.2
# or build from source
71
./container/build.sh --framework sglang
72
73
74
75
76
```

### Run container

```bash
77
./container/run.sh -it --framework sglang
78
79
```

80
## Run Single Node Examples
81

82
> [!IMPORTANT]
83
84
85
> Each example corresponds to a simple bash script that runs the OpenAI compatible server, processor, and optional router (written in Rust) and LLM engine (written in Python) in a single terminal. You can easily take each command and run them in separate terminals.
>
> Additionally - because we use sglang's argument parser, you can pass in any argument that sglang supports to the worker!
86

87
88

### Aggregated Serving
89
90

```bash
91
cd $DYNAMO_ROOT/components/backends/sglang
92
./launch/agg.sh
93
```
94

95
### Aggregated Serving with KV Routing
96
97

```bash
98
cd $DYNAMO_ROOT/components/backends/sglang
99
./launch/agg_router.sh
100
101
```

102
### Disaggregated serving
103

104
<details>
105
<summary>Under the hood: SGLang Load Balancer vs Dynamo Discovery</summary>
106
107

SGLang uses a mini load balancer to route requests to handle disaggregated serving. The load balancer functions as follows:
108
109
110
111
112
113
114
115

1. The load balancer receives a request from the client
2. A random `(prefill, decode)` pair is selected from the pool of available workers
3. Request is sent to both `prefill` and `decode` workers via asyncio tasks
4. Internally disaggregation is done from prefill -> decode

Because Dynamo has a discovery mechanism, we do not use a load balancer. Instead, we first route to a random prefill worker, select a random decode worker, and then send the request to both. Internally, SGLang's bootstrap server (which is a part of the `tokenizer_manager`) is used in conjuction with NIXL to handle the kv transfer.

116
117
</details>

118
119
120
121
> [!IMPORTANT]
> Disaggregated serving in SGLang currently requires each worker to have the same tensor parallel size [unless you are using an MLA based model](https://github.com/sgl-project/sglang/pull/5922)

```bash
122
cd $DYNAMO_ROOT/components/backends/sglang
123
./launch/disagg.sh
124
```
125

126
### Disaggregated Serving with Mixture-of-Experts (MoE) models and DP attention
127

128
You can use this configuration to test out disaggregated serving with dp attention and expert parallelism on a single node before scaling to the full DeepSeek-R1 model across multiple nodes.
129
130
131

```bash
# note this will require 4 GPUs
132
cd $DYNAMO_ROOT/components/backends/sglang
133
./launch/disagg_dp_attn.sh
134
```
135

136
137
When using MoE models, you can also use the our implementation of the native SGLang endpoints to record expert distribution data. The `disagg_dp_attn.sh` script automatically sets up the SGLang HTTP server, the environment variable that controls the expert distribution recording directory, and sets up the expert distribution recording mode to `stat`. You can learn more about expert parallelism load balancing [here](docs/expert-distribution-eplb.md).

138
139
## Request Migration

140
You can enable [request migration](../../../docs/architecture/request_migration.md) to handle worker failures gracefully. Use the `--migration-limit` flag to specify how many times a request can be migrated to another worker:
141
142
143
144
145

```bash
python3 -m dynamo.sglang ... --migration-limit=3
```

146
This allows a request to be migrated up to 3 times before failing. See the [Request Migration Architecture](../../../docs/architecture/request_migration.md) documentation for details on how this works.
147

148
149
150
151
## Advanced Examples

Below we provide a selected list of advanced examples. Please open up an issue if you'd like to see a specific example!

ishandhanani's avatar
ishandhanani committed
152
### Run a multi-node sized model
153
154
155
156
157
158
159
160
161
162
163
- **[Run a multi-node model](docs/multinode-examples.md)**

### Large scale P/D disaggregation with WideEP
- **[Run DeepSeek-R1 on 104+ H100s](docs/dsr1-wideep-h100.md)**
- **[Run DeepSeek-R1 on GB200s](docs/dsr1-wideep-gb200.md)**

### Supporting SGLang's native endpoints via Dynamo
- **[HTTP Server for native SGLang endpoints](docs/sgl-http-server.md)**

## Deployment

164
We currently provide deployment examples for Kubernetes and SLURM.
165

166
## Kubernetes
167
- **[Deploying Dynamo with SGLang on Kubernetes](deploy/README.md)**
168

169
## SLURM
170
- **[Deploying Dynamo with SGLang on SLURM](slurm_jobs/README.md)**