已关闭
docs: mark assume_constant_result as supported #42036
2501_93637465创建于 7月18日关闭于 7月27日
docs: mark assume_constant_result as supported #42036
已关闭
2501_93637465创建于 7月18日关闭于 7月27日
2501_93637465
2501_93637465
7月18日

【合入来源】

任务来源:https://gitcode.com/Ascend/pytorch/issues/2990

关联 Issue:https://gitcode.com/Ascend/pytorch/issues/3036

Fixes #3036

API:torch.compiler.assume_constant_result

目标分支:v2.7.1

【修改方案】

一、API 功能说明

torch.compiler.assume_constant_result 用于标记一个无参数函数,使 TorchDynamo 在编译期间将该函数的返回值视为常量。

本次 NPU 兼容性验证覆盖:

  • API 返回原函数对象;
  • 使用 NPU Tensor 时可被 torch.compile 正常捕获;
  • 编译函数连续执行结果正确;
  • 被标记函数的结果在编译期间只计算一次。

该 API 由 PyTorch TorchDynamo 提供,不需要新增 torch_npu 算子实现。

二、测试用例完备性

已新增独立 NPU 功能测试:

test/dynamo/test_assume_constant_result.py

相关测试 PR:

三、资料适配方案

v2.7.1 分支的原生 API 支持清单中,将 torch.compiler.assume_constant_result 的支持状态由“否”更新为“是”,限制与说明保持为“-”。

涉及以下版本:

  • PyTorch 2.7.1
  • PyTorch 2.9.0
  • PyTorch 2.10.0
  • PyTorch 2.11.0
  • PyTorch 2.12.0

按照任务规范,不更新 PyTorch 2.8.0 支持清单。

【资料变更】

涉及资料变更,修改以下文件:

  • docs/zh/native_apis/pytorch_2-7-1/torch-compiler.md
  • docs/zh/native_apis/pytorch_2-9-0/torch-compiler.md
  • docs/zh/native_apis/pytorch_2-10-0/torch-compiler.md
  • docs/zh/native_apis/pytorch_2-11-0/torch-compiler.md
  • docs/zh/native_apis/pytorch_2-12-0/torch-compiler.md

五个版本均将该 API 的支持状态更新为:

是 | -
likedislike
当前Pull Request已关闭, 关闭人@2501_93637465
2501_936374652501_93637465
7月18日 创建了 pull request,commit 4192e884
2501_936374652501_93637465
7月18日 关联了issue:【社区任务】7月社区任务第二期-Ascend for PyTorch API 一致性开发(93),[API一致性] torch.compiler.assume_constant_result NPU兼容性测试补齐
atomgit-bot
atomgit-bot
7月18日 评论:

变更摘要

本次 PR 是一个纯文档更新,将 torch.compiler.assume_constant_result API 在 NPU(Ascend)上的支持状态标记为"已支持"。该 API 由 PyTorch TorchDynamo 原生提供,用于标记无参数函数,使编译期间将其返回值视为常量。经过 NPU 兼容性验证(包括返回原函数对象、NPU Tensor 下 torch.compile 正常捕获、编译函数连续执行正确性、被标记函数结果仅计算一次等),现将其从支持清单中移入已支持类别,涉及 v2.7.1 分支的 API 支持矩阵文档。

主要改动

  • API 支持状态更新:在 NPU 原生 API 支持清单文档中,将 torch.compiler.assume_constant_result 从未支持/待验证状态更新为已支持状态。
  • 文档条目位置调整:对应条目在支持清单中的分类位置发生变更(从未支持列表移至已支持列表),涉及 5 处文档行的增删。
likedislike
不准确?
atomgit-bot
atomgit-bot
7月18日 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
此处折叠了50条消息 查看更多
ascend-robotascend-robot成员
7月22日 添加了label:docs-ci-pipeline-success
ascend-robotascend-robot成员
7月22日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
7月22日 添加了label:ci-pipeline-passed
ascend-robot
ascend-robot成员
7月22日 评论:
流水线 PR-pipeline_pytorch#48114 [ commitID:0932ca27 ] 已完成
>>>代码风格自动修复执行成功(无修复内容)
阶段 任务名 状态 详情
编译构建 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_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 >>>
此流水线已支持下列评论快捷指令,仅PR创建者和白名单成员[wujinyuan1, huangjingwei, liangsongwei, yashi999, culechan, Dring, wuyouqi1, L1919_snow, qq_52711437, WhiteNight12, nomiz, xiu_21, ffmh, wanglijun55, hss-shuai, husichao, smallsilly, lanshaozuishuai, jimmyisme1, lzy0920232, alpha-junh, Sunshine_Youngster, wei_zhuoyi, zhangyihuiben, zyw-hw, zzzkeke, rmch, yangch0324, LucciC, AACAES, renyujin, wjlflyer, senzhen-town, pengjingyou, qsc97, limuan, yule100, xiaoqi-zhou, kuhn7, chenxingying, hanye02, zichun_ye, anyrenwei, kkjocker, wangzili121, Lu_G, yvjc, puddingfjz, HandsoemLemon, bigprestigee1, huawuyi, zhenyu10, dairenjie, du-jin-hang, zou-jieyu, adelaideliu, TrHan, wanlinan, Windwindzzz, pengqihw, kisnwang, yuheng_wang, honghao_wang, jizewei, zhangguoguang, sunyu-xuan, chenrayray, hbhu_bin, liujunzhu, c_34, LiNuoh, maoyuanpeng1, zzhongmin, zhaoyu65, bellatan, jiabaolin, zhuofanshen, wencaiwen, lu_zhuge, caoshuyang, molly12, lyx324521, LQ1206, gitcode-chenjiao, cai-weiwei1989, CHDong, ogqin, yuanlipingGit, xuqinglin1, lqz2, zouwei1, chaoluoa, paradox325, jackzhang1116, yaoyao, akh, yujiacheng, dengjie0116, Hubert11111, Shine_Ws, wslhj555, longqiand, OYtao666, JiaqingQiang, luyyyy, Kingbelial, zhanghaiyu0101, wenxp1018, yanliu-luoluo, ksun_sekiro, liyong328, wgzheng, tangky, vivi_is_coding, aoiaoisola, weixin_44494597, wangmengmengwang65667, hid57809721, qq_35468730, comeonup, C547032, gcw_m5OQChA4, yao_yao_ling_xian, cnnbwcy, szqfes_12, cora_19, cann_lilin, can, shawnylee233, fanglanyue0916, hhz0, LiNuohang, taohuoquan]评论有效
  • compile、compile_inductor、compile_torchair : 运行流水线
  • retry : 重试流水线所有失败子任务
  • retry <任务名> : 仅重试指定失败子任务
  • stop : 停止流水线
likedislike
2501_936374652501_93637465
7月27日 关闭了 pull request