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

Meenakshi Sharma's avatar
Meenakshi Sharma committed
18
# NVIDIA Dynamo
Neelay Shah's avatar
Neelay Shah committed
19

20
21
[![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)
22
[![Discord](https://dcbadge.limes.pink/api/server/D92uqZRjCZ?style=flat)](https://discord.gg/nvidia-dynamo)
Meenakshi Sharma's avatar
Meenakshi Sharma committed
23

24
| **[Support Matrix](support_matrix.md)** | **[Guides](docs/guides)** | **[Architecture and Features](docs/architecture.md)** | **[APIs](lib/bindings/python/README.md)** | **[SDK](deploy/dynamo/sdk/README.md)** |
Neelay Shah's avatar
Neelay Shah committed
25

Neelay Shah's avatar
Neelay Shah committed
26
NVIDIA Dynamo is a high-throughput low-latency inference framework designed for serving generative AI and reasoning models in multi-node distributed environments. Dynamo is designed to be inference engine agnostic (supports TRT-LLM, vLLM, SGLang or others) and captures LLM-specific capabilities such as:
27

Neelay Shah's avatar
Neelay Shah committed
28
29
30
31
32
- **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
33

Neelay Shah's avatar
Neelay Shah committed
34
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.
Neelay Shah's avatar
Neelay Shah committed
35

Neelay Shah's avatar
Neelay Shah committed
36
### Installation
37

Neelay Shah's avatar
Neelay Shah committed
38
The following examples require a few system level packages.
39
Recommended to use Ubuntu 24.04 with a x86_64 CPU. See [support_matrix.md](support_matrix.md)
40

Neelay Shah's avatar
Neelay Shah committed
41
42
```
apt-get update
43
44
45
DEBIAN_FRONTEND=noninteractive apt-get install -yq python3-dev python3-pip python3-venv libucx0
python3 -m venv venv
source venv/bin/activate
46

47
pip install ai-dynamo[all]
Neelay Shah's avatar
Neelay Shah committed
48
```
49

50
### Building the Dynamo Base Image
51

52
53
54
55
Although not needed for local development, deploying your Dynamo pipelines to Kubernetes will require you to build and push a Dynamo base image to your container registry. You can use any container registry of your choice, such as:
- Docker Hub (docker.io)
- NVIDIA NGC Container Registry (nvcr.io)
- Any private registry
56

57
Here's how to build it:
58

59
60
61
62
63
64
65
66
67
68
69
```bash
export CI_REGISTRY_IMAGE=<your-registry>
export CI_COMMIT_SHA=<your-tag>

earthly --push +dynamo-base-docker --CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE --CI_COMMIT_SHA=$CI_COMMIT_SHA
```

After building, you can use this image by setting the `DYNAMO_IMAGE` environment variable to point to your built image:
```bash
export DYNAMO_IMAGE=<your-registry>/dynamo-base-docker:<your-tag>
```
70

Neelay Shah's avatar
Neelay Shah committed
71
### Running and Interacting with an LLM Locally
72

Neelay Shah's avatar
Neelay Shah committed
73
74
75
To run a model and interact with it locally you can call `dynamo
run` with a hugging face model. `dynamo run` supports several backends
including: `mistralrs`, `sglang`, `vllm`, and `tensorrtllm`.
76

Neelay Shah's avatar
Neelay Shah committed
77
#### Example Command
78

Neelay Shah's avatar
Neelay Shah committed
79
80
```
dynamo run out=vllm deepseek-ai/DeepSeek-R1-Distill-Llama-8B
81
```
82

Neelay Shah's avatar
Neelay Shah committed
83
84
85
86
87
```
? User › Hello, how are you?
✔ User · Hello, how are you?
Okay, so I'm trying to figure out how to respond to the user's greeting. They said, "Hello, how are you?" and then followed it with "Hello! I'm just a program, but thanks for asking." Hmm, I need to come up with a suitable reply. ...
```
88

Neelay Shah's avatar
Neelay Shah committed
89
### LLM Serving
90

Neelay Shah's avatar
Neelay Shah committed
91
92
Dynamo provides a simple way to spin up a local set of inference
components including:
93

Neelay Shah's avatar
Neelay Shah committed
94
95
96
- **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.
97

Neelay Shah's avatar
Neelay Shah committed
98
99
To run a minimal configuration you can use a pre-configured
example.
100

Neelay Shah's avatar
Neelay Shah committed
101
#### Start Dynamo Distributed Runtime Services
102

Neelay Shah's avatar
Neelay Shah committed
103
First start the Dynamo Distributed Runtime services:
104
105

```bash
Neelay Shah's avatar
Neelay Shah committed
106
docker compose -f deploy/docker-compose.yml up -d
107
```
Neelay Shah's avatar
Neelay Shah committed
108
109
110
111
#### Start Dynamo LLM Serving Components

Next serve a minimal configuration with an http server, basic
round-robin router, and a single worker.
112
113

```bash
Neelay Shah's avatar
Neelay Shah committed
114
115
cd examples/llm
dynamo serve graphs.agg:Frontend -f configs/agg.yaml
116
117
```

Neelay Shah's avatar
Neelay Shah committed
118
#### Send a Request
119

120
```bash
Neelay Shah's avatar
Neelay Shah committed
121
122
123
124
125
126
127
128
129
130
131
curl localhost:8000/v1/chat/completions   -H "Content-Type: application/json"   -d '{
    "model": "deepseek-ai/DeepSeek-R1-Distill-Llama-8B",
    "messages": [
    {
        "role": "user",
        "content": "Hello, how are you?"
    }
    ],
    "stream":false,
    "max_tokens": 300
  }' | jq
132
```
133
134
135

### Local Development

136
137
#### Container

138
139
140
141
142
143
144
145
146
147
To develop locally, we recommend working inside of the container

```bash
./container/build.sh
./container/run.sh -it --mount-workspace

cargo build --release
mkdir -p /workspace/deploy/dynamo/sdk/src/dynamo/sdk/cli/bin
cp /workspace/target/release/http /workspace/deploy/dynamo/sdk/src/dynamo/sdk/cli/bin
cp /workspace/target/release/llmctl /workspace/deploy/dynamo/sdk/src/dynamo/sdk/cli/bin
148
cp /workspace/target/release/dynamo-run /workspace/deploy/dynamo/sdk/src/dynamo/sdk/cli/bin
149
150
151

uv pip install -e .
```
152

153
154
155
156
157
158
159
160
161
162
163
164
165
166
#### Devcontainer Environment

For a consistent development environment, you can use the provided devcontainer configuration. This requires:
- [Docker](https://www.docker.com/products/docker-desktop)
- [VS Code](https://code.visualstudio.com/) with the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)

To use the devcontainer:
1. Open the project in VS Code
2. Click on the button in the bottom-left corner
3. Select "Reopen in Container"

This will build and start a container with all the necessary dependencies for Dynamo development.


167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#### Conda Environment

Alternately, you can use a conda environment

```bash
conda activate <ENV_NAME>

pip install nixl # Or install https://github.com/ai-dynamo/nixl from source

cargo build --release

# To install ai-dynamo-runtime from source
cd lib/bindings/python
pip install .

cd ../../../
pip install .[all]

# To test
docker compose -f deploy/docker-compose.yml up -d
cd examples/llm
dynamo serve graphs.agg:Frontend -f configs/agg.yaml
```