mindspore-ai / mindspore-ai/hyper-parallel

补充 core/shard 与 custom_ops/experimental 的 UT 覆盖率

Open
#714 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

背景

HyperParallel 对单文件 UT 覆盖率有 ≥70% 的要求。当前以下文件覆盖率不达标:

文件 当前覆盖率
hyper_parallel/core/shard/api.py 8%
hyper_parallel/core/shard/custom_shard.py 18%
hyper_parallel/core/shard/_op_dispatch.py 31%
hyper_parallel/core/shard/ops/parallel_flash_attention_score.py 0%
hyper_parallel/core/shard/ops/parallel_scaled_dot_product_attention.py 18%
hyper_parallel/core/shard/ops/parallel_tuple_elementwise.py 50%
hyper_parallel/core/shard/ops/parallel_ops.py 52%
hyper_parallel/core/shard/ops/parallel_one_hot_ext.py 54%
hyper_parallel/core/shard/ops/parallel_embedding.py 65%
hyper_parallel/core/shard/ops/parallel_conv3d.py 69%
hyper_parallel/custom_ops/experimental/ 0%(无 UT 文件)

此外,custom_ops/experimental/__init__.py 将实现与导出混写在同一文件,不符合模块分离约定。

目标

  1. 重构 custom_ops/experimental:将 5 个 wrapper 函数的实现从 __init__.py 提取到 experimental_ops.py__init__.py 保持纯 re-export,对外接口不变。

  2. 补充 UT,使所有文件达到 ≥70% 覆盖率

    • core/shard/api.py:新建 test_api.py,覆盖 hook 注册、layout 转换、DTensor 重分布路径
    • core/shard/custom_shard.py:新建 test_custom_shard.py,覆盖所有分支
    • core/shard/_op_dispatch.py:补充 test_op_dispatch.py,覆盖 LayoutCacheManager、_pack_infer_output、_with_layout_infer、dispatch 流程
    • ops/parallel_flash_attention_score.py:新建,覆盖 ParallelFlashAttention 各 layout 模式
    • ops/parallel_ops.py:新建,覆盖基类逻辑
    • ops/parallel_tuple_elementwise.py:新建,覆盖 layout 一致性推断
    • ops/parallel_scaled_dot_product_attention.py:补充,覆盖 get_expand_impl、causal mask
    • ops/parallel_embedding.pyops/parallel_conv3d.pyops/parallel_one_hot_ext.py:补充 get_expand_impl 路径
    • custom_ops/experimental/experimental_ops.py:新建 test_experimental_ops.py,100% 覆盖

所有 UT 使用 mock 平台,无 GPU/NPU 硬件依赖。

相关 PR

!665

schema_version: 1
source: gitcode
gitcode_repo: mindspore/hyper-parallel
gitcode_issue: 159
source_url: https://gitcode.com/mindspore/hyper-parallel/issues/159

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

Read the listed files under hyper_parallel/core/shard, core/shard/ops, and custom_ops/experimental, starting with custom_ops/experimental/init.py and the named UT entry points. Run the existing mock-platform tests and coverage checks to identify uncovered branches. Done means experimental_ops.py is covered at 100%, every listed file reaches at least 70%, and init.py preserves the public re-exports without hardware dependencies.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.