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 12, 14:45 UTC
Scheduled removal of `guided_*` config fields (#29326)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Harry Mellor committed
Nov 25, 2025 at 05:24 UTC
316c8492bf4d5fca8f9f8ea6f8ef1d76a0cb940f
5 files changed
+43
-262
docs/features/structured_outputs.md
+1
-1
@@ -7,7 +7,7 @@ This document shows you some examples of the different options that are
7
available to generate structured outputs.
8
9
!!! warning
10
- If you are still using the following deprecated API fields, please update your code to use `structured_outputs` as demonstrated in the rest of this document:
10
+ If you are still using the following deprecated API fields which were removed in v0.12.0, please update your code to use `structured_outputs` as demonstrated in the rest of this document:
11
12
- `guided_json` -> `{"structured_outputs": {"json": ...}}` or `StructuredOutputsParams(json=...)`
13
- `guided_regex` -> `{"structured_outputs": {"regex": ...}}` or `StructuredOutputsParams(regex=...)`
tests/v1/entrypoints/llm/test_struct_output_generate.py
+4
-25
@@ -3,7 +3,6 @@
3
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
4
5
import json
6
-from dataclasses import fields
6
from enum import Enum
7
from typing import TYPE_CHECKING, Any
8
@@ -21,7 +20,6 @@ from vllm.outputs import RequestOutput
20
from vllm.platforms import current_platform
21
from vllm.reasoning.abs_reasoning_parsers import ReasoningParserManager
22
from vllm.sampling_params import (
24
- GuidedDecodingParams,
23
SamplingParams,
24
StructuredOutputsParams,
25
)
@@ -108,23 +106,6 @@ class CarDescription(BaseModel):
106
car_type: CarType
107
108
111
-def test_guided_decoding_deprecated():
112
- with pytest.warns(DeprecationWarning, match="GuidedDecodingParams is deprecated.*"):
113
- guided_decoding = GuidedDecodingParams(json_object=True)
114
-
115
- structured_outputs = StructuredOutputsParams(json_object=True)
116
- assert fields(guided_decoding) == fields(structured_outputs)
117
-
118
- with pytest.warns(DeprecationWarning, match="guided_decoding is deprecated.*"):
119
- sp1 = SamplingParams(guided_decoding=guided_decoding)
120
-
121
- with pytest.warns(DeprecationWarning, match="guided_decoding is deprecated.*"):
122
- sp2 = SamplingParams.from_optional(guided_decoding=guided_decoding)
123
-
124
- assert sp1 == sp2
125
- assert sp1.structured_outputs == guided_decoding
126
-
127
-
109
@pytest.mark.parametrize(
110
"model_name, backend, tokenizer_mode, speculative_config",
111
PARAMS_MODELS_BACKENDS_TOKENIZER_MODE,
@@ -899,13 +880,11 @@ def test_structured_output_batched_with_non_structured_outputs_requests(
880
output_json = json.loads(generated_text)
881
882
902
-@pytest.mark.parametrize("guided_decoding_backend", ["xgrammar"])
903
-def test_structured_output_with_structural_tag(
904
- guided_decoding_backend: str,
905
-):
883
+@pytest.mark.parametrize("backend", ["xgrammar"])
884
+def test_structured_output_with_structural_tag(backend: str):
885
llm = LLM(
886
model="Qwen/Qwen2.5-1.5B-Instruct",
908
- guided_decoding_backend=guided_decoding_backend,
887
+ structured_outputs_config=StructuredOutputsConfig(backend=backend),
888
)
889
890
structural_tag_config = {
@@ -923,7 +902,7 @@ def test_structured_output_with_structural_tag(
902
sampling_params = SamplingParams(
903
temperature=0.0,
904
max_tokens=500,
926
- guided_decoding=StructuredOutputsParams(
905
+ structured_outputs=StructuredOutputsParams(
906
structural_tag=json.dumps(structural_tag_config)
907
),
908
)
vllm/engine/arg_utils.py
-33
@@ -502,11 +502,6 @@ class EngineArgs:
502
)
503
reasoning_parser: str = StructuredOutputsConfig.reasoning_parser
504
reasoning_parser_plugin: str | None = None
505
- # Deprecated guided decoding fields
506
- guided_decoding_backend: str | None = None
507
- guided_decoding_disable_fallback: bool | None = None
508
- guided_decoding_disable_any_whitespace: bool | None = None
509
- guided_decoding_disable_additional_properties: bool | None = None
505
506
logits_processor_pattern: str | None = ModelConfig.logits_processor_pattern
507
@@ -725,19 +720,6 @@ class EngineArgs:
720
"--reasoning-parser-plugin",
721
**structured_outputs_kwargs["reasoning_parser_plugin"],
722
)
728
- # Deprecated guided decoding arguments
729
- for arg, type in [
730
- ("--guided-decoding-backend", str),
731
- ("--guided-decoding-disable-fallback", bool),
732
- ("--guided-decoding-disable-any-whitespace", bool),
733
- ("--guided-decoding-disable-additional-properties", bool),
734
- ]:
735
- structured_outputs_group.add_argument(
736
- arg,
737
- type=type,
738
- help=(f"[DEPRECATED] {arg} will be removed in v0.12.0."),
739
- deprecated=True,
740
- )
723
724
# Parallel arguments
725
parallel_kwargs = get_kwargs(ParallelConfig)
@@ -1712,21 +1694,6 @@ class EngineArgs:
1694
self.reasoning_parser_plugin
1695
)
1696
1715
- # Forward the deprecated CLI args to the StructuredOutputsConfig
1716
- so_config = self.structured_outputs_config
1717
- if self.guided_decoding_backend is not None:
1718
- so_config.guided_decoding_backend = self.guided_decoding_backend
1719
- if self.guided_decoding_disable_fallback is not None:
1720
- so_config.disable_fallback = self.guided_decoding_disable_fallback
1721
- if self.guided_decoding_disable_any_whitespace is not None:
1722
- so_config.disable_any_whitespace = (
1723
- self.guided_decoding_disable_any_whitespace
1724
- )
1725
- if self.guided_decoding_disable_additional_properties is not None:
1726
- so_config.disable_additional_properties = (
1727
- self.guided_decoding_disable_additional_properties
1728
- )
1729
-
1697
observability_config = ObservabilityConfig(
1698
show_hidden_metrics_for_version=self.show_hidden_metrics_for_version,
1699
otlp_traces_endpoint=self.otlp_traces_endpoint,
vllm/entrypoints/openai/protocol.py
+38
-165
@@ -652,62 +652,6 @@ class ChatCompletionRequest(OpenAIBaseModel):
652
default=None,
653
description="Additional kwargs for structured outputs",
654
)
655
- guided_json: str | dict | BaseModel | None = Field(
656
- default=None,
657
- description=(
658
- "`guided_json` is deprecated. "
659
- "This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
660
- "Please pass `json` to `structured_outputs` instead."
661
- ),
662
- )
663
- guided_regex: str | None = Field(
664
- default=None,
665
- description=(
666
- "`guided_regex` is deprecated. "
667
- "This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
668
- "Please pass `regex` to `structured_outputs` instead."
669
- ),
670
- )
671
- guided_choice: list[str] | None = Field(
672
- default=None,
673
- description=(
674
- "`guided_choice` is deprecated. "
675
- "This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
676
- "Please pass `choice` to `structured_outputs` instead."
677
- ),
678
- )
679
- guided_grammar: str | None = Field(
680
- default=None,
681
- description=(
682
- "`guided_grammar` is deprecated. "
683
- "This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
684
- "Please pass `grammar` to `structured_outputs` instead."
685
- ),
686
- )
687
- structural_tag: str | None = Field(
688
- default=None,
689
- description=(
690
- "`structural_tag` is deprecated. "
691
- "This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
692
- "Please pass `structural_tag` to `structured_outputs` instead."
693
- ),
694
- )
695
- guided_decoding_backend: str | None = Field(
696
- default=None,
697
- description=(
698
- "`guided_decoding_backend` is deprecated. "
699
- "This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
700
- "Please remove it from your request."
701
- ),
702
- )
703
- guided_whitespace_pattern: str | None = Field(
704
- default=None,
705
- description=(
706
- "`guided_whitespace_pattern` is deprecated. "
707
- "This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
708
- "Please pass `whitespace_pattern` to `structured_outputs` instead."
709
- ),
710
- )
655
priority: int = Field(
656
default=0,
657
description=(
@@ -841,20 +785,6 @@ class ChatCompletionRequest(OpenAIBaseModel):
785
if prompt_logprobs is None and self.echo:
786
prompt_logprobs = self.top_logprobs
787
844
- # Forward deprecated guided_* parameters to structured_outputs
845
- if self.structured_outputs is None:
846
- kwargs = dict[str, Any](
847
- json=self.guided_json,
848
- regex=self.guided_regex,
849
- choice=self.guided_choice,
850
- grammar=self.guided_grammar,
851
- whitespace_pattern=self.guided_whitespace_pattern,
852
- structural_tag=self.structural_tag,
853
- )
854
- kwargs = {k: v for k, v in kwargs.items() if v is not None}
855
- if len(kwargs) > 0:
856
- self.structured_outputs = StructuredOutputsParams(**kwargs)
857
-
788
response_format = self.response_format
789
if response_format is not None:
790
# If structured outputs wasn't already enabled,
@@ -863,24 +793,23 @@ class ChatCompletionRequest(OpenAIBaseModel):
793
self.structured_outputs = StructuredOutputsParams()
794
795
# Set structured output params for response format
866
- if response_format is not None:
867
- if response_format.type == "json_object":
868
- self.structured_outputs.json_object = True
869
- elif response_format.type == "json_schema":
870
- json_schema = response_format.json_schema
871
- assert json_schema is not None
872
- self.structured_outputs.json = json_schema.json_schema
873
- elif response_format.type == "structural_tag":
874
- structural_tag = response_format
875
- assert structural_tag is not None and isinstance(
876
- structural_tag,
877
- (
878
- LegacyStructuralTagResponseFormat,
879
- StructuralTagResponseFormat,
880
- ),
881
- )
882
- s_tag_obj = structural_tag.model_dump(by_alias=True)
883
- self.structured_outputs.structural_tag = json.dumps(s_tag_obj)
796
+ if response_format.type == "json_object":
797
+ self.structured_outputs.json_object = True
798
+ elif response_format.type == "json_schema":
799
+ json_schema = response_format.json_schema
800
+ assert json_schema is not None
801
+ self.structured_outputs.json = json_schema.json_schema
802
+ elif response_format.type == "structural_tag":
803
+ structural_tag = response_format
804
+ assert structural_tag is not None and isinstance(
805
+ structural_tag,
806
+ (
807
+ LegacyStructuralTagResponseFormat,
808
+ StructuralTagResponseFormat,
809
+ ),
810
+ )
811
+ s_tag_obj = structural_tag.model_dump(by_alias=True)
812
+ self.structured_outputs.structural_tag = json.dumps(s_tag_obj)
813
814
extra_args: dict[str, Any] = self.vllm_xargs if self.vllm_xargs else {}
815
if self.kv_transfer_params:
@@ -1140,58 +1069,6 @@ class CompletionRequest(OpenAIBaseModel):
1069
default=None,
1070
description="Additional kwargs for structured outputs",
1071
)
1143
- guided_json: str | dict | BaseModel | None = Field(
1144
- default=None,
1145
- description=(
1146
- "`guided_json` is deprecated. "
1147
- "This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
1148
- "Please pass `json` to `structured_outputs` instead."
1149
- ),
1150
- )
1151
- guided_regex: str | None = Field(
1152
- default=None,
1153
- description=(
1154
- "`guided_regex` is deprecated. "
1155
- "This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
1156
- "Please pass `regex` to `structured_outputs` instead."
1157
- ),
1158
- )
1159
- guided_choice: list[str] | None = Field(
1160
- default=None,
1161
- description=(
1162
- "`guided_choice` is deprecated. "
1163
- "This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
1164
- "Please pass `choice` to `structured_outputs` instead."
1165
- ),
1166
- )
1167
- guided_grammar: str | None = Field(
1168
- default=None,
1169
- description=(
1170
- "`guided_grammar` is deprecated. "
1171
- "This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
1172
- "Please pass `grammar` to `structured_outputs` instead."
1173
- ),
1174
- )
1175
- structural_tag: str | None = Field(
1176
- default=None,
1177
- description=("If specified, the output will follow the structural tag schema."),
1178
- )
1179
- guided_decoding_backend: str | None = Field(
1180
- default=None,
1181
- description=(
1182
- "`guided_decoding_backend` is deprecated. "
1183
- "This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
1184
- "Please remove it from your request."
1185
- ),
1186
- )
1187
- guided_whitespace_pattern: str | None = Field(
1188
- default=None,
1189
- description=(
1190
- "`guided_whitespace_pattern` is deprecated. "
1191
- "This will be removed in v0.12.0 or v1.0.0, whichever is soonest. "
1192
- "Please pass `whitespace_pattern` to `structured_outputs` instead."
1193
- ),
1194
- )
1072
priority: int = Field(
1073
default=0,
1074
description=(
@@ -1336,35 +1213,31 @@ class CompletionRequest(OpenAIBaseModel):
1213
1214
echo_without_generation = self.echo and self.max_tokens == 0
1215
1339
- guided_json_object = None
1340
- if self.response_format is not None:
1341
- if self.response_format.type == "json_object":
1342
- guided_json_object = True
1343
- elif self.response_format.type == "json_schema":
1344
- json_schema = self.response_format.json_schema
1216
+ response_format = self.response_format
1217
+ if response_format is not None:
1218
+ # If structured outputs wasn't already enabled,
1219
+ # we must enable it for these features to work
1220
+ if self.structured_outputs is None:
1221
+ self.structured_outputs = StructuredOutputsParams()
1222
+
1223
+ # Set structured output params for response format
1224
+ if response_format.type == "json_object":
1225
+ self.structured_outputs.json_object = True
1226
+ elif response_format.type == "json_schema":
1227
+ json_schema = response_format.json_schema
1228
assert json_schema is not None
1346
- self.guided_json = json_schema.json_schema
1347
- elif self.response_format.type == "structural_tag":
1348
- structural_tag = self.response_format
1229
+ self.structured_outputs.json = json_schema.json_schema
1230
+ elif response_format.type == "structural_tag":
1231
+ structural_tag = response_format
1232
assert structural_tag is not None and isinstance(
1350
- structural_tag, StructuralTagResponseFormat
1233
+ structural_tag,
1234
+ (
1235
+ LegacyStructuralTagResponseFormat,
1236
+ StructuralTagResponseFormat,
1237
+ ),
1238
)
1239
s_tag_obj = structural_tag.model_dump(by_alias=True)
1353
- self.structural_tag = json.dumps(s_tag_obj)
1354
-
1355
- # Forward deprecated guided_* parameters to structured_outputs
1356
- if self.structured_outputs is None:
1357
- kwargs = dict[str, Any](
1358
- json=self.guided_json,
1359
- json_object=guided_json_object,
1360
- regex=self.guided_regex,
1361
- choice=self.guided_choice,
1362
- grammar=self.guided_grammar,
1363
- whitespace_pattern=self.guided_whitespace_pattern,
1364
- )
1365
- kwargs = {k: v for k, v in kwargs.items() if v is not None}
1366
- if len(kwargs) > 0:
1367
- self.structured_outputs = StructuredOutputsParams(**kwargs)
1240
+ self.structured_outputs.structural_tag = json.dumps(s_tag_obj)
1241
1242
extra_args: dict[str, Any] = self.vllm_xargs if self.vllm_xargs else {}
1243
if self.kv_transfer_params:
vllm/sampling_params.py
-38
@@ -3,7 +3,6 @@
3
"""Sampling parameters for text generation."""
4
5
import copy
6
-import warnings
6
from dataclasses import field
7
from enum import Enum, IntEnum
8
from functools import cached_property
@@ -100,19 +99,6 @@ class StructuredOutputsParams:
99
)
100
101
103
-@dataclass
104
-class GuidedDecodingParams(StructuredOutputsParams):
105
- def __post_init__(self):
106
- warnings.warn(
107
- "GuidedDecodingParams is deprecated. This will be removed in "
108
- "v0.12.0 or v1.0.0, which ever is soonest. Please use "
109
- "StructuredOutputsParams instead.",
110
- DeprecationWarning,
111
- stacklevel=2,
112
- )
113
- return super().__post_init__()
114
-
115
-
102
class RequestOutputKind(Enum):
103
# Return entire output so far in every RequestOutput
104
CUMULATIVE = 0
@@ -234,8 +220,6 @@ class SamplingParams(
220
# Fields used to construct logits processors
221
structured_outputs: StructuredOutputsParams | None = None
222
"""Parameters for configuring structured outputs."""
237
- guided_decoding: GuidedDecodingParams | None = None
238
- """Deprecated alias for structured_outputs."""
223
logit_bias: dict[int, float] | None = None
224
"""If provided, the engine will construct a logits processor that applies
225
these logit biases."""
@@ -283,7 +267,6 @@ class SamplingParams(
267
truncate_prompt_tokens: Annotated[int, msgspec.Meta(ge=-1)] | None = None,
268
output_kind: RequestOutputKind = RequestOutputKind.CUMULATIVE,
269
structured_outputs: StructuredOutputsParams | None = None,
286
- guided_decoding: GuidedDecodingParams | None = None,
270
logit_bias: dict[int, float] | dict[str, float] | None = None,
271
allowed_token_ids: list[int] | None = None,
272
extra_args: dict[str, Any] | None = None,
@@ -295,16 +278,6 @@ class SamplingParams(
278
int(token): min(100.0, max(-100.0, bias))
279
for token, bias in logit_bias.items()
280
}
298
- if guided_decoding is not None:
299
- warnings.warn(
300
- "guided_decoding is deprecated. This will be removed in "
301
- "v0.12.0 or v1.0.0, which ever is soonest. Please use "
302
- "structured_outputs instead.",
303
- DeprecationWarning,
304
- stacklevel=2,
305
- )
306
- structured_outputs = guided_decoding
307
- guided_decoding = None
281
282
return SamplingParams(
283
n=1 if n is None else n,
@@ -387,17 +360,6 @@ class SamplingParams(
360
# eos_token_id is added to this by the engine
361
self._all_stop_token_ids.update(self.stop_token_ids)
362
390
- if self.guided_decoding is not None:
391
- warnings.warn(
392
- "guided_decoding is deprecated. This will be removed in "
393
- "v0.12.0 or v1.0.0, which ever is soonest. Please use "
394
- "structured_outputs instead.",
395
- DeprecationWarning,
396
- stacklevel=2,
397
- )
398
- self.structured_outputs = self.guided_decoding
399
- self.guided_decoding = None
400
-
363
if self.skip_reading_prefix_cache is None:
364
# If prefix caching is enabled,
365
# the output of prompt logprobs may less than n_prompt_tokens,