[Rework] Add SwapAB Optimization for triton fused_moe_kernel on SM90.#16723
[Rework] Add SwapAB Optimization for triton fused_moe_kernel on SM90.#16723Fridge003 merged 3 commits intosgl-project:mainfrom
Conversation
Summary of ChangesHello @Insideyyy, 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 re-introduces a performance optimization, dubbed 'SwapAB', for the fused Mixture-of-Experts (MoE) kernel within the SGLang runtime. The core change involves conditionally transposing input matrices during the kernel's computation to improve efficiency on specific NVIDIA SM90 GPUs, particularly the H20. This re-implementation addresses and resolves the AMD CI failures that led to the previous reversion of this optimization, ensuring stability while delivering targeted performance enhancements. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe 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 by creating a comment using either
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 Limitations & Feedback Gemini Code Assist 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces the SwapAB optimization for the Triton fused_moe_kernel on SM90 GPUs, specifically targeting H20 devices for now. The changes are well-contained and add the necessary logic to detect the target hardware and conditionally apply the optimization within the kernel. The implementation appears correct. I have a couple of suggestions to enhance code readability and reduce duplication, which will improve long-term maintainability.
| device_name = get_device_name() | ||
| is_h20_device = device_name and "H20" in device_name and "H200" not in device_name | ||
| return ( | ||
| is_h20_device | ||
| and is_sm90_supported() | ||
| and BLOCK_SIZE_M < 64 | ||
| and BLOCK_SIZE_N >= 64 | ||
| ) |
There was a problem hiding this comment.
The logic to determine if the optimization should be enabled can be made more direct and readable by combining the checks into a single return statement and using is not None for explicit None checking. This removes the intermediate is_h20_device variable and makes the function's intent clearer at a glance.
| device_name = get_device_name() | |
| is_h20_device = device_name and "H20" in device_name and "H200" not in device_name | |
| return ( | |
| is_h20_device | |
| and is_sm90_supported() | |
| and BLOCK_SIZE_M < 64 | |
| and BLOCK_SIZE_N >= 64 | |
| ) | |
| device_name = get_device_name() | |
| return ( | |
| device_name is not None | |
| and "H20" in device_name | |
| and "H200" not in device_name | |
| and is_sm90_supported() | |
| and BLOCK_SIZE_M < 64 | |
| and BLOCK_SIZE_N >= 64 | |
| ) |
|
/tag-and-rerun-ci |
|
/rerun-failed-ci |
Motivation
Rework of reverted pr #15712, with AMD CI failures fixed.
Modifications
Accuracy Tests
Benchmarking and Profiling
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci) or contact authorized users to do so.