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.
Fix NPU LoRA for MindSpeed MoE grouped linear #118
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
Uh oh!
There was an error while loading. Please reload this page.
Fix NPU LoRA for MindSpeed MoE grouped linear #118
Changes from 2 commits
a1163a32cc4abf3c75f9eFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
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.
In
_fallback_forward, there is no validation to ensure that the length ofm_splitsmatchesself.num_gemms. Iflen(m_splits)is greater thanself.num_gemms, the loop will attempt to access non-existent attributes (e.g.,weight{i}), resulting in a crypticAttributeError.Add a defensive check at the beginning of
_fallback_forwardto verify thatlen(m_splits)matchesself.num_gemms.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.
The
forwardmethod ofNpuGroupedLoraLineardoes not accept arbitrary positional (*args) or keyword (**kwargs) arguments. However, inLoraParallelLinear.forward(withinsrc/mcore_bridge/tuners/lora.py), the adapter layers are called with*argsand**kwargs(e.g.,lora_A(dropout(x), *args, **kwargs)). If any extra keyword arguments or positional arguments are passed, this will raise aTypeError.To ensure compatibility and prevent runtime crashes, update the signature of
forwardinNpuGroupedLoraLinearto accept*argsand**kwargs.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.
In
_NpuGroupedLoraLinearGMM.forward,weight_input_Tis a tuple of tensors. Thetorch_npu.npu_grouped_matmuloperator expects a list of tensors for its inputs and weights. Passing a tuple instead of a list can lead to type errors or undefined behavior in the C++ bindings oftorch_npu.Convert
weight_input_Tto a list before passing it tonpu_grouped_matmul.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.
In
_NpuGroupedLoraLinearGMM.backward,weightsis retrieved as a slice ofctx.saved_tensors, which is a tuple. Similar to the forward pass,torch_npu.npu_grouped_matmulexpects a list of tensors.Convert
weightsto a list before passing it tonpu_grouped_matmul.Uh oh!
There was an error while loading. Please reload this page.