|
| 1 | +--- |
| 2 | +title: Dynamo |
| 3 | +description: Deploying zai-org/GLM-4.5-Air-FP8 using NVIDIA Dynamo |
| 4 | +--- |
| 5 | + |
| 6 | +# Dynamo |
| 7 | + |
| 8 | +This example shows how to deploy `zai-org/GLM-4.5-Air-FP8` using |
| 9 | +[NVIDIA Dynamo](https://github.com/ai-dynamo/dynamo) and `dstack`. |
| 10 | + |
| 11 | + |
| 12 | +## Apply a configuration |
| 13 | + |
| 14 | +Here's an example of a service that deploys `zai-org/GLM-4.5-Air-FP8` using |
| 15 | +Dynamo with PD disaggregation. |
| 16 | + |
| 17 | +<div editor-title="service.dstack.yml"> |
| 18 | + |
| 19 | +```yaml |
| 20 | +type: service |
| 21 | +name: dynamo-pd |
| 22 | + |
| 23 | +env: |
| 24 | + - HF_TOKEN |
| 25 | + - MODEL_ID=zai-org/GLM-4.5-Air-FP8 |
| 26 | + |
| 27 | +replicas: |
| 28 | + - count: 1 |
| 29 | + docker: true |
| 30 | + commands: |
| 31 | + - apt-get update |
| 32 | + - apt-get install -y python3-dev python3-venv |
| 33 | + - python3 -m venv ~/dyn-venv |
| 34 | + - source ~/dyn-venv/bin/activate |
| 35 | + - pip install -U pip |
| 36 | + - pip install "ai-dynamo[sglang]==1.1.1" |
| 37 | + - git clone https://github.com/ai-dynamo/dynamo.git |
| 38 | + # Brings up the NATS / etcd compose stack and runs the Dynamo HTTP frontend. |
| 39 | + - docker compose -f dynamo/deploy/docker-compose.yml up -d |
| 40 | + - | |
| 41 | + python3 -m dynamo.frontend \ |
| 42 | + --http-host 0.0.0.0 --http-port 8000 \ |
| 43 | + --discovery-backend etcd --router-mode kv \ |
| 44 | + --kv-cache-block-size 64 |
| 45 | + resources: |
| 46 | + cpu: 4 |
| 47 | + router: |
| 48 | + type: dynamo |
| 49 | + |
| 50 | + - count: 1..4 |
| 51 | + scaling: |
| 52 | + metric: rps |
| 53 | + target: 3 |
| 54 | + python: "3.12" |
| 55 | + nvcc: true |
| 56 | + commands: |
| 57 | + # dstack injects DSTACK_ROUTER_INTERNAL_IP after the router replica |
| 58 | + # is provisioned. Compose the etcd/NATS endpoints from it. |
| 59 | + - export ETCD_ENDPOINTS="http://$DSTACK_ROUTER_INTERNAL_IP:2379" |
| 60 | + - export NATS_SERVER="nats://$DSTACK_ROUTER_INTERNAL_IP:4222" |
| 61 | + # Set to enable /health endpoint required by dstack probes. |
| 62 | + - export DYN_SYSTEM_PORT="8000" |
| 63 | + # Wait until the router's etcd and NATS ports are actually accepting connections. |
| 64 | + - | |
| 65 | + until (echo > /dev/tcp/$DSTACK_ROUTER_INTERNAL_IP/2379) 2>/dev/null \ |
| 66 | + && (echo > /dev/tcp/$DSTACK_ROUTER_INTERNAL_IP/4222) 2>/dev/null; do |
| 67 | + echo "waiting for etcd/NATS on $DSTACK_ROUTER_INTERNAL_IP..."; sleep 3 |
| 68 | + done |
| 69 | + - pip install "ai-dynamo[sglang]==1.1.1" |
| 70 | + - | |
| 71 | + python3 -m dynamo.sglang \ |
| 72 | + --model-path $MODEL_ID --served-model-name $MODEL_ID \ |
| 73 | + --discovery-backend etcd --host 0.0.0.0 \ |
| 74 | + --page-size 64 \ |
| 75 | + --disaggregation-mode prefill --disaggregation-transfer-backend nixl |
| 76 | + resources: |
| 77 | + gpu: H200 |
| 78 | + |
| 79 | + - count: 1..8 |
| 80 | + scaling: |
| 81 | + metric: rps |
| 82 | + target: 2 |
| 83 | + python: "3.12" |
| 84 | + nvcc: true |
| 85 | + commands: |
| 86 | + - export ETCD_ENDPOINTS="http://$DSTACK_ROUTER_INTERNAL_IP:2379" |
| 87 | + - export NATS_SERVER="nats://$DSTACK_ROUTER_INTERNAL_IP:4222" |
| 88 | + - export DYN_SYSTEM_PORT="8000" |
| 89 | + - | |
| 90 | + until (echo > /dev/tcp/$DSTACK_ROUTER_INTERNAL_IP/2379) 2>/dev/null \ |
| 91 | + && (echo > /dev/tcp/$DSTACK_ROUTER_INTERNAL_IP/4222) 2>/dev/null; do |
| 92 | + echo "waiting for etcd/NATS on $DSTACK_ROUTER_INTERNAL_IP..."; sleep 3 |
| 93 | + done |
| 94 | + - pip install "ai-dynamo[sglang]==1.1.1" |
| 95 | + - | |
| 96 | + python3 -m dynamo.sglang \ |
| 97 | + --model-path $MODEL_ID --served-model-name $MODEL_ID \ |
| 98 | + --discovery-backend etcd --host 0.0.0.0 \ |
| 99 | + --page-size 64 \ |
| 100 | + --disaggregation-mode decode --disaggregation-transfer-backend nixl |
| 101 | + resources: |
| 102 | + gpu: H200 |
| 103 | + |
| 104 | +port: 8000 |
| 105 | +model: zai-org/GLM-4.5-Air-FP8 |
| 106 | + |
| 107 | +# Custom probe is required for PD disaggregation. |
| 108 | +probes: |
| 109 | + - type: http |
| 110 | + url: /health |
| 111 | + interval: 15s |
| 112 | +``` |
| 113 | +
|
| 114 | +</div> |
| 115 | +
|
| 116 | +> With the the `dynamo` router, you can use SGLang, vLLM, and TensorRT-LLM prefill and decode workers. |
| 117 | + |
| 118 | +Save the configuration as `service.dstack.yml`, then use the |
| 119 | +[`dstack apply`](../../reference/cli/dstack/apply.md) command. |
| 120 | + |
| 121 | +<div class="termy"> |
| 122 | + |
| 123 | +```shell |
| 124 | +$ dstack apply -f service.dstack.yml |
| 125 | +``` |
| 126 | + |
| 127 | +</div> |
| 128 | + |
| 129 | +If no gateway is created, the service endpoint will be available at `<dstack server URL>/proxy/services/<project name>/<run name>/`. |
| 130 | + |
| 131 | +<div class="termy"> |
| 132 | + |
| 133 | +```shell |
| 134 | +curl http://127.0.0.1:3000/proxy/services/main/dynamo-pd/v1/chat/completions \ |
| 135 | + -X POST \ |
| 136 | + -H 'Authorization: Bearer <user token>' \ |
| 137 | + -H 'Content-Type: application/json' \ |
| 138 | + -d '{ |
| 139 | + "model": "zai-org/GLM-4.5-Air-FP8", |
| 140 | + "messages": [ |
| 141 | + { |
| 142 | + "role": "user", |
| 143 | + "content": "What is prefill-decode disaggregation?" |
| 144 | + } |
| 145 | + ], |
| 146 | + "max_tokens": 1024 |
| 147 | + }' |
| 148 | +``` |
| 149 | + |
| 150 | +</div> |
| 151 | + |
| 152 | +> If a [gateway](../../concepts/gateways.md) is configured (e.g. to enable auto-scaling, HTTPS, rate limits, etc.), the service endpoint will be available at `https://dynamo-pd.<gateway domain>/`. |
| 153 | + |
| 154 | +## Configuration options |
| 155 | + |
| 156 | +Currently, auto-scaling only supports `rps` as the metric. TTFT and ITL metrics are coming soon. |
| 157 | + |
| 158 | +!!! info "Cluster" |
| 159 | + PD disaggregation requires the service to run in a fleet with `placement` set to `cluster`, because the replicas require an interconnect between instances. |
| 160 | + |
| 161 | + While the prefill and decode replicas run on GPUs, the router replica requires a CPU instance in the same cluster. |
| 162 | + |
| 163 | +## What's next? |
| 164 | + |
| 165 | +1. Read about [services](../../concepts/services.md) and [gateways](../../concepts/gateways.md) |
| 166 | +2. Browse the [NVIDIA Dynamo GitHub repository](https://github.com/ai-dynamo/dynamo) and the [SGLang](./sglang.md) example |
0 commit comments