Closed
[Bug]:jitCompile为enable时is_jit_compile_flase 优先根据jitCompileInit判定 #5251
JesseAdd on Sep 29Closed at Oct 8
Sep 29 Added label: bug
Sep 29 Added label: triage-reviewmodule: core
TorchNPU-Bot
Sep 29 Comments:
Sep 29 Comments:
问题为 is_jit_compile_false 接口配置优先级逻辑错误,属核心运行时配置管理问题
添加分类标签:module: core。
当前分类由社区bot提供,如分类有误请在评论中回复。


Sep 29 Change title to "[Bug]:is_jit_compile_flase返回值受", originally titled "[Bug]: ".
Sep 29 Change title to "[Bug]:CompileInit为enable时is_jit_compile_flase 优先根据jitCompileInit判定", originally titled "[Bug]:is_jit_compile_flase返回值受".
Sep 29 Change title to "[Bug]:CompileInit为enable时is_jit_compile_flase 优先根据jitCompileInit判定", originally titled "[Bug]:is_jit_compile_flase返回值受".
Sep 29 Added label: bot-triaged; Removed label: triage-review
TorchNPU-Bot
Sep 29 Comments:
Sep 29 Comments:
检测到当前 issue 已关联 PR,自动添加标签:bot-triaged


Sep 29 Associated pull request
12 event messages are collapsed here。 See more
Sep 30 Modify description of issue
chenrayray
Oct 8 Comments:
Oct 8 Comments:
因为本单相关实施 PR 已全部结束(13 个已合入、0 个已关闭),按照本轮 issue 整理规则,先关闭此单。
核对的 PR:
- pytorch !47367:已合入
- pytorch !47370:已合入
- pytorch !47371:已合入
- pytorch !47372:已合入
- pytorch !47373:已合入
- pytorch !47375:已合入
- pytorch !47429:已合入
- pytorch !47430:已合入
- pytorch !47431:已合入
- pytorch !47432:已合入
- pytorch !47433:已合入
- pytorch !47434:已合入
- pytorch !47435:已合入
如仍有问题或需要继续推进,请重新打开,并补充当前 PyTorch / TorchNPU / CANN 版本、硬件环境、复现步骤及相关日志;需求类请补充尚未完成的具体内容。


Oct 8 Close issue
Oct 8 changed custom state from TODO to DONE
Oct 8 Added label: resolved
在提交新问题之前,请确保您已经在社区中搜索过相关问题,并使用了社区中提供的资源/工具后,仍未找到满意的解决方式。
⚠️ 安全信息提醒:请仔细检查提供的文本内容,确保其不包含敏感数据信息,包括但不限于:
在分享配置信息或代码示例时,请将敏感信息脱敏处理,或使用
<TOKEN>等占位符替代原有内容。环境信息
pta2.7.1+
🐛 问题描述
显式开启 JIT Compile 后状态查询仍返回关闭
问题场景
在 NPU 已完成初始化、初始化阶段记录的 JIT Compile 状态为关闭时,再通过接口显式开启 JIT Compile:
import torch import torch_npu print(torch_npu.npu.is_jit_compile_false()) torch_npu.npu.set_compile_mode(jit_compile=True) print(torch_npu.npu.is_jit_compile_false())此时内部配置为:
预期第二次查询返回
False,表示当前 JIT Compile 已开启;实际仍返回True,导致以下断言失败:self.assertFalse(torch_npu.npu.is_jit_compile_false())该问题受npu初始化行为影响。若
test_jit_compile_false先执行,它会在初始化前显式设置jitCompile,使后续测试无法构造jitCompileInit=disable、jitCompile=enable的状态,因此问题会被掩盖。需要注意不同测试框架会影响 NPU 初始化时机。原因分析
jitCompileInit表示 NPU 初始化阶段读取并保存的初始状态,jitCompile表示用户后续显式设置的当前状态。原有
is_jit_compile_false判断逻辑只在jitCompile=disable时直接返回True。当jitCompile=enable时,代码仍继续读取jitCompileInit;如果初始值为disable,最终仍返回True:因此,初始化状态错误地覆盖了更新后的显式配置。该问题本质上是配置优先级错误,并非 Ascend 910B2 与 910B4 的设备类型判断差异。
修改方案
调整
is_jit_compile_false的判断优先级:jitCompile,直接以该配置为准:disable返回True;enable返回False。jitCompile未设置或不是有效值时,才回退读取jitCompileInit。修改主要是添加jitCompile=enable的判断逻辑:
不修改或清除
jitCompileInit,因为它仍用于表示初始化阶段的状态;只修正查询时的优先级关系。欢迎加入社区,感谢您对社区的贡献 🎉!