已关闭
docs: fix description for api torch.hub._get_torch_home #34365
xiemingda1002创建于 4月25日关闭于 7月28日
docs: fix description for api torch.hub._get_torch_home #34365
已关闭
从已删除 :add-torch-hub-doc-v2.7.1合入到Ascend/pytorchv2.7.1
当前Pull Request已关闭, 关闭人@xiemingda1002
4月25日 创建了 pull request,commit 0268c6ab
4月25日 关联了issue:[Usage]: test目录下 torch.hub.help 和 torch.hub._get_torch_home API测试用例缺失
ascend-robot
4月25日 评论:
4月25日 评论:
ascend-robot
4月25日 评论:
4月25日 评论:
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
⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| docs | ❌ (0/2)(You can also ask: renyujin, anyrenwei, zqwenn, wasd1111222, 褚博宁) | ❌ (0/1)(You can also ask: wangqiang160, medivh-x, guoqi1024, zichun_ye, 陈豪) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
xiemingda1002, thanks for your pull request. All authors of the commits have signed the CLA. 👍


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


4月25日 修改了pull request 的描述
此处折叠了25条事件消息 查看更多
4月25日 添加了label:ci-pipeline-failed
xiemingda1002
4月25日 评论:
4月25日 评论:
compile


4月25日 删除了label:ci-pipeline-failed
4月25日 添加了label:ci-pipeline-running
4月25日 删除了label:ci-pipeline-running
ascend-robot
4月25日 评论:
4月25日 评论:
流水线 PR-pipeline_pytorch#17214 已终止运行
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | 🟨 | >>> |
| Build_ARM | 🟨 | >>> | |
| Build_LibTorch_x86 | 🟨 | >>> | |
| Build_LibTorch_ARM | 🟨 | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| patch_test | 🛑 | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck | ✅ | >>> |
| check_error | ✅ | >>> | |
| CodeCheck_lintrunner | ✅ | >>> | |
| 开源片段检查 | 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 | 🕚 | >>> | |
| UT_ARM_A2_Part_03 | 🕚 | >>> | |
| 流水线 | PR-pipeline_pytorch | 🟨 | >>> |


4月25日 添加了label:ci-pipeline-running
4月25日 删除了label:ci-pipeline-running
4月25日 添加了label:ci-pipeline-passed
ascend-robot
4月25日 评论:
4月25日 评论:
流水线 PR-pipeline_pytorch#17215 已完成
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_ARM | ✅ | >>> | |
| Build_LibTorch_x86 | ✅ | >>> | |
| Build_LibTorch_ARM | ✅ | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| patch_test | 🛑 | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck | ✅ | >>> |
| check_error | ✅ | >>> | |
| CodeCheck_lintrunner | ✅ | >>> | |
| 开源片段检查 | 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 | ✅ | >>> | |
| UT_ARM_A2_Part_03 | ✅ | >>> | |
| 流水线 | PR-pipeline_pytorch | ✅ | >>> |


4月25日 修改了pull request 的描述
4月27日 修改了pull request 的描述
4月27日 修改了pull request 的描述
5月9日 修改了pull request 的描述
5月9日 修改了pull request 的描述
7月28日 关闭了 pull request
【合入来源】
【修改方案】
一、API 功能说明
torch.hub.help 和 torch.hub._get_torch_home 是 PyTorch hub 模块中用于文档查询和路径管理的辅助 API,功能说明如下:
torch.hub.help(github, model, force_reload=False, skip_validation=False, trust_repo=None)
torch.hub._get_torch_home()
上述 API 均为纯 Python 层实现,不涉及张量计算,仅负责文档查询和路径解析。
二、测试文件 test/test_hub_api.py 完整验证该 API 的原因
本测试文件针对 PyTorch 社区原生 test/test_hub.py 覆盖不足的 torch.hub.help / _get_torch_home API 进行补充验证,确保昇腾 NPU 环境下功能完整可用:
torch.hub.help API 验证
torch.hub._get_torch_home API 验证
测试隔离性保障
测试完整性
所有用例覆盖 API 的基础功能验证、接口存在性检查、环境变量交互、测试隔离性保障,完整覆盖昇腾 NPU 适配所需的最小功能集合。
三、昇腾 NPU 适配说明(解释为什么无需 NPU 适配)
torch.hub.help 和 torch.hub._get_torch_home 均具备硬件无关性、纯 Python 层实现、无底层算子依赖三大核心特征,决定了其无需针对昇腾 NPU 做适配,具体分析:
纯 Python 层抽象,无硬件相关逻辑
无底层算子 / 内核依赖
核心逻辑与硬件解耦
结论
torch.hub.help 和 torch.hub._get_torch_home 均是「硬件无关的纯 Python 层抽象」,核心逻辑不耦合任何特定硬件。测试用例无需导入 torch_npu,API 本身无需适配修改,可直接复用。
【资料变更】
刷新v2.7.1分支下多个版本资料。
torch.hub._get_torch_home API该API昇腾支持,但是在文档中并无描述,我已通过如下用PR例验证该api的支持没有问题,需要在文档中进行刷新。
master: https://gitcode.com/Ascend/pytorch/pull/34071
v2.11.0: https://gitcode.com/Ascend/pytorch/pull/34082
v2.10.0: https://gitcode.com/Ascend/pytorch/pull/34080
v2.9.0: https://gitcode.com/Ascend/pytorch/pull/34076
v2.8.0: https://gitcode.com/Ascend/pytorch/pull/34073
v2.7.1: https://gitcode.com/Ascend/pytorch/pull/34072
【接口变更】
不涉及
【功能验证】
测试文件路径:test/test_hub_api.py
本地验证结果:
所有测试用例执行通过。torch.hub.help 和 torch.hub._get_torch_home API 核心功能验证正常。
两个 API 均为纯 Python 层实现,不涉及张量操作,无需 NPU 设备适配。测试用例无需导入 torch_npu,API 本身可在任意硬件环境稳定运行。验证结果表明,torch.hub.help 和 torch.hub._get_torch_home 在昇腾 NPU 环境下功能正常可用,无需修改源码。
【CheckList】