-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ROCm] [Bugfix] [Critical]: Fix mamba compilation bug #20883
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
[ROCm] [Bugfix] [Critical]: Fix mamba compilation bug #20883
Conversation
Signed-off-by: tjtanaa <[email protected]>
Signed-off-by: tjtanaa <[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.
Summary of Changes
Hello @tjtanaa, 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 delivers a critical bug fix that addresses compilation issues for the Mamba kernel on ROCm, which was blocking vLLM package installation. It also extends functionality by unblocking speculative decoding for vLLM V1 on ROCm, enhancing the platform's capabilities on AMD hardware.
Highlights
- ROCm Compatibility Fixes: Implemented conditional compilation within the Mamba SSM kernel (
selective_scan_fwd.cu
) to correctly use HIP-specific error handling macros (C10_HIP_CHECK
,C10_HIP_KERNEL_LAUNCH_CHECK
) and function attribute setting (hipFuncSetAttribute
) when building for ROCm. This ensures the kernel compiles and runs correctly on AMD GPUs, resolving a critical bug that prevented vLLM installation on ROCm. - Speculative Decoding Unblocked for vLLM V1 on ROCm: Removed a
NotImplementedError
invllm/platforms/rocm.py
that previously prevented speculative decoding for vLLM V1 on ROCm. The configuration now correctly assigns thevllm.v1.worker.gpu_worker.Worker
class, enabling this feature on ROCm platforms.
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 aims to fix a Mamba compilation bug on ROCm. The changes include using conditional compilation for CUDA/HIP-specific headers and function calls in selective_scan_fwd.cu
. Additionally, it enables speculative decoding for vLLM V1 on ROCm by removing a NotImplementedError
in rocm.py
.
The changes are generally good and move towards better ROCm support. However, I've identified a critical issue in selective_scan_fwd.cu
where a CUDA-specific macro is used unconditionally, which will lead to compilation failures on ROCm. I've provided a comment with details on how to fix this.
#ifdef USE_ROCM | ||
C10_HIP_CHECK(hipFuncSetAttribute( | ||
reinterpret_cast<const void*>(kernel), hipFuncAttributeMaxDynamicSharedMemorySize, kSmemSize)); | ||
#else | ||
C10_CUDA_CHECK(cudaFuncSetAttribute( | ||
kernel, cudaFuncAttributeMaxDynamicSharedMemorySize, kSmemSize)); | ||
#endif |
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.
While you've correctly handled cudaFuncSetAttribute
with a conditional for ROCm, the C10_CUDA_KERNEL_LAUNCH_CHECK()
on line 336 is still CUDA-specific and will cause a compilation error on ROCm builds. This should also be wrapped in an #ifdef USE_ROCM
block to call C10_HIP_KERNEL_LAUNCH_CHECK()
for ROCm.
Signed-off-by: tjtanaa <[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, thanks for the context
…0883) Signed-off-by: tjtanaa <[email protected]> Co-authored-by: vllmellm <[email protected]> Signed-off-by: x22x22 <[email protected]>
…0883) Signed-off-by: tjtanaa <[email protected]> Co-authored-by: vllmellm <[email protected]>
…0883) Signed-off-by: tjtanaa <[email protected]> Co-authored-by: vllmellm <[email protected]>
…0883) Signed-off-by: tjtanaa <[email protected]> Co-authored-by: vllmellm <[email protected]> Signed-off-by: Jinzhen Lin <[email protected]>
…0883) Signed-off-by: tjtanaa <[email protected]> Co-authored-by: vllmellm <[email protected]> Signed-off-by: Paul Pak <[email protected]>
…0883) Signed-off-by: tjtanaa <[email protected]> Co-authored-by: vllmellm <[email protected]> Signed-off-by: Diego-Castan <[email protected]>
…0883) Signed-off-by: tjtanaa <[email protected]> Co-authored-by: vllmellm <[email protected]>
Essential Elements of an Effective PR Description Checklist
supported_models.md
andexamples
for a new model.Purpose
Fix this bug #20882 which breaks vLLM package installation on ROCm
Break introduced in commit 2c11a73
Bugfixes is a referenced to (#18565)
FIX #20882
Test Plan
Able to install on ROCm.
Run mamba unit tests
tests/kernels/mamba/test_causal_conv1d.py
tests/kernels/mamba/test_mamba_mixer2.py
tests/kernels/mamba/test_mamba_ssm_ssd.py
tests/kernels/mamba/test_mamba_ssm.py
Test Result
tests/kernels/mamba/test_causal_conv1d.py
: PASSED==== 244 passed in 95.18s (0:01:35) ====
tests/kernels/mamba/test_mamba_mixer2.py
: SKIPPED==== 4 skipped in 13.36s ====
tests/kernels/mamba/test_mamba_ssm.py
: PASSED==== 462 passed, 2 skipped in 151.27s (0:02:31) ====
tests/kernels/mamba/test_mamba_ssm_ssd.py::test_mamba_chunk_scan_single_example
: PASSEDtests/kernels/mamba/test_mamba_ssm_ssd.py::test_mamba_chunk_scan_cont_batch
: This test has been failing before the commit that breaks the compilation (commit: 2c11a73)Validated the same unit tests with commit
b639327ad94b3aa16022ebea49f8e525660b736b
(this commit is before commit: 2c11a73)For fixing this critical issue, it is suggested that we accept a partial fix. The core dump in unitt test is tracked at here. #20885
lm_eval score of
microsoft/Phi-4-mini-reasoning
V1 Enginevllm (pretrained=microsoft/Phi-4-mini-reasoning,tensor_parallel_size=1,max_model_len=32768,trust_remote_code=True), gen_kwargs: (None), limit: None, num_fewshot: 5, batch_size: auto
(Optional) Documentation Update