@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / cb1b02d0e8
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 4, 11:15 UTC

[Frontend] Add VLLM_SKIP_MODEL_NAME_VALIDATION environment variable (#34676)

Signed-off-by: Dhruv Singal <dhruvsingalabc@gmail.com> Signed-off-by: Dhruv Singal <dsingal@Dhruvs-MacBook-Pro.local> Signed-off-by: Your Name <you@example.com> Signed-off-by: vLLM Assistant <assistant@vllm.ai> Signed-off-by: Simon Mo <simon.mo@hey.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Dhruv Singal <dsingal@Dhruvs-MacBook-Pro.local> Co-authored-by: Your Name <you@example.com> Co-authored-by: OpenCode <noreply@openai.com> Co-authored-by: Simon Mo <simon.mo@hey.com>

Dhruv Singal committed Apr 29, 2026 at 23:19 UTC cb1b02d0e8159f25678b96667651ec539546022b
3 files changed +49
tests/entrypoints/openai/responses/test_errors.py
+34
@@ -6,7 +6,9 @@ from unittest.mock import MagicMock
6
7 import pytest
8
9 +import vllm.envs as envs
10 from vllm.entrypoints.openai.engine.serving import GenerationError, OpenAIServing
11 +from vllm.envs import disable_envs_cache
12
13
14 @pytest.mark.asyncio
@@ -60,3 +62,35 @@ async def test_convert_generation_error_to_streaming_response():
62 assert isinstance(error_json, str)
63 assert "Internal server error" in error_json
64 assert "InternalServerError" in error_json
65 +
66 +
67 +def test_is_model_supported_skip_name_validation_env(
68 + monkeypatch: pytest.MonkeyPatch,
69 +) -> None:
70 + """When VLLM_SKIP_MODEL_NAME_VALIDATION is set, accept any model id."""
71 + disable_envs_cache()
72 + monkeypatch.delenv("VLLM_SKIP_MODEL_NAME_VALIDATION", raising=False)
73 +
74 + mock_engine = MagicMock()
75 + mock_engine.model_config = MagicMock()
76 + mock_engine.model_config.max_model_len = 100
77 + mock_models = MagicMock()
78 + mock_models.is_base_model.return_value = False
79 +
80 + serving = OpenAIServing(
81 + engine_client=mock_engine,
82 + models=mock_models,
83 + request_logger=None,
84 + )
85 +
86 + assert serving._is_model_supported("not-a-registered-model") is False
87 +
88 + monkeypatch.setenv("VLLM_SKIP_MODEL_NAME_VALIDATION", "1")
89 + disable_envs_cache()
90 + assert envs.VLLM_SKIP_MODEL_NAME_VALIDATION is True
91 + assert serving._is_model_supported("not-a-registered-model") is True
92 +
93 + monkeypatch.setenv("VLLM_SKIP_MODEL_NAME_VALIDATION", "true")
94 + disable_envs_cache()
95 + assert envs.VLLM_SKIP_MODEL_NAME_VALIDATION is True
96 + assert serving._is_model_supported("another-alias") is True
vllm/entrypoints/openai/engine/serving.py
+2
@@ -755,6 +755,8 @@ class OpenAIServing:
755 def _is_model_supported(self, model_name: str | None) -> bool:
756 if not model_name:
757 return True
758 + if envs.VLLM_SKIP_MODEL_NAME_VALIDATION:
759 + return True
760 return self.models.is_base_model(model_name)
761
762
vllm/envs.py
+13
@@ -255,6 +255,10 @@ if TYPE_CHECKING:
255 VLLM_LORA_DISABLE_PDL: bool = False
256 VLLM_ENABLE_CUDA_COMPATIBILITY: bool = False
257 VLLM_CUDA_COMPATIBILITY_PATH: str | None = None
258 + VLLM_SKIP_MODEL_NAME_VALIDATION: bool = False
259 + """If set, vLLM will skip model name validation in API requests.
260 + This allows any model name to be accepted in the 'model' field of requests,
261 + making the server model-name agnostic. Useful for proxy/gateway scenarios."""
262 VLLM_ELASTIC_EP_SCALE_UP_LAUNCH: bool = False
263 VLLM_ELASTIC_EP_DRAIN_REQUESTS: bool = False
264 VLLM_MEMORY_PROFILER_ESTIMATE_CUDAGRAPHS: bool = True
@@ -1711,6 +1715,14 @@ environment_variables: dict[str, Callable[[], Any]] = {
1715 "VLLM_CUDA_COMPATIBILITY_PATH": lambda: os.environ.get(
1716 "VLLM_CUDA_COMPATIBILITY_PATH", None
1717 ),
1718 + # Skip model name validation in OpenAI API requests.
1719 + # When set to 1, any model name will be accepted in the 'model' field
1720 + # of API requests. This is useful for proxy/gateway scenarios where
1721 + # the actual model is served but different names may be used in requests.
1722 + "VLLM_SKIP_MODEL_NAME_VALIDATION": lambda: (
1723 + os.getenv("VLLM_SKIP_MODEL_NAME_VALIDATION", "0").strip().lower()
1724 + in ("1", "true")
1725 + ),
1726 # Whether it is a scale up launch engine for elastic EP,
1727 # Should only be set by EngineCoreClient.
1728 "VLLM_ELASTIC_EP_SCALE_UP_LAUNCH": lambda: bool(
@@ -1886,6 +1898,7 @@ def compile_factors() -> dict[str, object]:
1898 "VLLM_TEST_FORCE_LOAD_FORMAT",
1899 "VLLM_ENABLE_CUDA_COMPATIBILITY",
1900 "VLLM_CUDA_COMPATIBILITY_PATH",
1901 + "VLLM_SKIP_MODEL_NAME_VALIDATION",
1902 "LOCAL_RANK",
1903 "CUDA_VISIBLE_DEVICES",
1904 "NO_COLOR",