-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[Ascend] torch_npu.npu_mrope for MRotaryEmbedding #10907
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
Conversation
Summary of ChangesHello @Makcum888e, 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 introduces an optimization for the MRotaryEmbedding component by integrating the Highlights
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request aims to optimize MRotaryEmbedding for NPU by using torch_npu.npu_mrope. The changes involve renaming forward to forward_native and adding device-specific forward_cpu and forward_cuda methods. However, I've found some critical issues. The new forward_cpu and forward_cuda methods have incorrect signatures, which will lead to runtime errors. More importantly, the NPU implementation for MRotaryEmbedding seems to be missing. It inherits forward_npu from the base class, which is incorrect for MRotaryEmbedding and will not work as intended. I've provided suggestions to fix these issues.
ssshinigami
left a comment
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.
LGTM
ssshinigami
left a comment
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.
LGTM
Motivation
use of
torch_npuimplementation ofmropeinstead of torch native implementation with many small operations can give a significant increase of performanceModifications
forwardrenamed toforward_nativeoverridden functions
forward_cpuandforward_cudato not use it from base classoverridden function
forward_npuwith torch_npu implementationAccuracy Tests
tested on
Qwen3-VL-4B-InstructGSM8k:before
Accuracy: 0.729
Invalid: 0.122
Latency: 216.923 s
Output throughput: 961.137 token/s
after
Accuracy: 0.728
Invalid: 0.124
Latency: 178.438 s
Output throughput: 1155.518 token/s
MMMU:before
Benchmark time: 221.995
Overall accuracy: 0.499
after:
Benchmark time: 208.065
Overall accuracy: 0.496
Benchmarking and Profiling
bench_servingnum prompts 64 random input len 2048 random output len 2048before
Mean TTFT (ms): 3667.45
Mean ITL (ms): 49.65
after
Mean TTFT (ms): 3494.33
Mean ITL (ms): 43.61
Checklist