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, 03:30 UTC
[Frontend] improve vllm bench <bench_type> --help display (#20430)
Signed-off-by: reidliu41 <reid201711@gmail.com>
Reid committed
Jul 3, 2025 at 22:22 UTC
9854dc904039eb9f5d51aac88fbdaf23b96e1da9
4 files changed
+18
-6
vllm/entrypoints/cli/benchmark/main.py
+5
@@ -8,6 +8,8 @@ import typing
8
9
from vllm.entrypoints.cli.benchmark.base import BenchmarkSubcommandBase
10
from vllm.entrypoints.cli.types import CLISubcommand
11
+from vllm.entrypoints.utils import (VLLM_SUBCMD_PARSER_EPILOG,
12
+ show_filtered_argument_or_group_from_help)
13
14
if typing.TYPE_CHECKING:
15
from vllm.utils import FlexibleArgumentParser
@@ -45,6 +47,9 @@ class BenchmarkSubcommand(CLISubcommand):
47
)
48
cmd_subparser.set_defaults(dispatch_function=cmd_cls.cmd)
49
cmd_cls.add_cli_args(cmd_subparser)
50
+ show_filtered_argument_or_group_from_help(cmd_subparser,
51
+ ["bench", cmd_cls.name])
52
+ cmd_subparser.epilog = VLLM_SUBCMD_PARSER_EPILOG
53
return bench_parser
54
55
vllm/entrypoints/cli/run_batch.py
+1
-1
@@ -60,7 +60,7 @@ class RunBatchSubcommand(CLISubcommand):
60
)
61
run_batch_parser = make_arg_parser(run_batch_parser)
62
show_filtered_argument_or_group_from_help(run_batch_parser,
63
- "run-batch")
63
+ ["run-batch"])
64
run_batch_parser.epilog = VLLM_SUBCMD_PARSER_EPILOG
65
return run_batch_parser
66
vllm/entrypoints/cli/serve.py
+1
-1
@@ -97,7 +97,7 @@ class ServeSubcommand(CLISubcommand):
97
"https://docs.vllm.ai/en/latest/configuration/serve_args.html")
98
99
serve_parser = make_arg_parser(serve_parser)
100
- show_filtered_argument_or_group_from_help(serve_parser, "serve")
100
+ show_filtered_argument_or_group_from_help(serve_parser, ["serve"])
101
serve_parser.epilog = VLLM_SUBCMD_PARSER_EPILOG
102
return serve_parser
103
vllm/entrypoints/utils.py
+11
-4
@@ -1,6 +1,7 @@
1
# SPDX-License-Identifier: Apache-2.0
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4
+import argparse
5
import asyncio
6
import functools
7
import os
@@ -15,8 +16,8 @@ from vllm.logger import init_logger
16
logger = init_logger(__name__)
17
18
VLLM_SUBCMD_PARSER_EPILOG = (
18
- "Tip: Use `vllm [serve|run-batch] --help=<keyword>` "
19
- "to explore arguments from help.\n"
19
+ "Tip: Use `vllm [serve|run-batch|bench <bench_type>] "
20
+ "--help=<keyword>` to explore arguments from help.\n"
21
" - To view a argument group: --help=ModelConfig\n"
22
" - To view a single argument: --help=max-num-seqs\n"
23
" - To search by keyword: --help=max\n"
@@ -178,13 +179,19 @@ def _validate_truncation_size(
179
return truncate_prompt_tokens
180
181
181
-def show_filtered_argument_or_group_from_help(parser, subcommand_name):
182
+def show_filtered_argument_or_group_from_help(parser: argparse.ArgumentParser,
183
+ subcommand_name: list[str]):
184
import sys
185
186
# Only handle --help=<keyword> for the current subcommand.
187
# Since subparser_init() runs for all subcommands during CLI setup,
188
# we skip processing if the subcommand name is not in sys.argv.
187
- if subcommand_name not in sys.argv:
189
+ # sys.argv[0] is the program name. The subcommand follows.
190
+ # e.g., for `vllm bench latency`,
191
+ # sys.argv is `['vllm', 'bench', 'latency', ...]`
192
+ # and subcommand_name is "bench latency".
193
+ if len(sys.argv) <= len(subcommand_name) or sys.argv[
194
+ 1:1 + len(subcommand_name)] != subcommand_name:
195
return
196
197
for arg in sys.argv: