-
Notifications
You must be signed in to change notification settings - Fork 684
[Optimization] Accelerate Qwen3 QK RMSNorm via Fused Triton Kernel #5880
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Thanks for your contribution! |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #5880 +/- ##
==========================================
Coverage ? 67.33%
==========================================
Files ? 348
Lines ? 44688
Branches ? 6875
==========================================
Hits ? 30092
Misses ? 12374
Partials ? 2222
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…into opt_qknorm
zhoutianzi666
approved these changes
Jan 12, 2026
yuanlehome
approved these changes
Jan 12, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Qwen3 系列模型在执行 QK RMSNorm 前,需要先对 qkv_out 进行 split,归一化后再 concat 回去。这一过程涉及多次张量重排与内存拷贝,开销较大,同时现有的 RMSNorm kernel 在性能上也并非最优。
Modifications
通过 Triton kernel 融合优化,利用 offset 直接索引 Q/K/V 数据,把 split → reshape → RMSNorm(Q) → reshape → RMSNorm(K) → concat 融合成一个 Triton kernel,消除了 split/concat 开销,并提升了 RMSNorm kernel 的性能。
kernel性能
Qwen3-30B-A3B TP1
Qwen3-235B-A22B TP4
GLM_4.6 TP4
模型性能
Qwen3-30B-A3B FP8下TPS提升5%🚀
Usage or Command
Accuracy Tests
已添加单测,相比paddle api误差在1e-4内。
Checklist
[FDConfig],[APIServer],[Engine],[Scheduler],[PD Disaggregation],[Executor],[Graph Optimization],[Speculative Decoding],[RL],[Models],[Quantization],[Loader],[OP],[KVCache],[DataProcessor],[BugFix],[Docs],[CI],[Optimization],[Feature],[Benchmark],[Others],[XPU],[HPU],[GCU],[DCU],[Iluvatar],[Metax]]pre-commitbefore commit.releasebranch, make sure the PR has been submitted to thedevelopbranch, then cherry-pick it to thereleasebranch with the[Cherry-Pick]PR tag.