From 40dcaf101b53ccafaeb11501f4d16fae742189d8 Mon Sep 17 00:00:00 2001 From: DarkLight1337 Date: Wed, 28 May 2025 03:46:22 +0000 Subject: [PATCH 1/4] [Deprecation] Disallow pos-args other than `model` when initializing `LLM` Signed-off-by: DarkLight1337 --- vllm/entrypoints/llm.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/vllm/entrypoints/llm.py b/vllm/entrypoints/llm.py index 59cc44eb0e18..b3f161ced064 100644 --- a/vllm/entrypoints/llm.py +++ b/vllm/entrypoints/llm.py @@ -45,8 +45,7 @@ from vllm.transformers_utils.tokenizer import (AnyTokenizer, MistralTokenizer, get_cached_tokenizer) from vllm.usage.usage_lib import UsageContext -from vllm.utils import (Counter, Device, deprecate_args, deprecate_kwargs, - is_list_of) +from vllm.utils import Counter, Device, deprecate_kwargs, is_list_of if TYPE_CHECKING: from vllm.v1.metrics.reader import Metric @@ -143,12 +142,6 @@ class LLM: DEPRECATE_LEGACY: ClassVar[bool] = True """A flag to toggle whether to deprecate the legacy generate/encode API.""" - DEPRECATE_INIT_POSARGS: ClassVar[bool] = True - """ - A flag to toggle whether to deprecate positional arguments in - [LLM.__init__][]. - """ - @classmethod @contextmanager def deprecate_legacy_api(cls): @@ -158,16 +151,10 @@ def deprecate_legacy_api(cls): cls.DEPRECATE_LEGACY = False - @deprecate_args( - start_index=2, # Ignore self and model - is_deprecated=lambda: LLM.DEPRECATE_INIT_POSARGS, - additional_message=( - "All positional arguments other than `model` will be " - "replaced with keyword arguments in an upcoming version."), - ) def __init__( self, model: str, + /, tokenizer: Optional[str] = None, tokenizer_mode: TokenizerMode = "auto", skip_tokenizer_init: bool = False, From 8a2af9a08539f9bb615fc9e3aeb31d0f7d7edf0b Mon Sep 17 00:00:00 2001 From: DarkLight1337 Date: Wed, 28 May 2025 03:56:00 +0000 Subject: [PATCH 2/4] Fix Signed-off-by: DarkLight1337 --- vllm/entrypoints/llm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vllm/entrypoints/llm.py b/vllm/entrypoints/llm.py index b3f161ced064..b1c844848102 100644 --- a/vllm/entrypoints/llm.py +++ b/vllm/entrypoints/llm.py @@ -154,7 +154,7 @@ def deprecate_legacy_api(cls): def __init__( self, model: str, - /, + *, tokenizer: Optional[str] = None, tokenizer_mode: TokenizerMode = "auto", skip_tokenizer_init: bool = False, From 5ccf60e771d3fb525ef486019cb4999edd3ffe14 Mon Sep 17 00:00:00 2001 From: DarkLight1337 Date: Wed, 28 May 2025 03:56:34 +0000 Subject: [PATCH 3/4] Update Signed-off-by: DarkLight1337 --- vllm/entrypoints/llm.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vllm/entrypoints/llm.py b/vllm/entrypoints/llm.py index b1c844848102..a176a74d0f37 100644 --- a/vllm/entrypoints/llm.py +++ b/vllm/entrypoints/llm.py @@ -155,6 +155,7 @@ def __init__( self, model: str, *, + task: TaskOption = "auto", tokenizer: Optional[str] = None, tokenizer_mode: TokenizerMode = "auto", skip_tokenizer_init: bool = False, @@ -176,8 +177,6 @@ def __init__( hf_token: Optional[Union[bool, str]] = None, hf_overrides: Optional[HfOverrides] = None, mm_processor_kwargs: Optional[dict[str, Any]] = None, - # After positional args are removed, move this right below `model` - task: TaskOption = "auto", override_pooler_config: Optional[PoolerConfig] = None, compilation_config: Optional[Union[int, dict[str, Any]]] = None, **kwargs, From 9261d18150dfeaaff24cd9ed1842a331aa93c2b2 Mon Sep 17 00:00:00 2001 From: DarkLight1337 Date: Wed, 28 May 2025 05:12:16 +0000 Subject: [PATCH 4/4] Remove test Signed-off-by: DarkLight1337 --- tests/entrypoints/llm/test_init.py | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 tests/entrypoints/llm/test_init.py diff --git a/tests/entrypoints/llm/test_init.py b/tests/entrypoints/llm/test_init.py deleted file mode 100644 index 925bf56a9340..000000000000 --- a/tests/entrypoints/llm/test_init.py +++ /dev/null @@ -1,24 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -import pytest - -from vllm import LLM - -from ...utils import error_on_warning - -MODEL_NAME = "facebook/opt-125m" - - -def test_pos_args_deprecated(): - with error_on_warning(DeprecationWarning): - LLM(model=MODEL_NAME, tokenizer=MODEL_NAME) - - with error_on_warning(DeprecationWarning): - LLM(MODEL_NAME, tokenizer=MODEL_NAME) - - with pytest.warns(DeprecationWarning, match="'tokenizer'"): - LLM(MODEL_NAME, MODEL_NAME) - - with pytest.warns(DeprecationWarning, - match="'tokenizer', 'tokenizer_mode'"): - LLM(MODEL_NAME, MODEL_NAME, "auto")