Fix local/unfused Megatron attention and LoRA on Ascend - #9864
Draft
hazelduan wants to merge 3 commits into
Draft
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
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.
Summary
use_flash_attndisabled and reject padding-free mode for thelocalandunfusedbackendsColumnParallelLinearandRowParallelLinearwhen resolvingall-linearLoRA targetsRoot cause
attention_backendis normalized to an enum, but the NPU path compared it with the string"local". The comparison therefore enabled MindSpeed flash attention and generated an NPU flash-attention mask even for local attention. Local MCore attention also does not support padding-free packed sequences.The same legacy condition treated every backend except
localas flash attention. On NPU this silently routed the explicitunfusedbackend back through MindSpeed FlashAttention.unfusednow disables the flash flag and generated flash-attention mask while retaining its distinct backend value.After selecting a true local MCore layer spec, LoRA target discovery found no modules because it only recognized Transformer Engine linear classes. The local parallel linear classes are now included without changing TE targeting.
Validation
dxq, MindSpeed, Megatron Core 0.16.0, BF16, Qwen3-0.6B, a fixed 500-row dataset,padding_free=false, and identical seed/configuration for local and flash runscheckpoint-100All six valid runs completed 100 optimizer steps. SFT unfused/flash per-step loss correlation was 0.99992 with mean absolute delta 0.00546. GKD unfused/flash total-loss correlation was 0.99912 with mean absolute delta 0.00197; JSD-loss correlation was 0.99419. The GKD runs executed separate student and frozen-teacher forwards on every step and logged total loss, JSD loss, SFT loss, and grad norm.
The A3 image required test-only import shims for unused optional
acl/FLA paths; these are not repository changes. A separate Qwen3-30B-A3B teacher attempt reached local MoE construction but exposed an existing unsupportedMindSpeedGmmExpertsgrouped-weight loading layout. The controlled dense student/teacher comparison above keeps the test focused on the attention and LoRA changes in this PR.Paired PR: modelscope/mcore-bridge#159