-
-
Notifications
You must be signed in to change notification settings - Fork 10k
[Misc] Simplify vllm bench cli subcommand implementation #19948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Ye (Charlotte) Qi <yeq@meta.com>
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @yeqcharlotte, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly refactors the implementation of the vllm bench
CLI subcommands. The primary goal is to simplify the existing command-line interface structure, making it more maintainable and extensible. By transitioning from a manual, module-based registration system to a dynamic, class-based discovery mechanism, the changes reduce boilerplate code and streamline the process of adding new benchmark functionalities in the future.
Highlights
- Refactor CLI Subcommand Registration: The
vllm bench
CLI now dynamically discovers its subcommands (latency, serve, throughput) by inspecting subclasses ofBenchmarkSubcommandBase
. This eliminates the need for a manually maintained list (BENCHMARK_CMD_MODULES
) and explicitcmd_init()
functions in individual subcommand modules. - Simplified Subcommand Definitions: Benchmark subcommand classes (
BenchmarkLatencySubcommand
,BenchmarkServingSubcommand
,BenchmarkThroughputSubcommand
) are streamlined. Theirname
andhelp
attributes are now class-level properties, andadd_cli_args
is a class method, reducing boilerplate__init__
methods and@property
decorators. - Centralized Subparser Initialization: The logic for initializing
argparse
subparsers for benchmark commands has been moved from individual subcommand classes tovllm/entrypoints/cli/benchmark/main.py
, making theBenchmarkSubcommandBase
cleaner and reducing duplication across subcommand implementations. - Improved Extensibility: Adding new benchmark subcommands is now simpler, requiring only the creation of a new class inheriting from
BenchmarkSubcommandBase
and adding it tovllm/entrypoints/cli/__init__.py
, without needing to modify the mainvllm/entrypoints/cli/benchmark/main.py
file.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The pull request simplifies the implementation of the vllm bench CLI subcommand by iterating over subclasses of BenchmarkSubcommandBase
and using their attributes to initialize the parser. This approach reduces code duplication and makes it easier to add new subcommands.
@classmethod | ||
def add_cli_args(cls, parser: argparse.ArgumentParser) -> None: | ||
"""Add the CLI arguments to the parser.""" | ||
raise NotImplementedError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@classmethod | ||
def add_cli_args(cls, parser: argparse.ArgumentParser) -> None: | ||
add_cli_args(parser) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a @staticmethod
decorator since this method doesn't use cls
or instance attributes.
@classmethod | |
def add_cli_args(cls, parser: argparse.ArgumentParser) -> None: | |
add_cli_args(parser) | |
@staticmethod | |
def add_cli_args(cls, parser: argparse.ArgumentParser) -> None: | |
add_cli_args(parser) |
@classmethod | ||
def add_cli_args(cls, parser: argparse.ArgumentParser) -> None: | ||
add_cli_args(parser) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a @staticmethod
decorator since this method doesn't use cls
or instance attributes.
@classmethod | |
def add_cli_args(cls, parser: argparse.ArgumentParser) -> None: | |
add_cli_args(parser) | |
@staticmethod | |
def add_cli_args(cls, parser: argparse.ArgumentParser) -> None: | |
add_cli_args(parser) |
@classmethod | ||
def add_cli_args(cls, parser: argparse.ArgumentParser) -> None: | ||
add_cli_args(parser) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a @staticmethod
decorator since this method doesn't use cls
or instance attributes.
@classmethod | |
def add_cli_args(cls, parser: argparse.ArgumentParser) -> None: | |
add_cli_args(parser) | |
@staticmethod | |
def add_cli_args(cls, parser: argparse.ArgumentParser) -> None: | |
add_cli_args(parser) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and thanks for the cleanup! Feel free to also address Gemini's reviews but I don't think they're a big deal.
nvm - in your PR description you used Qwen as an example, so it's indeed working as expected. #19949 should make this better. |
…t#19948) Signed-off-by: juncheoll <th6re8e@naver.com>
…t#19948) Signed-off-by: fhl <2410591650@qq.com>
…t#19948) Signed-off-by: Will Eaton <weaton@redhat.com>
…t#19948) Signed-off-by: avigny <47987522+avigny@users.noreply.github.com>
Purpose
I found the existing implementation over-complicated:
cmd_init()
;BENCHMARK_CMD_MODULES
and iterate over it manually;This PR directly iterates over subclasses of
BenchmarkSubcommandBase
, use thename
,help
,add_cli_args
andcmd
to initialize new parser.If we'd like to add a new subcommand for bench, we only need to
vllm/entrypoints/cli/benchmark/throughput.py
__init__.py
.There's no need to change
vllm/entrypoints/cli/benchmark/main.py
and it'll make the import cleaner.Test Plan
Test Result
serve: https://gist.github.com/yeqcharlotte/e82fce865397fa985606fd9ff452a89b
latency: https://gist.github.com/yeqcharlotte/1ab09fb1371eb3bde62e67946c5cabe1
throughput: https://gist.github.com/yeqcharlotte/d3037681ac2b8649b54e77e497f771ba
2. Unit tests
it still functions
(Optional) Documentation Update