-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
[V1] [Hybrid] Enable piecewise CUDA Graph for mamba layers #21194
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
👋 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
The pull request enables piecewise CUDA Graph for mamba layers. The changes include modifications to several files to integrate mamba layers with CUDA graphs. The review identified several print statements that should be removed before merging, as well as a block of commented-out code that should be removed.
Signed-off-by: Thomas Parnell <tpa@zurich.ibm.com>
495b2df
to
db4b27b
Compare
Ready for review @heheda12345 @tlrmchlsmth |
op_name="mamba_mixer2", | ||
op_func=mamba_mixer2, |
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.
We should use a common op name here (unified_ssm_mixer
?) so we can avoid adding a bunch of cases to splitting_ops
(fine for this PR though)
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.
Glad this was so straightforward!
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.
Thanks for the great job. Does the performance match v0 now? If yes, is it the time to use v1 by default in supported cases? If no, do you know what else need we do?
output = torch.empty_like(hidden_states) | ||
self.mamba(hidden_states, output, mamba_cache_params, mamba2_metadata) |
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.
Is it possible to change the code back to output = self.mamba(...)
?
@heheda12345 Based on my benchmarking, there is still a gap to V0 for small batch sizes. This is because we are still not using CUDA graph for the mamba layers in V1 (whereas in V0 we do). It is a simple change to enable full cuda graphs for mamba layers for decode-only batches. I will create a PR but it would be ideal if we can first merge #21367 to enable the same for FlashInfer. Otherwise we will need to add some logic to handle attention layers using piecewise and mamba layers using full cuda graph. |
…ect#21194) Signed-off-by: Thomas Parnell <tpa@zurich.ibm.com>
Essential Elements of an Effective PR Description Checklist
supported_models.md
andexamples
for a new model.Purpose
Fairly straightforward implementation of piecewise CUDA graphs for mamba layers in V1. Just tried to follow what is done on main for attention layers. It brings a pretty big performance boost (see benchmarking below).
There is a lot of CPU overhead in the mamba layer, so there might still be some performance gap to V0 until we implement full CUDA graphs. I have a working branch that does this for decode-only batches. Once this one is merged I will follow-up quickly with that one.
Test Plan
I've removed
--enforce-eager
from thetest_hybrid
which should test it for all supported models.Test Result
All tests are passing for me locally.
Benchmarking
produces:
and now:
produces:
Correctness
In eager mode:
produces:
Using compile + piecewise CUDA graphs:
produces: