mindspore-ai / mindspore-ai/hyper-parallel
[feature] 分布式算子 ST 测试迁移至 Gloo CPU 后端(43 算子 206 用例)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 53
- Forks
- 63
- Avg merge
- 23h 45m
- Merged PRs (30d)
- 63
Description
分布式算子 ST 测试迁移至 Gloo CPU 后端
背景
当前 HyperParallel 的分布式算子 ST 测试(tests/torch/shard/ops/)依赖 Ascend NPU + HCCL 后端执行,只能在 NPU 机器上运行。这导致:
- 开发门槛高 — 开发者必须有 NPU 硬件才能运行分布式测试
- CI 覆盖受限 — NPU 资源有限,门禁压力大
- 迭代速度慢 — 算子开发/修改后需要排队等待 NPU 资源验证
方案
将所有分布式算子 ST 测试用例迁移至 Gloo CPU 后端,使测试可在任意 x86 机器上通过 torchrun 执行,无需 NPU 硬件。
迁移范围
- 43 个分布式算子,共 206 个测试用例
- 涵盖:element-wise(add/sub/mul/div/sin/cos/abs/neg/exp/log/sqrt/rsqrt/clamp/maximum/minimum)、矩阵(matmul/bmm)、归约(sum/mean/prod/max/min/norm/amax/amin)、形状(reshape/view/flatten/transpose/permute/split/chunk/slice/scatter/gather/cat/stack/expand/repeat/tile/flip/narrow/unsqueeze/squeeze/index_select/take/index_put/tensor_split/topk/select/index_add)、类型转换(cast)等
迁移方式
每个算子测试文件(parallel_op_*.py)末尾追加 test_gloo_* 系列函数,使用:
init_dist_gloo()替代init_dist()(Gloo CPU 后端初始化)device_type="cpu"替代device_type="npu"- 去除
.npu()设备转换 - 使用
init_device_mesh+distribute_tensor直接构造 DTensor
对应的 shell 入口文件(test_parallel_op_*.py)追加 @arg_mark(plat_marks=["cpu_linux"]) 测试入口,通过 torchrun_case 启动。
影响分析
- 零影响 — 所有原有 NPU 测试函数和逻辑完全不变
- 纯增量 — 仅在文件末尾追加 Gloo 测试函数和 shell 入口
- 基础设施 — 新增
init_dist_gloo()辅助函数(tests/torch/utils.py),扩展mark_utils.py支持列表参数
schema_version: 1
source: gitcode
gitcode_repo: mindspore/hyper-parallel
gitcode_issue: 122
source_url: https://gitcode.com/mindspore/hyper-parallel/issues/122
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the distributed operator tests under tests/torch/shard/ops/ and compare the existing parallel_op_.py files with their test_parallel_op_.py shell entry points. Read tests/torch/utils.py and mark_utils.py first, then verify the Gloo initialization, CPU device setup, and torchrun entry points across the 43 operators. Done means all 206 cases run on x86 CPU with Gloo while the existing NPU tests remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- distributed-systems, testing-qa
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100