File tree Expand file tree Collapse file tree 5 files changed +58
-3
lines changed Expand file tree Collapse file tree 5 files changed +58
-3
lines changed Original file line number Diff line number Diff line change @@ -36,3 +36,36 @@ def create_config():
36
36
assert deep_compare (normal_config_dict , empty_config_dict ), (
37
37
"Configs with normal CUDA_VISIBLE_DEVICES and CUDA_VISIBLE_DEVICES=\" \" "
38
38
" should be equivalent" )
39
+
40
+
41
+ def test_ray_runtime_env (monkeypatch : pytest .MonkeyPatch ):
42
+ # In testing, this method needs to be nested inside as ray does not
43
+ # see the test module.
44
+ def create_config ():
45
+ engine_args = EngineArgs (model = "deepseek-ai/DeepSeek-V2-Lite" ,
46
+ trust_remote_code = True )
47
+ return engine_args .create_engine_config ()
48
+
49
+ config = create_config ()
50
+ parallel_config = config .parallel_config
51
+ assert parallel_config .ray_runtime_env is None
52
+
53
+ import ray
54
+ ray .init ()
55
+
56
+ runtime_env = {
57
+ "env_vars" : {
58
+ "TEST_ENV_VAR" : "test_value" ,
59
+ },
60
+ }
61
+
62
+ config_ref = ray .remote (create_config ).options (
63
+ runtime_env = runtime_env , ).remote ()
64
+
65
+ config = ray .get (config_ref )
66
+ parallel_config = config .parallel_config
67
+ assert parallel_config .ray_runtime_env is not None
68
+ assert parallel_config .ray_runtime_env .env_vars ().get (
69
+ "TEST_ENV_VAR" ) == "test_value"
70
+
71
+ ray .shutdown ()
Original file line number Diff line number Diff line change 56
56
57
57
if TYPE_CHECKING :
58
58
from _typeshed import DataclassInstance
59
- from ray .util .placement_group import PlacementGroup
60
59
from ray .runtime_env import RuntimeEnv
60
+ from ray .util .placement_group import PlacementGroup
61
61
from transformers .configuration_utils import PretrainedConfig
62
62
63
63
import vllm .model_executor .layers .quantization as me_quant
Original file line number Diff line number Diff line change @@ -1068,7 +1068,7 @@ def create_engine_config(
1068
1068
# as opposed to is_in_ray_actor().
1069
1069
import ray
1070
1070
ray_runtime_env = ray .get_runtime_context ().runtime_env
1071
- logger .info (f "Using ray runtime env: { ray_runtime_env } " )
1071
+ logger .info ("Using ray runtime env: %s" , ray_runtime_env )
1072
1072
1073
1073
# Get the current placement group if Ray is initialized and
1074
1074
# we are in a Ray actor. If so, then the placement group will be
Original file line number Diff line number Diff line change
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+
4
+
5
+ def is_ray_initialized ():
6
+ """Check if Ray is initialized."""
7
+ try :
8
+ import ray
9
+ return ray .is_initialized ()
10
+ except ImportError :
11
+ return False
12
+
13
+
14
+ def is_in_ray_actor ():
15
+ """Check if we are in a Ray actor."""
16
+
17
+ try :
18
+ import ray
19
+ return (ray .is_initialized ()
20
+ and ray .get_runtime_context ().get_actor_id () is not None )
21
+ except ImportError :
22
+ return False
Original file line number Diff line number Diff line change 71
71
72
72
import vllm .envs as envs
73
73
from vllm .logger import enable_trace_function_call , init_logger
74
- from vllm .ray .utils import is_in_ray_actor
74
+ from vllm .ray .lazy_utils import is_in_ray_actor
75
75
76
76
if TYPE_CHECKING :
77
77
from argparse import Namespace
You can’t perform that action at this time.
0 commit comments