@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / f0ca0671c7
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 8, 12:30 UTC

[Feature] Warn about unrecognized environment variables (#33581)

Signed-off-by: Gregory Shtrasberg <Gregory.Shtrasberg@amd.com>

Gregory Shtrasberg committed Feb 10, 2026 at 15:45 UTC f0ca0671c70fae6d1562127e3330eeaedf4abb3f
3 files changed +45
tests/config/test_config_generation.py
+24
@@ -78,3 +78,27 @@ def test_ray_runtime_env(monkeypatch: pytest.MonkeyPatch):
78 )
79
80 ray.shutdown()
81 +
82 +
83 +def test_unrecognized_env():
84 + import os
85 +
86 + # Test that if fail_on_environ_validation is True, then an error
87 + # is raised when an unrecognized vLLM environment variable is set
88 + os.environ["VLLM_UNRECOGNIZED_ENV_VAR"] = "some_value"
89 + engine_args = EngineArgs(
90 + fail_on_environ_validation=True,
91 + )
92 + with pytest.raises(ValueError, match="Unknown vLLM environment variable detected"):
93 + engine_args.create_engine_config()
94 +
95 + # Test that if fail_on_environ_validation is False, then no error is raised
96 + engine_args = EngineArgs()
97 + engine_args.create_engine_config()
98 +
99 + # Test that when the unrecognized env var is removed, no error is raised
100 + os.environ.pop("VLLM_UNRECOGNIZED_ENV_VAR", None)
101 + engine_args = EngineArgs(
102 + fail_on_environ_validation=True,
103 + )
104 + engine_args.create_engine_config()
vllm/engine/arg_utils.py
+12
@@ -593,6 +593,8 @@ class EngineArgs:
593 "weight_transfer_config",
594 )
595
596 + fail_on_environ_validation: bool = False
597 +
598 def __post_init__(self):
599 # support `EngineArgs(compilation_config={...})`
600 # without having to manually construct a
@@ -1239,6 +1241,14 @@ class EngineArgs:
1241 help="Log aggregate rather than per-engine statistics "
1242 "when using data parallelism.",
1243 )
1244 +
1245 + parser.add_argument(
1246 + "--fail-on-environ-validation",
1247 + help="If set, the engine will raise an error if "
1248 + "environment validation fails.",
1249 + default=False,
1250 + action=argparse.BooleanOptionalAction,
1251 + )
1252 return parser
1253
1254 @classmethod
@@ -1396,6 +1406,8 @@ class EngineArgs:
1406
1407 device_config = DeviceConfig(device=cast(Device, current_platform.device_type))
1408
1409 + envs.validate_environ(self.fail_on_environ_validation)
1410 +
1411 # Check if the model is a speculator and override model/tokenizer/config
1412 # BEFORE creating ModelConfig, so the config is created with the target model
1413 # Skip speculator detection for cloud storage models (eg: S3, GCS) since
vllm/envs.py
+9
@@ -1606,6 +1606,15 @@ def is_set(name: str):
1606 raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
1607
1608
1609 +def validate_environ(hard_fail: bool) -> None:
1610 + for env in os.environ:
1611 + if env.startswith("VLLM_") and env not in environment_variables:
1612 + if hard_fail:
1613 + raise ValueError(f"Unknown vLLM environment variable detected: {env}")
1614 + else:
1615 + logger.warning("Unknown vLLM environment variable detected: %s", env)
1616 +
1617 +
1618 def compile_factors() -> dict[str, object]:
1619 """Return env vars used for torch.compile cache keys.
1620