| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
test: Since the PyTorch community's test cases do not provide full coverage, we adopt the method of adding new test cases to supplement and cover all test case scenarios. Co-authored-by: xin_heyun<919112805@qq.com> # message auto-generated for no-merge-commit merge: !42826 merge test_allreduce_hook_v2.12.0 into v2.12.0 test: Since the PyTorch community's test cases do not provide full coverage, we adopt the method of adding new test cases to supplement and cover all test case scenarios. Created-by: xin_heyun Commit-by: xin_heyun Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> 社区任务issue地址:https://gitcode.com/Ascend/pytorch/issues/3129 issue分析报告地址:https://gitcode.com/Ascend/pytorch/issues/3364 - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 1. 新增 test/distributed/algorithms/ddp_comm_hooks/test_allreduce_hook.py 独立测试文件和 TestAllreduceHook 测试类。测试通过 torch.accelerator.current_accelerator() 获取设备类型,将参与运算的张量迁移到 NPU,并使用 HCCL、动态空闲端口和显式进程组清理完成分布式验证。 2. 新增 12 个测试方法,验证 torch.distributed.algorithms.ddp_comm_hooks.default_hooks.allreduce_hook 的基础 DDP 梯度一致性、gradient_as_bucket_view、static_graph、两者组合、process_group=None、注册辅助接口、自定义子进程组和多 bucket 场景。 3. 验证 torch.float32、torch.float16、torch.bfloat16 的平均结果、shape、dtype、NPU设备和 torch._C.Future 返回契约,并覆盖 FP16 溢出边界、单 rank HCCL 正常调用以及缺少参数、空 bucket、非法进程组等异常场景。 4. 对统一启动双进程测试的 _spawn helper 应用 skipIfUnsupportMultiNPU(WORLD_SIZE)。少于两张 NPU时跳过依赖双进程的 10 个测试,继续执行单 NPU契约和异常参数测试;具备至少两张 NPU时执行全部 12 个测试,避免 rank 1 使用非法设备索引。 5. PyTorch 社区相关覆盖主要集中于 CUDA/NCCL,并包含 wrapper 和 ZeRO overlap 等组合调用。新增独立测试用于补齐 HCCL/NPU 下的输入、返回契约、边界值、组合配置、异常参数和单设备执行覆盖,为该 API 的 NPU行为提供回归保护。 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” 不涉及。API 本身已经适配,master/docs/zh/api/native_api 目录文档已经记录,无需资料变更。 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” 不涉及。本次仅新增测试用例,不调整 torch.distributed.algorithms.ddp_comm_hooks.default_hooks.allreduce_hook 的实现或对外接口。 # 【功能验证】 ## v2.7.1 执行命令: bash python test/distributed/algorithms/ddp_comm_hooks/test_allreduce_hook.py -v 结果: text test_allreduce_hook ... ok test_allreduce_hook_custom_subgroup ... ok test_allreduce_hook_future_and_dtypes ... ok test_allreduce_hook_grad_is_view ... ok test_allreduce_hook_grad_is_view_static_graph ... ok test_allreduce_hook_invalid_arguments ... ok test_allreduce_hook_multiple_buckets ... ok test_allreduce_hook_none_pg ... ok test_allreduce_hook_overflow_boundary ... ok test_allreduce_hook_registration_helper ... ok test_allreduce_hook_single_npu_contract ... ok test_allreduce_hook_static_graph ... ok ---------------------------------------------------------------------- Ran 12 tests in 162.849s OK ## v2.11.0 执行命令: bash python test/distributed/algorithms/ddp_comm_hooks/test_allreduce_hook.py -v 结果: text test_allreduce_hook ... ok test_allreduce_hook_custom_subgroup ... ok test_allreduce_hook_future_and_dtypes ... ok test_allreduce_hook_grad_is_view ... ok test_allreduce_hook_grad_is_view_static_graph ... ok test_allreduce_hook_invalid_arguments ... ok test_allreduce_hook_multiple_buckets ... ok test_allreduce_hook_none_pg ... ok test_allreduce_hook_overflow_boundary ... ok test_allreduce_hook_registration_helper ... ok test_allreduce_hook_single_npu_contract ... ok test_allreduce_hook_static_graph ... ok ---------------------------------------------------------------------- Ran 12 tests in 163.894s OK ## v2.12.0 执行命令: bash python test/distributed/algorithms/ddp_comm_hooks/test_allreduce_hook.py -v 结果: text test_allreduce_hook ... ok test_allreduce_hook_custom_subgroup ... ok test_allreduce_hook_future_and_dtypes ... ok test_allreduce_hook_grad_is_view ... ok test_allreduce_hook_grad_is_view_static_graph ... ok test_allreduce_hook_invalid_arguments ... ok test_allreduce_hook_multiple_buckets ... ok test_allreduce_hook_none_pg ... ok test_allreduce_hook_overflow_boundary ... ok test_allreduce_hook_registration_helper ... ok test_allreduce_hook_single_npu_contract ... ok test_allreduce_hook_static_graph ... ok ---------------------------------------------------------------------- Ran 12 tests in 163.101s OK ## master 执行命令: bash python test/distributed/algorithms/ddp_comm_hooks/test_allreduce_hook.py -v 结果: text test_allreduce_hook ... ok test_allreduce_hook_custom_subgroup ... ok test_allreduce_hook_future_and_dtypes ... ok test_allreduce_hook_grad_is_view ... ok test_allreduce_hook_grad_is_view_static_graph ... ok test_allreduce_hook_invalid_arguments ... ok test_allreduce_hook_multiple_buckets ... ok test_allreduce_hook_none_pg ... ok test_allreduce_hook_overflow_boundary ... ok test_allreduce_hook_registration_helper ... ok test_allreduce_hook_single_npu_contract ... ok test_allreduce_hook_static_graph ... ok ---------------------------------------------------------------------- Ran 12 tests in 148.368s OK # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!42826 | 28 天前 | |
test: Add test cases for torch.distributed.algorithms.ddp_comm_hooks.default_hooks.fp16_compress_wrapper to cover all scenarios. Co-authored-by: xin_heyun<919112805@qq.com> # message auto-generated for no-merge-commit merge: !42840 merge test_fp16_compress_wrapper_v2.12.0 into v2.12.0 test: Add test cases for torch.distributed.algorithms.ddp_comm_hooks.default_hooks.fp16_compress_wrapper to cover all scenarios. Created-by: xin_heyun Commit-by: xin_heyun Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> 社区issue任务地址:https://gitcode.com/Ascend/pytorch/issues/3133 issue分析报告地址:https://gitcode.com/Ascend/pytorch/issues/3367 - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 1. 新增 test/distributed/algorithms/ddp_comm_hooks/test_fp16_compress_wrapper.py 独立测试文件和 TestFp16CompressWrapper 测试类。测试通过 torch.accelerator.current_accelerator() 获取设备类型,将参与运算的张量迁移到 NPU,并使用 HCCL、动态空闲端口和显式进程组清理完成分布式验证。 2. 新增 15 个测试方法,验证 torch.distributed.algorithms.ddp_comm_hooks.default_hooks.fp16_compress_wrapper 包装 allreduce_hook、powerSGD_hook 和自定义 Future hook 时的行为,覆盖 gradient_as_bucket_view、static_graph、两者组合、process_group=None、自定义子进程组和多 bucket 场景。 3. 验证 torch.float32、torch.float16、torch.bfloat16 输入下的 state 透传、内部 FP16 dtype、Future 类型、结果 shape、dtype、设备和最终梯度,并覆盖 FP16 溢出边界、单 NPU直接调用契约及缺少 hook、非法 bucket、非 Future 返回和内部异常等错误场景。 4. 对统一启动双进程测试的 _spawn helper 应用 skipIfUnsupportMultiNPU(WORLD_SIZE)。少于两张 NPU时跳过依赖双进程的 13 个测试,继续执行单 NPU契约和异常参数测试;具备至少两张 NPU时执行全部 15 个测试,避免 rank 1 使用非法设备索引。 5. PyTorch 社区相关测试依赖 CUDA/NCCL,主要覆盖 all-reduce、PowerSGD 和 bucket view。新增独立测试用于补齐 HCCL/NPU 下的组合配置、dtype/Future/state 契约、边界值、异常参数和单设备执行覆盖,为该 API 的 NPU行为提供回归保护。 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” 不涉及。API 本身已经适配,master/docs/zh/api/native_api 目录文档已经记录,无需资料变更。 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” 不涉及。本次仅新增测试用例,不调整 torch.distributed.algorithms.ddp_comm_hooks.default_hooks.fp16_compress_wrapper 的实现或对外接口。 # 【功能验证】 ## v2.7.1 执行命令: bash python test/distributed/algorithms/ddp_comm_hooks/test_fp16_compress_wrapper.py -v 结果: text test_fp16_compress_wrapper_allreduce ... ok test_fp16_compress_wrapper_allreduce_grad_is_view ... ok test_fp16_compress_wrapper_allreduce_grad_is_view_static_graph ... ok test_fp16_compress_wrapper_allreduce_none_pg ... ok test_fp16_compress_wrapper_allreduce_static_graph ... ok test_fp16_compress_wrapper_custom_subgroup ... ok test_fp16_compress_wrapper_future_dtype_and_state ... ok test_fp16_compress_wrapper_invalid_arguments ... ok test_fp16_compress_wrapper_multiple_buckets ... ok test_fp16_compress_wrapper_predivide_overflow_boundary ... ok test_fp16_compress_wrapper_powersgd ... ok test_fp16_compress_wrapper_powersgd_grad_is_view ... ok test_fp16_compress_wrapper_powersgd_grad_is_view_static_graph ... ok test_fp16_compress_wrapper_powersgd_static_graph ... ok test_fp16_compress_wrapper_single_npu_contract ... ok ---------------------------------------------------------------------- Ran 15 tests in 215.079s OK ## v2.11.0 执行命令: bash python test/distributed/algorithms/ddp_comm_hooks/test_fp16_compress_wrapper.py -v 结果: text test_fp16_compress_wrapper_allreduce ... ok test_fp16_compress_wrapper_allreduce_grad_is_view ... ok test_fp16_compress_wrapper_allreduce_grad_is_view_static_graph ... ok test_fp16_compress_wrapper_allreduce_none_pg ... ok test_fp16_compress_wrapper_allreduce_static_graph ... ok test_fp16_compress_wrapper_custom_subgroup ... ok test_fp16_compress_wrapper_future_dtype_and_state ... ok test_fp16_compress_wrapper_invalid_arguments ... ok test_fp16_compress_wrapper_multiple_buckets ... ok test_fp16_compress_wrapper_predivide_overflow_boundary ... ok test_fp16_compress_wrapper_powersgd ... ok test_fp16_compress_wrapper_powersgd_grad_is_view ... ok test_fp16_compress_wrapper_powersgd_grad_is_view_static_graph ... ok test_fp16_compress_wrapper_powersgd_static_graph ... ok test_fp16_compress_wrapper_single_npu_contract ... ok ---------------------------------------------------------------------- Ran 15 tests in 209.623s OK ## v2.12.0 执行命令: bash python test/distributed/algorithms/ddp_comm_hooks/test_fp16_compress_wrapper.py -v 结果: text test_fp16_compress_wrapper_allreduce ... ok test_fp16_compress_wrapper_allreduce_grad_is_view ... ok test_fp16_compress_wrapper_allreduce_grad_is_view_static_graph ... ok test_fp16_compress_wrapper_allreduce_none_pg ... ok test_fp16_compress_wrapper_allreduce_static_graph ... ok test_fp16_compress_wrapper_custom_subgroup ... ok test_fp16_compress_wrapper_future_dtype_and_state ... ok test_fp16_compress_wrapper_invalid_arguments ... ok test_fp16_compress_wrapper_multiple_buckets ... ok test_fp16_compress_wrapper_predivide_overflow_boundary ... ok test_fp16_compress_wrapper_powersgd ... ok test_fp16_compress_wrapper_powersgd_grad_is_view ... ok test_fp16_compress_wrapper_powersgd_grad_is_view_static_graph ... ok test_fp16_compress_wrapper_powersgd_static_graph ... ok test_fp16_compress_wrapper_single_npu_contract ... ok ---------------------------------------------------------------------- Ran 15 tests in 214.918s OK ## master 执行命令: bash python test/distributed/algorithms/ddp_comm_hooks/test_fp16_compress_wrapper.py -v 结果: text test_fp16_compress_wrapper_allreduce ... ok test_fp16_compress_wrapper_allreduce_grad_is_view ... ok test_fp16_compress_wrapper_allreduce_grad_is_view_static_graph ... ok test_fp16_compress_wrapper_allreduce_none_pg ... ok test_fp16_compress_wrapper_allreduce_static_graph ... ok test_fp16_compress_wrapper_custom_subgroup ... ok test_fp16_compress_wrapper_future_dtype_and_state ... ok test_fp16_compress_wrapper_invalid_arguments ... ok test_fp16_compress_wrapper_multiple_buckets ... ok test_fp16_compress_wrapper_predivide_overflow_boundary ... ok test_fp16_compress_wrapper_powersgd ... ok test_fp16_compress_wrapper_powersgd_grad_is_view ... ok test_fp16_compress_wrapper_powersgd_grad_is_view_static_graph ... ok test_fp16_compress_wrapper_powersgd_static_graph ... ok test_fp16_compress_wrapper_single_npu_contract ... ok ---------------------------------------------------------------------- Ran 15 tests in 189.099s OK # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!42840 | 29 天前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 28 天前 | ||
| 29 天前 |