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

Signed-off-by: reidliu41 <reid201711@gmail.com>
This commit is contained in:
Reid
2025-07-03 14:22:16 +00:00
committed by GitHub
parent ff5c60fad8
commit 9854dc9040
4 changed files with 18 additions and 6 deletions
+11 -4
View File
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import argparse
import asyncio
import functools
import os
@@ -15,8 +16,8 @@ from vllm.logger import init_logger
logger = init_logger(__name__)
VLLM_SUBCMD_PARSER_EPILOG = (
"Tip: Use `vllm [serve|run-batch] --help=<keyword>` "
"to explore arguments from help.\n"
"Tip: Use `vllm [serve|run-batch|bench <bench_type>] "
"--help=<keyword>` 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"
@@ -178,13 +179,19 @@ def _validate_truncation_size(
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
# Only handle --help=<keyword> 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:
# 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
for arg in sys.argv: