README.md 8.73 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
-->

Alec's avatar
Alec committed
6
# LLM Deployment using vLLM
7

8
This directory contains reference implementations for deploying Large Language Models (LLMs) in various configurations using vLLM. For Dynamo integration, we leverage vLLM's native KV cache events, NIXL based transfer mechanisms, and metric reporting to enable KV-aware routing and P/D disaggregation.
9

Anish's avatar
Anish committed
10
## Use the Latest Release
11

Anish's avatar
Anish committed
12
We recommend using the latest stable release of Dynamo to avoid breaking changes:
13

Anish's avatar
Anish committed
14
[![GitHub Release](https://img.shields.io/github/v/release/ai-dynamo/dynamo)](https://github.com/ai-dynamo/dynamo/releases/latest)
15

Anish's avatar
Anish committed
16
You can find the latest release [here](https://github.com/ai-dynamo/dynamo/releases/latest) and check out the corresponding branch with:
17

Anish's avatar
Anish committed
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
```bash
git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
```

---

## Table of Contents
- [Feature Support Matrix](#feature-support-matrix)
- [Quick Start](#quick-start)
- [Single Node Examples](#run-single-node-examples)
- [Advanced Examples](#advanced-examples)
- [Deploy on Kubernetes](#kubernetes-deployment)
- [Configuration](#configuration)

## Feature Support Matrix

### Core Dynamo Features

| Feature | vLLM | Notes |
|---------|------|-------|
38
39
40
| [**Disaggregated Serving**](../../../docs/design_docs/disagg_serving.md) | ✅ |  |
| [**Conditional Disaggregation**](../../../docs/design_docs/disagg_serving.md#conditional-disaggregation) | 🚧 | WIP |
| [**KV-Aware Routing**](../../../docs/router/kv_cache_routing.md) | ✅ |  |
41
42
43
| [**SLA-Based Planner**](../../../docs/planner/sla_planner.md) | ✅ |  |
| [**Load Based Planner**](../../../docs/planner/load_planner.md) | 🚧 | WIP |
| [**KVBM**](../../../docs/kvbm/kvbm_architecture.md) | ✅ |  |
44
| [**LMCache**](./LMCache_Integration.md) | ✅ |  |
Anish's avatar
Anish committed
45
46
47
48
49
50
51
52
53

### Large Scale P/D and WideEP Features

| Feature            | vLLM | Notes                                                                 |
|--------------------|------|-----------------------------------------------------------------------|
| **WideEP**         | ✅   | Support for PPLX / DeepEP not verified                                           |
| **DP Rank Routing**| ✅   | Supported via external control of DP ranks |
| **GB200 Support**  | 🚧   | Container functional on main |

54
## vLLM Quick Start
Anish's avatar
Anish committed
55
56
57
58
59
60

Below we provide a guide that lets you run all of our the common deployment patterns on a single node.

### Start NATS and ETCD in the background

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

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

Anish's avatar
Anish committed
66
67
68
### Pull or build container

We have public images available on [NGC Catalog](https://catalog.ngc.nvidia.com/orgs/nvidia/teams/ai-dynamo/collections/ai-dynamo/artifacts). If you'd like to build your own container from source:
69
70

```bash
Alec's avatar
Alec committed
71
./container/build.sh --framework VLLM
72
73
```

Anish's avatar
Anish committed
74
75
### Run container

76
```bash
Alec's avatar
Alec committed
77
./container/run.sh -it --framework VLLM [--mount-workspace]
78
79
```

Alec's avatar
Alec committed
80
This includes the specific commit [vllm-project/vllm#19790](https://github.com/vllm-project/vllm/pull/19790) which enables support for external control of the DP ranks.
81

Anish's avatar
Anish committed
82
83
84
85
## Run Single Node Examples

> [!IMPORTANT]
> Below we provide simple shell scripts that run the components for each configuration. Each shell script runs `python3 -m dynamo.frontend` to start the ingress and uses `python3 -m dynamo.vllm` to start the vLLM workers. You can also run each command in separate terminals for better log visibility.
86

Alec's avatar
Alec committed
87
This figure shows an overview of the major components to deploy:
88

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
```mermaid
%%{init: {'theme':'base', 'themeVariables': { 'fontSize':'10px', 'primaryColor':'#2e8b57', 'primaryTextColor':'#fff', 'primaryBorderColor':'#333', 'lineColor':'#81b1db', 'secondaryColor':'#b35900', 'tertiaryColor':'#808080', 'edgeLabelBackground':'transparent'}}}%%
graph TD
    %% Node Definitions with custom shapes
    HTTP[HTTP]
    ROUTER[Router]
    PREFILL[vLLM Prefill Worker]
    DECODE[vLLM Decode Worker]

    %% Class Definitions for color
    classDef worker_style fill:#2e8b57,stroke:#333,stroke-width:2px,color:#fff;
    classDef router_style fill:#b35900,stroke:#333,stroke-width:2px,color:#fff;

    %% Applying classes to nodes
    class PREFILL,DECODE worker_style
    class ROUTER router_style

    %% Request/Response flow
    HTTP <--> |"request/response"| ROUTER
    ROUTER --> |"1. send to prefill"| PREFILL
    PREFILL --> |"2. return NIXL metadata"| ROUTER
    ROUTER --> |"3. send with metadata"| DECODE
    DECODE --> |"4. stream response"| ROUTER

    %% KV Events publishing
    PREFILL -.-> |"publish kv events"| ROUTER
Alec's avatar
Alec committed
115
```
116

Alec's avatar
Alec committed
117
Note: The above architecture illustrates all the components. The final components that get spawned depend upon the chosen deployment pattern.
118

Anish's avatar
Anish committed
119
### Aggregated Serving
120
121

```bash
Alec's avatar
Alec committed
122
# requires one gpu
123
cd examples/backends/vllm
Alec's avatar
Alec committed
124
bash launch/agg.sh
125
126
```

Anish's avatar
Anish committed
127
### Aggregated Serving with KV Routing
128
129

```bash
Alec's avatar
Alec committed
130
# requires two gpus
131
cd examples/backends/vllm
Alec's avatar
Alec committed
132
bash launch/agg_router.sh
133
134
```

Anish's avatar
Anish committed
135
### Disaggregated Serving
136
137

```bash
Alec's avatar
Alec committed
138
# requires two gpus
139
cd examples/backends/vllm
Alec's avatar
Alec committed
140
bash launch/disagg.sh
141
142
```

Anish's avatar
Anish committed
143
### Disaggregated Serving with KV Routing
144
145

```bash
Alec's avatar
Alec committed
146
# requires three gpus
147
cd examples/backends/vllm
Alec's avatar
Alec committed
148
bash launch/disagg_router.sh
149
150
```

Anish's avatar
Anish committed
151
### Single Node Data Parallel Attention / Expert Parallelism
Alec's avatar
Alec committed
152

Anish's avatar
Anish committed
153
This example is not meant to be performant but showcases Dynamo routing to data parallel workers
154
155

```bash
Alec's avatar
Alec committed
156
# requires four gpus
157
cd examples/backends/vllm
Alec's avatar
Alec committed
158
bash launch/dep.sh
159
160
```

Alec's avatar
Alec committed
161
162
> [!TIP]
> Run a disaggregated example and try adding another prefill worker once the setup is running! The system will automatically discover and utilize the new worker.
163

Anish's avatar
Anish committed
164
165
166
167
## Advanced Examples

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

168
169
170
171
172
173
174
### Speculative Decoding with Aggregated Serving (Meta-Llama-3.1-8B-Instruct + Eagle3)

Run **Meta-Llama-3.1-8B-Instruct** with **Eagle3** as a draft model using **aggregated speculative decoding** on a single node.
This setup demonstrates how to use Dynamo to create an instance using Eagle-based speculative decoding under the **VLLM aggregated serving framework** for faster inference while maintaining accuracy.

**Guide:** [Speculative Decoding Quickstart](./speculative_decoding.md)

175
176
### Kubernetes Deployment

177
For complete Kubernetes deployment instructions, configurations, and troubleshooting, see [vLLM Kubernetes Deployment Guide](../../../examples/backends/vllm/deploy/README.md)
Alec's avatar
Alec committed
178
179
180
181
182
183
184
185

## Configuration

vLLM workers are configured through command-line arguments. Key parameters include:

- `--model`: Model to serve (e.g., `Qwen/Qwen3-0.6B`)
- `--is-prefill-worker`: Enable prefill-only mode for disaggregated serving
- `--metrics-endpoint-port`: Port for publishing KV metrics to Dynamo
186
- `--connector`: Specify which kv_transfer_config you want vllm to use `[nixl, lmcache, kvbm, none]`. This is a helper flag which overwrites the engines KVTransferConfig.
Alec's avatar
Alec committed
187
188
189
190

See `args.py` for the full list of configuration options and their defaults.

The [documentation](https://docs.vllm.ai/en/v0.9.2/configuration/serve_args.html?h=serve+arg) for the vLLM CLI args points to running 'vllm serve --help' to see what CLI args can be added. We use the same argument parser as vLLM.
191

192
193
194
195
196
197
198
199
200
201
### Hashing Consistency for KV Events

When using KV-aware routing, ensure deterministic hashing across processes to avoid radix tree mismatches. Choose one of the following:

- Set `PYTHONHASHSEED=0` for all vLLM processes when relying on Python's builtin hashing for prefix caching.
- If your vLLM version supports it, configure a deterministic prefix caching algorithm, for example:

```bash
vllm serve ... --enable-prefix-caching --prefix-caching-algo sha256
```
202
See the high-level notes in [KV Cache Routing](../../../docs/router/kv_cache_routing.md) on deterministic event IDs.
203

204
205
## Request Migration

206
You can enable [request migration](../../../docs/fault_tolerance/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:
207
208
209
210
211

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

212
This allows a request to be migrated up to 3 times before failing. See the [Request Migration Architecture](../../../docs/fault_tolerance/request_migration.md) documentation for details on how this works.
213
214
215
216
217
218
219
220
221
222
223
224

## Request Cancellation

When a user cancels a request (e.g., by disconnecting from the frontend), the request is automatically cancelled across all workers, freeing compute resources for other requests.

### Cancellation Support Matrix

| | Prefill | Decode |
|-|---------|--------|
| **Aggregated** | ✅ | ✅ |
| **Disaggregated** | ✅ | ✅ |

225
For more details, see the [Request Cancellation Architecture](../../../docs/fault_tolerance/request_cancellation.md) documentation.