From 1aeb925f34495f505bf3053e4f66b8ca4886452e Mon Sep 17 00:00:00 2001 From: Reid <61492567+reidliu41@users.noreply.github.com> Date: Thu, 5 Jun 2025 19:16:25 +0800 Subject: [PATCH] [Frontend] improve vllm run-batch --help display (#19187) Signed-off-by: reidliu41 Co-authored-by: reidliu41 --- vllm/entrypoints/cli/main.py | 4 ++-- vllm/entrypoints/cli/run_batch.py | 8 +++++++- vllm/entrypoints/cli/serve.py | 6 +++--- vllm/entrypoints/utils.py | 14 +++++++++++--- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/vllm/entrypoints/cli/main.py b/vllm/entrypoints/cli/main.py index 3e834b3b2964..9bb1162e38d8 100644 --- a/vllm/entrypoints/cli/main.py +++ b/vllm/entrypoints/cli/main.py @@ -11,7 +11,7 @@ import vllm.entrypoints.cli.openai import vllm.entrypoints.cli.run_batch import vllm.entrypoints.cli.serve import vllm.version -from vllm.entrypoints.utils import VLLM_SERVE_PARSER_EPILOG, cli_env_setup +from vllm.entrypoints.utils import VLLM_SUBCMD_PARSER_EPILOG, cli_env_setup from vllm.utils import FlexibleArgumentParser CMD_MODULES = [ @@ -37,7 +37,7 @@ def main(): parser = FlexibleArgumentParser( description="vLLM CLI", - epilog=VLLM_SERVE_PARSER_EPILOG, + epilog=VLLM_SUBCMD_PARSER_EPILOG, ) parser.add_argument('-v', '--version', diff --git a/vllm/entrypoints/cli/run_batch.py b/vllm/entrypoints/cli/run_batch.py index 353034f881f7..6bdd3b63c26d 100644 --- a/vllm/entrypoints/cli/run_batch.py +++ b/vllm/entrypoints/cli/run_batch.py @@ -10,6 +10,8 @@ from vllm.entrypoints.cli.types import CLISubcommand from vllm.entrypoints.logger import logger from vllm.entrypoints.openai.run_batch import main as run_batch_main from vllm.entrypoints.openai.run_batch import make_arg_parser +from vllm.entrypoints.utils import (VLLM_SUBCMD_PARSER_EPILOG, + show_filtered_argument_or_group_from_help) from vllm.utils import FlexibleArgumentParser from vllm.version import __version__ as VLLM_VERSION @@ -49,7 +51,11 @@ class RunBatchSubcommand(CLISubcommand): usage= "vllm run-batch -i INPUT.jsonl -o OUTPUT.jsonl --model ", ) - return 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, + "run-batch") + run_batch_parser.epilog = VLLM_SUBCMD_PARSER_EPILOG + return run_batch_parser def cmd_init() -> list[CLISubcommand]: diff --git a/vllm/entrypoints/cli/serve.py b/vllm/entrypoints/cli/serve.py index f9c56e655461..51807a953e02 100644 --- a/vllm/entrypoints/cli/serve.py +++ b/vllm/entrypoints/cli/serve.py @@ -16,7 +16,7 @@ from vllm.entrypoints.openai.api_server import (run_server, run_server_worker, setup_server) from vllm.entrypoints.openai.cli_args import (make_arg_parser, validate_parsed_serve_args) -from vllm.entrypoints.utils import (VLLM_SERVE_PARSER_EPILOG, +from vllm.entrypoints.utils import (VLLM_SUBCMD_PARSER_EPILOG, show_filtered_argument_or_group_from_help) from vllm.executor.multiproc_worker_utils import _add_prefix from vllm.logger import init_logger @@ -101,8 +101,8 @@ class ServeSubcommand(CLISubcommand): ) serve_parser = make_arg_parser(serve_parser) - show_filtered_argument_or_group_from_help(serve_parser) - serve_parser.epilog = VLLM_SERVE_PARSER_EPILOG + show_filtered_argument_or_group_from_help(serve_parser, "serve") + serve_parser.epilog = VLLM_SUBCMD_PARSER_EPILOG return serve_parser diff --git a/vllm/entrypoints/utils.py b/vllm/entrypoints/utils.py index 6fb32ff187cc..16ba2b4531ac 100644 --- a/vllm/entrypoints/utils.py +++ b/vllm/entrypoints/utils.py @@ -14,8 +14,9 @@ from vllm.logger import init_logger logger = init_logger(__name__) -VLLM_SERVE_PARSER_EPILOG = ( - "Tip: Use `vllm serve --help=` to explore arguments from help.\n" +VLLM_SUBCMD_PARSER_EPILOG = ( + "Tip: Use `vllm [serve|run-batch] --help=` " + "to explore arguments from help.\n" " - To view a argument group: --help=ModelConfig\n" " - To view a single argument: --help=max-num-seqs\n" " - To search by keyword: --help=max\n" @@ -173,8 +174,15 @@ def _validate_truncation_size( return truncate_prompt_tokens -def show_filtered_argument_or_group_from_help(parser): +def show_filtered_argument_or_group_from_help(parser, subcommand_name): import sys + + # Only handle --help= for the current subcommand. + # Since subparser_init() runs for all subcommands during CLI setup, + # we skip processing if the subcommand name is not in sys.argv. + if subcommand_name not in sys.argv: + return + for arg in sys.argv: if arg.startswith('--help='): search_keyword = arg.split('=', 1)[1]