Unverified Commit 9854dc90 authored by Reid's avatar Reid Committed by GitHub
Browse files

[Frontend] improve vllm bench <bench_type> --help display (#20430)


Signed-off-by: default avatarreidliu41 <reid201711@gmail.com>
parent ff5c60fa
...@@ -8,6 +8,8 @@ import typing ...@@ -8,6 +8,8 @@ import typing
from vllm.entrypoints.cli.benchmark.base import BenchmarkSubcommandBase from vllm.entrypoints.cli.benchmark.base import BenchmarkSubcommandBase
from vllm.entrypoints.cli.types import CLISubcommand from vllm.entrypoints.cli.types import CLISubcommand
from vllm.entrypoints.utils import (VLLM_SUBCMD_PARSER_EPILOG,
show_filtered_argument_or_group_from_help)
if typing.TYPE_CHECKING: if typing.TYPE_CHECKING:
from vllm.utils import FlexibleArgumentParser from vllm.utils import FlexibleArgumentParser
...@@ -45,6 +47,9 @@ class BenchmarkSubcommand(CLISubcommand): ...@@ -45,6 +47,9 @@ class BenchmarkSubcommand(CLISubcommand):
) )
cmd_subparser.set_defaults(dispatch_function=cmd_cls.cmd) cmd_subparser.set_defaults(dispatch_function=cmd_cls.cmd)
cmd_cls.add_cli_args(cmd_subparser) cmd_cls.add_cli_args(cmd_subparser)
show_filtered_argument_or_group_from_help(cmd_subparser,
["bench", cmd_cls.name])
cmd_subparser.epilog = VLLM_SUBCMD_PARSER_EPILOG
return bench_parser return bench_parser
......
...@@ -60,7 +60,7 @@ class RunBatchSubcommand(CLISubcommand): ...@@ -60,7 +60,7 @@ class RunBatchSubcommand(CLISubcommand):
) )
run_batch_parser = make_arg_parser(run_batch_parser) run_batch_parser = make_arg_parser(run_batch_parser)
show_filtered_argument_or_group_from_help(run_batch_parser, show_filtered_argument_or_group_from_help(run_batch_parser,
"run-batch") ["run-batch"])
run_batch_parser.epilog = VLLM_SUBCMD_PARSER_EPILOG run_batch_parser.epilog = VLLM_SUBCMD_PARSER_EPILOG
return run_batch_parser return run_batch_parser
......
...@@ -97,7 +97,7 @@ class ServeSubcommand(CLISubcommand): ...@@ -97,7 +97,7 @@ class ServeSubcommand(CLISubcommand):
"https://docs.vllm.ai/en/latest/configuration/serve_args.html") "https://docs.vllm.ai/en/latest/configuration/serve_args.html")
serve_parser = make_arg_parser(serve_parser) serve_parser = make_arg_parser(serve_parser)
show_filtered_argument_or_group_from_help(serve_parser, "serve") show_filtered_argument_or_group_from_help(serve_parser, ["serve"])
serve_parser.epilog = VLLM_SUBCMD_PARSER_EPILOG serve_parser.epilog = VLLM_SUBCMD_PARSER_EPILOG
return serve_parser return serve_parser
......
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import argparse
import asyncio import asyncio
import functools import functools
import os import os
...@@ -15,8 +16,8 @@ from vllm.logger import init_logger ...@@ -15,8 +16,8 @@ from vllm.logger import init_logger
logger = init_logger(__name__) logger = init_logger(__name__)
VLLM_SUBCMD_PARSER_EPILOG = ( VLLM_SUBCMD_PARSER_EPILOG = (
"Tip: Use `vllm [serve|run-batch] --help=<keyword>` " "Tip: Use `vllm [serve|run-batch|bench <bench_type>] "
"to explore arguments from help.\n" "--help=<keyword>` to explore arguments from help.\n"
" - To view a argument group: --help=ModelConfig\n" " - To view a argument group: --help=ModelConfig\n"
" - To view a single argument: --help=max-num-seqs\n" " - To view a single argument: --help=max-num-seqs\n"
" - To search by keyword: --help=max\n" " - To search by keyword: --help=max\n"
...@@ -178,13 +179,19 @@ def _validate_truncation_size( ...@@ -178,13 +179,19 @@ def _validate_truncation_size(
return truncate_prompt_tokens return truncate_prompt_tokens
def show_filtered_argument_or_group_from_help(parser, subcommand_name): def show_filtered_argument_or_group_from_help(parser: argparse.ArgumentParser,
subcommand_name: list[str]):
import sys import sys
# Only handle --help=<keyword> for the current subcommand. # Only handle --help=<keyword> for the current subcommand.
# Since subparser_init() runs for all subcommands during CLI setup, # Since subparser_init() runs for all subcommands during CLI setup,
# we skip processing if the subcommand name is not in sys.argv. # we skip processing if the subcommand name is not in sys.argv.
if subcommand_name not in sys.argv: # sys.argv[0] is the program name. The subcommand follows.
# e.g., for `vllm bench latency`,
# sys.argv is `['vllm', 'bench', 'latency', ...]`
# and subcommand_name is "bench latency".
if len(sys.argv) <= len(subcommand_name) or sys.argv[
1:1 + len(subcommand_name)] != subcommand_name:
return return
for arg in sys.argv: for arg in sys.argv:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment