已合并
test(fx): add NPU tests for symbolic_shapes.lru_cache and PropagateUnbackedSymInts #38674
Nokstella创建于 6月16日
test(fx): add NPU tests for symbolic_shapes.lru_cache and PropagateUnbackedSymInts #38674
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 Nokstella 的贡献)6月16日 关联了issue:【开源实习】Torch-NPU API一致性对齐:补齐测试用例、API功能对齐、补齐文档(11)
ascend-robot
6月16日 评论:
6月16日 评论:
6月16日 添加了label:ascend-cla/yes
ascend-robot
6月16日 评论:
6月16日 评论:
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
wangshiqi-2026, thanks for your pull request. All authors of the commits have signed the CLA. 👍


此处折叠了215条消息 查看更多
li_jing_hw
20 天前 评论:
20 天前 评论:
/approve


20 天前 添加了label:approvedlgtm
20 天前 删除了label:ci-pipeline-passed
20 天前 合入了pull request
ascend-robot
20 天前 评论:
20 天前 评论:
流水线 pytorch_gitcode_PR_multiVersion#13734 [ commitID:9deb5212 ] 已完成


【合入来源】
如有社区issue,请关联issue链接
请勿携带内部流程信息(需求链接、问题单、内部issue等)
问题单
issue/工单
关联issue:https://gitcode.com/Ascend/pytorch/issues/1617
【修改方案】
完善 Torch-NPU 对
torch.fx.experimental.symbolic_shapes下 5 个 API 在 NPU 环境下的兼容性验证,覆盖以下 API:1. 上游社区用例情况分析
在 PyTorch 上游仓库(github.com/pytorch/pytorch)中搜索这 5 个 API:
torch/fx/experimental/symbolic_shapes.py中有公开实现,但上游test/目录下无针对symbolic_shapes.lru_cache的直接单测覆盖symbolic_shapes.py,上游仅在test/fx/test_fx_traceback.py中间接涉及,无独立、直接的 API 验证用例torch.fx.Interpreter,上游无针对 PropagateUnbackedSymInts 这三个方法的直接单测结论:5 个 API 均属于上游"无直接用例"场景,按 1.3 规范自写用例,提交到 torch-npu 的
test/目录。2. NPU 适配方案
5 个 API 均为 FX / symbolic_shapes 框架层纯 Python 接口,不涉及 NPU 算子调用,在 NPU 上行为与 CPU 一致,无需做任何 API 代码适配修改。
3. 新增测试用例
新增/扩展以下测试文件进行覆盖:
test_public_lru_cache→ lru_cachetest_propagate_unbacked_symints_run等 → PropagateUnbackedSymIntstest_propagate_unbacked_symints_boxed_run→ boxed_runtest_propagate_unbacked_symints_call_function→ call_functiontest_propagate_unbacked_symints_call_method→ call_method4. API 补齐
不需要。5 个 API 在 NPU 上运行结果与 PyTorch 社区一致。
5. 多版本分支合入
目标分支:
v2.12.0【资料变更】
不涉及(文档补齐在独立 docs PR 中完成)。
【接口变更】
不涉及(无新增/修改对外 C++ 或 Python 接口,仅新增测试用例)
【功能验证】
1. 测试环境
设备:Ascend NPU
框架:torch-npu + PyTorch
说明:5 个 API 为 FX/symbolic_shapes 的框架层纯 Python 接口,不涉及张量算子差异;用例中涉及张量时使用
.to(device_type)运行在当前 accelerator。2. 测试命令
cd /tmp source /usr/local/Ascend/ascend-toolkit/set_env.sh python /workspace/pytorch/test/fx/test_symbolic_shapes_api.py -k test_public_lru_cache python /workspace/pytorch/test/fx/test_fx_propagate_unbacked_symints.py -k propagate_unbacked3. 测试结果(运行日志)
4. 与上游用例的关系
【CheckList】
PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]