[Perf] Cache vllm.env.__getattr__ result to avoid recomputation (#26146)

Signed-off-by: Jialin Ouyang <Jialin.Ouyang@gmail.com>
This commit is contained in:
Jialin Ouyang
2025-10-14 14:03:21 -07:00
committed by GitHub
parent b92ab3deda
commit 380f17527c
4 changed files with 84 additions and 2 deletions

View File

@@ -33,6 +33,7 @@ from vllm.distributed.parallel_state import (
get_pp_group,
get_tp_group,
)
from vllm.envs import enable_envs_cache
from vllm.logger import init_logger
from vllm.utils import (
_maybe_force_spawn,
@@ -455,6 +456,10 @@ class WorkerProc:
# Load model
self.worker.load_model()
# Enable environment variable cache (e.g. assume no more
# environment variable overrides after this point)
enable_envs_cache()
@staticmethod
def make_worker_process(
vllm_config: VllmConfig,