[Frontend][Core] Standardize request error handling with VLLMError hierarchy (#49665)

Signed-off-by: Zach Zhu <zzqshu@126.com>
This commit is contained in:
Zach Zhu
2026-07-29 04:20:40 +00:00
committed by GitHub
parent f37f03db4a
commit 58f9659397
46 changed files with 370 additions and 248 deletions
+15 -12
View File
@@ -7,6 +7,7 @@ from typing import Any, Literal
import vllm.envs as envs
from vllm.config import VllmConfig
from vllm.exceptions import VLLMValidationError
from vllm.inputs import (
EngineInput,
PromptType,
@@ -90,7 +91,7 @@ class InputProcessor:
task for task in supported_tasks if task in GENERATION_TASKS
]
if not supported_generation_tasks:
raise ValueError("This model does not support generation")
raise VLLMValidationError("This model does not support generation")
params.verify(
self.model_config,
@@ -104,13 +105,13 @@ class InputProcessor:
self.vllm_config.reasoning_config is None
or not self.vllm_config.reasoning_config.enabled
):
raise ValueError(
raise VLLMValidationError(
"thinking_token_budget is set but reasoning_config is "
"not configured. Please set --reasoning-parser "
"and/or --reasoning-config to use thinking_token_budget."
)
if self.use_v2_model_runner:
raise ValueError(
raise VLLMValidationError(
"thinking_token_budget is not yet supported by the V2 "
"model runner. Run vLLM with VLLM_USE_V2_MODEL_RUNNER=0 "
"to use thinking_token_budget."
@@ -120,7 +121,7 @@ class InputProcessor:
task for task in supported_tasks if task in POOLING_TASKS
]
if not supported_pooling_tasks:
raise ValueError("This model does not support pooling")
raise VLLMValidationError("This model does not support pooling")
if params.task is None:
if "token_embed" in supported_pooling_tasks:
@@ -131,7 +132,7 @@ class InputProcessor:
params.task = "plugin"
if params.task not in supported_pooling_tasks:
raise ValueError(
raise VLLMValidationError(
f"Unsupported task: {params.task!r} "
f"Supported tasks: {supported_pooling_tasks}"
)
@@ -149,7 +150,7 @@ class InputProcessor:
# LoRA request passed in while LoRA is not enabled
if not self.lora_config:
raise ValueError(
raise VLLMValidationError(
f"Got lora_request {lora_request} but LoRA is not enabled!"
)
@@ -261,7 +262,7 @@ class InputProcessor:
dp_local_size = parallel_config.data_parallel_size_local
num_ranks = dp_local_size if parallel_config.local_engines_only else dp_size
if data_parallel_rank is not None and not (0 <= data_parallel_rank < num_ranks):
raise ValueError(
raise VLLMValidationError(
f"data_parallel_rank {data_parallel_rank} "
f"is out of range [0, {num_ranks})."
)
@@ -393,7 +394,7 @@ class InputProcessor:
return
if prompt_len == 0 and prompt_type == "decoder":
raise ValueError(f"The {prompt_type} prompt cannot be empty")
raise VLLMValidationError(f"The {prompt_type} prompt cannot be empty")
model_config = self.model_config
max_prompt_len = (
@@ -415,7 +416,7 @@ class InputProcessor:
"number of text tokens."
)
raise ValueError(
raise VLLMValidationError(
f"The {prompt_type} prompt (length {prompt_len}) is "
f"longer than the maximum model length of {max_prompt_len}. "
f"{suggestion}"
@@ -425,7 +426,7 @@ class InputProcessor:
"Make sure that `max_model_len` is no smaller than the "
"number of text tokens (prompt + requested output tokens)."
)
raise ValueError(
raise VLLMValidationError(
f"The {prompt_type} prompt (length {prompt_len}) plus the number of "
f"requested output tokens (at least 1) is longer than the maximum "
f"model length of {max_prompt_len}. {suggestion}"
@@ -457,7 +458,7 @@ class InputProcessor:
for mm_position in mm_positions:
num_embeds = mm_position.get_num_embeds()
if num_embeds > self.mm_encoder_cache_size:
raise ValueError(
raise VLLMValidationError(
f"The {prompt_type} prompt contains a(n) {modality} item "
f"with {num_embeds} embedding tokens, which exceeds the "
f"pre-allocated encoder cache size "
@@ -481,7 +482,9 @@ class InputProcessor:
# truly out-of-vocabulary.
model_vocab_size = model_config.get_vocab_size()
if max_input_id > max(tokenizer.max_token_id, model_vocab_size - 1):
raise ValueError(f"Token id {max_input_id} is out of vocabulary")
raise VLLMValidationError(
f"Token id {max_input_id} is out of vocabulary"
)
def _validate_model_inputs(
self,