Add RMSNorm kernels for npu - #41098
Conversation
|
[For maintainers] Suggested jobs to run (before merge) run-slow: qwen3, qwen3_moe, qwen3_next, qwen3_omni_moe, qwen3_vl, qwen3_vl_moe |
Supplement test by LLaMA-Factoryenvcann=8.2.RC1 configresultUsing LLaMA-Factory, we fine-tuned Qwen3-0.6B.
No RMSNorm kernelsAdd RMSNorm kernels(631.4651 - 558.9375) / 631.4651 ≈ 11.5% The results show an approximate 11% speedup from adding the RMSNorm kernels. |
|
@ArthurZucker I've added a supplementary experiment. Could you please review this PR. |
|
@MekkCyber Yes, the
|
|
Thanks for the explanation @zheliuyu, but doesn't torch dispatch automatically to this implementation when having a |
|
@MekkCyber Thanks for your review.
If it's not explicitly called, the |
|
@MekkCyber Hey, I was wondering if you'd consider merging this PR. Alternatively, if you have any suggestions, please do let me know. |
|
Hey @zheliuyu, my only concern is that we are using big machinery to just call |
|
@MekkCyber I believe you're right. Let me check if we can directly reuse the kernels from the kernels-community project. |

What does this PR do?
Add support for
kernels-ext-npu/RMSNormacceleration on npu.Basework
Test
Prepare the env
Test script
logging.basicConfig(level=logging.DEBUG)to observe if"kernels-ext-npu/RMSNorm"takes effect.use_kernels=Trueuse_kernel_forward_from_hub("RMSNorm")on modeling_qwen3.pyOutput
Before submitting
Pull Request section?
to it if that's the case.
@ArthurZucker Ready for review.