add Qwen3.5 MTP & CP Training Support and NPU Base Environment Upgrade - #288
add Qwen3.5 MTP & CP Training Support and NPU Base Environment Upgrade#288Lw135 wants to merge 17 commits into
Conversation
feat(docker): upgrade NPU env to CANN 9.0.0 with FLA and MindSpeed-Ops # ⭐ Feature ## Upgrade CANN base image and toolchain - Upgrade CANN base image from 8.5.1-a3 to 9.0.0-a3 - Upgrade torch_npu from v2.9.0-7.3.0 to v26.0.1-pytorch2.9.0 - Upgrade triton-ascend from 3.2.0 to 3.2.1 ## Add AscendC Flash Linear Attention (FLA) support - Clone and build fla_npu from flash-linear-attention-npu v26.1.0 - Compile causal_conv1d and gated_delta_rule ops for ascend910_93 ## Add MindSpeed-Ops support - Clone, checkout and install MindSpeed-Ops - Add mindspeed-ops.patch for gated_delta_rule autotune key fix --- # ♻️ Refactor ## Restructure Dockerfile build order - Move torch/torch_npu install before repo clone - Delay COPY . /root/Relax to just before patching - Consolidate Megatron-Bridge into Megatron-LM via cp instead of separate path - Install MindSpeed-Bridge with --no-deps to avoid circular dependency ## Migrate mindspeed-bridge to FLA ops - Replace causal_conv1d from causal_conv1d with FLA implementation - Replace mindspeed_ops l2norm with naive_l2norm fallback - Switch to flash_gated_delta_rule when FLA is available --- # 🐛 Bug Fix ## Fix various compatibility issues - Fix autotune key in gated_delta_rule kernel by removing USE_G and IS_VARLEN - Fix lambda closure bug in transformer_config_init_subclass (use default arg binding) - Fix attention_mask dtype from int32 to bool in model preprocess - Fix vision model config with MoE permute fusion disabled - Handle OmegaConf DictConfig/ListConfig in remove_non_pickleables - Guard apex MixedFusedLayerNorm import with is_npu_available check ## Update sgl-kernel-npu - Upgrade sgl-kernel-npu checkout from 2026.04.15.rc3 to 2026.7.2 - Remove obsolete cherry-pick workaround feat(docker): upgrade NPU env to CANN 9.0.0 with FLA and MindSpeed-Ops feat(docker): upgrade NPU env to CANN 9.0.0 with FLA and MindSpeed-Ops # ⭐ Feature ## Upgrade CANN base image and toolchain - Upgrade CANN base image from 8.5.1-a3 to 9.0.0-a3 - Upgrade torch_npu from v2.9.0-7.3.0 to v26.0.1-pytorch2.9.0 - Upgrade triton-ascend from 3.2.0 to 3.2.1 ## Add AscendC Flash Linear Attention (FLA) support - Clone and build fla_npu from flash-linear-attention-npu v26.1.0 - Compile causal_conv1d and gated_delta_rule ops for ascend910_93 ## Add MindSpeed-Ops support - Clone, checkout and install MindSpeed-Ops - Add mindspeed-ops.patch for gated_delta_rule autotune key fix --- # ♻️ Refactor ## Restructure Dockerfile build order - Move torch/torch_npu install before repo clone - Delay COPY . /root/Relax to just before patching - Consolidate Megatron-Bridge into Megatron-LM via cp instead of separate path - Install MindSpeed-Bridge with --no-deps to avoid circular dependency ## Migrate mindspeed-bridge to FLA ops - Replace causal_conv1d from causal_conv1d with FLA implementation - Replace mindspeed_ops l2norm with naive_l2norm fallback - Switch to flash_gated_delta_rule when FLA is available --- # 🐛 Bug Fix ## Fix various compatibility issues - Fix autotune key in gated_delta_rule kernel by removing USE_G and IS_VARLEN - Fix lambda closure bug in transformer_config_init_subclass (use default arg binding) - Fix attention_mask dtype from int32 to bool in model preprocess - Fix vision model config with MoE permute fusion disabled - Handle OmegaConf DictConfig/ListConfig in remove_non_pickleables - Guard apex MixedFusedLayerNorm import with is_npu_available check ## Update sgl-kernel-npu - Upgrade sgl-kernel-npu checkout from 2026.04.15.rc3 to 2026.7.2 - Remove obsolete cherry-pick workaround [NPU] update sglang
Merge branch 'wqw_base_lw_dev_0808' into ascend-dev-0808 Created-by: dabuliu123 Commit-by: wuqiwei;lixionglong;dabuliu123;@dabuliu123 Merged-by: dabuliu123 Description: ## What <!-- What changes does this PR introduce? --> ## Why <!-- Why are these changes needed? Link related issues with "Fixes redai-studio#123" or "Relates to #456". --> ## How <!-- How do the changes work? Describe the technical approach. --> ## Testing <!-- How were the changes tested? Include commands, test results, or screenshots. --> - [ ] `pre-commit run --all-files` passes - [ ] Tests pass (`pytest tests/`) - [ ] New tests added (if applicable) - [ ] Documentation updated (if applicable) ## Type of Change - [ ] Bug fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Refactoring (no functional changes) - [ ] Performance improvement - [ ] CI/CD or build changes ## Screenshots / Logs <!-- If applicable, add screenshots or log output to help explain the changes. --> See merge request: hw-pbclouds/Relax!57
# 🐛 Bug Fix ## Fix bridge mapping registry failure with PP > 1 - Set model_bridge._hf_config from bridge.hf_pretrained.config when missing
# 🔩 Chore ## Sync NPU patches - Add sgl-kernel-npu.patch (1847 lines) - Update sglang-npu.patch (+1070 lines) - Update mindspeed.patch / mindspeed-bridge.patch / megatron patches
# 🔩 Chore ## Upgrade NPU Dockerfile dependencies - Bump base image CANN 8.5.1 → 9.0.0 - Upgrade torch_npu to v26.0.1 (PyTorch 2.9.0) - Upgrade triton-ascend 3.2.0 → 3.2.1
feat(npu): add Qwen3.5 MTP training scripts for 0821 # ⭐ Feature ## Add Qwen3.5 MTP training launch scripts - run_qwen35-35B-pokemon-sft-mtp-8xnpu.sh: Qwen3.5-35B-A3B MTP SFT on pokemon-gpt4o-captions, 8xNPU single-node, ray-submit launch - run_qwen35-35B-A3B-16xnpu-colocate-thd.sh: Qwen3.5-35B-A3B colocate THD training on 16xNPU - run_qwen35_9B_mtp_8xnpu_thd.sh: Qwen3.5-9B MTP THD training on 8xNPU --- # 🐛 Bug Fix ## Fix EXP_DIR silently overridden by MODEL_DIR default - EXP_DIR now uses its own default with MODEL_DIR following EXP_DIR, matching the 9B THD script pattern --- # 🔩 Chore ## Align script naming and comments - Rename scripts to the 8xnpu naming convention and drop duplicated .sh suffix - Remove commented-out --qkv-format bshd / --micro-batch-size 1 lines - Sync Usage comments with actual script names
feat(npu): add Qwen3.5 MTP SFT/training scripts Created-by: Tgz27 Commit-by: 唐二十七 Merged-by: Tgz27 Description: 新增 3 个 NPU MTP 训练脚本: - run_qwen35-35B-pokemon-sft-mtp.sh: 35B-A3B MTP SFT on pokemon dataset, 8xNPU - run_qwen35-35B-A3B-16xnpu-colocate-thd.sh: 35B-A3B colocate THD training on 16xNPU - run_qwen35_9B_mtp_8npu_thd.sh.sh: 9B MTP THD training on 8xNPU See merge request: hw-pbclouds/Relax!58
This reverts commit 57809b4.
…idge_converter.py
feat(npu): add Qwen3.5-9B CP training script # ⭐ Feature ## Add Qwen3.5-9B CP colocate training script - Add run-qwen35-9B-8xnpu-cp.sh for DAPO math training with TP4/CP4 on 16 NPUs - Set MINDSPEED_BRIDGE_GDN_USE_TORCH_CONV=1 to use torch conv fallback for GDN ## Support GDN causal conv on NPU via fla_npu - Replace causal_conv1d with fla_npu in mindspeed-bridge.patch GDN layer - Add MINDSPEED_BRIDGE_GDN_USE_TORCH_CONV env switch to fall back to torch conv --- # 🐛 Bug Fix ## Fix repatch ordering before Megatron init - Move repatch(args) before init(args) in MegatronTrainRayActor so bridge patches apply during initialization fix(npu): rename Qwen3.5-9B CP script to 16xnpu # 🐛 Bug Fix ## Fix Qwen3.5-9B CP script naming for 16 NPUs - Rename run-qwen35-9B-8xnpu-cp.sh to run-qwen35-9B-16xnpu-cp.sh to match the actual 16-NPU setup - Update header comment to 16xNPU and log filename to qwen35-9B-GRPO-npu16 docs(npu): add feature support table # 📝 Documentation ## Add feature support table to NPU training guide - Add 特性支持 table covering Qwen3.5-9B CP, Qwen3.5-9B MTP, and Qwen3.5-35B-A3B SFT MTP with reference scripts - Update 下一步 checklist from feature support to performance optimization - Fix MTP row minimum card count to 4卡 to match the script's 8 NPUs
fix(npu): rename Qwen3.5-9B CP script to 16xnpu Created-by: dabuliu123 Commit-by: dabuliu123 Merged-by: dabuliu123 Description: ## What <!-- What changes does this PR introduce? --> ## Why <!-- Why are these changes needed? Link related issues with "Fixes redai-studio#123" or "Relates to #456". --> ## How <!-- How do the changes work? Describe the technical approach. --> ## Testing <!-- How were the changes tested? Include commands, test results, or screenshots. --> - [ ] `pre-commit run --all-files` passes - [ ] Tests pass (`pytest tests/`) - [ ] New tests added (if applicable) - [ ] Documentation updated (if applicable) ## Type of Change - [ ] Bug fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Refactoring (no functional changes) - [ ] Performance improvement - [ ] CI/CD or build changes ## Screenshots / Logs <!-- If applicable, add screenshots or log output to help explain the changes. --> See merge request: hw-pbclouds/Relax!59
# 🔒 Security
## Remove hardcoded internal paths from Qwen3.5 NPU scripts
- Replace /mnt/tidalfs-hwwh01 EXP_DIR defaults with the repo-standard `${SCRIPT_DIR}/../../../../exps` in run_qwen35-35B-pokemon-sft-mtp-8xnpu.sh, run_qwen35-35B-A3B-16xnpu-colocate-thd.sh and run_qwen35_9B_mtp_8xnpu_thd.sh
- Replace bare /mnt/ placeholder in run-qwen35-9B-16xnpu-cp.sh with the same repo-standard default
- Switch the SFT script DATA_DIR default to the `${DATA_DIR:-${EXP_DIR}}` convention used by all other training scripts
---
# 🎨 Style
## End-of-file fixer
- Remove trailing blank line from docker/Dockerfile.npu
Co-Authored-By: Claude <noreply@anthropic.com>
|
建议修改: P1 — 指定 token-ID logprobs 的请求会直接报 AttributeError。 P1 — Qwen2-MoE 的 NPU multi-stream 路径必崩。 P1 — 当前 NPU Dockerfile 无法从声明的干净 base 完成构建。 P1 — 新 CP 脚本会把 WANDB_API_KEY 明文写入日志。 P2 — MTP_NUM_LAYERS > 1 时 bridge 权重转换缺少 layer 1+ 映射。 P2 — top-logprob 路径对全词表执行了两次 topk。 |
add validation in the *sft.sh script to ensure that MTP_NUM_LAYERS can only be 1
fix: enforce MTP_NUM_LAYERS=1 for Qwen3.5 NPU scripts Created-by: lixionglong Commit-by: lixionglong Merged-by: lixionglong Description: ## What <!-- What changes does this PR introduce? --> 在 Qwen3.5 的 NPU MTP 启动脚本(`scripts/training/text/run_qwen35_9B_mtp_8xnpu_thd.sh`、`scripts/training/sft/run_qwen35-35B-pokemon-sft-mtp-8xnpu.sh`)中加入 `MTP_NUM_LAYERS` 校验:开启 MTP 训练时该参数只能为 `1`,否则脚本报错退出;同时在 `docker/npu-training.md` 中补充了该约束的说明。 ## Why <!-- Why are these changes needed? Link related issues with "Fixes redai-studio#123" or "Relates to #456". --> Qwen3.5 原始 checkpoint 中只包含 1 层 MTP 权重(`mtp_num_hidden_layers=1`),若用户将 `MTP_NUM_LAYERS` 设为非 `1` 的值,训练会在模型加载/初始化阶段失败且报错不直观。增加快速校验可以让非法配置在脚本启动阶段就给出明确报错(fail fast)。 ## How <!-- How do the changes work? Describe the technical approach. --> 两个脚本在组装 `MTP_ARGS` 前检查 `${MTP_NUM_LAYERS:-1}`(未设置时默认为 `1`):若值非 `1`,向 stderr 输出 `ERROR: MTP_NUM_LAYERS must be 1 for Qwen3.5 (checkpoint has mtp_num_hidden_layers=1).` 并以退出码 `1` 终止。 ## Testing <!-- How were the changes tested? Include commands, test results, or screenshots. --> 纯 shell 启动脚本改动,不涉及 Python 代码,`pytest tests/` 不受影响。可通过如下命令快速验证校验逻辑: ```bash MTP_NUM_LAYERS=2 bash scripts/training/text/run_qwen35_9B_mtp_8xnpu_thd.sh # 应报错退出 bash scripts/training/text/run_qwen35_9B_mtp_8xnpu_thd.sh # 未设置,默认 1,校验通过 See merge request: hw-pbclouds/Relax!60
fix(docker): install gawk non-interactively # 🐛 Bug Fix ## Make gawk install non-interactive in NPU Dockerfile - Replace `apt install gawk` with `apt-get install -y --no-install-recommends gawk` - `apt install` prompts for confirmation and aborts in unattended Docker builds refactor(npu): drop wandb wiring from CP script # ♻️ Refactor ## Drop script-local wandb wiring from Qwen3.5-9B CP script - Remove WANDB_API_KEY injection into Ray runtime_env via jq - Remove WANDB_API_KEY-gated --use-wandb/--wandb-project/--wandb-group args - Wandb is configured centrally via --use-wandb/--wandb-key CLI args
refactor(npu): drop wandb wiring from CP script Created-by: dabuliu123 Commit-by: dabuliu123 Merged-by: Tgz27 Description: ## What <!-- What changes does this PR introduce? --> ## Why <!-- Why are these changes needed? Link related issues with "Fixes redai-studio#123" or "Relates to #456". --> ## How <!-- How do the changes work? Describe the technical approach. --> ## Testing <!-- How were the changes tested? Include commands, test results, or screenshots. --> - [ ] `pre-commit run --all-files` passes - [ ] Tests pass (`pytest tests/`) - [ ] New tests added (if applicable) - [ ] Documentation updated (if applicable) ## Type of Change - [ ] Bug fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Refactoring (no functional changes) - [ ] Performance improvement - [ ] CI/CD or build changes ## Screenshots / Logs <!-- If applicable, add screenshots or log output to help explain the changes. --> See merge request: hw-pbclouds/Relax!61
This batch of merges focuses on NPU (Ascend) support upgrades and Qwen3.5 training capabilities, including a CANN 9.0.0 base-image upgrade, an NPU patch-set refresh, and new Qwen3.5 MTP / CP training scripts along with related fixes.
Key Changes
1. NPU Base Environment Upgrade
Dockerfile.npu2. Qwen3.5 MTP Training Support
run_qwen35_9B_mtp_8xnpu_thd.sh(9B, 8-NPU THD)run_qwen35-35B-pokemon-sft-mtp-8xnpu.sh(SFT example)_hf_configattachment when pp>1, and updated the Qwen3.5 MTP weight mapping in the mindspeed-bridge patch3. Qwen3.5-9B CP (Context Parallel) Training
4. Documentation
docker/npu-training.mdMajor Commits
25a42cc3f51dcc9d3ac5e700b291/e5f12e50127ec457809b4_hf_configfor MTP bridge when pp>141606129c39605