Skip to content

Commit 9854dc9

Browse files
authored
[Frontend] improve vllm bench <bench_type> --help display (#20430)
Signed-off-by: reidliu41 <reid201711@gmail.com>
1 parent ff5c60f commit 9854dc9

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

vllm/entrypoints/cli/benchmark/main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
from vllm.entrypoints.cli.benchmark.base import BenchmarkSubcommandBase
1010
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)
1113

1214
if typing.TYPE_CHECKING:
1315
from vllm.utils import FlexibleArgumentParser
@@ -45,6 +47,9 @@ def subparser_init(
4547
)
4648
cmd_subparser.set_defaults(dispatch_function=cmd_cls.cmd)
4749
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
4853
return bench_parser
4954

5055

vllm/entrypoints/cli/run_batch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def subparser_init(
6060
)
6161
run_batch_parser = make_arg_parser(run_batch_parser)
6262
show_filtered_argument_or_group_from_help(run_batch_parser,
63-
"run-batch")
63+
["run-batch"])
6464
run_batch_parser.epilog = VLLM_SUBCMD_PARSER_EPILOG
6565
return run_batch_parser
6666

vllm/entrypoints/cli/serve.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def subparser_init(
9797
"https://docs.vllm.ai/en/latest/configuration/serve_args.html")
9898

9999
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"])
101101
serve_parser.epilog = VLLM_SUBCMD_PARSER_EPILOG
102102
return serve_parser
103103

vllm/entrypoints/utils.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
33

4+
import argparse
45
import asyncio
56
import functools
67
import os
@@ -15,8 +16,8 @@
1516
logger = init_logger(__name__)
1617

1718
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"
2021
" - To view a argument group: --help=ModelConfig\n"
2122
" - To view a single argument: --help=max-num-seqs\n"
2223
" - To search by keyword: --help=max\n"
@@ -178,13 +179,19 @@ def _validate_truncation_size(
178179
return truncate_prompt_tokens
179180

180181

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]):
182184
import sys
183185

184186
# Only handle --help=<keyword> for the current subcommand.
185187
# Since subparser_init() runs for all subcommands during CLI setup,
186188
# 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:
188195
return
189196

190197
for arg in sys.argv:

0 commit comments

Comments
 (0)