Support piecewise cuda graph for dsv3 fp4#15531
Conversation
Summary of ChangesHello @ispobock, 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 integrates piecewise CUDA graph capabilities for DeepSeek V3 FP4 models, aiming to optimize performance by allowing graph capture for specific computational segments. It involves adapting the attention and MoE layers to work seamlessly with this new execution mode, ensuring proper fallback mechanisms and preventing conflicts with Torch Dynamo. The changes are validated through new dedicated test suites covering accuracy and speed. 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
|
|
/tag-and-rerun-ci |
There was a problem hiding this comment.
Code Review
This pull request adds support for piecewise CUDA graphs for DeepSeek V3 FP4 models, which is a great enhancement for performance. The changes are well-structured and include necessary fallbacks, custom operators for CUDA graph compatibility, and workarounds for torch.dynamo limitations. The addition of a dedicated test suite for this feature is also a good practice. I have one minor suggestion to remove a redundant assertion to improve code clarity.
| assert TopKOutputChecker.format_is_bypassed( | ||
| topk_output | ||
| ), "Only bypassed topk output is supported for flashinfer fp4 moe" | ||
|
|
There was a problem hiding this comment.
| w = layer.weight_packed.T | ||
| w_blockscale = layer.weight_scale.T | ||
|
|
||
| out = _sglang_fp4_gemm( |
There was a problem hiding this comment.
QQ: we can just delete this wrapper now probably right
There was a problem hiding this comment.
yes, we can check the usage of it
There was a problem hiding this comment.
All the ci passed: https://github.com/sgl-project/sglang/actions/runs/20395182671?pr=15531 We can check and remove it in another PR.
There was a problem hiding this comment.
I think it cannot be removed, since it's registered to this sglang.fp4_gemm op.
Motivation
#11490
Accuracy Tests