-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[DP] Copy environment variables to Ray DPEngineCoreActors #20344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
import json | ||
import os | ||
from typing import Optional | ||
|
||
import vllm.envs as envs | ||
from vllm.logger import init_logger | ||
|
||
logger = init_logger(__name__) | ||
|
||
CONFIG_HOME = envs.VLLM_CONFIG_ROOT | ||
|
||
# This file contains a list of env vars that should not be copied | ||
# from the driver to the Ray workers. | ||
RAY_NON_CARRY_OVER_ENV_VARS_FILE = os.path.join( | ||
CONFIG_HOME, "ray_non_carry_over_env_vars.json") | ||
Comment on lines
+16
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this there in the first place? is there really a need to customize it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah @youkaichao suggested this to allow customization: #14099 (comment) |
||
|
||
try: | ||
if os.path.exists(RAY_NON_CARRY_OVER_ENV_VARS_FILE): | ||
with open(RAY_NON_CARRY_OVER_ENV_VARS_FILE) as f: | ||
RAY_NON_CARRY_OVER_ENV_VARS = set(json.load(f)) | ||
else: | ||
RAY_NON_CARRY_OVER_ENV_VARS = set() | ||
except json.JSONDecodeError: | ||
logger.warning( | ||
"Failed to parse %s. Using an empty set for non-carry-over env vars.", | ||
RAY_NON_CARRY_OVER_ENV_VARS_FILE) | ||
RAY_NON_CARRY_OVER_ENV_VARS = set() | ||
|
||
|
||
def get_env_vars_to_copy(exclude_vars: Optional[set[str]] = None, | ||
additional_vars: Optional[set[str]] = None, | ||
destination: Optional[str] = None) -> set[str]: | ||
""" | ||
Get the environment variables to copy to downstream Ray actors. | ||
Example use cases: | ||
- Copy environment variables from RayDistributedExecutor to Ray workers. | ||
- Copy environment variables from RayDPClient to Ray DPEngineCoreActor. | ||
Args: | ||
exclude_vars: A set of vllm defined environment variables to exclude | ||
from copying. | ||
additional_vars: A set of additional environment variables to copy. | ||
destination: The destination of the environment variables. | ||
Returns: | ||
A set of environment variables to copy. | ||
""" | ||
exclude_vars = exclude_vars or set() | ||
additional_vars = additional_vars or set() | ||
|
||
env_vars_to_copy = { | ||
v | ||
for v in envs.environment_variables | ||
if v not in exclude_vars and v not in RAY_NON_CARRY_OVER_ENV_VARS | ||
} | ||
env_vars_to_copy.update(additional_vars) | ||
|
||
to_destination = " to " + destination if destination is not None else "" | ||
|
||
logger.info("RAY_NON_CARRY_OVER_ENV_VARS from config: %s", | ||
RAY_NON_CARRY_OVER_ENV_VARS) | ||
logger.info("Copying the following environment variables%s: %s", | ||
to_destination, | ||
[v for v in env_vars_to_copy if v in os.environ]) | ||
logger.info( | ||
"If certain env vars should NOT be copied, add them to " | ||
"%s file", RAY_NON_CARRY_OVER_ENV_VARS_FILE) | ||
|
||
return env_vars_to_copy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeaah this logic seems like a hack to me in the first place. Do you know in what context this was used? Who owns the content of the json file? What are the default values in there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #14099 (comment) . This allows customization of env vars.