@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 35bc8bd5fb
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 15, 01:00 UTC

[Misc] Copy HF_TOKEN env var to Ray workers (#21406)

Signed-off-by: Rui Qiao <ruisearch42@gmail.com>

Rui Qiao committed Jul 22, 2025 at 16:18 UTC 35bc8bd5fb302dee4c2a7c7bc7e2e1f303478b09
2 files changed +8 -3
vllm/executor/ray_distributed_executor.py
+5 -1
@@ -58,6 +58,9 @@ class RayDistributedExecutor(DistributedExecutorBase):
58 "VLLM_HOST_IP", "VLLM_HOST_PORT", "LOCAL_RANK", "CUDA_VISIBLE_DEVICES"
59 }
60
61 + # These non-vLLM env vars are copied from the driver to workers
62 + ADDITIONAL_ENV_VARS = {"HF_TOKEN", "HUGGING_FACE_HUB_TOKEN"}
63 +
64 uses_ray: bool = True
65
66 def _init_executor(self) -> None:
@@ -326,7 +329,8 @@ class RayDistributedExecutor(DistributedExecutorBase):
329 # Environment variables to copy from driver to workers
330 env_vars_to_copy = get_env_vars_to_copy(
331 exclude_vars=self.WORKER_SPECIFIC_ENV_VARS,
329 - additional_vars=set(current_platform.additional_env_vars),
332 + additional_vars=set(current_platform.additional_env_vars).union(
333 + self.ADDITIONAL_ENV_VARS),
334 destination="workers")
335
336 # Copy existing env vars to each worker's args
vllm/ray/ray_env.py
+3 -2
@@ -43,6 +43,8 @@ def get_env_vars_to_copy(exclude_vars: Optional[set[str]] = None,
43 exclude_vars: A set of vllm defined environment variables to exclude
44 from copying.
45 additional_vars: A set of additional environment variables to copy.
46 + If a variable is in both exclude_vars and additional_vars, it will
47 + be excluded.
48 destination: The destination of the environment variables.
49 Returns:
50 A set of environment variables to copy.
@@ -52,10 +54,9 @@ def get_env_vars_to_copy(exclude_vars: Optional[set[str]] = None,
54
55 env_vars_to_copy = {
56 v
55 - for v in envs.environment_variables
57 + for v in set(envs.environment_variables).union(additional_vars)
58 if v not in exclude_vars and v not in RAY_NON_CARRY_OVER_ENV_VARS
59 }
58 - env_vars_to_copy.update(additional_vars)
60
61 to_destination = " to " + destination if destination is not None else ""
62