已合并
【fix】 fix inductor upcast_to_fp32 codegen #33344
kkjocker创建于 4月8日
【fix】 fix inductor upcast_to_fp32 codegen #33344
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 kkjocker 的贡献)ascend-robot
4月8日 评论:
4月8日 评论:
4月8日 添加了label:stat/needs-squash
ascend-robot
4月8日 评论:
4月8日 评论:
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 | ✅ zichun_ye, adrian07110 (2/2) | ✅ zichun_ye, adrian07110 (2/1) |
| torch_npu/_inductor | ✅ zichun_ye, adrian07110 (2/2) | ✅ zichun_ye, adrian07110 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
kkjocker, thanks for your pull request. All authors of the commits have signed the CLA. 👍


4月8日 添加了label:ascend-cla/yes
ascend-robot
4月8日 评论:
4月8日 评论:
问题/功能描述
本次PR主要包含三项核心变更,旨在提升NPU后端的兼容性、功能健壮性和数值精度。首先,修复了因PyTorch内部模块结构调整导致的CachingAutotuner导入路径错误,确保NPU后端的自动调优功能正常。其次,增强了内核名称解析逻辑,使其能够同时兼容空格和下划线两种分隔符格式,提升了代码的容错性。最后,为Triton代码生成器增加了对半精度浮点数(float16/bfloat16)的向上类型转换(upcast to fp32)支持,以提升计算精度和稳定性。
修改方案描述
- 修复导入路径:将
torch_npu/_inductor/__init__.py中CachingAutotuner的导入路径从torch._inductor.triton_heuristics更新为torch._inductor.runtime.triton_heuristics,以匹配上游PyTorch的模块重构。 - 增强内核名称解析:在
loadKernel函数中,扩展了nameFuncMode字符串的解析逻辑。在原有空格分隔逻辑基础上,新增了对最后一个下划线作为分隔符的支持,从而兼容"kernel_name kernel_mode"和"kernel_name_kernel_mode"两种格式。 - 实现向上类型转换:在
NPUIndexTritonKernel类的load方法中,新增条件判断。当被加载数据的原始类型为torch.float16或torch.bfloat16且全局配置config.triton.codegen_upcast_to_fp32启用时,在生成的tl.load指令后追加.to(tl.float32)转换,并将后续代码生成的dtype更新为torch.float32。 - 新增单元测试:新增参数化单元测试
test_codegen_upcast_to_fp32_emits_cast,用于验证上述向上类型转换功能在NPU设备上是否按预期工作,检查生成的Triton代码中是否包含预期的类型转换指令,并验证计算结果的正确性。


4月8日 update merge request[project id: 7404318, iid: 33344, commit_id: 0d384e0da9a10c55bf52bbadddefb7700f3bdb8e] virtual merging success
4月8日 update merge request[project id: 7404318, iid: 33344, commit_id: 0d384e0da9a10c55bf52bbadddefb7700f3bdb8e] virtual merging success
4月8日 update merge request[project id: 7404318, iid: 33344, commit_id: a7df8246db81accab3cf135f89576e7f3581c3e3] virtual merging success
4月8日 update merge request[project id: 7404318, iid: 33344, commit_id: a7df8246db81accab3cf135f89576e7f3581c3e3] virtual merging success
4月8日 删除了label:stat/needs-squash
4月8日 添加了label:ci-pipeline-failed
kkjocker
4月8日 评论:
4月8日 评论:
add_component


4月8日 添加了label:MindSpore-Component
kkjocker
4月8日 评论:
4月8日 评论:
compile


4月8日 删除了label:ci-pipeline-failed
此处折叠了10条事件消息 查看更多
4月9日 添加了label:ci-pipeline-passed
ascend-robot
4月9日 评论:
4月9日 评论:
流水线 PR-pipeline_pytorch#14691 (重试第3次)已完成
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_ARM | ✅ | >>> | |
| Build_LibTorch_x86 | ✅ | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| Build_ARM_inductor | ✅ | >>> | |
| 恶意代码检查 | 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 | ✅ | >>> |


zichun_ye
4月9日 评论:
4月9日 评论:
/approve


4月9日 添加了label:approved
ZhihaoLi
4月9日 评论:
4月9日 评论:
/approve


4月9日 添加了label:lgtm
ascend-robot
4月9日 评论:
4月9日 评论:
Review Guide
This pull-request passes review.
Committers who wrote a comment of /approve are: zichun_ye, adrian07110.
Reviewers who wrote a comment of /lgtm are: zichun_ye, adrian07110.


4月9日 合入了pull request
补充codegen将fp16和bfp16升精度到32的逻辑
【合入来源】
【修改方案】
【资料变更】
【接口变更】
【功能验证】
【CheckList】