Skip to content

vllm.ray.ray_env

CONFIG_HOME module-attribute

CONFIG_HOME = VLLM_CONFIG_ROOT

RAY_NON_CARRY_OVER_ENV_VARS module-attribute

RAY_NON_CARRY_OVER_ENV_VARS = set(load(f))

RAY_NON_CARRY_OVER_ENV_VARS_FILE module-attribute

RAY_NON_CARRY_OVER_ENV_VARS_FILE = join(
    CONFIG_HOME, "ray_non_carry_over_env_vars.json"
)

logger module-attribute

logger = init_logger(__name__)

get_env_vars_to_copy

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.

Parameters:

Name Type Description Default
exclude_vars Optional[set[str]]

A set of vllm defined environment variables to exclude from copying.

None
additional_vars Optional[set[str]]

A set of additional environment variables to copy. If a variable is in both exclude_vars and additional_vars, it will be excluded.

None
destination Optional[str]

The destination of the environment variables.

None

Returns: A set of environment variables to copy.

Source code in vllm/ray/ray_env.py
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.
            If a variable is in both exclude_vars and additional_vars, it will
            be excluded.
        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 set(envs.environment_variables).union(additional_vars)
        if v not in exclude_vars and v not in RAY_NON_CARRY_OVER_ENV_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