README.md 12.6 KB
Newer Older
Neelay Shah's avatar
Neelay Shah committed
1
<!--
Neelay Shah's avatar
Neelay Shah committed
2
SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Neelay Shah's avatar
Neelay Shah committed
3
SPDX-License-Identifier: Apache-2.0
4
5
6
7
8
9
10
11
12
13
14
15

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Neelay Shah's avatar
Neelay Shah committed
16
-->
17
![Dynamo banner](./docs/images/frontpage-banner.png)
Neelay Shah's avatar
Neelay Shah committed
18

19
20
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![GitHub Release](https://img.shields.io/github/v/release/ai-dynamo/dynamo)](https://github.com/ai-dynamo/dynamo/releases/latest)
21
[![Discord](https://dcbadge.limes.pink/api/server/D92uqZRjCZ?style=flat)](https://discord.gg/D92uqZRjCZ)
22
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/ai-dynamo/dynamo)
Meenakshi Sharma's avatar
Meenakshi Sharma committed
23

Harry Kim's avatar
Harry Kim committed
24
| **[Roadmap](https://github.com/ai-dynamo/dynamo/issues/762)** | **[Support matrix](https://github.com/ai-dynamo/dynamo/blob/main/docs/support_matrix.md)** | **[Documentation](https://docs.nvidia.com/dynamo/latest/index.html)** | **[Examples](https://github.com/ai-dynamo/dynamo/tree/main/examples)** | **[Prebuilt containers](https://catalog.ngc.nvidia.com/orgs/nvidia/teams/ai-dynamo/collections/ai-dynamo)** | **[Design Proposals](https://github.com/ai-dynamo/enhancements)** | **[Blogs](https://developer.nvidia.com/blog/tag/nvidia-dynamo)**
25

Anish's avatar
Anish committed
26
# NVIDIA Dynamo
27

Anish's avatar
Anish committed
28
High-throughput, low-latency inference framework designed for serving generative AI and reasoning models in multi-node distributed environments.
29

30
31
32
33
## Latest News

* [08/05] Deploy `openai/gpt-oss-120b` with disaggregated serving on NVIDIA Blackwell GPUs using Dynamo [➡️ link](./components/backends/trtllm/gpt-oss.md)

Anish's avatar
Anish committed
34
## The Era of Multi-GPU, Multi-Node
35

Anish's avatar
Anish committed
36
37
38
<p align="center">
  <img src="./docs/images/frontpage-gpu-vertical.png" alt="Multi Node Multi-GPU topology" width="600" />
</p>
39

Anish's avatar
Anish committed
40
Large language models are quickly outgrowing the memory and compute budget of any single GPU. Tensor-parallelism solves the capacity problem by spreading each layer across many GPUs—and sometimes many servers—but it creates a new one: how do you coordinate those shards, route requests, and share KV cache fast enough to feel like one accelerator? This orchestration gap is exactly what NVIDIA Dynamo is built to close.
41

Anish's avatar
Anish committed
42
Dynamo is designed to be inference engine agnostic (supports TRT-LLM, vLLM, SGLang or others) and captures LLM-specific capabilities such as:
43

Neelay Shah's avatar
Neelay Shah committed
44
45
46
47
48
- **Disaggregated prefill & decode inference** – Maximizes GPU throughput and facilitates trade off between throughput and latency.
- **Dynamic GPU scheduling** – Optimizes performance based on fluctuating demand
- **LLM-aware request routing** – Eliminates unnecessary KV cache re-computation
- **Accelerated data transfer** – Reduces inference response time using NIXL.
- **KV cache offloading** – Leverages multiple memory hierarchies for higher system throughput
49

Anish's avatar
Anish committed
50
51
52
53
54
<p align="center">
  <img src="./docs/images/frontpage-architecture.png" alt="Dynamo architecture" width="600" />
</p>

## Framework Support Matrix
Neelay Shah's avatar
Neelay Shah committed
55

Anish's avatar
Anish committed
56
57
58
59
60
| Feature | vLLM | SGLang | TensorRT-LLM |
|---------|----------------------|----------------------------|----------------------------------------|
| [**Disaggregated Serving**](/docs/architecture/disagg_serving.md) | ✅ | ✅ | ✅ |
| [**Conditional Disaggregation**](/docs/architecture/disagg_serving.md#conditional-disaggregation) | 🚧 | 🚧 | 🚧 |
| [**KV-Aware Routing**](/docs/architecture/kv_cache_routing.md) | ✅ | ✅ | ✅ |
61
62
| [**Load Based Planner**](/docs/architecture/load_planner.md) | 🚧 | 🚧 | 🚧 |
| [**SLA-Based Planner**](/docs/architecture/sla_planner.md) | ✅ | ✅ | 🚧 |
Harry Kim's avatar
Harry Kim committed
63
| [**KVBM**](/docs/architecture/kvbm_architecture.md) | ✅ | 🚧 | ✅ |
64

Anish's avatar
Anish committed
65
66
67
68
To learn more about each framework and their capabilities, check out each framework's README!
- **[vLLM](components/backends/vllm/README.md)**
- **[SGLang](components/backends/sglang/README.md)**
- **[TensorRT-LLM](components/backends/trtllm/README.md)**
69

Anish's avatar
Anish committed
70
71
72
Built in Rust for performance and in Python for extensibility, Dynamo is fully open-source and driven by a transparent, OSS (Open Source Software) first development approach.

# Installation
73

Neelay Shah's avatar
Neelay Shah committed
74
The following examples require a few system level packages.
75
Recommended to use Ubuntu 24.04 with a x86_64 CPU. See [docs/support_matrix.md](docs/support_matrix.md)
76

Anish's avatar
Anish committed
77
78
79
80
81
82
## 1. Initial setup

The Dynamo team recommends the `uv` Python package manager, although any way works. Install uv:
```
curl -LsSf https://astral.sh/uv/install.sh | sh
```
83

Anish's avatar
Anish committed
84
85
86
### Install etcd and NATS (required)

To coordinate across a data center, Dynamo relies on etcd and NATS. To run Dynamo locally, these need to be available.
87

88
89
- [etcd](https://etcd.io/) can be run directly as `./etcd`.
- [nats](https://nats.io/) needs jetstream enabled: `nats-server -js`.
90

Anish's avatar
Anish committed
91
To quickly setup etcd & NATS, you can also run:
92
```
Anish's avatar
Anish committed
93
94
# At the root of the repository:
docker compose -f deploy/docker-compose.yml up -d
95
96
```

Anish's avatar
Anish committed
97
## 2. Select an engine
98

Anish's avatar
Anish committed
99
We publish Python wheels specialized for each of our supported engines: vllm, sglang, trtllm, and llama.cpp. The examples that follow use SGLang; continue reading for other engines.
100

101
```
102
103
104
uv venv venv
source venv/bin/activate
uv pip install pip
105

106
# Choose one
Anish's avatar
Anish committed
107
uv pip install "ai-dynamo[sglang]"  #replace with [vllm], [trtllm], etc.
108
```
109

Anish's avatar
Anish committed
110
## 3. Run Dynamo
111
112
113
114

### Running an LLM API server

Dynamo provides a simple way to spin up a local set of inference components including:
115

Neelay Shah's avatar
Neelay Shah committed
116
117
118
- **OpenAI Compatible Frontend** – High performance OpenAI compatible http api server written in Rust.
- **Basic and Kv Aware Router** – Route and load balance traffic to a set of workers.
- **Workers** – Set of pre-configured LLM serving engines.
119
120

```
Graham King's avatar
Graham King committed
121
122
# Start an OpenAI compatible HTTP server, a pre-processor (prompt templating and tokenization) and a router.
# Pass the TLS certificate and key paths to use HTTPS instead of HTTP.
123
python -m dynamo.frontend --http-port 8000 [--tls-cert-path cert.pem] [--tls-key-path key.pem]
124

Anish's avatar
Anish committed
125
# Start the SGLang engine, connecting to NATS and etcd to receive requests. You can run several of these,
126
# both for the same model and for multiple models. The frontend node will discover them.
127
python -m dynamo.sglang.worker --model deepseek-ai/DeepSeek-R1-Distill-Llama-8B --skip-tokenizer-init
128
129
```

Neelay Shah's avatar
Neelay Shah committed
130
#### Send a Request
131

132
```bash
133
curl localhost:8000/v1/chat/completions   -H "Content-Type: application/json"   -d '{
Neelay Shah's avatar
Neelay Shah committed
134
135
136
137
138
139
140
141
142
143
    "model": "deepseek-ai/DeepSeek-R1-Distill-Llama-8B",
    "messages": [
    {
        "role": "user",
        "content": "Hello, how are you?"
    }
    ],
    "stream":false,
    "max_tokens": 300
  }' | jq
144
```
145

146
147
Rerun with `curl -N` and change `stream` in the request to `true` to get the responses as soon as the engine issues them.

Anish's avatar
Anish committed
148
149
150
151
152
### Deploying Dynamo

- Follow the [Quickstart Guide](docs/guides/dynamo_deploy/README.md) to deploy on Kubernetes.
- Check out [Backends](components/backends) to deploy various workflow configurations (e.g. SGLang with router, vLLM with disaggregated serving, etc.)
- Run some [Examples](examples) to learn about building components in Dynamo and exploring various integrations.
153

154
155
156
157
158
159
160
### Benchmarking Dynamo

Dynamo provides comprehensive benchmarking tools to evaluate and optimize your deployments:

* **[Benchmarking Guide](docs/benchmarks/benchmarking.md)** – Compare deployment topologies (aggregated vs. disaggregated vs. vanilla vLLM) using GenAI-Perf
* **[Pre-Deployment Profiling](docs/benchmarks/pre_deployment_profiling.md)** – Optimize configurations before deployment to meet SLA requirements

Anish's avatar
Anish committed
161
# Engines
162

Anish's avatar
Anish committed
163
Dynamo is designed to be inference engine agnostic. To use any engine with Dynamo, NATS and etcd need to be installed, along with a Dynamo frontend (`python -m dynamo.frontend [--interactive]`).
164

Anish's avatar
Anish committed
165
## vLLM
166
167
168
169
170
171
172
173
174
175

```
uv pip install ai-dynamo[vllm]
```

Run the backend/worker like this:
```
python -m dynamo.vllm --help
```

Anish's avatar
Anish committed
176
vLLM attempts to allocate enough KV cache for the full context length at startup. If that does not fit in your available memory pass `--context-length <value>`.
177
178
179

To specify which GPUs to use set environment variable `CUDA_VISIBLE_DEVICES`.

Anish's avatar
Anish committed
180
## SGLang
181
182

```
183
184
185
# Install libnuma
apt install -y libnuma-dev

186
187
188
189
190
uv pip install ai-dynamo[sglang]
```

Run the backend/worker like this:
```
191
python -m dynamo.sglang.worker --help
192
193
```

194
You can pass any sglang flags directly to this worker, see https://docs.sglang.ai/advanced_features/server_arguments.html . See there to use multiple GPUs.
195

Anish's avatar
Anish committed
196
## TensorRT-LLM
197

Anish's avatar
Anish committed
198
It is recommended to use [NGC PyTorch Container](https://catalog.ngc.nvidia.com/orgs/nvidia/containers/pytorch) for running the TensorRT-LLM engine.
199
200
201

> [!Note]
> Ensure that you select a PyTorch container image version that matches the version of TensorRT-LLM you are using.
202
> For example, if you are using `tensorrt-llm==1.1.0rc3`, use the PyTorch container image version `25.06`.
203
204
205
206
207
> To find the correct PyTorch container version for your desired `tensorrt-llm` release, visit the [TensorRT-LLM Dockerfile.multi](https://github.com/NVIDIA/TensorRT-LLM/blob/main/docker/Dockerfile.multi) on GitHub. Switch to the branch that matches your `tensorrt-llm` version, and look for the `BASE_TAG` line to identify the recommended PyTorch container tag.

> [!Important]
> Launch container with the following additional settings `--shm-size=1g --ulimit memlock=-1`

Anish's avatar
Anish committed
208
### Install prerequisites
209
210
```
# Optional step: Only required for Blackwell and Grace Hopper
211
212
213
214
uv pip install torch==2.7.1 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128

# Required until the trtllm version is bumped to include this pinned dependency itself
uv pip install "cuda-python>=12,<13"
215
216
217
218
219
220
221

sudo apt-get -y install libopenmpi-dev
```

> [!Tip]
> You can learn more about these prequisites and known issues with TensorRT-LLM pip based installation [here](https://nvidia.github.io/TensorRT-LLM/installation/linux.html).

Anish's avatar
Anish committed
222
### After installing the pre-requisites above, install Dynamo
223
```
224
uv pip install ai-dynamo[trtllm]
225
226
227
228
229
230
231
232
```

Run the backend/worker like this:
```
python -m dynamo.trtllm --help
```

To specify which GPUs to use set environment variable `CUDA_VISIBLE_DEVICES`.
233

Anish's avatar
Anish committed
234
# Developing Locally
235

Anish's avatar
Anish committed
236
## 1. Install libraries
237
238
239
240
241

**Ubuntu:**
```
sudo apt install -y build-essential libhwloc-dev libudev-dev pkg-config libclang-dev protobuf-compiler python3-dev cmake
```
242

243
244
245
246
247
248
249
**macOS:**
- [Homebrew](https://brew.sh/)
```
# if brew is not installed on your system, install it
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
- [Xcode](https://developer.apple.com/xcode/)
250

251
252
```
brew install cmake protobuf
253

254
255
256
257
258
259
## Check that Metal is accessible
xcrun -sdk macosx metal
```
If Metal is accessible, you should see an error like `metal: error: no input files`, which confirms it is installed correctly.


Anish's avatar
Anish committed
260
## 2. Install Rust
261

262
263
264
```
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
265
```
266

Anish's avatar
Anish committed
267
## 3. Create a Python virtual env:
268

269
270
271
272
273
Follow the instructions in [uv installation](https://docs.astral.sh/uv/#installation) guide to install uv if you don't have `uv` installed. Once uv is installed, create a virtual environment and activate it.

- Install uv
```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
274
```
275
276
277

- Create a virtual environment
```bash
278
279
280
uv venv dynamo
source dynamo/bin/activate
```
281

Anish's avatar
Anish committed
282
## 4. Install build tools
283

284
285
286
```
uv pip install pip maturin
```
287

288
[Maturin](https://github.com/PyO3/maturin) is the Rust<->Python bindings build tool.
289

Anish's avatar
Anish committed
290
## 5. Build the Rust bindings
291

292
```
293
cd lib/bindings/python
294
295
296
maturin develop --uv
```

Anish's avatar
Anish committed
297
## 6. Install the wheel
298
299
300
301

```
cd $PROJECT_ROOT
uv pip install .
302
303
# For development, use
export PYTHONPATH="${PYTHONPATH}:$(pwd)/components/frontend/src:$(pwd)/components/planner/src:$(pwd)/components/backends/vllm/src:$(pwd)/components/backends/sglang/src:$(pwd)/components/backends/trtllm/src:$(pwd)/components/backends/llama_cpp/src:$(pwd)/components/backends/mocker/src"
304
305
```

306
307
> [!Note]
> Editable (`-e`) does not work because the `dynamo` package is split over multiple directories, one per backend.
308
309
310
311
312
313
314
315

You should now be able to run `python -m dynamo.frontend`.

Remember that nats and etcd must be running (see earlier).

Set the environment variable `DYN_LOG` to adjust the logging level; for example, `export DYN_LOG=debug`. It has the same syntax as `RUST_LOG`.

If you use vscode or cursor, we have a .devcontainer folder built on [Microsofts Extension](https://code.visualstudio.com/docs/devcontainers/containers). For instructions see the [ReadMe](.devcontainer/README.md) for more details.