Skip to content

Improve error for structured output backend selection #16717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 17, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions vllm/v1/engine/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from vllm.inputs import ProcessorInputs, PromptType, SingletonInputs
from vllm.inputs.parse import split_enc_dec_inputs
from vllm.inputs.preprocess import InputPreprocessor
from vllm.logger import init_logger
from vllm.lora.request import LoRARequest
from vllm.multimodal import (MULTIMODAL_REGISTRY, MultiModalKwargs,
MultiModalRegistry)
Expand All @@ -25,6 +26,8 @@
from vllm.v1.structured_output.backend_xgrammar import (
validate_xgrammar_grammar)

logger = init_logger(__name__)


class Processor:

Expand Down Expand Up @@ -154,11 +157,16 @@ def _validate_structured_output(self, params: SamplingParams) -> None:
raise ValueError(f"Only {supported_backends} structured output is "
"supported in V1.")
if params.guided_decoding.backend:
logger.warning(
"Request-level structured output backend selection is not "
"supported in V1. Please only specify structured output "
"backend at the engine level.")
if params.guided_decoding.backend != engine_level_backend:
raise ValueError("Request-level structured output backend "
"must match engine-level backend. "
f"{params.guided_decoding.backend}"
f" != {engine_level_backend}")
raise ValueError(
"Request-level structured output backend must match "
"engine-level backend. The request specified "
f"'{params.guided_decoding.backend}', but the engine was "
f"initialised with '{engine_level_backend}'.")
else:
params.guided_decoding.backend = engine_level_backend

Expand Down