已开启
补充 core/shard 与 custom_ops/experimental 的 UT 覆盖率 #159
hedongdong创建于 5月20日
Hhedongdong
5月20日 关联了pull request:test: improve UT coverage for core/shard and custom_ops/experimental
5月20日 关联了pull request:test: improve UT coverage for core/shard and custom_ops/experimental
5月20日 修改了issue 的描述
背景
HyperParallel 对单文件 UT 覆盖率有 ≥70% 的要求。当前以下文件覆盖率不达标:
hyper_parallel/core/shard/api.pyhyper_parallel/core/shard/custom_shard.pyhyper_parallel/core/shard/_op_dispatch.pyhyper_parallel/core/shard/ops/parallel_flash_attention_score.pyhyper_parallel/core/shard/ops/parallel_scaled_dot_product_attention.pyhyper_parallel/core/shard/ops/parallel_tuple_elementwise.pyhyper_parallel/core/shard/ops/parallel_ops.pyhyper_parallel/core/shard/ops/parallel_one_hot_ext.pyhyper_parallel/core/shard/ops/parallel_embedding.pyhyper_parallel/core/shard/ops/parallel_conv3d.pyhyper_parallel/custom_ops/experimental/此外,
custom_ops/experimental/__init__.py将实现与导出混写在同一文件,不符合模块分离约定。目标
重构
custom_ops/experimental:将 5 个 wrapper 函数的实现从__init__.py提取到experimental_ops.py,__init__.py保持纯 re-export,对外接口不变。补充 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 maskops/parallel_embedding.py、ops/parallel_conv3d.py、ops/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