Skip to content

feat(npu): Add FSDP2 LoRA example for Qwen3.8-27B for Ascend NPU - #9920

Merged
hjh0119 merged 2 commits into
modelscope:mainfrom
zheliuyu:feat/ascend-qwen3-8-27b-lora-fsdp2-16card
Aug 18, 2026
Merged

hjh0119 merged 2 commits into
modelscope:mainfrom
zheliuyu:feat/ascend-qwen3-8-27b-lora-fsdp2-16card

Conversation

@zheliuyu

@zheliuyu zheliuyu commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Add Qwen3.8-27B Ascend NPU FSDP2 LoRA Training Example

ms-swift + flash-linear-attention NPU adaptation

Summary

Qwen3.8 and Qwen3.5 share a similar architecture—both use GDN—so this PR is primarily about demonstrating that ms-swift + flash-linear-attention works on Ascend NPU.

The main advantage of this setup is that no extra NPU training stack is required: both ms-swift and flash-linear-attention provide native NPU support.

Timeline for this PR:

  • Aug 14 — Qwen3.8 open-sourced; swap in the Qwen3.8 model name, verify training, and open the PR
  • Aug 13 — Environment setup; validate end-to-end training with Qwen3.5 first
  • Early Aug — ms-swift + flash-linear-attention fully working on Qwen3.5
  • Early Jul — flash-linear-attention NPU adaptation
  • ms-swift NPU adaptation

PR Type

  • Bug Fix
  • New Feature
  • Document Updates
  • More Models or Datasets Support

Description

Adds an FSDP2 + LoRA SFT training example for Qwen3.8-27B on Ascend NPU, ready for post-release NPU adaptation.

New files

  • examples/ascend/train/qwen3_8/qwen3_8_27b_lora_fsdp2.sh — training entry script
  • examples/ascend/train/qwen3_8/qwen3_8_27b_fsdp2.json — Accelerate FSDP2 config

Key points

  • Transformers path + FLA GDN (USE_MCORE_GDN=0), with packing=true and max_length=2048
  • Requires explicit --model_type qwen3_5 (Qwen3.8 config also matches ovis_ocr2, so auto-detection fails)
  • flash-linear-attention commit: ab181c671576fd9cdeed678d216a6273185be700

Environment setup

pip install torch==2.7.1 torch_npu==2.7.1.post4 torchvision==0.22.1 torchaudio==2.7.1
pip install triton-ascend==3.2.1 --extra-index-url=https://mirrors.huaweicloud.com/ascend/repos/pypi
source /home/cann/cann9.1.0/ascend-toolkit/set_env.sh

git clone https://github.com/fla-org/flash-linear-attention.git
pip install -e ./ --no-deps

git clone https://github.com/modelscope/ms-swift.git
pip install -e ./

Usage

bash examples/ascend/train/qwen3_8/qwen3_8_27b_lora_fsdp2.sh

# Use local weights
MODEL=/path/to/Qwen3.8-27B bash examples/ascend/train/qwen3_8/qwen3_8_27b_lora_fsdp2.sh

Results

loss grad_norm memory_gib token_acc train_speed learning_rate

Prepare 0-day NPU training script and accelerate config ahead of the Qwen3.8-27B release. Date: 2026/08/14-22:52
@zheliuyu
zheliuyu marked this pull request as ready for review August 14, 2026 17:24
@zheliuyu zheliuyu changed the title Add Ascend NPU FSDP2 LoRA example for Qwen3.8-27B feat(npu): Add FSDP2 LoRA example for Qwen3.8-27B for Ascend NPU Aug 18, 2026
@zheliuyu

Copy link
Copy Markdown
Contributor Author
image

@hjh0119 @tastelikefeet The failing citest / unittest job looks unrelated to this PR. This change only adds Ascend example scripts; lint and citest-npu both passed.

The GPU unittest failure matches the known CUDA CI issue in #9862: pip install . in ci_container_test.sh re-resolves transformers onto 5.x (and/or later suites get polluted by the StructBERT remote-code install), then imports such as transformers.models.gemma3 fail.

Should we wait for that CI fix to land and then re-run unittest before requesting review, or is it fine to review this PR as-is?

@hjh0119
hjh0119 merged commit 191313a into modelscope:main Aug 18, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants