Pull Request已成功合入, 合并人@ascend-robot
(感谢 gcw_rZ2ZS0CZ 的贡献)变更摘要
本次变更新增独立测试文件 test/test_qint32_storage_dtype.py,聚焦验证 torch.QInt32Storage.dtype 的类属性与实例属性。由于 PyTorch 社区测试 test_storage_error 在遍历 torch._storage_classes 全局注册表时会混入 torch.cuda.* 与 torch_npu.npu.* 等设备相关 storage 类,无法在 NPU 环境下对 QInt32Storage 做针对性验证,因此新增该独立测试文件。该 API 为设备无关的纯 Python legacy Storage 类,不涉及代码逻辑修改。
主要改动
- 新增测试文件
test/test_qint32_storage_dtype.py:创建独立的测试模块,包含TestQInt32StorageDtype测试类,继承自TestCase,用于聚焦验证torch.QInt32Storage.dtype属性。 - 新增
test_class_dtype测试用例:通过assertIs断言torch.QInt32Storage.dtype类属性值为torch.qint32,覆盖类级别 dtype 的验证。 - 新增
test_instance_dtype测试用例:覆盖空构造torch.QInt32Storage()、指定大小torch.QInt32Storage(4)和序列构造torch.QInt32Storage([0, 1, 2])三种实例化方式,验证每种方式下实例的dtype均为torch.qint32,且与类属性torch.QInt32Storage.dtype一致。


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 | ✅ li_jing_hw, huangjingwei (2/2) | ✅ li_jing_hw (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
gcw_rZ2ZS0CZ, thanks for your pull request. All authors of the commits have signed the CLA. 👍


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


ascend docs pipeline is running...


✅ 跳过 docs ci 检查,没有需要检查的文档文件


| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_ARM | ✅ | >>> | |
| Build_LibTorch_x86 | ✅ | >>> | |
| Build_LibTorch_ARM | ✅ | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| patch_test | 🛑 | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | codecheck_pre-commit | ✅ | >>> |
| check_error | ✅ | >>> | |
| lintrunner | ✅ | >>> | |
| 开源片段检查 | SCA | ✅ | >>> |
| 开发者测试 | UT_ARM_A3_Part_01 | ✅ | >>> |
| UT_ARM_A3_Part_02 | ✅ | >>> | |
| UT_ARM_A2_Part_01 | ✅ | >>> | |
| UT_ARM_A2_Part_02 | ✅ | >>> | |
| UT_ARM_A2_Part_03 | ✅ | >>> | |
| UT_inductor_Part_01 | 🛑 | >>> | |
| UT_inductor_Part_02 | 🛑 | >>> | |
| UT_inductor_Part_03 | 🛑 | >>> | |
| UT_inductor_Part_04 | 🛑 | >>> | |
| UT_DIST_ARM_Part_01 | 🛑 | >>> | |
| UT_DIST_ARM_Part_02 | 🛑 | >>> | |
| UT_DIST_ARM_Part_03 | 🛑 | >>> | |
| UT_DIST_ARM_Part_04 | 🛑 | >>> | |
| UT_ARM_A2_Select_Part_01 | ✅ | >>> | |
| UT_ARM_A2_Select_Part_02 | ✅ | >>> | |
| 流水线 | PR-pipeline_pytorch | ✅ | >>> |
- compile、compile_inductor、compile_torchair : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


/approve


/lgtm




【合入来源】
关联任务issue: https://gitcode.com/Ascend/pytorch/issues/3529
【修改方案】
torch.QInt32Storage.dtype
PyTorch 官方社区在 test/test_torch.py::TestTorch::test_storage_error(master 第 7814 行起,v2.7.1 第 7767 行起)中对
legacy storage 类有遍历式错误路径测试,将 torch.QInt32Storage 列入 quantized_storages 列表。但该测试遍历
torch._storage_classes 全局注册表,在 NPU 环境下会混入 torch.cuda.* 与 torch_npu.npu.* 等设备相关 storage 类,无法针对
QInt32Storage 做聚焦验证;且 test_torch.py 为大型社区文件,不宜叠加改动。因此新增独立测试文件
test/test_qint32_storage_dtype.py。
该 API 为设备无关的纯 Python legacy Storage 类(torch.storage._LegacyStorage 子类,对应 torch.qint32 量化 dtype)的
dtype 属性,不涉及 NPU 适配,不需要代码修改。
新增 test/test_qint32_storage_dtype.py,验证 torch.QInt32Storage.dtype 的类属性与实例属性(空 / size / 序列构造)。
【资料变更】
不涉及资料修改。torch.QInt32Storage 为 legacy typed storage 类,PyTorch 官方已在 dtype 属性上调用
_warn_typed_storage_removal 标记弃用,native_api 文档无需补充;非计算类 API 与数据类型无关。
【接口变更】
不涉及
【功能介绍】
torch.QInt32Storage.dtype 返回 torch.QInt32Storage 对应的量化 dtype(torch.qint32)。QInt32Storage 是
torch.storage._LegacyStorage 的量化子类,dtype 同时为类属性与实例属性,为设备无关的纯 Python 元数据。
【功能验证】
test_qint32_storage_dtype.py (torch.QInt32Storage.dtype)
运行命令:
python -m pytest /workspace/user_data/pytorch-v2.7.1/test/test_qint32_storage_dtype.py -v
运行结果:
【CheckList】