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 6, 14:30 UTC
[Misc] Use VLLMValidationError in batch, pooling, and tokenize protocol validators (#36256)
Signed-off-by: umut-polat <52835619+umut-polat@users.noreply.github.com>
Umut Polat committed
Mar 17, 2026 at 16:52 UTC
56cb1baa667e413c9bfa38c7c44da38bd41fc612
3 files changed
+13
-8
vllm/entrypoints/openai/run_batch.py
+7
-4
@@ -54,6 +54,7 @@ from vllm.entrypoints.pooling.score.protocol import (
54
ScoreResponse,
55
)
56
from vllm.entrypoints.utils import create_error_response
57
+from vllm.exceptions import VLLMValidationError
58
from vllm.logger import init_logger
59
from vllm.reasoning import ReasoningParserManager
60
from vllm.utils import random_uuid
@@ -86,9 +87,10 @@ class BatchTranscriptionRequest(TranscriptionRequest):
87
def validate_no_file(cls, data: Any):
88
"""Ensure file field is not provided in batch requests."""
89
if isinstance(data, dict) and "file" in data:
89
- raise ValueError(
90
+ raise VLLMValidationError(
91
"The 'file' field is not supported in batch requests. "
91
- "Use 'file_url' instead."
92
+ "Use 'file_url' instead.",
93
+ parameter="file",
94
)
95
return data
96
@@ -116,9 +118,10 @@ class BatchTranslationRequest(TranslationRequest):
118
def validate_no_file(cls, data: Any):
119
"""Ensure file field is not provided in batch requests."""
120
if isinstance(data, dict) and "file" in data:
119
- raise ValueError(
121
+ raise VLLMValidationError(
122
"The 'file' field is not supported in batch requests. "
121
- "Use 'file_url' instead."
123
+ "Use 'file_url' instead.",
124
+ parameter="file",
125
)
126
return data
127
vllm/entrypoints/pooling/base/protocol.py
+3
-2
@@ -11,6 +11,7 @@ from vllm.entrypoints.chat_utils import (
11
ChatTemplateContentFormatOption,
12
)
13
from vllm.entrypoints.openai.engine.protocol import OpenAIBaseModel
14
+from vllm.exceptions import VLLMValidationError
15
from vllm.renderers import ChatParams, merge_kwargs
16
from vllm.utils import random_uuid
17
from vllm.utils.serial_utils import EmbedDType, EncodingFormat, Endianness
@@ -147,9 +148,9 @@ class ChatRequestMixin(OpenAIBaseModel):
148
@classmethod
149
def check_generation_prompt(cls, data):
150
if data.get("continue_final_message") and data.get("add_generation_prompt"):
150
- raise ValueError(
151
+ raise VLLMValidationError(
152
"Cannot set both `continue_final_message` and "
152
- "`add_generation_prompt` to True."
153
+ "`add_generation_prompt` to True.",
154
)
155
return data
156
vllm/entrypoints/serve/tokenize/protocol.py
+3
-2
@@ -17,6 +17,7 @@ from vllm.entrypoints.openai.chat_completion.protocol import (
17
from vllm.entrypoints.openai.engine.protocol import (
18
OpenAIBaseModel,
19
)
20
+from vllm.exceptions import VLLMValidationError
21
from vllm.renderers import ChatParams, TokenizeParams, merge_kwargs
22
23
@@ -120,9 +121,9 @@ class TokenizeChatRequest(OpenAIBaseModel):
121
@classmethod
122
def check_generation_prompt(cls, data):
123
if data.get("continue_final_message") and data.get("add_generation_prompt"):
123
- raise ValueError(
124
+ raise VLLMValidationError(
125
"Cannot set both `continue_final_message` and "
125
- "`add_generation_prompt` to True."
126
+ "`add_generation_prompt` to True.",
127
)
128
return data
129