[Platform] Move env check function to platform interface (#48599)
Signed-off-by: wangxiyuan <wangxiyuan1007@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
wangxiyuan committed
Sep 16, 2026 at 18:08 UTC
118e17f5ff301f67f1f4f5bdae2c9ae5e50242c5
3 files changed
+19
-10
vllm/engine/arg_utils.py
+1
-1
@@ -2051,7 +2051,7 @@ class EngineArgs:
2051
2052
device_config = DeviceConfig(device=cast(Device, current_platform.device_type))
2053
2054
- envs.validate_environ(self.fail_on_environ_validation)
2054
+ current_platform.validate_environ(self.fail_on_environ_validation)
2055
2056
# Check if the model is a speculator and override model/tokenizer/config
2057
# BEFORE creating ModelConfig, so the config is created with the target model
vllm/envs.py
-9
@@ -2249,15 +2249,6 @@ def is_set(name: str):
2249
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
2250
2251
2252
-def validate_environ(hard_fail: bool) -> None:
2253
- for env in os.environ:
2254
- if env.startswith("VLLM_") and env not in environment_variables:
2255
- if hard_fail:
2256
- raise ValueError(f"Unknown vLLM environment variable detected: {env}")
2257
- else:
2258
- logger.warning("Unknown vLLM environment variable detected: %s", env)
2259
-
2260
-
2252
def compile_factors() -> dict[str, object]:
2253
"""Return env vars used for torch.compile cache keys.
2254
vllm/platforms/interface.py
+18
@@ -1334,6 +1334,24 @@ class Platform:
1334
"""
1335
return False
1336
1337
+ @classmethod
1338
+ def validate_environ(cls, hard_fail: bool) -> None:
1339
+ """
1340
+ Validate environment variables for the current platform.
1341
+ """
1342
+ from vllm import envs
1343
+
1344
+ for env in os.environ:
1345
+ if env.startswith("VLLM_") and env not in envs.environment_variables:
1346
+ if hard_fail:
1347
+ raise ValueError(
1348
+ f"Unknown vLLM environment variable detected: {env}"
1349
+ )
1350
+ else:
1351
+ logger.warning(
1352
+ "Unknown vLLM environment variable detected: %s", env
1353
+ )
1354
+
1355
1356
class UnspecifiedPlatform(Platform):
1357
_enum = PlatformEnum.UNSPECIFIED