Skip to content

Commit b10b955

Browse files
committed
Use ROLLOUT_VISIBLE_DEVICE env var for vLLM GPU placement; rename vllm_dtype to engine_dtype
1 parent 15faa6c commit b10b955

4 files changed

Lines changed: 24 additions & 13 deletions

File tree

training/opsd/README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ NUM_TRAIN_GPUS=6 INCLUDE_GPUS=0,1,2,3,4,5 \
8686
bash scripts/train_opsd_vllm.sh configs/opsd_vllm_disjoint.json
8787
```
8888

89-
vLLM gets dedicated GPUs (`rollout.gpus` in the config). Training rank 0
90-
constructs the `LLM` handle; other training ranks receive generated token
91-
ids via NCCL broadcast.
89+
vLLM gets dedicated GPUs via the `ROLLOUT_VISIBLE_DEVICE` environment
90+
variable (comma-separated CUDA device indices, e.g.
91+
`ROLLOUT_VISIBLE_DEVICE=6,7`). Training rank 0 spawns the vLLM server as
92+
a subprocess with `CUDA_VISIBLE_DEVICES` set to those devices; other
93+
training ranks receive generated token ids via NCCL broadcast.
9294

9395
### Smoke tests (5 steps, small models)
9496

@@ -100,7 +102,8 @@ end-to-end before scaling up.
100102
cd examples/opsd
101103
deepspeed --num_gpus 2 main.py --config configs/smoke_hybrid.json
102104
# For vLLM (uses GPUs 0,1 for training and 2,3 for vLLM):
103-
NUM_TRAIN_GPUS=2 INCLUDE_GPUS=0,1 deepspeed --num_gpus 2 --include localhost:0,1 \
105+
NUM_TRAIN_GPUS=2 INCLUDE_GPUS=0,1 ROLLOUT_VISIBLE_DEVICE=2,3 \
106+
deepspeed --num_gpus 2 --include localhost:0,1 \
104107
main.py --config configs/smoke_vllm.json
105108
```
106109

@@ -133,6 +136,13 @@ python -m pytest tests/ -v
133136
See `configs/opsd_hybrid_engine.json` and `configs/opsd_vllm_disjoint.json`
134137
for fully-populated examples.
135138

139+
**GPU placement for vLLM rollout:** The GPUs available to the vLLM server
140+
are controlled by the `ROLLOUT_VISIBLE_DEVICE` environment variable
141+
(comma-separated CUDA device indices, e.g. `ROLLOUT_VISIBLE_DEVICE=6,7`),
142+
not by a field in the JSON config. This keeps the vLLM device assignment
143+
decoupled from the DeepSpeed launcher's own `CUDA_VISIBLE_DEVICES` /
144+
`--include` flags, which control only the training ranks.
145+
136146
## Adding a new model architecture
137147

138148
No special steps are needed for new model architectures. vLLM's RLHF weight

training/opsd/configs/opsd_vllm_disjoint.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818
"top_p": 1.0,
1919
"top_k": -1,
2020
"n_samples_per_prompt": 1,
21-
"gpus": [6, 7],
2221
"tensor_parallel_size": 2,
2322
"gpu_memory_utilization": 0.85,
24-
"vllm_dtype": "bfloat16",
23+
"engine_dtype": "bfloat16",
2524
"weight_sync_interval": 4,
2625
"vllm_min_version": "0.6.4",
2726
"vllm_port": 8000

training/opsd/configs/smoke_vllm.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818
"top_p": 1.0,
1919
"top_k": -1,
2020
"n_samples_per_prompt": 1,
21-
"gpus": [],
2221
"tensor_parallel_size": 1,
2322
"gpu_memory_utilization": 0.3,
24-
"vllm_dtype": "bfloat16",
23+
"engine_dtype": "bfloat16",
2524
"weight_sync_interval": 2,
2625
"vllm_min_version": "0.6.4",
2726
"vllm_enforce_eager": true,

training/opsd/scripts/train_opsd_vllm.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,20 @@
88
#
99
# The vLLM server is started **lazily** as a subprocess by training rank 0
1010
# on first use, so no separate vLLM launch step is required. The GPUs
11-
# listed in ``rollout.gpus`` in the config are assigned to the vLLM server
12-
# via ``CUDA_VISIBLE_DEVICES`` in the subprocess environment.
11+
# assigned to the vLLM server are controlled by the ROLLOUT_VISIBLE_DEVICE
12+
# environment variable (comma-separated CUDA device indices). The training
13+
# ranks must run on a *different* set of GPUs so the two don't contend for
14+
# memory.
1315
#
14-
# Default config assumes 8 GPUs: ranks 0..5 train (ZeRO-3), devices 6-7
15-
# run vLLM with TP=2. Adjust configs/opsd_vllm_disjoint.json::rollout.gpus
16-
# and NUM_TRAIN_GPUS to match your topology.
16+
# Default topology: ranks 0..5 train on GPUs 0-5 (ZeRO-3), devices 6-7
17+
# run vLLM with TP=2. Override via:
18+
# ROLLOUT_VISIBLE_DEVICE=... NUM_TRAIN_GPUS=.. INCLUDE_GPUS=.. bash ...
1719
set -euo pipefail
1820

1921
CONFIG="${1:-configs/opsd_vllm_disjoint.json}"
2022
NUM_TRAIN_GPUS="${NUM_TRAIN_GPUS:-6}"
2123
INCLUDE_GPUS="${INCLUDE_GPUS:-0,1,2,3,4,5}"
24+
export ROLLOUT_VISIBLE_DEVICE="${ROLLOUT_VISIBLE_DEVICE:-6,7}"
2225

2326
deepspeed --num_gpus "${NUM_TRAIN_GPUS}" --include "localhost:${INCLUDE_GPUS}" \
2427
main.py --config "${CONFIG}"

0 commit comments

Comments
 (0)