GeezerVison is showing github.com — Update Ascend Megatron stack to Core 0.18 (#1841) · modelscope/modelscope@34844f9
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: docker/ascend/Dockerfile.ascend +9-6Lines changed: 9 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -91,7 +91,8 @@ RUN git clone --depth 1 --branch {vllm_ascend_git_ref} \ | 91 | 91 |
| 92 | 92 | # ---------- Clone training-side repositories ---------- | 93 | 93 | 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 && \ | 95 | 96 | git clone --depth 1 --single-branch --branch {mcore_bridge_branch} https://github.com/modelscope/mcore-bridge.git /mcore-bridge && \ | 96 | 97 | GIT_LFS_SKIP_SMUDGE=1 git clone --depth 1 -b {swift_branch} --single-branch https://github.com/modelscope/ms-swift.git /ms-swift | 97 | 98 |
| @@ -100,8 +101,9 @@ RUN git clone --depth 1 --branch {megatron_branch} https://github.com/NVIDIA/Meg | 100 | 101 | RUN export PIP_EXTRA_INDEX_URL="${PIP_EXTRA_INDEX_URL}" && \ | 101 | 102 | source /usr/local/Ascend/ascend-toolkit/set_env.sh && \ | 102 | 103 | 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 . && \ | 104 | 104 | 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 && \ | 105 | 107 | pip install --no-cache-dir -U modelscope && \ | 106 | 108 | cd /ms-swift && pip install --no-cache-dir -e . | 107 | 109 |
| @@ -141,10 +143,9 @@ RUN export PIP_EXTRA_INDEX_URL="${PIP_EXTRA_INDEX_URL}" && \ | 141 | 143 | if [ -f /usr/local/Ascend/nnal/atb/set_env.sh ]; then source /usr/local/Ascend/nnal/atb/set_env.sh; fi && \ | 142 | 144 | pip install --no-cache-dir -U pip && \ | 143 | 145 | 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 && \ | 145 | 147 | pip install --no-cache-dir -r /ms-swift/requirements/eval.txt && \ | 146 | 148 | pip install --no-cache-dir -U evalscope --no-dependencies && \ | 147 | | - pip install --no-cache-dir 'numpy>=2.0' --force-reinstall --no-deps && \ | 148 | 149 | pip install --no-cache-dir -U ms-agent --no-dependencies && \ | 149 | 150 | pip install --no-cache-dir --no-build-isolation OpenCC && \ | 150 | 151 | 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- | 164 | 165 |
| 165 | 166 | # ---------- Re-pin triton-ascend after all editable installs ---------- | 166 | 167 | # 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. | 167 | 169 | RUN set -eux; \ | 168 | 170 | ASCEND_PYPI_INDEX_URL="${PIP_EXTRA_INDEX_URL}"; \ | 169 | 171 | pip uninstall -y triton || true; \ | 170 | 172 | pip uninstall -y triton-ascend || true; \ | 171 | 173 | PIP_INDEX_URL="${ASCEND_PYPI_INDEX_URL}" \ | 172 | 174 | PIP_EXTRA_INDEX_URL="${PYPI_OFFICIAL_INDEX_URL}" \ | 173 | 175 | 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' | 175 | 178 |
| 176 | 179 | RUN echo 'source /usr/local/Ascend/ascend-toolkit/set_env.sh' >> /root/.bashrc && \ | 177 | 180 | 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 | 183 | 186 |
| 184 | 187 | # Show install results and verify that editable packages resolve from retained source trees. | 185 | 188 | 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)" | 187 | 190 | WORKDIR /workspace | 188 | 191 |
| 189 | 192 | CMD ["/bin/bash"] |
Collapse file 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 number | Diff line number | Diff line change |
|---|
| 2 | 2 |
| 3 | 3 | > English | [中文](https://github.com/modelscope/modelscope/blob/master/docker/ascend/OVERVIEW.ascend.zh.md) | 4 | 4 |
| 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. | 6 | 6 |
| 7 | 7 | ## Quick Reference | 8 | 8 |
| @@ -30,8 +30,9 @@ The Ascend Dockerfile installs and configures: | 30 | 30 | | vLLM | Official `vllm-project/vllm` source tag `v0.18.0` by default; configurable with `--vllm_version`; built with the empty target device | | 31 | 31 | | 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 | | 32 | 32 | | 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` | | 35 | 36 | | mcore-bridge | editable source checkout from `modelscope/mcore-bridge`, default branch `main`; configurable with `--mcore_bridge_branch` using a branch or release tag | | 36 | 37 | | ms-swift | source checkout from `modelscope/ms-swift`, default branch `main`; configurable with `--swift_branch` | | 37 | 38 | | 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 \ | 89 | 90 | --image_type ascend | 90 | 91 | ``` | 91 | 92 |
| 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`. | 94 | 95 |
| 95 | 96 | ```bash | 96 | 97 | export DOCKER_REGISTRY=registry.example.com/ms-swift/ms-swift | @@ -109,10 +110,11 @@ python docker/build_image.py \ | 109 | 110 | --fla_version main \ | 110 | 111 | --triton_ascend_version 3.2.2 \ | 111 | 112 | --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 | 116 | 118 | ``` | 117 | 119 |
| 118 | 120 | ## Custom Build Parameters | @@ -138,8 +140,9 @@ are consumed by the current Ascend build path: | 138 | 140 | - `--pip_extra_index_url` (default: Huawei Cloud Ascend PyPI): sets the primary package index for Ascend-specific dependencies. | 139 | 141 | - `--pypi_official_index_url` (default: `https://pypi.org/simple`): sets the fallback package index. | 140 | 142 | - `--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. | 143 | 146 | - `--mcore_bridge_branch` (default: `main`): selects the mcore-bridge source branch or release tag for the editable install. | 144 | 147 |
| 145 | 148 | `--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 | 210 | 213 |
| 211 | 214 | ## License | 212 | 215 |
| 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 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 number | Diff line number | Diff line change |
|---|
| 2 | 2 |
| 3 | 3 | > [English](https://github.com/modelscope/modelscope/blob/master/docker/ascend/OVERVIEW.ascend.md) | 中文 | 4 | 4 |
| 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 运行组件。 | 6 | 6 |
| 7 | 7 | ## 快速参考 | 8 | 8 |
| @@ -30,8 +30,9 @@ Ascend Dockerfile 会安装和配置: | 30 | 30 | | vLLM | 默认从官方 `vllm-project/vllm` 源码 tag `v0.18.0` 构建;可通过 `--vllm_version` 配置;使用 empty target device | | 31 | 31 | | vLLM Ascend | 默认从官方 `vllm-project/vllm-ascend` 源码 tag `v0.18.0` 构建;可通过 `--vllm_ascend_version` 配置;会初始化 submodule;构建与运行依赖以华为云 Ascend PyPI 为主索引、官方 PyPI 为备用索引 | | 32 | 32 | | 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` 配置 | | 35 | 36 | | mcore-bridge | 从 `modelscope/mcore-bridge` 源码 checkout 并以 editable 模式安装,默认 `main` 分支;可通过 `--mcore_bridge_branch` 指定分支或 release tag | | 36 | 37 | | ms-swift | 来自 `modelscope/ms-swift` 的源码 checkout,默认分支 `main`;可通过 `--swift_branch` 配置 | | 37 | 38 | | DeepSpeed | 安装满足 `deepspeed>=0.19` 的最新发布包;`TORCH_DEVICE_BACKEND_AUTOLOAD=0` 仅作用于构建时的安装命令 | | @@ -89,7 +90,7 @@ python docker/build_image.py \ | 89 | 90 | --image_type ascend | 90 | 91 | ``` | 91 | 92 |
| 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`。 | 93 | 94 |
| 94 | 95 | ```bash | 95 | 96 | export DOCKER_REGISTRY=registry.example.com/ms-swift/ms-swift | @@ -108,10 +109,11 @@ python docker/build_image.py \ | 108 | 109 | --fla_version main \ | 109 | 110 | --triton_ascend_version 3.2.2 \ | 110 | 111 | --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 | 115 | 117 | ``` | 116 | 118 |
| 117 | 119 | ## 自定义构建参数 | @@ -136,8 +138,9 @@ python docker/build_image.py \ | 136 | 138 | - `--pip_extra_index_url`(默认:华为云 Ascend PyPI):设置 Ascend 特定依赖的主索引。 | 137 | 139 | - `--pypi_official_index_url`(默认:`https://pypi.org/simple`):设置备用包索引。 | 138 | 140 | - `--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。 | 141 | 144 | - `--mcore_bridge_branch`(默认:`main`):选择 mcore-bridge 源码分支或 release tag,并以 editable 模式安装。 | 142 | 145 |
| 143 | 146 | Ascend 镜像的 Python 版本必须通过 `--base_image` 选择,`--python_version` | @@ -207,4 +210,4 @@ pip show ms-swift modelscope mcore-bridge torch-npu triton-ascend | 207 | 210 |
| 208 | 211 | ## License | 209 | 212 |
| 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 Copy file name to clipboardExpand all lines: docker/build_image.py +9-4Lines changed: 9 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1272,8 +1272,10 @@ def generate_dockerfile(self) -> str: | 1272 | 1272 | content = content.replace('{swift_branch}', self.args.swift_branch) | 1273 | 1273 | content = content.replace('{megatron_branch}', | 1274 | 1274 | 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) | 1277 | 1279 | content = content.replace('{mcore_bridge_branch}', | 1278 | 1280 | self.args.mcore_bridge_branch) | 1279 | 1281 | return content | @@ -1395,8 +1397,11 @@ def print_build_summary(results: List[Tuple[Builder, Optional[BaseException]]], | 1395 | 1397 | help='Minor build only: install modelscope from the released PyPI version ' | 1396 | 1398 | '(--modelscope_version, default) or from --modelscope_branch source.') | 1397 | 1399 | 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') | 1400 | 1405 | parser.add_argument('--mcore_bridge_branch', type=str, default='main') | 1401 | 1406 | parser.add_argument('--soc_version', type=str, default='ascend910_9391') | 1402 | 1407 | parser.add_argument('--arch', type=str, choices=['x86', 'arm'], default=None) | |
Collapse file Copy file name to clipboardExpand all lines: tests/test_metrics/test_ned_metric.py +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -17,7 +17,8 @@ def test_an_empty_string_does_not_score_below_zero(self): | 17 | 17 | # An empty string against "ab" used to return distance 2, so the | 18 | 18 | # score was -1. The normalized distance is 1, so the score is 0. | 19 | 19 | # 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) | 21 | 22 |
| 22 | 23 |
| 23 | 24 | if __name__ == '__main__': | |
|