Skip to content

Commit fb38d2b

Browse files
[Misc] pass Ray runtime env to engine core
Signed-off-by: eric-higgins-ai <[email protected]>
1 parent ac9fb73 commit fb38d2b

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

vllm/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
if TYPE_CHECKING:
5858
from _typeshed import DataclassInstance
5959
from ray.util.placement_group import PlacementGroup
60+
from ray.runtime_env import RuntimeEnv
6061
from transformers.configuration_utils import PretrainedConfig
6162

6263
import vllm.model_executor.layers.quantization as me_quant
@@ -73,6 +74,7 @@
7374
else:
7475
DataclassInstance = Any
7576
PlacementGroup = Any
77+
RuntimeEnv = Any
7678
PretrainedConfig = Any
7779
ExecutorBase = Any
7880
QuantizationConfig = Any
@@ -1902,6 +1904,9 @@ class ParallelConfig:
19021904
placement_group: Optional["PlacementGroup"] = None
19031905
"""ray distributed model workers placement group."""
19041906

1907+
runtime_env: Optional["RuntimeEnv"] = None
1908+
"""ray runtime environment for distributed workers"""
1909+
19051910
distributed_executor_backend: Optional[Union[DistributedExecutorBackend,
19061911
type["ExecutorBase"]]] = None
19071912
"""Backend to use for distributed model

vllm/engine/arg_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,12 +1088,14 @@ def create_engine_config(
10881088
# we are in a Ray actor. If so, then the placement group will be
10891089
# passed to spawned processes.
10901090
placement_group = None
1091+
runtime_env = None
10911092
if is_in_ray_actor():
10921093
import ray
10931094

10941095
# This call initializes Ray automatically if it is not initialized,
10951096
# but we should not do this here.
10961097
placement_group = ray.util.get_current_placement_group()
1098+
runtime_env = ray.get_runtime_context().runtime_env
10971099

10981100
data_parallel_external_lb = self.data_parallel_rank is not None
10991101
if data_parallel_external_lb:
@@ -1170,6 +1172,7 @@ def create_engine_config(
11701172
disable_custom_all_reduce=self.disable_custom_all_reduce,
11711173
ray_workers_use_nsight=self.ray_workers_use_nsight,
11721174
placement_group=placement_group,
1175+
runtime_env=runtime_env,
11731176
distributed_executor_backend=self.distributed_executor_backend,
11741177
worker_cls=self.worker_cls,
11751178
worker_extension_cls=self.worker_extension_cls,

vllm/executor/ray_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,14 @@ def initialize_ray_cluster(
288288
elif current_platform.is_rocm() or current_platform.is_xpu():
289289
# Try to connect existing ray instance and create a new one if not found
290290
try:
291-
ray.init("auto")
291+
ray.init("auto", runtime_env=parallel_config.runtime_env)
292292
except ConnectionError:
293293
logger.warning(
294294
"No existing RAY instance detected. "
295295
"A new instance will be launched with current node resources.")
296-
ray.init(address=ray_address, num_gpus=parallel_config.world_size)
296+
ray.init(address=ray_address, num_gpus=parallel_config.world_size, runtime_env=parallel_config.runtime_env)
297297
else:
298-
ray.init(address=ray_address)
298+
ray.init(address=ray_address, runtime_env=parallel_config.runtime_env)
299299

300300
device_str = current_platform.ray_device_key
301301
if not device_str:

0 commit comments

Comments
 (0)