已合并
Expanded DeviceMesh Class Implementation #94
lzy0920232创建于 1月9日
Expanded DeviceMesh Class Implementation #94
已合并
从refs/pull/94/head合入到master
Pull Request已成功合入, 合并人@
(感谢 lzy0920232 的贡献)1月9日 指派了 CODEOWNER kisnwang 审查
1月9日 添加了
mindspore-cla/yes
标签
1月9日 添加了
pr-check-pass
标签
DeviceMesh相关的东西,可以单独弄个 device_mesh.py


里面具体的类型也体现一下,比如tuple(int), tuple(str)之类的


当前一定要指定alias_name 和 rank_list 吗?
rank_list有没有默认值,alias_name 可不可以后续指定


这个方法的返回值是啥


这个方法在什么场景会使用?
会返回一个新的DeviceMesh对象?alias_name是拼接后的?


所有的类型校验后续可以抽出来个功能方法,可以参考mindspore\python\mindspore_checkparam.py


tests/mindspore/ut/test_device_mesh.py
@@ -0,0 +31,4 @@
31+ # Mock communication group creation (return Mock object)
32+ mock_group = Mock()
33+ platform_mock.create_group.return_value = mock_group
34+ yield platform_mock
格式--逗号后面加空格


tests/mindspore/ut/test_device_mesh.py
@@ -0,0 +107,4 @@
107+ assert device_mesh.rank_list == (0, 2, 1, 3) # Flattened from custom layout
108+ assert device_mesh.ndim == 2
109+
110+ def test_device_mesh_direct_construction_with_list(self, mock_platform):
这边的门禁好像对用例注释有规范,一般按这种格式:
'''
Feature:
Description:
Expectation:
'''


liuchongming74
1月9日 评论:
1月9日 评论:
/ai-review


6月5日 修改了pull request 的描述
相关的Issue
https://gitcode.com/mindspore/hyper-parallel/issues/188
原因(目的、解决的问题等)
在 Hyper-Parallel 框架中,分布式训练需要一个统一的设备拓扑抽象来管理多维并行策略。DeviceMesh 模块旨在:
flatten方法将多维网格转换为一维,便于全局通信操作描述(做了什么,变更了什么)
核心实现
新增 DeviceMesh 类 (
hyper_parallel/core/device_mesh.py)DeviceMesh类,提供设备网格的拓扑抽象init_device_mesh工厂函数,支持自动 rank_list 生成和缓存机制__getitem__方法按维度名称获取子网格get_group方法获取指定维度的通信组get_local_rank方法获取当前进程在指定维度的本地排名flatten方法将多维网格转换为一维网格主要功能
__getitem__get_groupget_local_rankflattenget_device_num_along_axisget_rank_list_along_axisget_global_shape测试用例
单元测试 (
tests/mindspore/ut/test_device_mesh.py)新增 5 个单元测试用例:
test_init_device_mesh_basictest_device_mesh_getitem_validtest_device_mesh_get_group_validtest_device_mesh_get_local_ranktest_device_mesh_flatten变更文件列表
新增文件(2个):
hyper_parallel/core/device_mesh.pytests/mindspore/ut/test_device_mesh.py代码统计:
测试用例(新增、改动、可能影响的功能)
新增测试用例
单元测试(UT):
test_init_device_mesh_basic- init_device_mesh 基础功能测试test_device_mesh_getitem_valid- 子网格获取测试test_device_mesh_get_group_valid- 通信组获取测试test_device_mesh_get_local_rank- 本地排名计算测试test_device_mesh_flatten- 网格扁平化测试测试执行方式
# 运行单元测试 cd /path/to/hyper-parallel pytest tests/mindspore/ut/test_device_mesh.py -v可能影响的功能
测试覆盖范围
测试状态