已合并
test(distributed):add test for validate_checkpoint_id, reset, set_up_storage_reader from BroadcastingTorchSaveReader for master(fixed) #33996
xh-zhan创建于 4月20日
test(distributed):add test for validate_checkpoint_id, reset, set_up_storage_reader from BroadcastingTorchSaveReader for master(fixed) #33996
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 xh-zhan 的贡献)4月20日 关联了issue:[API一致性] BroadcastingTorchSaveReader的下三个API:validate_checkpoint_id、reset、set_up_storage_reader无需NPU适配
4月20日 关联了issue:[API一致性] BroadcastingTorchSaveReader的下三个API:validate_checkpoint_id、reset、set_up_storage_reader无需NPU适配
ascend-robot
4月20日 评论:
4月20日 评论:
ascend-robot
4月20日 评论:
4月20日 评论:
Thanks for your pull-request.
The full list of commands accepted by me can be found at here。
You can get sig-info at here
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| test | ✅ 李伟, yuhaiyan (2/2) | ✅ 李伟 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
xh-zhan, thanks for your pull request. All authors of the commits have signed the CLA. 👍


4月20日 添加了label:ascend-cla/yes
ascend-robot
4月20日 评论:
4月20日 评论:
当前仓库存在以下 保护分支 :
| Protected Branch | Version | Release |
|---|---|---|
| master | ||
| v2.7.1 | ||
| v2.10.0 | ||
| v2.9.0 | ||
| v2.11.0 | ||
| v2.8.0 |
评论 /sync <branch1> <branch2> ... 可将当前 PR 修改同步到其它分支(创建同步 PR):
a) 如果当前 PR 是 Open 状态,同步操作将延迟到 PR 被合并时执行
b) 如果当前 PR 已经 Merged,将立即执行同步操作
注意:
- /sync 命令可以指定同步到多个分支,仅最后一个 /sync 命令生效
- 如果创建的同步 PR 不正确,可通过向同步 PR 的源分支提交轻量级 PR 完善,或使用 /close 命令关闭


xh-zhan
4月20日 评论:
4月20日 评论:
compile


4月20日 添加了label:ci-pipeline-running
4月20日 删除了label:ci-pipeline-running
4月20日 添加了label:ci-pipeline-passed
ascend-robot
4月20日 评论:
4月20日 评论:
流水线 PR-pipeline_pytorch#16146 已完成
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_ARM | ✅ | >>> | |
| Build_LibTorch_x86 | ✅ | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck | ✅ | >>> |
| check_error | ✅ | >>> | |
| 开源片段检查 | SCA | ✅ | >>> |
| 开发者测试 | UT_X86_Part_01 | 🛑 | >>> |
| UT_X86_Part_02 | 🛑 | >>> | |
| UT_ARM_A3_Part_01 | 🛑 | >>> | |
| UT_ARM_A3_Part_02 | 🛑 | >>> | |
| UT_DIST_X86_Part_01 | ✅ | >>> | |
| UT_DIST_X86_Part_02 | ✅ | >>> | |
| UT_DIST_X86_Part_03 | ✅ | >>> | |
| UT_DIST_X86_Part_04 | ✅ | >>> | |
| UT_inductor_Part_01 | 🛑 | >>> | |
| UT_inductor_Part_02 | 🛑 | >>> | |
| UT_inductor_Part_03 | 🛑 | >>> | |
| UT_inductor_Part_04 | 🛑 | >>> | |
| UT_ARM_A2_Part_01 | ✅ | >>> | |
| UT_ARM_A2_Part_02 | ✅ | >>> | |
| 流水线 | PR-pipeline_pytorch | ✅ | >>> |


4月20日 添加了label:approved
haiyan8
4月21日 评论:
4月21日 评论:
/lgtm


4月21日 添加了label:lgtm
ascend-robot
4月21日 评论:
4月21日 评论:
4月21日 合入了pull request
/kind feature
What does this PR do / why do we need it:
本次 PR 为
BroadcastingTorchSaveReader类中的三个核心 API 新增了单元测试用例,以确保其在torch_npu环境下的行为与 PyTorch 原生行为保持一致。测试用例路径:
test/distributed/checkpoint/test_broadcasting_reader.pyAPI 功能说明:
torch.distributed.checkpoint.format_utils.BroadcastingTorchSaveReader.validate_checkpoint_id:纯逻辑 API,用于检查给定的 checkpoint 文件路径是否存在。torch.distributed.checkpoint.format_utils.BroadcastingTorchSaveReader.reset:纯逻辑 API,用于重置BroadcastingTorchSaveReader实例的checkpoint_id属性,支持更新为新的路径或None。torch.distributed.checkpoint.format_utils.BroadcastingTorchSaveReader.set_up_storage_reader:用于设置存储读取器的元数据及协调者(coordinator)状态。包含协调者身份校验和checkpoint_id非空检查。用例完备性说明:
由于Pytorch社区无上述三个API的测试用例,故本次PR新增用例
test_broadcasting_reader.py。本次提交的测试用例覆盖了以下场景,确保 API 的健壮性:validate_checkpoint_id:TrueFalsereset:checkpoint_id正确变更None→checkpoint_id正确变更为Noneset_up_storage_reader:is_coordinator属性AssertionErrorcheckpoint_id为None时抛出AssertionError适配方案:
经分析,这三个 API 均为纯 Python 逻辑,不依赖任何 NPU 特定算子或硬件特性。本次提交 无需对 API 本身进行任何代码适配,仅增加单元测试以完成 NPU 环境下的兼容性验证。
Which issue(s) this PR fixes:
Fixes #1680
Related PR
This PR is a follow-up fix to the previously merged PR #33733.
Special notes for your reviewers:
test/distributed/checkpoint/test_broadcasting_reader.pyRan 7 tests in 0.011s
OK
torch-npu仓库规范(test_开头 + 核心关键词),文件内添加了完整 API 名称和测试维度注释,便于后续检索和维护。master分支。