Repository navigation
Conversation
- Reuse the existing NPU GMM implementation for Xing4 grouped experts while preserving FP32 routing precision. - Add an Ascend FSDP2 LoRA SFT example with FlashAttention 2 and packing. - Add regression tests for expert dispatch, weight layouts and packed LoRA gradients. - Fix uninitialized buffers in the existing tiny-model test fixture. Co-authored-by: Codex
This branch has not been deployed
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.
PR type
PR information
This PR optimizes Grouped MM expert computation for Xing4.0-29B-A4B on Ascend NPUs and adds an FSDP2 LoRA SFT training example.
In the tested Ascend NPU environment, the native Grouped MM path performs individual expert matrix multiplications. This PR reuses the existing NPU Grouped Matmul implementation in ms-swift to improve end-to-end training performance.
The main changes include:
GmmFunctionfor Xing4 expert computation while preserving the original weight layout, dtype conversion, and FP32 routing semantics.Experiment results
Environment
Training configuration
The native and optimized Grouped MM implementations were evaluated for 120 LoRA SFT steps on 8 Ascend A3 NPUs, using identical initial model weights, LoRA parameters, training data, data order, and training configurations.
Training comparison
Both implementations successfully completed 120 training steps. The loss and gradient norm remained finite throughout training, with closely matching training curves.
Performance comparison
Each run consists of 120 optimizer steps, with the first 20 steps used for warmup and the remaining 100 steps used for performance measurement. Checkpoint saving is disabled during benchmarking.
The measured results show a 20.01% reduction in average step time and a 25.02% increase in token throughput.
Intermittent external workloads were observed during the native run.
Tests
Checklist