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 7, 12:45 UTC
[Deprecation] Deprecate code in 0.17 as scheduled (#35441)
Signed-off-by: yewentao256 <zhyanwentao@126.com> Signed-off-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com> Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
Wentao Ye committed
Feb 28, 2026 at 12:32 UTC
e113a301136402301381a86fb89d58da488ab55b
22 files changed
+31
-250
tests/entrypoints/pooling/embed/test_online.py
+6
-6
@@ -683,13 +683,13 @@ async def test_params_not_supported(
683
684
@pytest.mark.asyncio
685
@pytest.mark.parametrize("model_name", [MODEL_NAME])
686
-async def test_normalize(server: RemoteOpenAIServer, model_name: str):
687
- async def get_outputs(normalize):
686
+async def test_use_activation(server: RemoteOpenAIServer, model_name: str):
687
+ async def get_outputs(use_activation):
688
request_args = {
689
"model": MODEL_NAME,
690
"input": input_text,
691
"encoding_format": "float",
692
- "normalize": normalize,
692
+ "use_activation": use_activation,
693
}
694
695
response = requests.post(server.url_for("v1/embeddings"), json=request_args)
@@ -697,9 +697,9 @@ async def test_normalize(server: RemoteOpenAIServer, model_name: str):
697
698
return torch.tensor([x["embedding"] for x in outputs["data"]])
699
700
- default = await get_outputs(normalize=None)
701
- w_normal = await get_outputs(normalize=True)
702
- wo_normal = await get_outputs(normalize=False)
700
+ default = await get_outputs(use_activation=None)
701
+ w_normal = await get_outputs(use_activation=True)
702
+ wo_normal = await get_outputs(use_activation=False)
703
704
assert torch.allclose(default, w_normal, atol=1e-2), "Default should use normal."
705
assert not torch.allclose(w_normal, wo_normal, atol=1e-2), (
vllm/entrypoints/grpc_server.py
+12
-3
@@ -101,11 +101,15 @@ class VllmEngineServicer(vllm_engine_pb2_grpc.VllmEngineServicer):
101
sampling_params = self._sampling_params_from_proto(
102
request.sampling_params, stream=request.stream
103
)
104
+ tokenization_kwargs = self._tokenization_kwargs_from_proto(
105
+ request.sampling_params
106
+ )
107
108
async for output in self.async_llm.generate(
109
prompt=prompt,
110
sampling_params=sampling_params,
111
request_id=request_id,
112
+ tokenization_kwargs=tokenization_kwargs,
113
):
114
# Convert vLLM output to protobuf
115
# For streaming, always send chunks
@@ -308,9 +312,6 @@ class VllmEngineServicer(vllm_engine_pb2_grpc.VllmEngineServicer):
312
seed=params.seed if params.HasField("seed") else None,
313
include_stop_str_in_output=params.include_stop_str_in_output,
314
logit_bias=dict(params.logit_bias) if params.logit_bias else None,
311
- truncate_prompt_tokens=params.truncate_prompt_tokens
312
- if params.HasField("truncate_prompt_tokens")
313
- else None,
315
structured_outputs=structured_outputs,
316
# detokenize must be True if stop strings are used
317
detokenize=bool(stop),
@@ -319,6 +320,14 @@ class VllmEngineServicer(vllm_engine_pb2_grpc.VllmEngineServicer):
320
else RequestOutputKind.FINAL_ONLY,
321
)
322
323
+ @staticmethod
324
+ def _tokenization_kwargs_from_proto(
325
+ params: vllm_engine_pb2.SamplingParams,
326
+ ) -> dict[str, int] | None:
327
+ if params.HasField("truncate_prompt_tokens"):
328
+ return {"truncate_prompt_tokens": params.truncate_prompt_tokens}
329
+ return None
330
+
331
@staticmethod
332
def _chunk_response(output: RequestOutput) -> vllm_engine_pb2.GenerateResponse:
333
"""
vllm/entrypoints/llm.py
+10
-54
@@ -2,7 +2,6 @@
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4
import itertools
5
-import warnings
5
from collections.abc import Callable, Iterable, Sequence
6
from typing import TYPE_CHECKING, Any
7
@@ -1030,7 +1029,6 @@ class LLM:
1029
prompts: PromptType | Sequence[PromptType] | DataPrompt,
1030
pooling_params: PoolingParams | Sequence[PoolingParams] | None = None,
1031
*,
1033
- truncate_prompt_tokens: int | None = None,
1032
use_tqdm: bool | Callable[..., tqdm] = True,
1033
lora_request: list[LoRARequest] | LoRARequest | None = None,
1034
pooling_task: PoolingTask | None = None,
@@ -1088,20 +1086,6 @@ class LLM:
1086
"pooling model."
1087
)
1088
1091
- if truncate_prompt_tokens is not None:
1092
- warnings.warn(
1093
- "The `truncate_prompt_tokens` parameter in `LLM.encode()` "
1094
- "is deprecated and will be removed in v0.16. "
1095
- "Please pass it via `tokenization_kwargs` instead.",
1096
- DeprecationWarning,
1097
- stacklevel=2,
1098
- )
1099
-
1100
- tokenization_kwargs = merge_kwargs(
1101
- tokenization_kwargs,
1102
- dict(truncate_prompt_tokens=truncate_prompt_tokens),
1103
- )
1104
-
1089
if use_io_processor := (isinstance(prompts, dict) and "data" in prompts):
1090
if self.io_processor is None:
1091
raise ValueError(
@@ -1185,7 +1169,6 @@ class LLM:
1169
self,
1170
prompts: PromptType | Sequence[PromptType],
1171
*,
1188
- truncate_prompt_tokens: int | None = None,
1172
use_tqdm: bool | Callable[..., tqdm] = True,
1173
pooling_params: PoolingParams | Sequence[PoolingParams] | None = None,
1174
lora_request: list[LoRARequest] | LoRARequest | None = None,
@@ -1221,12 +1204,6 @@ class LLM:
1204
"Try converting the model using `--convert embed`."
1205
)
1206
1224
- if truncate_prompt_tokens is not None:
1225
- tokenization_kwargs = merge_kwargs(
1226
- tokenization_kwargs,
1227
- dict(truncate_prompt_tokens=truncate_prompt_tokens),
1228
- )
1229
-
1207
items = self.encode(
1208
prompts,
1209
use_tqdm=use_tqdm,
@@ -1294,7 +1271,6 @@ class LLM:
1271
/,
1272
*,
1273
pooling_params: PoolingParams | Sequence[PoolingParams] | None = None,
1297
- truncate_prompt_tokens: int | None = None,
1274
use_tqdm: bool | Callable[..., tqdm] = True,
1275
lora_request: list[LoRARequest] | LoRARequest | None = None,
1276
tokenization_kwargs: dict[str, Any] | None = None,
@@ -1319,13 +1295,11 @@ class LLM:
1295
A list of `PoolingRequestOutput` objects containing the
1296
pooled hidden states in the same order as the input prompts.
1297
"""
1322
-
1298
return self.encode(
1299
prompts,
1300
use_tqdm=use_tqdm,
1301
lora_request=lora_request,
1302
pooling_params=pooling_params,
1328
- truncate_prompt_tokens=truncate_prompt_tokens,
1303
pooling_task="token_classify",
1304
tokenization_kwargs=tokenization_kwargs,
1305
)
@@ -1771,23 +1745,15 @@ class LLM:
1745
seq_prompts = prompt_to_seq(prompts)
1746
seq_params = self._params_to_seq(params, len(seq_prompts))
1747
seq_lora_requests = self._lora_request_to_seq(lora_request, len(seq_prompts))
1774
- seq_tok_kwargs = [
1775
- merge_kwargs(
1776
- tokenization_kwargs,
1777
- dict(truncate_prompt_tokens=param.truncate_prompt_tokens),
1778
- )
1779
- for param in seq_params
1780
- ]
1748
seq_priority = self._priority_to_seq(priority, len(prompts))
1749
1750
return self._render_and_add_requests(
1751
prompts=(
1785
- self._preprocess_cmpl_one(prompt, tok_kwargs)
1786
- for prompt, tok_kwargs in zip(
1787
- maybe_tqdm(
1788
- seq_prompts, use_tqdm=use_tqdm, desc="Rendering prompts"
1789
- ),
1790
- seq_tok_kwargs,
1752
+ self._preprocess_cmpl_one(prompt, tokenization_kwargs)
1753
+ for prompt in maybe_tqdm(
1754
+ seq_prompts,
1755
+ use_tqdm=use_tqdm,
1756
+ desc="Rendering prompts",
1757
)
1758
),
1759
params=seq_params,
@@ -1841,13 +1807,6 @@ class LLM:
1807
seq_convs = conversation_to_seq(messages)
1808
seq_params = self._params_to_seq(params, len(seq_convs))
1809
seq_lora_requests = self._lora_request_to_seq(lora_request, len(seq_convs))
1844
- seq_tok_kwargs = [
1845
- merge_kwargs(
1846
- tokenization_kwargs,
1847
- dict(truncate_prompt_tokens=param.truncate_prompt_tokens),
1848
- )
1849
- for param in seq_params
1850
- ]
1810
1811
return self._render_and_run_requests(
1812
prompts=(
@@ -1859,16 +1818,13 @@ class LLM:
1818
add_generation_prompt=add_generation_prompt,
1819
continue_final_message=continue_final_message,
1820
tools=tools,
1862
- tokenization_kwargs=tok_kwargs,
1821
+ tokenization_kwargs=tokenization_kwargs,
1822
mm_processor_kwargs=mm_processor_kwargs,
1823
)
1865
- for conversation, tok_kwargs in zip(
1866
- maybe_tqdm(
1867
- seq_convs,
1868
- use_tqdm=use_tqdm,
1869
- desc="Rendering conversations",
1870
- ),
1871
- seq_tok_kwargs,
1824
+ for conversation in maybe_tqdm(
1825
+ seq_convs,
1826
+ use_tqdm=use_tqdm,
1827
+ desc="Rendering conversations",
1828
)
1829
),
1830
params=seq_params,
vllm/entrypoints/openai/chat_completion/protocol.py
-1
@@ -490,7 +490,6 @@ class ChatCompletionRequest(OpenAIBaseModel):
490
skip_special_tokens=self.skip_special_tokens,
491
spaces_between_special_tokens=self.spaces_between_special_tokens,
492
include_stop_str_in_output=self.include_stop_str_in_output,
493
- truncate_prompt_tokens=self.truncate_prompt_tokens,
493
output_kind=RequestOutputKind.DELTA
494
if self.stream
495
else RequestOutputKind.FINAL_ONLY,
vllm/entrypoints/openai/completion/protocol.py
-1
@@ -302,7 +302,6 @@ class CompletionRequest(OpenAIBaseModel):
302
skip_special_tokens=self.skip_special_tokens,
303
spaces_between_special_tokens=self.spaces_between_special_tokens,
304
include_stop_str_in_output=self.include_stop_str_in_output,
305
- truncate_prompt_tokens=self.truncate_prompt_tokens,
305
output_kind=RequestOutputKind.DELTA
306
if self.stream
307
else RequestOutputKind.FINAL_ONLY,
vllm/entrypoints/openai/translations/__init__.py
deleted
-12
@@ -1,12 +0,0 @@
1
-# SPDX-License-Identifier: Apache-2.0
2
-# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
-
4
-import warnings
5
-
6
-warnings.warn(
7
- "The 'vllm.entrypoints.openai.translations' module has been renamed to "
8
- "'vllm.entrypoints.openai.speech_to_text'. Please update your imports. "
9
- "This backward-compatible alias will be removed in version 0.17+.",
10
- DeprecationWarning,
11
- stacklevel=2,
12
-)
vllm/entrypoints/openai/translations/api_router.py
deleted
-14
@@ -1,14 +0,0 @@
1
-# SPDX-License-Identifier: Apache-2.0
2
-# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
-
4
-import warnings
5
-
6
-warnings.warn(
7
- "'vllm.entrypoints.openai.translations.api_router' has been moved to "
8
- "'vllm.entrypoints.openai.speech_to_text.api_router'. Please update your "
9
- "imports. This backward-compatible alias will be removed in version 0.17+.",
10
- DeprecationWarning,
11
- stacklevel=2,
12
-)
13
-
14
-from vllm.entrypoints.openai.speech_to_text.api_router import * # noqa: F401,F403,E402
vllm/entrypoints/openai/translations/protocol.py
deleted
-14
@@ -1,14 +0,0 @@
1
-# SPDX-License-Identifier: Apache-2.0
2
-# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
-
4
-import warnings
5
-
6
-warnings.warn(
7
- "'vllm.entrypoints.openai.translations.protocol' has been moved to "
8
- "'vllm.entrypoints.openai.speech_to_text.protocol'. Please update your "
9
- "imports. This backward-compatible alias will be removed in version 0.17+.",
10
- DeprecationWarning,
11
- stacklevel=2,
12
-)
13
-
14
-from vllm.entrypoints.openai.speech_to_text.protocol import * # noqa: F401,F403,E402
vllm/entrypoints/openai/translations/serving.py
deleted
-14
@@ -1,14 +0,0 @@
1
-# SPDX-License-Identifier: Apache-2.0
2
-# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
-
4
-import warnings
5
-
6
-warnings.warn(
7
- "'vllm.entrypoints.openai.translations.serving' has been moved to "
8
- "'vllm.entrypoints.openai.speech_to_text.serving'. Please update your "
9
- "imports. This backward-compatible alias will be removed in version 0.17+.",
10
- DeprecationWarning,
11
- stacklevel=2,
12
-)
13
-
14
-from vllm.entrypoints.openai.speech_to_text.serving import * # noqa: F401,F403,E402
vllm/entrypoints/openai/translations/speech_to_text.py
deleted
-15
@@ -1,15 +0,0 @@
1
-# SPDX-License-Identifier: Apache-2.0
2
-# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
-
4
-import warnings
5
-
6
-warnings.warn(
7
- "'vllm.entrypoints.openai.translations.speech_to_text' has been moved to "
8
- "'vllm.entrypoints.openai.speech_to_text.speech_to_text'. Please update "
9
- "your imports. This backward-compatible alias will be removed in version "
10
- "0.17+.",
11
- DeprecationWarning,
12
- stacklevel=2,
13
-)
14
-
15
-from vllm.entrypoints.openai.speech_to_text.speech_to_text import * # noqa: F401,F403,E402
vllm/entrypoints/pooling/base/protocol.py
-4
@@ -190,10 +190,6 @@ class EmbedRequestMixin(EncodingRequestMixin):
190
description="Whether to use activation for the pooler outputs. "
191
"`None` uses the pooler's default, which is `True` in most cases.",
192
)
193
- normalize: bool | None = Field(
194
- default=None,
195
- description="Deprecated; please pass `use_activation` instead",
196
- )
193
# --8<-- [end:embed-extra-params]
194
195
vllm/entrypoints/pooling/classify/protocol.py
-2
@@ -40,7 +40,6 @@ class ClassificationCompletionRequest(
40
def to_pooling_params(self):
41
return PoolingParams(
42
task="classify",
43
- truncate_prompt_tokens=self.truncate_prompt_tokens,
43
use_activation=self.use_activation,
44
)
45
@@ -63,7 +62,6 @@ class ClassificationChatRequest(
62
def to_pooling_params(self):
63
return PoolingParams(
64
task="classify",
66
- truncate_prompt_tokens=self.truncate_prompt_tokens,
65
use_activation=self.use_activation,
66
)
67
vllm/entrypoints/pooling/embed/protocol.py
-19
@@ -14,12 +14,9 @@ from vllm.entrypoints.pooling.base.protocol import (
14
EmbedRequestMixin,
15
PoolingBasicRequestMixin,
16
)
17
-from vllm.logger import init_logger
17
from vllm.renderers import TokenizeParams
18
from vllm.utils import random_uuid
19
21
-logger = init_logger(__name__)
22
-
20
21
def _get_max_total_output_tokens(
22
model_config: ModelConfig,
@@ -60,18 +57,10 @@ class EmbeddingCompletionRequest(
57
)
58
59
def to_pooling_params(self):
63
- if self.normalize is not None:
64
- logger.warning_once(
65
- "`normalize` is deprecated and will be removed in v0.17. "
66
- "Please pass `use_activation` instead."
67
- )
68
- self.use_activation = self.normalize
69
-
60
return PoolingParams(
61
task="embed",
62
dimensions=self.dimensions,
63
use_activation=self.use_activation,
74
- truncate_prompt_tokens=self.truncate_prompt_tokens,
64
)
65
66
@@ -97,18 +86,10 @@ class EmbeddingChatRequest(
86
)
87
88
def to_pooling_params(self):
100
- if self.normalize is not None:
101
- logger.warning_once(
102
- "`normalize` is deprecated and will be removed in v0.17. "
103
- "Please pass `use_activation` instead."
104
- )
105
- self.use_activation = self.normalize
106
-
89
return PoolingParams(
90
task="embed",
91
dimensions=self.dimensions,
92
use_activation=self.use_activation,
111
- truncate_prompt_tokens=self.truncate_prompt_tokens,
93
)
94
95
vllm/entrypoints/pooling/pooling/protocol.py
-19
@@ -16,13 +16,10 @@ from vllm.entrypoints.pooling.base.protocol import (
16
EncodingRequestMixin,
17
PoolingBasicRequestMixin,
18
)
19
-from vllm.logger import init_logger
19
from vllm.renderers import TokenizeParams
20
from vllm.tasks import PoolingTask
21
from vllm.utils import random_uuid
22
24
-logger = init_logger(__name__)
25
-
23
24
class PoolingCompletionRequest(
25
PoolingBasicRequestMixin,
@@ -45,16 +42,8 @@ class PoolingCompletionRequest(
42
)
43
44
def to_pooling_params(self):
48
- if self.normalize is not None:
49
- logger.warning_once(
50
- "`normalize` is deprecated and will be removed in v0.17. "
51
- "Please pass `use_activation` instead."
52
- )
53
- self.use_activation = self.normalize
54
-
45
return PoolingParams(
46
task=self.task,
57
- truncate_prompt_tokens=self.truncate_prompt_tokens,
47
use_activation=self.use_activation,
48
dimensions=self.dimensions,
49
)
@@ -78,16 +67,8 @@ class PoolingChatRequest(
67
)
68
69
def to_pooling_params(self):
81
- if self.normalize is not None:
82
- logger.warning_once(
83
- "`normalize` is deprecated and will be removed in v0.17. "
84
- "Please pass `use_activation` instead."
85
- )
86
- self.use_activation = self.normalize
87
-
70
return PoolingParams(
71
task=self.task,
90
- truncate_prompt_tokens=self.truncate_prompt_tokens,
72
use_activation=self.use_activation,
73
dimensions=self.dimensions,
74
)
vllm/entrypoints/pooling/score/protocol.py
-2
@@ -37,7 +37,6 @@ class ScoreRequestMixin(PoolingBasicRequestMixin, ClassifyRequestMixin):
37
def to_pooling_params(self, task: PoolingTask = "score"):
38
return PoolingParams(
39
task=task,
40
- truncate_prompt_tokens=self.truncate_prompt_tokens,
40
use_activation=self.use_activation,
41
)
42
@@ -113,7 +112,6 @@ class RerankRequest(PoolingBasicRequestMixin, ClassifyRequestMixin):
112
def to_pooling_params(self, task: PoolingTask = "score"):
113
return PoolingParams(
114
task=task,
116
- truncate_prompt_tokens=self.truncate_prompt_tokens,
115
use_activation=self.use_activation,
116
)
117
vllm/model_executor/layers/mamba/mamba_utils.py
-3
@@ -289,9 +289,6 @@ def get_temporal_copy_spec(
289
)
290
291
292
-get_full_copy_spec = get_temporal_copy_spec
293
-
294
-
292
class MambaStateCopyFuncCalculator:
293
@classmethod
294
def linear_attention_state_copy_func(cls):
vllm/model_executor/models/ovis2_5.py
-3
@@ -43,12 +43,9 @@ from vllm.utils.tensor_schema import TensorSchema, TensorShape
43
from .interfaces import MultiModalEmbeddings, SupportsMultiModal, SupportsPP
44
45
IMAGE_TOKEN = "<image>"
46
-IMAGE_PLACEHOLDER_ID = 151669
46
VIDEO_TOKEN = "<video>"
48
-VIDEO_PLACEHOLDER_ID = 151670
47
INDICATOR_IDS = [151672, 151673, 151674, 151675]
48
IMAGE_PAD_TOKEN_ID = 151655
51
-THINK_END_TOKEN_ID = 151668
49
50
51
class Ovis2_5ImagePatchInputs(TensorSchema):
vllm/multimodal/processing/processor.py
+1
-11
@@ -17,7 +17,7 @@ from typing import (
17
18
import regex as re
19
import torch
20
-from typing_extensions import TypeVar, assert_never, deprecated
20
+from typing_extensions import TypeVar, assert_never
21
22
from vllm.logger import init_logger
23
from vllm.tokenizers import TokenizerLike
@@ -996,16 +996,6 @@ class BaseMultiModalProcessor(ABC, Generic[_I]):
996
997
self.data_parser = self.info.get_data_parser()
998
999
- @property
1000
- @deprecated("Will be removed in v0.17. Use `info.supported_mm_limits` instead.")
1001
- def supported_mm_limits(self):
1002
- return self.info.supported_mm_limits
1003
-
1004
- @property
1005
- @deprecated("Will be removed in v0.17. Use `info.allowed_mm_limits` instead.")
1006
- def allowed_mm_limits(self):
1007
- return self.info.allowed_mm_limits
1008
-
999
def __call__(
1000
self,
1001
prompt: str,
vllm/multimodal/utils.py
-18
@@ -2,7 +2,6 @@
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4
import mimetypes
5
-import warnings
5
from collections import defaultdict
6
from collections.abc import Generator, Sequence
7
from itertools import groupby
@@ -30,23 +29,6 @@ else:
29
torch = LazyLoader("torch", globals(), "torch")
30
31
33
-def __getattr__(name: str):
34
- if name == "MEDIA_CONNECTOR_REGISTRY":
35
- from .media import MEDIA_CONNECTOR_REGISTRY
36
-
37
- warnings.warn(
38
- "`vllm.multimodal.utils.MEDIA_CONNECTOR_REGISTRY` "
39
- "has been moved to `vllm.multimodal.media.MEDIA_CONNECTOR_REGISTRY`. "
40
- "The old name will be removed in v0.17.",
41
- DeprecationWarning,
42
- stacklevel=2,
43
- )
44
-
45
- return MEDIA_CONNECTOR_REGISTRY
46
-
47
- raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
48
-
49
-
32
def encode_audio_base64(
33
audio: np.ndarray,
34
sampling_rate: int,
vllm/pooling_params.py
+1
-7
@@ -2,7 +2,7 @@
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4
from copy import deepcopy
5
-from typing import Annotated, Any
5
+from typing import Any
6
7
import msgspec
8
@@ -19,10 +19,6 @@ class PoolingParams(
19
"""API parameters for pooling models.
20
21
Attributes:
22
- truncate_prompt_tokens: Controls prompt truncation.
23
- Set to -1 to use the model's default truncation size.
24
- Set to k to keep only the last k tokens (left truncation).
25
- Set to None to disable truncation.
22
use_activation: Whether to apply activation function to the pooler outputs.
23
`None` uses the pooler's default, which is `True` in most cases.
24
dimensions: Reduce the dimensions of embeddings
@@ -30,7 +26,6 @@ class PoolingParams(
26
"""
27
28
# --8<-- [start:common-pooling-params]
33
- truncate_prompt_tokens: Annotated[int, msgspec.Meta(ge=-1)] | None = None
29
use_activation: bool | None = None
30
# --8<-- [end:common-pooling-params]
31
@@ -198,7 +193,6 @@ class PoolingParams(
193
f"returned_token_ids={self.returned_token_ids}, "
194
f"requires_token_ids={self.requires_token_ids}, "
195
f"skip_reading_prefix_cache={self.skip_reading_prefix_cache}, "
201
- f"truncate_prompt_tokens={self.truncate_prompt_tokens}, "
196
f"extra_kwargs={self.extra_kwargs})"
197
)
198
vllm/sampling_params.py
+1
-17
@@ -7,7 +7,7 @@ import json as json_mod
7
from dataclasses import field
8
from enum import Enum, IntEnum
9
from functools import cached_property
10
-from typing import Annotated, Any
10
+from typing import Any
11
12
import msgspec
13
from pydantic.dataclasses import dataclass
@@ -209,10 +209,6 @@ class SamplingParams(
209
"""Whether to add spaces between special tokens in the output."""
210
include_stop_str_in_output: bool = False
211
"""Whether to include the stop strings in output text."""
212
- truncate_prompt_tokens: Annotated[int, msgspec.Meta(ge=-1)] | None = None
213
- """If set to -1, will use the truncation size supported by the model. If
214
- set to an integer k, will use only the last k tokens from the prompt
215
- (i.e., left truncation). If set to `None`, truncation is disabled."""
212
output_kind: RequestOutputKind = RequestOutputKind.CUMULATIVE
213
skip_clone: bool = False
214
"""Internal flag indicating that this SamplingParams instance is safe to
@@ -273,7 +269,6 @@ class SamplingParams(
269
detokenize: bool = True,
270
skip_special_tokens: bool = True,
271
spaces_between_special_tokens: bool = True,
276
- truncate_prompt_tokens: Annotated[int, msgspec.Meta(ge=-1)] | None = None,
272
output_kind: RequestOutputKind = RequestOutputKind.CUMULATIVE,
273
structured_outputs: StructuredOutputsParams | None = None,
274
logit_bias: dict[int, float] | dict[str, float] | None = None,
@@ -313,7 +308,6 @@ class SamplingParams(
308
detokenize=detokenize,
309
skip_special_tokens=skip_special_tokens,
310
spaces_between_special_tokens=spaces_between_special_tokens,
316
- truncate_prompt_tokens=truncate_prompt_tokens,
311
output_kind=output_kind,
312
structured_outputs=structured_outputs,
313
logit_bias=logit_bias,
@@ -449,15 +443,6 @@ class SamplingParams(
443
parameter="prompt_logprobs",
444
value=self.prompt_logprobs,
445
)
452
- if self.truncate_prompt_tokens is not None and (
453
- self.truncate_prompt_tokens == 0 or self.truncate_prompt_tokens < -1
454
- ):
455
- raise VLLMValidationError(
456
- f"truncate_prompt_tokens must be an integer >= 1 or -1, "
457
- f"got {self.truncate_prompt_tokens}",
458
- parameter="truncate_prompt_tokens",
459
- value=self.truncate_prompt_tokens,
460
- )
446
assert isinstance(self.stop_token_ids, list)
447
if not all(isinstance(st_id, int) for st_id in self.stop_token_ids):
448
raise ValueError(
@@ -835,7 +820,6 @@ class SamplingParams(
820
f"skip_special_tokens={self.skip_special_tokens}, "
821
"spaces_between_special_tokens="
822
f"{self.spaces_between_special_tokens}, "
838
- f"truncate_prompt_tokens={self.truncate_prompt_tokens}, "
823
f"structured_outputs={self.structured_outputs}, "
824
f"extra_args={self.extra_args})"
825
)
vllm/v1/engine/input_processor.py
-11
@@ -2,7 +2,6 @@
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4
import time
5
-import warnings
5
from collections.abc import Mapping
6
from typing import Any, Literal
7
@@ -114,16 +113,6 @@ class InputProcessor:
113
supported_tasks: tuple[SupportedTask, ...],
114
) -> None:
115
"""Raise `ValueError` if SamplingParams or PoolingParams is not valid."""
117
- if params.truncate_prompt_tokens is not None:
118
- params_type = type(params).__name__
119
- warnings.warn(
120
- f"The `truncate_prompt_tokens` parameter in `{params_type}` "
121
- "is deprecated and will be removed in v0.17. "
122
- "Please pass it via `tokenization_kwargs` instead.",
123
- DeprecationWarning,
124
- stacklevel=2,
125
- )
126
-
116
if isinstance(params, SamplingParams):
117
supported_generation_tasks = [
118
task for task in supported_tasks if task in GENERATION_TASKS