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 15, 11:00 UTC
[Feat] Add deprecated=True to CLI args (#17426)
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
Aaron Pham committed
May 6, 2025 at 11:11 UTC
175bda67a1d930c46076562e6e7dd71fab249478
2 files changed
+77
-2
vllm/engine/arg_utils.py
+1
@@ -531,6 +531,7 @@ class EngineArgs:
531
guided_decoding_group.add_argument(
532
"--enable-reasoning",
533
action=argparse.BooleanOptionalAction,
534
+ deprecated=True,
535
help="[DEPRECATED] The `--enable-reasoning` flag is deprecated as "
536
"of v0.8.6. Use `--reasoning-parser` to specify the reasoning "
537
"parser backend insteadThis flag (`--enable-reasoning`) will be "
vllm/utils.py
+76
-2
@@ -33,7 +33,7 @@ import uuid
33
import warnings
34
import weakref
35
from argparse import (Action, ArgumentDefaultsHelpFormatter, ArgumentParser,
36
- ArgumentTypeError)
36
+ ArgumentTypeError, _ArgumentGroup)
37
from asyncio import FIRST_COMPLETED, AbstractEventLoop, Task
38
from collections import UserDict, defaultdict
39
from collections.abc import (AsyncGenerator, Awaitable, Generator, Hashable,
@@ -41,6 +41,7 @@ from collections.abc import (AsyncGenerator, Awaitable, Generator, Hashable,
41
from concurrent.futures.process import ProcessPoolExecutor
42
from dataclasses import dataclass, field
43
from functools import cache, lru_cache, partial, wraps
44
+from gettext import gettext as _gettext
45
from types import MappingProxyType
46
from typing import (TYPE_CHECKING, Any, Callable, Generic, Literal, NamedTuple,
47
Optional, Sequence, Tuple, Type, TypeVar, Union, cast,
@@ -70,6 +71,8 @@ import vllm.triton_utils # noqa: F401
71
from vllm.logger import enable_trace_function_call, init_logger
72
73
if TYPE_CHECKING:
74
+ from argparse import Namespace
75
+
76
from vllm.config import ModelConfig, VllmConfig
77
78
logger = init_logger(__name__)
@@ -1323,16 +1326,78 @@ class SortedHelpFormatter(ArgumentDefaultsHelpFormatter):
1326
super().add_arguments(actions)
1327
1328
1329
+class _FlexibleArgumentGroup(_ArgumentGroup):
1330
+
1331
+ def __init__(self, parser: FlexibleArgumentParser, *args, **kwargs):
1332
+ self._parser = parser
1333
+ super().__init__(*args, **kwargs)
1334
+
1335
+ def add_argument(self, *args: Any, **kwargs: Any):
1336
+ if sys.version_info < (3, 13):
1337
+ deprecated = kwargs.pop('deprecated', False)
1338
+ action = super().add_argument(*args, **kwargs)
1339
+ object.__setattr__(action, 'deprecated', deprecated)
1340
+ if deprecated and action.dest not in \
1341
+ self._parser.__class__._deprecated:
1342
+ self._parser._deprecated.add(action)
1343
+ return action
1344
+
1345
+ # python>3.13
1346
+ return super().add_argument(*args, **kwargs)
1347
+
1348
+
1349
class FlexibleArgumentParser(ArgumentParser):
1350
"""ArgumentParser that allows both underscore and dash in names."""
1351
1352
+ _deprecated: set[Action] = set()
1353
+ _seen: set[str] = set()
1354
+
1355
def __init__(self, *args, **kwargs):
1356
# Set the default 'formatter_class' to SortedHelpFormatter
1357
if 'formatter_class' not in kwargs:
1358
kwargs['formatter_class'] = SortedHelpFormatter
1359
super().__init__(*args, **kwargs)
1360
1335
- def parse_args(self, args=None, namespace=None):
1361
+ if sys.version_info < (3, 13):
1362
+
1363
+ def parse_known_args( # type: ignore[override]
1364
+ self,
1365
+ args: Sequence[str] | None = None,
1366
+ namespace: Namespace | None = None,
1367
+ ) -> tuple[Namespace | None, list[str]]:
1368
+ namespace, args = super().parse_known_args(args, namespace)
1369
+ for action in FlexibleArgumentParser._deprecated:
1370
+ if action.dest not in FlexibleArgumentParser._seen and getattr(
1371
+ namespace, action.dest,
1372
+ None) != action.default: # noqa: E501
1373
+ self._warning(
1374
+ _gettext("argument '%(argument_name)s' is deprecated")
1375
+ % {'argument_name': action.dest})
1376
+ FlexibleArgumentParser._seen.add(action.dest)
1377
+ return namespace, args
1378
+
1379
+ def add_argument(self, *args: Any, **kwargs: Any):
1380
+ # add a deprecated=True compatibility
1381
+ # for python < 3.13
1382
+ deprecated = kwargs.pop('deprecated', False)
1383
+ action = super().add_argument(*args, **kwargs)
1384
+ object.__setattr__(action, 'deprecated', deprecated)
1385
+ if deprecated and \
1386
+ action not in FlexibleArgumentParser._deprecated:
1387
+ self._deprecated.add(action)
1388
+
1389
+ return action
1390
+
1391
+ def _warning(self, message: str):
1392
+ self._print_message(
1393
+ _gettext('warning: %(message)s\n') % {'message': message},
1394
+ sys.stderr)
1395
+
1396
+ def parse_args( # type: ignore[override]
1397
+ self,
1398
+ args: list[str] | None = None,
1399
+ namespace: Namespace | None = None,
1400
+ ):
1401
if args is None:
1402
args = sys.argv[1:]
1403
@@ -1503,6 +1568,15 @@ class FlexibleArgumentParser(ArgumentParser):
1568
1569
return processed_args
1570
1571
+ def add_argument_group(
1572
+ self,
1573
+ *args: Any,
1574
+ **kwargs: Any,
1575
+ ) -> _FlexibleArgumentGroup:
1576
+ group = _FlexibleArgumentGroup(self, self, *args, **kwargs)
1577
+ self._action_groups.append(group)
1578
+ return group
1579
+
1580
1581
async def _run_task_with_lock(task: Callable, lock: asyncio.Lock, *args,
1582
**kwargs):