mindspore-ai / mindspore-ai/hyper-parallel

[feature] 分布式算子 ST 测试迁移至 Gloo CPU 后端(43 算子 206 用例)

Open
#304 0 comments 0 reactions 0 assignees View on GitHub

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 机器上运行。这导致:

  1. 开发门槛高 — 开发者必须有 NPU 硬件才能运行分布式测试
  2. CI 覆盖受限 — NPU 资源有限,门禁压力大
  3. 迭代速度慢 — 算子开发/修改后需要排队等待 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.