已合并
feat: for the FSDP2 backend README, always pull from the MindSpeed master branch. #2869
feat: for the FSDP2 backend README, always pull from the MindSpeed master branch. #2869
已合并
xubin创建于 7月21日
11 个文件变更+55-22
@@ -67,7 +67,7 @@ commit_id=7eb5002
67执行如下指令一键安装:67执行如下指令一键安装:
68 68 
69```bash69```bash
70-bash scripts/install.sh && bash pip install tiktoken==0.12.070+bash scripts/install.sh --msbranch 26.1.0_core_r0.12.1 && bash pip install tiktoken==0.12.0
71```71```
72 72 
73---73---
@@ -85,7 +85,7 @@ commit_id=28c3c73fe557666c3de176e1e50a5220152ccfca
85git clone https://gitcode.com/Ascend/MindSpeed-MM.git85git clone https://gitcode.com/Ascend/MindSpeed-MM.git
86 86 
87# 2. 安装 mindspeed 及依赖(如已集成可跳过)87# 2. 安装 mindspeed 及依赖(如已集成可跳过)
88-git clone https://gitcode.com/Ascend/MindSpeed.git88+git clone -b 26.1.0_core_r0.12.1 https://gitcode.com/Ascend/MindSpeed.git
89cd MindSpeed89cd MindSpeed
90cp -r mindspeed ../MindSpeed-MM/90cp -r mindspeed ../MindSpeed-MM/
91cd ../MindSpeed-MM91cd ../MindSpeed-MM
@@ -64,7 +64,7 @@ cd MindSpeed-MM
64执行如下指令一键安装:64执行如下指令一键安装:
65 65 
66```bash66```bash
67-bash scripts/install.sh --msid eb10b92 && pip install transformers==5.2.0 accelerate==1.2.067+bash scripts/install.sh --msbranch 26.1.0_core_r0.12.1 && pip install transformers==5.2.0 accelerate==1.2.0
68```68```
69 69 
70---70---
@@ -59,7 +59,7 @@ commit_id=fd7dac7
59git clone https://gitcode.com/Ascend/MindSpeed-MM.git59git clone https://gitcode.com/Ascend/MindSpeed-MM.git
60 60 
61# 安装mindspeed及依赖61# 安装mindspeed及依赖
62-git clone https://gitcode.com/Ascend/MindSpeed.git62+git clone -b 26.1.0_core_r0.12.1 https://gitcode.com/Ascend/MindSpeed.git
63cd MindSpeed63cd MindSpeed
64cp -r mindspeed ../MindSpeed-MM/64cp -r mindspeed ../MindSpeed-MM/
65 65 
@@ -68,7 +68,7 @@ cd MindSpeed-MM
68执行如下指令一键安装:68执行如下指令一键安装:
69 69 
70```bash70```bash
71-bash scripts/install.sh --msid eb10b92 && bash examples/qwen3_5/install_extensions.sh71+bash scripts/install.sh --msbranch 26.1.0_core_r0.12.1 && bash examples/qwen3_5/install_extensions.sh
72```72```
73 73 
74### 3. 安装配套版本的Triton-Ascend74### 3. 安装配套版本的Triton-Ascend
@@ -59,7 +59,7 @@ cd MindSpeed-MM
59执行如下指令安装:59执行如下指令安装:
60 60 
61```bash61```bash
62-bash scripts/install.sh --msid eb10b9262+bash scripts/install.sh --msbranch 26.1.0_core_r0.12.1
63pip install transformers==5.2.0 triton-ascend==3.2.0 accelerate==1.2.063pip install transformers==5.2.0 triton-ascend==3.2.0 accelerate==1.2.0
64```64```
65 65 
@@ -60,7 +60,7 @@ commit_id=7a833d1
60```bash60```bash
61git clone https://gitcode.com/Ascend/MindSpeed-MM.git61git clone https://gitcode.com/Ascend/MindSpeed-MM.git
62# 安装mindspeed及依赖62# 安装mindspeed及依赖
63-git clone https://gitcode.com/Ascend/MindSpeed.git63+git clone -b 26.1.0_core_r0.12.1 https://gitcode.com/Ascend/MindSpeed.git
64cd MindSpeed64cd MindSpeed
65cp -r mindspeed ../MindSpeed-MM/65cp -r mindspeed ../MindSpeed-MM/
66 66 
@@ -57,7 +57,7 @@ commit_id=022e286
57git clone https://gitcode.com/Ascend/MindSpeed-MM.git57git clone https://gitcode.com/Ascend/MindSpeed-MM.git
58 58 
59# 安装mindspeed及依赖59# 安装mindspeed及依赖
60-git clone https://gitcode.com/Ascend/MindSpeed.git60+git clone -b 26.1.0_core_r0.12.1 https://gitcode.com/Ascend/MindSpeed.git
61cd MindSpeed61cd MindSpeed
62cp -r mindspeed ../MindSpeed-MM/62cp -r mindspeed ../MindSpeed-MM/
63 63 
@@ -61,7 +61,7 @@ commit_id=c0dbe09
61git clone https://gitcode.com/Ascend/MindSpeed-MM.git61git clone https://gitcode.com/Ascend/MindSpeed-MM.git
62 62 
63# 安装mindspeed及依赖63# 安装mindspeed及依赖
64-git clone https://gitcode.com/Ascend/MindSpeed.git64+git clone -b 26.1.0_core_r0.12.1 https://gitcode.com/Ascend/MindSpeed.git
65cd MindSpeed65cd MindSpeed
66cp -r mindspeed ../MindSpeed-MM/66cp -r mindspeed ../MindSpeed-MM/
67 67 
@@ -51,7 +51,7 @@ url=https://huggingface.co/stepfun-ai/Step3-VL-10B
51git clone https://gitcode.com/Ascend/MindSpeed-MM.git51git clone https://gitcode.com/Ascend/MindSpeed-MM.git
52 52 
53# 安装mindspeed及依赖53# 安装mindspeed及依赖
54-git clone https://gitcode.com/Ascend/MindSpeed.git54+git clone -b 26.1.0_core_r0.12.1 https://gitcode.com/Ascend/MindSpeed.git
55cd MindSpeed55cd MindSpeed
56cp -r mindspeed ../MindSpeed-MM/56cp -r mindspeed ../MindSpeed-MM/
57 57 
@@ -8,6 +8,7 @@ Usage: $0 [OPTIONS]
8Options:8Options:
9 -t, --torchversion VERSION PyTorch version to install (default: 2.7.1)9 -t, --torchversion VERSION PyTorch version to install (default: 2.7.1)
10 -m, --msid COMMIT_ID MindSpeed commit ID (optional, use latest if not specified)10 -m, --msid COMMIT_ID MindSpeed commit ID (optional, use latest if not specified)
11+ -b, --msbranch BRANCH MindSpeed branch name (optional, mutually exclusive with --msid)
11 -y, --yes Auto confirm all reinstallations12 -y, --yes Auto confirm all reinstallations
12 -n, --no Auto skip all reinstallations13 -n, --no Auto skip all reinstallations
13 -mt, --megatron Install Megatron-LM14 -mt, --megatron Install Megatron-LM
@@ -18,6 +19,9 @@ Examples:
18 # Install with latest MindSpeed (no commit ID)19 # Install with latest MindSpeed (no commit ID)
19 bash $0 --torchversion 2.7.1 --install-cann20 bash $0 --torchversion 2.7.1 --install-cann
20 21 
22+ # Install with specific MindSpeed branch
23+ bash $0 --torchversion 2.7.1 --msbranch master --install-cann
24+ 
21 # Install with specific commit ID25 # Install with specific commit ID
22 bash $0 --torchversion 2.7.1 --msid 93c45456c7044bacddebc5072316c01006c938f9 --install-cann26 bash $0 --torchversion 2.7.1 --msid 93c45456c7044bacddebc5072316c01006c938f9 --install-cann
23 27 
@@ -38,6 +42,7 @@ EOF
38# Default values42# Default values
39TORCH_VERSION="2.7.1"43TORCH_VERSION="2.7.1"
40MINDSPEED_COMMIT_ID=""44MINDSPEED_COMMIT_ID=""
45+MINDSPEED_BRANCH=""
41AUTO_CONFIRM="" # Auto confirm mode: "", "yes", "no"46AUTO_CONFIRM="" # Auto confirm mode: "", "yes", "no"
42INSTALL_MEGATRON=false # Whether to install Megatron-LM47INSTALL_MEGATRON=false # Whether to install Megatron-LM
43INSTALL_CANN=false # Whether to install CANN48INSTALL_CANN=false # Whether to install CANN
@@ -47,6 +52,7 @@ while [[ $# -gt 0 ]]; do
47 case $1 in52 case $1 in
48 -t|--torchversion) TORCH_VERSION="$2"; shift 2 ;;53 -t|--torchversion) TORCH_VERSION="$2"; shift 2 ;;
49 -m|--msid) MINDSPEED_COMMIT_ID="$2"; shift 2 ;;54 -m|--msid) MINDSPEED_COMMIT_ID="$2"; shift 2 ;;
55+ -b|--msbranch) MINDSPEED_BRANCH="$2"; shift 2 ;;
50 -y|--yes) AUTO_CONFIRM="yes"; shift ;;56 -y|--yes) AUTO_CONFIRM="yes"; shift ;;
51 -n|--no) AUTO_CONFIRM="no"; shift ;;57 -n|--no) AUTO_CONFIRM="no"; shift ;;
52 -mt|--megatron) INSTALL_MEGATRON=true; shift ;;58 -mt|--megatron) INSTALL_MEGATRON=true; shift ;;
@@ -56,11 +62,24 @@ while [[ $# -gt 0 ]]; do
56 esac62 esac
57done63done
58 64 
65+# Validate that --msid and --msbranch are mutually exclusive
66+if [ -n "$MINDSPEED_COMMIT_ID" ] && [ -n "$MINDSPEED_BRANCH" ]; then
67+ echo "Error: --msid and --msbranch are mutually exclusive. Please specify only one."
68+ show_help
69+ exit 1
70+fi
71+ 
59echo "========================================"72echo "========================================"
60echo "Installation Configuration"73echo "Installation Configuration"
61echo "========================================"74echo "========================================"
62echo "PyTorch Version: $TORCH_VERSION"75echo "PyTorch Version: $TORCH_VERSION"
63-echo "MindSpeed Commit ID: ${MINDSPEED_COMMIT_ID:-"latest"}"76+if [ -n "$MINDSPEED_BRANCH" ]; then
77+ echo "MindSpeed Branch: $MINDSPEED_BRANCH"
78+elif [ -n "$MINDSPEED_COMMIT_ID" ]; then
79+ echo "MindSpeed Commit ID: $MINDSPEED_COMMIT_ID"
80+else
81+ echo "MindSpeed: latest"
82+fi
64echo "Auto Confirm Mode: ${AUTO_CONFIRM:-"interactive"}"83echo "Auto Confirm Mode: ${AUTO_CONFIRM:-"interactive"}"
65echo "Install Megatron-LM: $INSTALL_MEGATRON"84echo "Install Megatron-LM: $INSTALL_MEGATRON"
66echo "Install CANN: $INSTALL_CANN"85echo "Install CANN: $INSTALL_CANN"
@@ -220,8 +239,9 @@ if [ "$INSTALL_CANN" = true ]; then
220 # Call install_cann.sh and pass ARCH parameter239 # Call install_cann.sh and pass ARCH parameter
221 echo "Calling install_cann.sh with architecture: $ARCH"240 echo "Calling install_cann.sh with architecture: $ARCH"
222 # Execute CANN installation script241 # Execute CANN installation script
223- if ! "$CANN_INSTALL_SCRIPT" "$ARCH"; then242+ "$CANN_INSTALL_SCRIPT" "$ARCH"
224- cann_exit_code=$?243+ cann_exit_code=$?
244+ if [ $cann_exit_code -ne 0 ]; then
225 echo "Error: CANN installation failed with exit code: $cann_exit_code"245 echo "Error: CANN installation failed with exit code: $cann_exit_code"
226 echo "Aborting installation due to CANN installation failure."246 echo "Aborting installation due to CANN installation failure."
227 exit 1247 exit 1
@@ -555,19 +575,30 @@ else
555fi575fi
556 576 
557# Install mindspeed with retry mechanism577# Install mindspeed with retry mechanism
558-if [ -z "$MINDSPEED_COMMIT_ID" ]; then578+if [ -n "$MINDSPEED_BRANCH" ]; then
559- echo "[INFO] Installing MindSpeed with latest version (no commit ID specified)"579+ echo "[INFO] Installing MindSpeed with branch: $MINDSPEED_BRANCH"
560-else580+elif [ -n "$MINDSPEED_COMMIT_ID" ]; then
561 echo "[INFO] Installing MindSpeed with commit ID: $MINDSPEED_COMMIT_ID"581 echo "[INFO] Installing MindSpeed with commit ID: $MINDSPEED_COMMIT_ID"
582+else
583+ echo "[INFO] Installing MindSpeed with latest version (no commit ID or branch specified)"
562fi584fi
563 585 
564if [ ! -d "MindSpeed" ]; then586if [ ! -d "MindSpeed" ]; then
565- git clone https://gitcode.com/Ascend/MindSpeed.git587+ # Clone and checkout the specified branch in one step when --msbranch is provided
588+ if [ -n "$MINDSPEED_BRANCH" ]; then
589+ git clone -b "$MINDSPEED_BRANCH" https://gitcode.com/Ascend/MindSpeed.git
590+ else
591+ git clone https://gitcode.com/Ascend/MindSpeed.git
592+ fi
566fi593fi
567cd MindSpeed594cd MindSpeed
568 595 
569-# Only checkout specific commit if COMMIT_ID is provided596+if [ -n "$MINDSPEED_BRANCH" ]; then
570-if [ -n "$MINDSPEED_COMMIT_ID" ]; then597+ # For existing clone, fetch and checkout the branch to keep it up to date
598+ git fetch origin "$MINDSPEED_BRANCH"
599+ git checkout "$MINDSPEED_BRANCH"
atomgit-bot
atomgit-botatomgit-bot7月21日

🟠 High Priority

PR 目标为"每次都拉取最新的 MindSpeed master 分支代码",但现有实现中,当 MindSpeed 目录已存在时:

  1. git fetch origin "$MINDSPEED_BRANCH" — 从远程拉取最新提交,更新 origin/<branch> 引用
  2. git checkout "$MINDSPEED_BRANCH" — 切换到本地同名分支,但不会合并 origin/<branch> 的更新

结果:本地分支仍停留在上次运行时的提交,不会更新到远程最新。后续 pip3 install -e . 安装的仍是旧代码。首次运行(无现有目录)时 git clone -b 可以拿到最新;但第二次及之后的运行就会安装过时版本,违背了"每次都拉取最新"的意图。

触发条件:用户第二次执行 bash scripts/install.sh --msbranch master 且 MindSpeed 目录已存在。

建议:在 git checkout 后将本地分支重置到远程最新,或使用 git checkout -B 强制重建分支到 origin 的最新位置。

改动建议
599
+ if [ -n "$MINDSPEED_BRANCH" ]; then
600
+ # For existing clone, fetch and checkout the branch to keep it up to date
601
+ git fetch origin "$MINDSPEED_BRANCH"
599
- git checkout "$MINDSPEED_BRANCH"
602
+ git checkout "$MINDSPEED_BRANCH"
603
+ git reset --hard "origin/$MINDSPEED_BRANCH"
应用建议
likedislike
不准确?
xubin
7月21日 评论:
600+elif [ -n "$MINDSPEED_COMMIT_ID" ]; then
601+ # Only checkout specific commit if COMMIT_ID is provided
571 git checkout "$MINDSPEED_COMMIT_ID"602 git checkout "$MINDSPEED_COMMIT_ID"
572fi603fi
573 604 
@@ -577,10 +608,12 @@ if ! install_with_retry "mindspeed" "pip3 install -e ."; then
577 exit 1608 exit 1
578fi609fi
579 610 
580-if [ -z "$MINDSPEED_COMMIT_ID" ]; then611+if [ -n "$MINDSPEED_BRANCH" ]; then
581- echo "[INFO] MindSpeed latest version successfully installed!"612+ echo "[INFO] MindSpeed with branch: $MINDSPEED_BRANCH successfully installed!"
582-else613+elif [ -n "$MINDSPEED_COMMIT_ID" ]; then
583 echo "[INFO] MindSpeed with commit ID: $MINDSPEED_COMMIT_ID successfully installed!"614 echo "[INFO] MindSpeed with commit ID: $MINDSPEED_COMMIT_ID successfully installed!"
615+else
616+ echo "[INFO] MindSpeed latest version successfully installed!"
584fi617fi
585 618 
586cd ..619cd ..