-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
[Model] Replace Mamba2 RMSNorm Gated with Fused Triton Kernel #20839
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
👋 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 @cyang49, 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!
I've summarized this pull request as primarily focused on enhancing the performance of the RMSNormGated
layer within the Mamba model executor. My analysis shows it achieves this by replacing the existing, less efficient unfused operations with a highly optimized, fused Triton kernel. I expect this change to yield substantial speedups, particularly for longer prompt lengths, by reducing the overhead of multiple discrete GPU operations into a single, efficient kernel.
Highlights
- Performance Optimization: I see that the existing multi-operation RMSNormGated implementation has been replaced with a single, fused Triton kernel for significant speedup. This addresses performance bottlenecks identified with 16k and 32k prompt lengths.
- Triton Kernel Integration: I've noted the introduction of a new Triton-based kernel (
layernorm_gated.py
), adapted from themamba_ssm
repository, to handle the fused RMSNorm and gating logic. - Targeted Application: I observe that the new fused kernel is currently applied specifically to
TP=1
(Tensor Parallelism) andngroups=1
configurations, with the PR description indicating that broader use cases might require similar fixes.
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
This pull request replaces the existing RMSNormGated
implementation with a more performant, fused Triton kernel from the mamba_ssm
library. The changes are well-contained and correctly implement the fusion for the TP=1
and ngroups=1
case as intended. The new Triton kernel and its wrapper functions are correctly implemented. I have one minor suggestion to improve code clarity by removing an unused parameter from a function signature in the new layernorm_gated.py
file.
Signed-off-by: Chih-Chieh-Yang <7364402+cyang49@users.noreply.github.com>
Signed-off-by: Chih-Chieh-Yang <7364402+cyang49@users.noreply.github.com>
d276a6f
to
9af4bf9
Compare
c0cff38
to
ec0a8c6
Compare
Signed-off-by: Chih-Chieh-Yang <7364402+cyang49@users.noreply.github.com>
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 good, just one comment
Signed-off-by: Chih-Chieh Yang <7364402+cyang49@users.noreply.github.com>
Waiting for unit test PR which covers RMSNormGated to be merged, instead of adding a new unit test |
Essential Elements of an Effective PR Description Checklist
supported_models.md
andexamples
for a new model.Purpose
This PR improves RMSNormGated performance. The original implementation has unfused operations which results in slow execution time. In the experiments with 16k and 32k prompt length, we found that RMSNormGated layer took as much time as mamba2 SSD computations, much longer than expected.
The fix replaces the current implementation with a fused kernel from the mamba_ssm repo. It applies to TP=1 and ngroups=1 cases only for now. It is likely that similar fixes are needed for broader use cases.
@tdoublep @tlrmchlsmth
Test Plan
Since the RMSNormGated is replaced with a new implementation, the output quality will be tested e2e using lm_eval with gsm8k. The performance gain will be show through benchmark_latency results.
Test Result
Experiments done on H100-80GB
Before results are tested with f29fd8a
benchmark_latency.py
Before
16k
32k
After
16k
32k
Approximately 8~9% latency improvements observed.
lm_eval Bamba-9B
Before
After
(Optional) Documentation Update