GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update Ascend Megatron stack to Core 0.18 (#1841) · modelscope/modelscope@34844f9

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • docker
    • ascend
      • Dockerfile.ascend
      • OVERVIEW.ascend.md
      • OVERVIEW.ascend.zh.md
    • build_image.py
  • tests/test_metrics
    • test_ned_metric.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docker/ascend/Dockerfile.ascend‎

Copy file name to clipboardExpand all lines: docker/ascend/Dockerfile.ascend
+9-6Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ RUN git clone --depth 1 --branch {vllm_ascend_git_ref} \
9191

9292
# ---------- Clone training-side repositories ----------
9393
RUN git clone --depth 1 --branch {megatron_branch} https://github.com/NVIDIA/Megatron-LM.git /Megatron-LM && \
94-
git clone --depth 1 --branch {mindspeed_branch} https://gitcode.com/Ascend/MindSpeed.git /MindSpeed && \
94+
git clone --depth 1 --branch {megatron_adaptor_branch} https://gitcode.com/Ascend/MegatronAdaptor.git /MegatronAdaptor && \
95+
git clone --depth 1 --branch {transformer_engine_npu_branch} https://gitcode.com/Ascend/TransformerEngineNPU.git /TransformerEngineNPU && \
9596
git clone --depth 1 --single-branch --branch {mcore_bridge_branch} https://github.com/modelscope/mcore-bridge.git /mcore-bridge && \
9697
GIT_LFS_SKIP_SMUDGE=1 git clone --depth 1 -b {swift_branch} --single-branch https://github.com/modelscope/ms-swift.git /ms-swift
9798

@@ -100,8 +101,9 @@ RUN git clone --depth 1 --branch {megatron_branch} https://github.com/NVIDIA/Meg
100101
RUN export PIP_EXTRA_INDEX_URL="${PIP_EXTRA_INDEX_URL}" && \
101102
source /usr/local/Ascend/ascend-toolkit/set_env.sh && \
102103
if [ -f /usr/local/Ascend/nnal/atb/set_env.sh ]; then source /usr/local/Ascend/nnal/atb/set_env.sh; fi && \
103-
cd /MindSpeed && pip install --no-cache-dir -e . && \
104104
cd /mcore-bridge && pip install --no-cache-dir -e . && \
105+
cd /MegatronAdaptor && pip install --no-cache-dir -e . && \
106+
cd /TransformerEngineNPU && pip install --no-cache-dir -e . --no-build-isolation && \
105107
pip install --no-cache-dir -U modelscope && \
106108
cd /ms-swift && pip install --no-cache-dir -e .
107109

@@ -141,10 +143,9 @@ RUN export PIP_EXTRA_INDEX_URL="${PIP_EXTRA_INDEX_URL}" && \
141143
if [ -f /usr/local/Ascend/nnal/atb/set_env.sh ]; then source /usr/local/Ascend/nnal/atb/set_env.sh; fi && \
142144
pip install --no-cache-dir -U pip && \
143145
pip install --no-cache-dir -U icecream soundfile pybind11 py-spy funasr scikit-learn && \
144-
pip install --no-cache-dir -U qwen_vl_utils qwen_omni_utils 'librosa<1.0' 'timm>=0.9.0' transformers accelerate peft trl safetensors && \
146+
pip install --no-cache-dir -U qwen_vl_utils qwen_omni_utils 'librosa<1.0' 'timm>=0.9.0' transformers accelerate 'peft>=0.11,<0.21' 'trl>=0.15,<1.0' safetensors && \
145147
pip install --no-cache-dir -r /ms-swift/requirements/eval.txt && \
146148
pip install --no-cache-dir -U evalscope --no-dependencies && \
147-
pip install --no-cache-dir 'numpy>=2.0' --force-reinstall --no-deps && \
148149
pip install --no-cache-dir -U ms-agent --no-dependencies && \
149150
pip install --no-cache-dir --no-build-isolation OpenCC && \
150151
pip install --no-cache-dir diffusers omegaconf==2.3.0 && \
@@ -164,14 +165,16 @@ RUN git clone --depth 1 --branch {fla_version} https://github.com/fla-org/flash-
164165

165166
# ---------- Re-pin triton-ascend after all editable installs ----------
166167
# vllm-ascend may otherwise replace the CANN-specific version selected above.
168+
# Restore NumPy 2 for PyArrow after Triton-Ascend pins NumPy 1.26.4.
167169
RUN set -eux; \
168170
ASCEND_PYPI_INDEX_URL="${PIP_EXTRA_INDEX_URL}"; \
169171
pip uninstall -y triton || true; \
170172
pip uninstall -y triton-ascend || true; \
171173
PIP_INDEX_URL="${ASCEND_PYPI_INDEX_URL}" \
172174
PIP_EXTRA_INDEX_URL="${PYPI_OFFICIAL_INDEX_URL}" \
173175
pip install --no-cache-dir --force-reinstall \
174-
triton-ascend=={triton_ascend_version}
176+
triton-ascend=={triton_ascend_version} && \
177+
pip install --no-cache-dir --upgrade --no-deps 'numpy>=2.0'
175178

176179
RUN echo 'source /usr/local/Ascend/ascend-toolkit/set_env.sh' >> /root/.bashrc && \
177180
echo '[ -f /usr/local/Ascend/nnal/atb/set_env.sh ] && source /usr/local/Ascend/nnal/atb/set_env.sh' >> /root/.bashrc && \
@@ -183,7 +186,7 @@ ENV MODELSCOPE_CACHE=/mnt/workspace/.cache/modelscope/hub
183186

184187
# Show install results and verify that editable packages resolve from retained source trees.
185188
RUN pip list && \
186-
TORCH_DEVICE_BACKEND_AUTOLOAD=0 python -c "import importlib.metadata as m; import importlib.util as u; import os; expected = {'vllm': '/vllm', 'vllm_ascend': '/vllm-ascend', 'swift': '/ms-swift', 'megatron': '/Megatron-LM', 'mindspeed': '/MindSpeed', 'fla': '/flash-linear-attention'}; specs = {name: u.find_spec(name) for name in expected}; origins = {name: (spec.origin or next(iter(spec.submodule_search_locations or []), None) if spec else None) for name, spec in specs.items()}; assert all(path and os.path.commonpath([os.path.realpath(path), root]) == root for name, root in expected.items() for path in [origins[name]]), origins; assert u.find_spec('modelscope') and m.version('modelscope'); assert m.version('triton-ascend') == '{triton_ascend_version}', m.version('triton-ascend'); print(origins)"
189+
TORCH_DEVICE_BACKEND_AUTOLOAD=0 python -c "import importlib.metadata as m; import importlib.util as u; import os; expected = {'vllm': '/vllm', 'vllm_ascend': '/vllm-ascend', 'swift': '/ms-swift', 'megatron': '/Megatron-LM', 'megatron_adaptor': '/MegatronAdaptor', 'transformer_engine': '/TransformerEngineNPU', 'mcore_bridge': '/mcore-bridge', 'fla': '/flash-linear-attention'}; specs = {name: u.find_spec(name) for name in expected}; origins = {name: (spec.origin or next(iter(spec.submodule_search_locations or []), None) if spec else None) for name, spec in specs.items()}; assert all(path and os.path.commonpath([os.path.realpath(path), root]) == root for name, root in expected.items() for path in [origins[name]]), origins; assert u.find_spec('mindspeed') is None; assert u.find_spec('modelscope') and m.version('modelscope'); assert m.version('triton-ascend') == '{triton_ascend_version}', m.version('triton-ascend'); print(origins)"
187190
WORKDIR /workspace
188191

189192
CMD ["/bin/bash"]
Collapse file

‎docker/ascend/OVERVIEW.ascend.md‎

Copy file name to clipboardExpand all lines: docker/ascend/OVERVIEW.ascend.md
+15-12Lines changed: 15 additions & 12 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> English | [中文](https://github.com/modelscope/modelscope/blob/master/docker/ascend/OVERVIEW.ascend.zh.md)
44
5-
ms-swift Ascend images provide a ready-to-use ms-swift environment for Huawei Ascend Atlas NPUs. The images are built on top of the Ascend CANN container images and include the Python, CANN, TorchNPU, vLLM Ascend, FLA, Megatron, MindSpeed, mcore-bridge, ms-swift, and ModelScope runtime components needed for Ascend inference and training workflows.
5+
ms-swift Ascend images provide a ready-to-use ms-swift environment for Huawei Ascend Atlas NPUs. The images are built on top of the Ascend CANN container images and include the Python, CANN, TorchNPU, vLLM Ascend, FLA, Megatron, MegatronAdaptor, TransformerEngineNPU, mcore-bridge, ms-swift, and ModelScope runtime components needed for Ascend inference and training workflows.
66

77
## Quick Reference
88

@@ -30,8 +30,9 @@ The Ascend Dockerfile installs and configures:
3030
| vLLM | Official `vllm-project/vllm` source tag `v0.18.0` by default; configurable with `--vllm_version`; built with the empty target device |
3131
| vLLM Ascend | Official `vllm-project/vllm-ascend` source tag `v0.18.0` by default; configurable with `--vllm_ascend_version`; initializes submodules; resolves build and runtime dependencies from Huawei Cloud Ascend PyPI with official PyPI as fallback |
3232
| FLA | source checkout from `fla-org/flash-linear-attention`, default branch `main`; configurable with `--fla_version` using a branch or release tag |
33-
| Megatron-LM | source checkout, default branch `v0.15.3`; configurable with `--megatron_branch` |
34-
| MindSpeed | source checkout, default branch `core_r0.15.3`; configurable with `--mindspeed_branch` |
33+
| Megatron-LM | source checkout, default branch `core_r0.18.0`; configurable with `--megatron_branch` |
34+
| MegatronAdaptor | editable source checkout from `Ascend/MegatronAdaptor`, default branch `core_r0.18.0`; configurable with `--megatron_adaptor_branch` |
35+
| TransformerEngineNPU | editable source checkout from `Ascend/TransformerEngineNPU`, default branch `main`; installed with `--no-build-isolation`; configurable with `--transformer_engine_npu_branch` |
3536
| mcore-bridge | editable source checkout from `modelscope/mcore-bridge`, default branch `main`; configurable with `--mcore_bridge_branch` using a branch or release tag |
3637
| ms-swift | source checkout from `modelscope/ms-swift`, default branch `main`; configurable with `--swift_branch` |
3738
| DeepSpeed | newest package satisfying `deepspeed>=0.19`; `TORCH_DEVICE_BACKEND_AUTOLOAD=0` is scoped to its build-time install command |
@@ -89,8 +90,8 @@ python docker/build_image.py \
8990
--image_type ascend
9091
```
9192

92-
Complete version-pinned reference (CANN 9.1.0, Atlas A2, Ubuntu 22.04,
93-
Python 3.12, ARM64):
93+
Complete build reference (CANN 9.1.0, Atlas A2, Ubuntu 22.04,
94+
Python 3.12, ARM64). The Megatron components follow the [ms-swift NPU installation guide](https://swift.readthedocs.io/zh-cn/latest/BestPractices/NPU-support.html#megatronadaptor-transformerenginenpu): MCore 0.18, MegatronAdaptor and TransformerEngineNPU, without MindSpeed. Use compatible ms-swift and mcore-bridge branches containing this integration; the example uses `main`.
9495

9596
```bash
9697
export DOCKER_REGISTRY=registry.example.com/ms-swift/ms-swift
@@ -109,10 +110,11 @@ python docker/build_image.py \
109110
--fla_version main \
110111
--triton_ascend_version 3.2.2 \
111112
--modelscope_branch master \
112-
--swift_branch v4.5.2 \
113-
--megatron_branch core_v0.16.0 \
114-
--mindspeed_branch core_r0.16.0 \
115-
--mcore_bridge_branch v1.6.2
113+
--swift_branch main \
114+
--megatron_branch core_r0.18.0 \
115+
--megatron_adaptor_branch core_r0.18.0 \
116+
--transformer_engine_npu_branch main \
117+
--mcore_bridge_branch main
116118
```
117119

118120
## Custom Build Parameters
@@ -138,8 +140,9 @@ are consumed by the current Ascend build path:
138140
- `--pip_extra_index_url` (default: Huawei Cloud Ascend PyPI): sets the primary package index for Ascend-specific dependencies.
139141
- `--pypi_official_index_url` (default: `https://pypi.org/simple`): sets the fallback package index.
140142
- `--swift_branch` (default: `main`): selects the ms-swift source branch or tag and is included in the output image tag.
141-
- `--megatron_branch` (default: `v0.15.3`): selects the Megatron-LM source branch or tag.
142-
- `--mindspeed_branch` (default: `core_r0.15.3`): selects the MindSpeed source branch or tag.
143+
- `--megatron_branch` (default: `core_r0.18.0`): selects the Megatron-LM source branch or tag.
144+
- `--megatron_adaptor_branch` (default: `core_r0.18.0`): selects the MegatronAdaptor source branch or tag.
145+
- `--transformer_engine_npu_branch` (default: `main`): selects the TransformerEngineNPU source branch or tag.
143146
- `--mcore_bridge_branch` (default: `main`): selects the mcore-bridge source branch or release tag for the editable install.
144147

145148
`--python_version` does not override the Python version for Ascend images;
@@ -210,4 +213,4 @@ When running containers with these images, consider the following security risks
210213

211214
## License
212215

213-
ms-swift and ModelScope components follow their upstream repository licenses. CANN, MindSpeed, TorchNPU, vLLM Ascend, and other pre-installed third-party components are subject to their own upstream licenses.
216+
ms-swift and ModelScope components follow their upstream repository licenses. CANN, MegatronAdaptor, TransformerEngineNPU, TorchNPU, vLLM Ascend, and other pre-installed third-party components are subject to their own upstream licenses.
Collapse file

‎docker/ascend/OVERVIEW.ascend.zh.md‎

Copy file name to clipboardExpand all lines: docker/ascend/OVERVIEW.ascend.zh.md
+14-11Lines changed: 14 additions & 11 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> [English](https://github.com/modelscope/modelscope/blob/master/docker/ascend/OVERVIEW.ascend.md) | 中文
44
5-
ms-swift Ascend 镜像面向华为昇腾 Atlas NPU,提供可直接使用的 ms-swift 运行环境。镜像基于 Ascend CANN 容器镜像构建,包含 Ascend 推理和训练工作流所需的 Python、CANN、TorchNPU、vLLM Ascend、FLA、Megatron、MindSpeed、mcore-bridge、ms-swift 以及 ModelScope 运行组件。
5+
ms-swift Ascend 镜像面向华为昇腾 Atlas NPU,提供可直接使用的 ms-swift 运行环境。镜像基于 Ascend CANN 容器镜像构建,包含 Ascend 推理和训练工作流所需的 Python、CANN、TorchNPU、vLLM Ascend、FLA、Megatron、MegatronAdaptor、TransformerEngineNPU、mcore-bridge、ms-swift 以及 ModelScope 运行组件。
66

77
## 快速参考
88

@@ -30,8 +30,9 @@ Ascend Dockerfile 会安装和配置:
3030
| vLLM | 默认从官方 `vllm-project/vllm` 源码 tag `v0.18.0` 构建;可通过 `--vllm_version` 配置;使用 empty target device |
3131
| vLLM Ascend | 默认从官方 `vllm-project/vllm-ascend` 源码 tag `v0.18.0` 构建;可通过 `--vllm_ascend_version` 配置;会初始化 submodule;构建与运行依赖以华为云 Ascend PyPI 为主索引、官方 PyPI 为备用索引 |
3232
| FLA | 从 `fla-org/flash-linear-attention` 源码 checkout,默认 `main` 分支;可通过 `--fla_version` 指定分支或 release tag |
33-
| Megatron-LM | 源码 checkout,默认分支 `v0.15.3`;可通过 `--megatron_branch` 配置 |
34-
| MindSpeed | 源码 checkout,默认分支 `core_r0.15.3`;可通过 `--mindspeed_branch` 配置 |
33+
| Megatron-LM | 源码 checkout,默认分支 `core_r0.18.0`;可通过 `--megatron_branch` 配置 |
34+
| MegatronAdaptor | 从 `Ascend/MegatronAdaptor` 源码 checkout 并以 editable 模式安装,默认分支 `core_r0.18.0`;可通过 `--megatron_adaptor_branch` 配置 |
35+
| TransformerEngineNPU | 从 `Ascend/TransformerEngineNPU` 源码 checkout 并以 editable 模式安装,默认分支 `main`;安装时使用 `--no-build-isolation`;可通过 `--transformer_engine_npu_branch` 配置 |
3536
| mcore-bridge | 从 `modelscope/mcore-bridge` 源码 checkout 并以 editable 模式安装,默认 `main` 分支;可通过 `--mcore_bridge_branch` 指定分支或 release tag |
3637
| ms-swift | 来自 `modelscope/ms-swift` 的源码 checkout,默认分支 `main`;可通过 `--swift_branch` 配置 |
3738
| DeepSpeed | 安装满足 `deepspeed>=0.19` 的最新发布包;`TORCH_DEVICE_BACKEND_AUTOLOAD=0` 仅作用于构建时的安装命令 |
@@ -89,7 +90,7 @@ python docker/build_image.py \
8990
--image_type ascend
9091
```
9192

92-
完整固定版本参考(CANN 9.1.0、Atlas A2、Ubuntu 22.04、Python 3.12、ARM64):
93+
完整构建参考(CANN 9.1.0、Atlas A2、Ubuntu 22.04、Python 3.12、ARM64)。Megatron 组件遵循 [ms-swift NPU 安装文档](https://swift.readthedocs.io/zh-cn/latest/BestPractices/NPU-support.html#megatronadaptor-transformerenginenpu):使用 MCore 0.18、MegatronAdaptor 和 TransformerEngineNPU,不安装 MindSpeed。ms-swift 和 mcore-bridge 应选择已包含配套适配的兼容分支;示例使用 `main`。
9394

9495
```bash
9596
export DOCKER_REGISTRY=registry.example.com/ms-swift/ms-swift
@@ -108,10 +109,11 @@ python docker/build_image.py \
108109
--fla_version main \
109110
--triton_ascend_version 3.2.2 \
110111
--modelscope_branch master \
111-
--swift_branch v4.5.2 \
112-
--megatron_branch core_v0.16.0 \
113-
--mindspeed_branch core_r0.16.0 \
114-
--mcore_bridge_branch v1.6.2
112+
--swift_branch main \
113+
--megatron_branch core_r0.18.0 \
114+
--megatron_adaptor_branch core_r0.18.0 \
115+
--transformer_engine_npu_branch main \
116+
--mcore_bridge_branch main
115117
```
116118

117119
## 自定义构建参数
@@ -136,8 +138,9 @@ python docker/build_image.py \
136138
- `--pip_extra_index_url`(默认:华为云 Ascend PyPI):设置 Ascend 特定依赖的主索引。
137139
- `--pypi_official_index_url`(默认:`https://pypi.org/simple`):设置备用包索引。
138140
- `--swift_branch`(默认:`main`):选择 ms-swift 源码分支或 tag,并写入输出镜像 tag。
139-
- `--megatron_branch`(默认:`v0.15.3`):选择 Megatron-LM 源码分支或 tag。
140-
- `--mindspeed_branch`(默认:`core_r0.15.3`):选择 MindSpeed 源码分支或 tag。
141+
- `--megatron_branch`(默认:`core_r0.18.0`):选择 Megatron-LM 源码分支或 tag。
142+
- `--megatron_adaptor_branch`(默认:`core_r0.18.0`):选择 MegatronAdaptor 源码分支或 tag。
143+
- `--transformer_engine_npu_branch`(默认:`main`):选择 TransformerEngineNPU 源码分支或 tag。
141144
- `--mcore_bridge_branch`(默认:`main`):选择 mcore-bridge 源码分支或 release tag,并以 editable 模式安装。
142145

143146
Ascend 镜像的 Python 版本必须通过 `--base_image` 选择,`--python_version`
@@ -207,4 +210,4 @@ pip show ms-swift modelscope mcore-bridge torch-npu triton-ascend
207210

208211
## License
209212

210-
ms-swift 和 ModelScope 组件遵循各自上游仓库的 license。CANN、MindSpeed、TorchNPU、vLLM Ascend 以及其他预装第三方组件遵循各自上游 license。
213+
ms-swift 和 ModelScope 组件遵循各自上游仓库的 license。CANN、MegatronAdaptor、TransformerEngineNPU、TorchNPU、vLLM Ascend 以及其他预装第三方组件遵循各自上游 license。
Collapse file

‎docker/build_image.py‎

Copy file name to clipboardExpand all lines: docker/build_image.py
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,8 +1272,10 @@ def generate_dockerfile(self) -> str:
12721272
content = content.replace('{swift_branch}', self.args.swift_branch)
12731273
content = content.replace('{megatron_branch}',
12741274
self.args.megatron_branch)
1275-
content = content.replace('{mindspeed_branch}',
1276-
self.args.mindspeed_branch)
1275+
content = content.replace('{megatron_adaptor_branch}',
1276+
self.args.megatron_adaptor_branch)
1277+
content = content.replace('{transformer_engine_npu_branch}',
1278+
self.args.transformer_engine_npu_branch)
12771279
content = content.replace('{mcore_bridge_branch}',
12781280
self.args.mcore_bridge_branch)
12791281
return content
@@ -1395,8 +1397,11 @@ def print_build_summary(results: List[Tuple[Builder, Optional[BaseException]]],
13951397
help='Minor build only: install modelscope from the released PyPI version '
13961398
'(--modelscope_version, default) or from --modelscope_branch source.')
13971399
parser.add_argument('--swift_branch', type=str, default='main')
1398-
parser.add_argument('--megatron_branch', type=str, default='v0.15.3')
1399-
parser.add_argument('--mindspeed_branch', type=str, default='core_r0.15.3')
1400+
parser.add_argument('--megatron_branch', type=str, default='core_r0.18.0')
1401+
parser.add_argument(
1402+
'--megatron_adaptor_branch', type=str, default='core_r0.18.0')
1403+
parser.add_argument(
1404+
'--transformer_engine_npu_branch', type=str, default='main')
14001405
parser.add_argument('--mcore_bridge_branch', type=str, default='main')
14011406
parser.add_argument('--soc_version', type=str, default='ascend910_9391')
14021407
parser.add_argument('--arch', type=str, choices=['x86', 'arm'], default=None)
Collapse file

‎tests/test_metrics/test_ned_metric.py‎

Copy file name to clipboardExpand all lines: tests/test_metrics/test_ned_metric.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def test_an_empty_string_does_not_score_below_zero(self):
1717
# An empty string against "ab" used to return distance 2, so the
1818
# score was -1. The normalized distance is 1, so the score is 0.
1919
# cat/cut is still 2/3 and an exact match is still 1.
20-
self.assertAlmostEqual(score, (0.0 + 0.0 + (1.0 - 1.0 / 3.0) + 1.0) / 4.0)
20+
expected_score = (0.0 + 0.0 + (1.0 - 1.0 / 3.0) + 1.0) / 4.0
21+
self.assertAlmostEqual(score, expected_score)
2122

2223

2324
if __name__ == '__main__':

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.