Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
2c11a29f
Unverified
Commit
2c11a29f
authored
Jun 22, 2025
by
Ye (Charlotte) Qi
Committed by
GitHub
Jun 22, 2025
Browse files
[Misc] Simplify vllm bench cli subcommand implementation (#19948)
parent
c76a506b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
80 deletions
+44
-80
vllm/entrypoints/cli/__init__.py
vllm/entrypoints/cli/__init__.py
+12
-0
vllm/entrypoints/cli/benchmark/base.py
vllm/entrypoints/cli/benchmark/base.py
+3
-17
vllm/entrypoints/cli/benchmark/latency.py
vllm/entrypoints/cli/benchmark/latency.py
+4
-13
vllm/entrypoints/cli/benchmark/main.py
vllm/entrypoints/cli/benchmark/main.py
+17
-24
vllm/entrypoints/cli/benchmark/serve.py
vllm/entrypoints/cli/benchmark/serve.py
+4
-13
vllm/entrypoints/cli/benchmark/throughput.py
vllm/entrypoints/cli/benchmark/throughput.py
+4
-13
No files found.
vllm/entrypoints/cli/__init__.py
View file @
2c11a29f
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from
vllm.entrypoints.cli.benchmark.latency
import
BenchmarkLatencySubcommand
from
vllm.entrypoints.cli.benchmark.serve
import
BenchmarkServingSubcommand
from
vllm.entrypoints.cli.benchmark.throughput
import
(
BenchmarkThroughputSubcommand
)
__all__
:
list
[
str
]
=
[
"BenchmarkLatencySubcommand"
,
"BenchmarkServingSubcommand"
,
"BenchmarkThroughputSubcommand"
,
]
\ No newline at end of file
vllm/entrypoints/cli/benchmark/base.py
View file @
2c11a29f
...
...
@@ -3,18 +3,15 @@
import
argparse
from
vllm.entrypoints.cli.types
import
CLISubcommand
from
vllm.utils
import
FlexibleArgumentParser
class
BenchmarkSubcommandBase
(
CLISubcommand
):
""" The base class of subcommands for vllm bench. """
@
property
def
help
(
self
)
->
str
:
"""The help message of the subcommand."""
raise
NotImplementedError
help
:
str
def
add_cli_args
(
self
,
parser
:
argparse
.
ArgumentParser
)
->
None
:
@
classmethod
def
add_cli_args
(
cls
,
parser
:
argparse
.
ArgumentParser
)
->
None
:
"""Add the CLI arguments to the parser."""
raise
NotImplementedError
...
...
@@ -26,14 +23,3 @@ class BenchmarkSubcommandBase(CLISubcommand):
args: The arguments to the command.
"""
raise
NotImplementedError
def
subparser_init
(
self
,
subparsers
:
argparse
.
_SubParsersAction
)
->
FlexibleArgumentParser
:
parser
=
subparsers
.
add_parser
(
self
.
name
,
help
=
self
.
help
,
description
=
self
.
help
,
usage
=
f
"vllm bench
{
self
.
name
}
[options]"
)
self
.
add_cli_args
(
parser
)
return
parser
vllm/entrypoints/cli/benchmark/latency.py
View file @
2c11a29f
...
...
@@ -4,27 +4,18 @@ import argparse
from
vllm.benchmarks.latency
import
add_cli_args
,
main
from
vllm.entrypoints.cli.benchmark.base
import
BenchmarkSubcommandBase
from
vllm.entrypoints.cli.types
import
CLISubcommand
class
BenchmarkLatencySubcommand
(
BenchmarkSubcommandBase
):
""" The `latency` subcommand for vllm bench. """
def
__init__
(
self
):
self
.
name
=
"latency"
super
().
__init__
()
name
=
"latency"
help
=
"Benchmark the latency of a single batch of requests."
@
property
def
help
(
self
)
->
str
:
return
"Benchmark the latency of a single batch of requests."
def
add_cli_args
(
self
,
parser
:
argparse
.
ArgumentParser
)
->
None
:
@
classmethod
def
add_cli_args
(
cls
,
parser
:
argparse
.
ArgumentParser
)
->
None
:
add_cli_args
(
parser
)
@
staticmethod
def
cmd
(
args
:
argparse
.
Namespace
)
->
None
:
main
(
args
)
def
cmd_init
()
->
list
[
CLISubcommand
]:
return
[
BenchmarkLatencySubcommand
()]
vllm/entrypoints/cli/benchmark/main.py
View file @
2c11a29f
...
...
@@ -2,51 +2,44 @@
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
argparse
import
vllm.entrypoints.cli.benchmark.latency
import
vllm.entrypoints.cli.benchmark.serve
import
vllm.entrypoints.cli.benchmark.throughput
from
vllm.entrypoints.cli.benchmark.base
import
BenchmarkSubcommandBase
from
vllm.entrypoints.cli.types
import
CLISubcommand
from
vllm.utils
import
FlexibleArgumentParser
BENCHMARK_CMD_MODULES
=
[
vllm
.
entrypoints
.
cli
.
benchmark
.
latency
,
vllm
.
entrypoints
.
cli
.
benchmark
.
serve
,
vllm
.
entrypoints
.
cli
.
benchmark
.
throughput
,
]
class
BenchmarkSubcommand
(
CLISubcommand
):
""" The `bench` subcommand for the vLLM CLI. """
def
__init__
(
self
):
self
.
name
=
"bench"
super
().
__init__
()
name
=
"bench"
help
=
"vLLM bench subcommand."
@
staticmethod
def
cmd
(
args
:
argparse
.
Namespace
)
->
None
:
args
.
dispatch_function
(
args
)
def
validate
(
self
,
args
:
argparse
.
Namespace
)
->
None
:
if
args
.
bench_type
in
self
.
cmds
:
self
.
cmds
[
args
.
bench_type
].
validate
(
args
)
pass
def
subparser_init
(
self
,
subparsers
:
argparse
.
_SubParsersAction
)
->
FlexibleArgumentParser
:
bench_parser
=
subparsers
.
add_parser
(
"bench"
,
help
=
"vLLM bench subcommand."
,
description
=
"vLLM bench subcommand."
,
self
.
name
,
help
=
self
.
help
,
description
=
self
.
help
,
usage
=
"vllm bench <bench_type> [options]"
)
bench_subparsers
=
bench_parser
.
add_subparsers
(
required
=
True
,
dest
=
"bench_type"
)
self
.
cmds
=
{}
for
cmd_module
in
BENCHMARK_CMD_MODULES
:
new_cmds
=
cmd_module
.
cmd_init
()
for
cmd
in
new_cmds
:
cmd
.
subparser_init
(
bench_subparsers
).
set_defaults
(
dispatch_function
=
cmd
.
cmd
)
self
.
cmds
[
cmd
.
name
]
=
cmd
for
cmd_cls
in
BenchmarkSubcommandBase
.
__subclasses__
():
cmd_subparser
=
bench_subparsers
.
add_parser
(
cmd_cls
.
name
,
help
=
cmd_cls
.
help
,
description
=
cmd_cls
.
help
,
)
cmd_subparser
.
set_defaults
(
dispatch_function
=
cmd_cls
.
cmd
)
cmd_cls
.
add_cli_args
(
cmd_subparser
)
return
bench_parser
...
...
vllm/entrypoints/cli/benchmark/serve.py
View file @
2c11a29f
...
...
@@ -4,27 +4,18 @@ import argparse
from
vllm.benchmarks.serve
import
add_cli_args
,
main
from
vllm.entrypoints.cli.benchmark.base
import
BenchmarkSubcommandBase
from
vllm.entrypoints.cli.types
import
CLISubcommand
class
BenchmarkServingSubcommand
(
BenchmarkSubcommandBase
):
""" The `serve` subcommand for vllm bench. """
def
__init__
(
self
):
self
.
name
=
"serve"
super
().
__init__
()
name
=
"serve"
help
=
"Benchmark the online serving throughput."
@
property
def
help
(
self
)
->
str
:
return
"Benchmark the online serving throughput."
def
add_cli_args
(
self
,
parser
:
argparse
.
ArgumentParser
)
->
None
:
@
classmethod
def
add_cli_args
(
cls
,
parser
:
argparse
.
ArgumentParser
)
->
None
:
add_cli_args
(
parser
)
@
staticmethod
def
cmd
(
args
:
argparse
.
Namespace
)
->
None
:
main
(
args
)
def
cmd_init
()
->
list
[
CLISubcommand
]:
return
[
BenchmarkServingSubcommand
()]
vllm/entrypoints/cli/benchmark/throughput.py
View file @
2c11a29f
...
...
@@ -4,27 +4,18 @@ import argparse
from
vllm.benchmarks.throughput
import
add_cli_args
,
main
from
vllm.entrypoints.cli.benchmark.base
import
BenchmarkSubcommandBase
from
vllm.entrypoints.cli.types
import
CLISubcommand
class
BenchmarkThroughputSubcommand
(
BenchmarkSubcommandBase
):
""" The `throughput` subcommand for vllm bench. """
def
__init__
(
self
):
self
.
name
=
"throughput"
super
().
__init__
()
name
=
"throughput"
help
=
"Benchmark offline inference throughput."
@
property
def
help
(
self
)
->
str
:
return
"Benchmark offline inference throughput."
def
add_cli_args
(
self
,
parser
:
argparse
.
ArgumentParser
)
->
None
:
@
classmethod
def
add_cli_args
(
cls
,
parser
:
argparse
.
ArgumentParser
)
->
None
:
add_cli_args
(
parser
)
@
staticmethod
def
cmd
(
args
:
argparse
.
Namespace
)
->
None
:
main
(
args
)
def
cmd_init
()
->
list
[
CLISubcommand
]:
return
[
BenchmarkThroughputSubcommand
()]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment