-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
[EP+DP] Optimize the little operations in the DeepGEMM + DeepEP low latency case #19885
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: Varun Sundar Rabindranath <[email protected]>
- Quantized dispatch - Fused act-and-mul-and-quant in the right layout for DeepGEMM Signed-off-by: Tyler Michael Smith <[email protected]>
Signed-off-by: Varun Sundar Rabindranath <[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 @tlrmchlsmth, 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 focuses on critical performance optimizations for the DeepGEMM + DeepEP low-latency path, particularly for decode workers. My changes streamline the data flow and computation by integrating quantization and activation operations directly into the DeepEP dispatch and introducing a highly optimized fused kernel. This significantly reduces overhead from previously identified bottlenecks like quantization, SiLU-and-mul, and data copying, leading to substantial throughput and latency improvements.
Highlights
- DeepEP Dispatch Optimization: I've enabled
use_fp8_dispatch
in DeepEP's dispatch operation. This allows DeepEP to handle the quantization process directly, ensuring that the scales are in the correct layout for DeepGEMM and reducing the need for separate copy operations. - Fused SiLU-Mul-Quant Kernel: I've introduced a new Triton-based fused
silu-mul-quant
kernel. This kernel efficiently performs the SiLU activation, multiplication, and FP8 quantization in a single operation. It's designed to produce tensors with the precise shape and strides required by DeepGEMM and is optimized to avoid processing or loading padded tokens, which is critical for CUDA graph support in low-latency scenarios. - Performance Improvement: These optimizations have led to significant performance gains in the pure decode benchmark. Request throughput and output token throughput have both improved by approximately 2.4x, while Time to First Token (TTFT) is about 3.1x faster and Time per Output Token (TPOT) is about 2.4x faster.
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 PR introduces optimizations for the DeepGEMM + DeepEP low latency case, including setting use_fp8_dispatch
to True
in DeepEP's dispatch operation and a triton fused silu-mul-quant kernel. The changes significantly improve performance, as demonstrated by the benchmark results. The code is well-structured and includes necessary assertions. However, some comments could be added to improve readability and explain certain design choices.
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.
Clean implementation, thanks for the summary! I think we can land with fixed pre-commit. It would be nice to have a kernel test comparing this fused version versus the previous version, but that may be overkill.
|
||
f_info = torch.finfo(fp8_dtype) | ||
fp8_max = f_info.max | ||
fp8_min = -f_info.max |
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.
nit: might as well use f_info.min
Signed-off-by: Tyler Michael Smith <[email protected]>
Signed-off-by: Tyler Michael Smith <[email protected]>
Signed-off-by: Tyler Michael Smith <[email protected]>
Signed-off-by: Tyler Michael Smith <[email protected]>
Signed-off-by: Tyler Michael Smith <[email protected]>
Signed-off-by: Tyler Michael Smith <[email protected]>
Summary
Optimizations when using DeepGEMM + DeepEP (for the decode worker in a P/D setup). On current main, the majority of time is spent in quantize ops, silu-and-mul, and copy operations to put the scales in the layout needed for DeepGEMM.
This PR has two pieces:
use_fp8_dispatch
toTrue
in DeepEP's dispatch operation. This lets DeepEP take care of the quantization, and puts the scales in the right layout for DeepGEMM.Performance
Running the following pure decode benchmark:
Main:
This PR:
Testing
This is covered by
tests/kernels/moe/test_deepep_deepgemm_moe.py
which remains green. I ran lm_eval gsm8k onQwen/Qwen3-235B-A22B-FP8
and the score was around 0.9 (I stupidly threw away the result).TODO: Unit test for the fused act-and-mul-and-quant kernel.