|
| 1 | + |
| 2 | +#!/bin/bash |
| 3 | +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 4 | +# SPDX-License-Identifier: Apache-2.0 |
| 5 | +set -e |
| 6 | +trap 'echo Cleaning up...; kill 0' EXIT |
| 7 | + |
| 8 | +# Set deterministic hash for KV event IDs |
| 9 | +export PYTHONHASHSEED=0 |
| 10 | + |
| 11 | +# Common configuration |
| 12 | +MODEL="Qwen/Qwen3-0.6B" |
| 13 | +BLOCK_SIZE=64 |
| 14 | +VLLM_NIXL_DEVICE_TO_DEVICE=true |
| 15 | +NIXL_BUFFER_DEVICE=xpu |
| 16 | +VLLM_NIXL_BACKEND=UCX |
| 17 | +export UCX_MEMTYPE_CACHE=0 |
| 18 | +export UCX_NET_DEVICES=mlx5_0:1,mlx5_1:1,mlx5_2:1,mlx5_3:1 |
| 19 | +export UCX_TLS=ib,rc,ze_copy |
| 20 | + |
| 21 | + |
| 22 | +# Start frontend with KV routing |
| 23 | +# The frontend will automatically detect prefill workers and activate an internal prefill router |
| 24 | +# edit --router-mode to random / round-robin / kv |
| 25 | +python -m dynamo.frontend \ |
| 26 | + --router-mode kv \ |
| 27 | + --http-port 8000 \ |
| 28 | + --router-reset-states & |
| 29 | + |
| 30 | +# two decode workers |
| 31 | +VLLM_NIXL_SIDE_CHANNEL_PORT=20096 \ |
| 32 | +ZE_AFFINITY_MASK=0 python3 -m dynamo.vllm \ |
| 33 | + --model $MODEL \ |
| 34 | + --block-size $BLOCK_SIZE \ |
| 35 | + --kv-transfer-config "{\"kv_connector\": \"NixlConnector\", \"kv_role\": \"kv_both\", \"kv_buffer_device\": \"${NIXL_BUFFER_DEVICE}\", \"kv_connector_extra_config\": {\"backends\": [\"${VLLM_NIXL_BACKEND}\"]}}" \ |
| 36 | + --kv-events-config '{"publisher":"zmq","topic":"kv-events","endpoint":"tcp://*:5556", "enable_kv_cache_events":true}' & |
| 37 | + |
| 38 | +VLLM_NIXL_SIDE_CHANNEL_PORT=20097 \ |
| 39 | +ZE_AFFINITY_MASK=1 python3 -m dynamo.vllm \ |
| 40 | + --model $MODEL \ |
| 41 | + --block-size $BLOCK_SIZE \ |
| 42 | + --kv-transfer-config "{\"kv_connector\": \"NixlConnector\", \"kv_role\": \"kv_both\", \"kv_buffer_device\": \"${NIXL_BUFFER_DEVICE}\", \"kv_connector_extra_config\": {\"backends\": [\"${VLLM_NIXL_BACKEND}\"]}}" \ |
| 43 | + --kv-events-config '{"publisher":"zmq","topic":"kv-events","endpoint":"tcp://*:5557", "enable_kv_cache_events":true}' & |
| 44 | + |
| 45 | +# two prefill workers |
| 46 | +# When registered with --is-prefill-worker, these workers are automatically detected |
| 47 | +# by the frontend, which activates an internal prefill router for KV-aware prefill routing |
| 48 | +VLLM_NIXL_SIDE_CHANNEL_PORT=20098 \ |
| 49 | +ZE_AFFINITY_MASK=2 python3 -m dynamo.vllm \ |
| 50 | + --model $MODEL \ |
| 51 | + --block-size $BLOCK_SIZE \ |
| 52 | + --kv-transfer-config "{\"kv_connector\": \"NixlConnector\", \"kv_role\": \"kv_both\", \"kv_buffer_device\": \"${NIXL_BUFFER_DEVICE}\", \"kv_connector_extra_config\": {\"backends\": [\"${VLLM_NIXL_BACKEND}\"]}}" \ |
| 53 | + --is-prefill-worker \ |
| 54 | + --kv-events-config '{"publisher":"zmq","topic":"kv-events","endpoint":"tcp://*:5558", "enable_kv_cache_events":true}' & |
| 55 | + |
| 56 | +VLLM_NIXL_SIDE_CHANNEL_PORT=20099 \ |
| 57 | +ZE_AFFINITY_MASK=3 python3 -m dynamo.vllm \ |
| 58 | + --model $MODEL \ |
| 59 | + --block-size $BLOCK_SIZE \ |
| 60 | + --kv-transfer-config "{\"kv_connector\": \"NixlConnector\", \"kv_role\": \"kv_both\", \"kv_buffer_device\": \"${NIXL_BUFFER_DEVICE}\", \"kv_connector_extra_config\": {\"backends\": [\"${VLLM_NIXL_BACKEND}\"]}}" \ |
| 61 | + --is-prefill-worker \ |
| 62 | + --kv-events-config '{"publisher":"zmq","topic":"kv-events","endpoint":"tcp://*:5559", "enable_kv_cache_events":true}' |
0 commit comments