| @@ -8,6 +8,7 @@ Usage: $0 [OPTIONS] |
| Options: | Options: |
| -t, --torchversion VERSION PyTorch version to install (default: 2.7.1) | -t, --torchversion VERSION PyTorch version to install (default: 2.7.1) |
| -m, --msid COMMIT_ID MindSpeed commit ID (optional, use latest if not specified) | -m, --msid COMMIT_ID MindSpeed commit ID (optional, use latest if not specified) |
| + -b, --msbranch BRANCH MindSpeed branch name (optional, mutually exclusive with --msid) |
| -y, --yes Auto confirm all reinstallations | -y, --yes Auto confirm all reinstallations |
| -n, --no Auto skip all reinstallations | -n, --no Auto skip all reinstallations |
| -mt, --megatron Install Megatron-LM | -mt, --megatron Install Megatron-LM |
| @@ -18,6 +19,9 @@ Examples: |
| # Install with latest MindSpeed (no commit ID) | # Install with latest MindSpeed (no commit ID) |
| bash $0 --torchversion 2.7.1 --install-cann | bash $0 --torchversion 2.7.1 --install-cann |
| | |
| + # Install with specific MindSpeed branch |
| + bash $0 --torchversion 2.7.1 --msbranch master --install-cann |
| + |
| # Install with specific commit ID | # Install with specific commit ID |
| bash $0 --torchversion 2.7.1 --msid 93c45456c7044bacddebc5072316c01006c938f9 --install-cann | bash $0 --torchversion 2.7.1 --msid 93c45456c7044bacddebc5072316c01006c938f9 --install-cann |
| | |
| @@ -38,6 +42,7 @@ EOF |
| # Default values | # Default values |
| TORCH_VERSION="2.7.1" | TORCH_VERSION="2.7.1" |
| MINDSPEED_COMMIT_ID="" | MINDSPEED_COMMIT_ID="" |
| +MINDSPEED_BRANCH="" |
| AUTO_CONFIRM="" # Auto confirm mode: "", "yes", "no" | AUTO_CONFIRM="" # Auto confirm mode: "", "yes", "no" |
| INSTALL_MEGATRON=false # Whether to install Megatron-LM | INSTALL_MEGATRON=false # Whether to install Megatron-LM |
| INSTALL_CANN=false # Whether to install CANN | INSTALL_CANN=false # Whether to install CANN |
| @@ -47,6 +52,7 @@ while [[ $# -gt 0 ]]; do |
| case $1 in | case $1 in |
| -t|--torchversion) TORCH_VERSION="$2"; shift 2 ;; | -t|--torchversion) TORCH_VERSION="$2"; shift 2 ;; |
| -m|--msid) MINDSPEED_COMMIT_ID="$2"; shift 2 ;; | -m|--msid) MINDSPEED_COMMIT_ID="$2"; shift 2 ;; |
| + -b|--msbranch) MINDSPEED_BRANCH="$2"; shift 2 ;; |
| -y|--yes) AUTO_CONFIRM="yes"; shift ;; | -y|--yes) AUTO_CONFIRM="yes"; shift ;; |
| -n|--no) AUTO_CONFIRM="no"; shift ;; | -n|--no) AUTO_CONFIRM="no"; shift ;; |
| -mt|--megatron) INSTALL_MEGATRON=true; shift ;; | -mt|--megatron) INSTALL_MEGATRON=true; shift ;; |
| @@ -56,11 +62,24 @@ while [[ $# -gt 0 ]]; do |
| esac | esac |
| done | done |
| | |
| +# Validate that --msid and --msbranch are mutually exclusive |
| +if [ -n "$MINDSPEED_COMMIT_ID" ] && [ -n "$MINDSPEED_BRANCH" ]; then |
| + echo "Error: --msid and --msbranch are mutually exclusive. Please specify only one." |
| + show_help |
| + exit 1 |
| +fi |
| + |
| echo "========================================" | echo "========================================" |
| echo "Installation Configuration" | echo "Installation Configuration" |
| echo "========================================" | echo "========================================" |
| echo "PyTorch Version: $TORCH_VERSION" | echo "PyTorch Version: $TORCH_VERSION" |
| -echo "MindSpeed Commit ID: ${MINDSPEED_COMMIT_ID:-"latest"}" | +if [ -n "$MINDSPEED_BRANCH" ]; then |
| + echo "MindSpeed Branch: $MINDSPEED_BRANCH" |
| +elif [ -n "$MINDSPEED_COMMIT_ID" ]; then |
| + echo "MindSpeed Commit ID: $MINDSPEED_COMMIT_ID" |
| +else |
| + echo "MindSpeed: latest" |
| +fi |
| echo "Auto Confirm Mode: ${AUTO_CONFIRM:-"interactive"}" | echo "Auto Confirm Mode: ${AUTO_CONFIRM:-"interactive"}" |
| echo "Install Megatron-LM: $INSTALL_MEGATRON" | echo "Install Megatron-LM: $INSTALL_MEGATRON" |
| echo "Install CANN: $INSTALL_CANN" | echo "Install CANN: $INSTALL_CANN" |
| @@ -220,8 +239,9 @@ if [ "$INSTALL_CANN" = true ]; then |
| # Call install_cann.sh and pass ARCH parameter | # Call install_cann.sh and pass ARCH parameter |
| echo "Calling install_cann.sh with architecture: $ARCH" | echo "Calling install_cann.sh with architecture: $ARCH" |
| # Execute CANN installation script | # Execute CANN installation script |
| - if ! "$CANN_INSTALL_SCRIPT" "$ARCH"; then | + "$CANN_INSTALL_SCRIPT" "$ARCH" |
| - cann_exit_code=$? | + cann_exit_code=$? |
| + if [ $cann_exit_code -ne 0 ]; then |
| echo "Error: CANN installation failed with exit code: $cann_exit_code" | echo "Error: CANN installation failed with exit code: $cann_exit_code" |
| echo "Aborting installation due to CANN installation failure." | echo "Aborting installation due to CANN installation failure." |
| exit 1 | exit 1 |
| @@ -555,19 +575,30 @@ else |
| fi | fi |
| | |
| # Install mindspeed with retry mechanism | # Install mindspeed with retry mechanism |
| -if [ -z "$MINDSPEED_COMMIT_ID" ]; then | +if [ -n "$MINDSPEED_BRANCH" ]; then |
| - echo "[INFO] Installing MindSpeed with latest version (no commit ID specified)" | + echo "[INFO] Installing MindSpeed with branch: $MINDSPEED_BRANCH" |
| -else | +elif [ -n "$MINDSPEED_COMMIT_ID" ]; then |
| echo "[INFO] Installing MindSpeed with commit ID: $MINDSPEED_COMMIT_ID" | echo "[INFO] Installing MindSpeed with commit ID: $MINDSPEED_COMMIT_ID" |
| +else |
| + echo "[INFO] Installing MindSpeed with latest version (no commit ID or branch specified)" |
| fi | fi |
| | |
| if [ ! -d "MindSpeed" ]; then | if [ ! -d "MindSpeed" ]; then |
| - git clone https://gitcode.com/Ascend/MindSpeed.git | + # Clone and checkout the specified branch in one step when --msbranch is provided |
| + if [ -n "$MINDSPEED_BRANCH" ]; then |
| + git clone -b "$MINDSPEED_BRANCH" https://gitcode.com/Ascend/MindSpeed.git |
| + else |
| + git clone https://gitcode.com/Ascend/MindSpeed.git |
| + fi |
| fi | fi |
| cd MindSpeed | cd MindSpeed |
| | |
| -# Only checkout specific commit if COMMIT_ID is provided | +if [ -n "$MINDSPEED_BRANCH" ]; then |
| -if [ -n "$MINDSPEED_COMMIT_ID" ]; then | + # For existing clone, fetch and checkout the branch to keep it up to date |
| + git fetch origin "$MINDSPEED_BRANCH" |
| + git checkout "$MINDSPEED_BRANCH" |
| +elif [ -n "$MINDSPEED_COMMIT_ID" ]; then |
| + # Only checkout specific commit if COMMIT_ID is provided |
| git checkout "$MINDSPEED_COMMIT_ID" | git checkout "$MINDSPEED_COMMIT_ID" |
| fi | fi |
| | |
| @@ -577,10 +608,12 @@ if ! install_with_retry "mindspeed" "pip3 install -e ."; then |
| exit 1 | exit 1 |
| fi | fi |
| | |
| -if [ -z "$MINDSPEED_COMMIT_ID" ]; then | +if [ -n "$MINDSPEED_BRANCH" ]; then |
| - echo "[INFO] MindSpeed latest version successfully installed!" | + echo "[INFO] MindSpeed with branch: $MINDSPEED_BRANCH successfully installed!" |
| -else | +elif [ -n "$MINDSPEED_COMMIT_ID" ]; then |
| echo "[INFO] MindSpeed with commit ID: $MINDSPEED_COMMIT_ID successfully installed!" | echo "[INFO] MindSpeed with commit ID: $MINDSPEED_COMMIT_ID successfully installed!" |
| +else |
| + echo "[INFO] MindSpeed latest version successfully installed!" |
| fi | fi |
| | |
| cd .. | cd .. |
| |
🟠 High Priority
PR 目标为"每次都拉取最新的 MindSpeed master 分支代码",但现有实现中,当 MindSpeed 目录已存在时:
git fetch origin "$MINDSPEED_BRANCH"— 从远程拉取最新提交,更新origin/<branch>引用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 的最新位置。