From ac7383084704d343a046eb2c053d5c93fd96cba2 Mon Sep 17 00:00:00 2001 From: wangxiyuan Date: Tue, 14 Jul 2026 17:14:14 +0800 Subject: [PATCH] [Platform] Move env check function to platform interface Signed-off-by: wangxiyuan --- vllm/engine/arg_utils.py | 2 +- vllm/envs.py | 9 --------- vllm/platforms/interface.py | 18 ++++++++++++++++++ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/vllm/engine/arg_utils.py b/vllm/engine/arg_utils.py index 742d62ac3698..97cf4c219dee 100644 --- a/vllm/engine/arg_utils.py +++ b/vllm/engine/arg_utils.py @@ -1844,7 +1844,7 @@ def create_engine_config( device_config = DeviceConfig(device=cast(Device, current_platform.device_type)) - envs.validate_environ(self.fail_on_environ_validation) + current_platform.validate_environ(self.fail_on_environ_validation) # Check if the model is a speculator and override model/tokenizer/config # BEFORE creating ModelConfig, so the config is created with the target model diff --git a/vllm/envs.py b/vllm/envs.py index 611752a11b09..6f4844ba1165 100755 --- a/vllm/envs.py +++ b/vllm/envs.py @@ -2085,15 +2085,6 @@ def is_set(name: str): raise AttributeError(f"module {__name__!r} has no attribute {name!r}") -def validate_environ(hard_fail: bool) -> None: - for env in os.environ: - if env.startswith("VLLM_") and env not in environment_variables: - if hard_fail: - raise ValueError(f"Unknown vLLM environment variable detected: {env}") - else: - logger.warning("Unknown vLLM environment variable detected: %s", env) - - def compile_factors() -> dict[str, object]: """Return env vars used for torch.compile cache keys. diff --git a/vllm/platforms/interface.py b/vllm/platforms/interface.py index 7cf009c80716..93713cf50bb7 100644 --- a/vllm/platforms/interface.py +++ b/vllm/platforms/interface.py @@ -1288,6 +1288,24 @@ def is_arch_support_pdl(cls) -> bool: """ return False + @classmethod + def validate_environ(cls, hard_fail: bool) -> None: + """ + Validate environment variables for the current platform. + """ + from vllm import envs + + for env in os.environ: + if env.startswith("VLLM_") and env not in envs.environment_variables: + if hard_fail: + raise ValueError( + f"Unknown vLLM environment variable detected: {env}" + ) + else: + logger.warning( + "Unknown vLLM environment variable detected: %s", env + ) + class UnspecifiedPlatform(Platform): _enum = PlatformEnum.UNSPECIFIED