@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 07ca70af8d
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 14, 05:30 UTC

[Core][Easy] Use envs.__getattr__ for all Unify to environment variable access (#26810)

Signed-off-by: Jialin Ouyang <Jialin.Ouyang@gmail.com>

Jialin Ouyang committed Oct 14, 2025 at 18:41 UTC 07ca70af8d8a0d0e20727d8de6972a7ad87cf996
4 files changed +10 -11
vllm/multimodal/cache.py
+3 -3
@@ -10,12 +10,12 @@ from typing import TYPE_CHECKING, Generic, TypeAlias, TypeVar, cast
10 import torch
11 from typing_extensions import override
12
13 +import vllm.envs as envs
14 from vllm.distributed.device_communicators.shm_object_storage import (
15 MsgpackSerde,
16 SingleWriterShmObjectStorage,
17 SingleWriterShmRingBuffer,
18 )
18 -from vllm.envs import VLLM_OBJECT_STORAGE_SHM_BUFFER_NAME
19 from vllm.logger import init_logger
20 from vllm.utils import GiB_bytes, MiB_bytes
21 from vllm.utils.cache import CacheInfo, LRUCache
@@ -436,7 +436,7 @@ class ShmObjectStoreSenderCache(BaseMultiModalProcessorCache):
436
437 ring_buffer = SingleWriterShmRingBuffer(
438 data_buffer_size=int(mm_config.mm_processor_cache_gb * GiB_bytes),
439 - name=VLLM_OBJECT_STORAGE_SHM_BUFFER_NAME,
439 + name=envs.VLLM_OBJECT_STORAGE_SHM_BUFFER_NAME,
440 create=True, # sender is the writer
441 )
442 self._shm_cache = SingleWriterShmObjectStorage(
@@ -678,7 +678,7 @@ class ShmObjectStoreReceiverCache(BaseMultiModalReceiverCache):
678
679 ring_buffer = SingleWriterShmRingBuffer(
680 data_buffer_size=int(mm_config.mm_processor_cache_gb * GiB_bytes),
681 - name=VLLM_OBJECT_STORAGE_SHM_BUFFER_NAME,
681 + name=envs.VLLM_OBJECT_STORAGE_SHM_BUFFER_NAME,
682 create=False, # Server is a reader
683 )
684 self._shm_cache = SingleWriterShmObjectStorage(
vllm/transformers_utils/utils.py
+2 -2
@@ -8,7 +8,7 @@ from os import PathLike
8 from pathlib import Path
9 from typing import Any
10
11 -from vllm.envs import VLLM_MODEL_REDIRECT_PATH
11 +import vllm.envs as envs
12 from vllm.logger import init_logger
13
14 logger = init_logger(__name__)
@@ -86,7 +86,7 @@ def maybe_model_redirect(model: str) -> str:
86 :return: maybe redirect to a local folder
87 """
88
89 - model_redirect_path = VLLM_MODEL_REDIRECT_PATH
89 + model_redirect_path = envs.VLLM_MODEL_REDIRECT_PATH
90
91 if not model_redirect_path:
92 return model
vllm/utils/gc_utils.py
+3 -3
@@ -7,7 +7,7 @@ from collections import Counter
7 from contextlib import suppress
8 from typing import Any
9
10 -from vllm.envs import VLLM_GC_DEBUG
10 +import vllm.envs as envs
11 from vllm.logger import init_logger
12
13 logger = init_logger(__name__)
@@ -36,7 +36,7 @@ class GCDebugConfig:
36 self.top_objects = json_conf.get("top_objects", -1)
37 except Exception:
38 self.enabled = False
39 - logger.error("Failed to parse VLLM_GC_DEBUG(%s)", VLLM_GC_DEBUG)
39 + logger.error("Failed to parse VLLM_GC_DEBUG(%s)", envs.VLLM_GC_DEBUG)
40 logger.info("GC Debug Config. %s", str(self))
41
42 def __repr__(self) -> str:
@@ -93,7 +93,7 @@ def maybe_attach_gc_debug_callback() -> None:
93 """
94 Attached a callback for GC debug when VLLM_GC_DEBUG is enabled.
95 """
96 - config = GCDebugConfig(VLLM_GC_DEBUG)
96 + config = GCDebugConfig(envs.VLLM_GC_DEBUG)
97 if config.enabled:
98 debugger: GCDebugger = GCDebugger(config)
99
vllm/v1/engine/async_llm.py
+2 -3
@@ -16,7 +16,6 @@ from vllm.config import VllmConfig
16 from vllm.engine.arg_utils import AsyncEngineArgs
17 from vllm.engine.protocol import EngineClient
18 from vllm.entrypoints.utils import _validate_truncation_size
19 -from vllm.envs import VLLM_V1_OUTPUT_PROC_CHUNK_SIZE
19 from vllm.inputs import PromptType
20 from vllm.logger import init_logger
21 from vllm.lora.request import LoRARequest
@@ -483,12 +482,12 @@ class AsyncLLM(EngineClient):
482 # Split outputs into chunks of at most
483 # VLLM_V1_OUTPUT_PROC_CHUNK_SIZE, so that we don't block the
484 # event loop for too long.
486 - if num_outputs <= VLLM_V1_OUTPUT_PROC_CHUNK_SIZE:
485 + if num_outputs <= envs.VLLM_V1_OUTPUT_PROC_CHUNK_SIZE:
486 slices = (outputs.outputs,)
487 else:
488 slices = np.array_split(
489 outputs.outputs,
491 - cdiv(num_outputs, VLLM_V1_OUTPUT_PROC_CHUNK_SIZE),
490 + cdiv(num_outputs, envs.VLLM_V1_OUTPUT_PROC_CHUNK_SIZE),
491 )
492
493 for i, outputs_slice in enumerate(slices):