-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
[V1] [Hybrid] Enable Full CUDA graph by default for models with mamba2 layers in V1 #22594
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Thomas Parnell <[email protected]>
👋 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.
Code Review
This pull request enables full CUDA graphs by default for hybrid models to improve performance, which is a great optimization. I have one suggestion regarding the implementation to ensure user configurations are not unintentionally overridden.
Signed-off-by: Thomas Parnell <[email protected]>
Signed-off-by: Thomas Parnell <[email protected]>
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.
Looks reasonable to me, the difference is huge! The main concern would be if we enable full cudagraph by default for Mamba2 but one of the non-mamba layers needs to use an attention backend without full cg support
if compilation_config.full_cuda_graph is None: | ||
compilation_config.full_cuda_graph = True |
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.
Might be worth leaving an info_once log here about what is going on and why
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.
Amazing speedup! Can you update the doc?
cls = MODELS_CONFIG_MAP.get(architecture, None) | ||
if cls is not None: | ||
cls.verify_and_update_config(self) | ||
|
||
if self.model_config.is_hybrid: | ||
HybridAttentionMambaModelConfig.verify_and_update_config(self) | ||
|
||
if self.model_config.has_mamba2: | ||
Mamba2ModelConfig.verify_and_update_config(self) |
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.
what about maintaining a white list in HybridAttentionMambaModelConfig for models that should use v1? For example I think we can enable mamba1 and minimax soon. has_mamba2
is only a very temporary way to determine cuda graph.
@@ -214,7 +214,7 @@ class CompilationConfig: | |||
are always used, it can set this to False. Otherwise, it should | |||
set this to True, and the compiler will copy the input to an | |||
internally managed buffer. Default is False.""" | |||
full_cuda_graph: bool = False | |||
full_cuda_graph: Optional[bool] = None |
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.
Why change this default?
Also FYI this config is to be replaced with cudagraph_mode
in https://github.com/vllm-project/vllm/pull/20059/files#diff-19413af30c8d2ba8cdaf4989476312ece57b0e9811b39a62286623b99c7fd0a8
This pull request has merge conflicts that must be resolved before it can be |
@tdoublep This is great. Suggestion - Everything here is not very mamba2 specific, meaning, once we add full cuda support to mamba1 (we have the PR waiting to be opened), we would want to add this code to it as well without duplicating it. So perhaps its worth removing the |
Essential Elements of an Effective PR Description Checklist
supported_models.md
andexamples
for a new model.Purpose
The mamba2 layer has a lot of CPU overhead which mean its performance is really poor for small batches unless CUDA graphs are used. This means that the default V1 performance is still significantly worse than the default V0 performance (see below).
We recently merged #21401 which solves this problem by enabling full CUDA graphs for decode-only batches. This PR proposes to enable this by default for models with mamba2. Without this change, users will continue to experience poor performance when switching from V0 to V1, unless they really know what they are doing.
In my view, this PR and #21549 would be the last steps required to enable V1 by default for these models and to start stripping out the V0 code.
cc @heheda12345 @tlrmchlsmth
Test Plan
Test Result
Default V0 performance (main):
Default V1 performance (main):
Default V1 performance (this PR):
(Optional) Documentation Update