-
Notifications
You must be signed in to change notification settings - Fork 13
npu qwen3.5 megatron padding_free fix #50
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |||||
| from megatron.core.transformer.transformer_block import TransformerBlockSubmodules | ||||||
| from megatron.core.utils import deprecate_inference_params, is_fa_min_version | ||||||
| from packaging import version | ||||||
| from transformers.utils import is_torch_npu_available | ||||||
| from typing import Optional, Tuple, Union | ||||||
|
|
||||||
| from mcore_bridge.bridge import GPTBridge | ||||||
|
|
@@ -58,6 +59,17 @@ | |||||
| logger = get_logger() | ||||||
|
|
||||||
|
|
||||||
| def resolve_gdn_attention_mask(kwargs) -> Optional[torch.Tensor]: | ||||||
| if is_torch_npu_available(): | ||||||
| attention_mask = kwargs.get('attention_mask_2d') | ||||||
| if attention_mask is not None: | ||||||
| return attention_mask.to(torch.bool) | ||||||
| attention_mask = kwargs.get('attention_mask') | ||||||
| if attention_mask is None: | ||||||
| return None | ||||||
| return (~attention_mask).sum(dim=(1, 2)) > 0 | ||||||
|
|
||||||
|
|
||||||
| class Qwen3NextRMSNorm(torch.nn.Module): | ||||||
| """ | ||||||
| Zero-Centered RMSNorm for Qwen3-Next. | ||||||
|
|
@@ -485,9 +497,7 @@ def forward(self, hidden_states: torch.Tensor, **kwargs): | |||||
| hidden_states = new_hidden_states | ||||||
| else: | ||||||
| hidden_states = hidden_states.transpose(0, 1) | ||||||
| attention_mask = kwargs.get('attention_mask') | ||||||
| if attention_mask is not None: | ||||||
| attention_mask = (~attention_mask).sum(dim=(1, 2)) > 0 | ||||||
| attention_mask = resolve_hf_attention_mask(kwargs) | ||||||
|
||||||
| attention_mask = resolve_hf_attention_mask(kwargs) | |
| attention_mask = resolve_gdn_attention_mask(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.
The function call
resolve_hf_attention_mask(kwargs)appears to be a typo. The function defined earlier in this file (at line 62) is namedresolve_gdn_attention_mask. Using the incorrect name will result in aNameErrorat runtime.