Closed
[Bug] NPU autotuning logs full compiler diagnostics at ERROR level #4714
stonexxxAdd on  Sep 9Closed at  Sep 29
stonexxx
stonexxxCollaborators
Sep 9 Create

问题现象

在 torch_npu: 2.13.0、NPU: Ascend 950 环境中开启 TORCHINDUCTOR_MAX_AUTOTUNE=1 后,部分 autotune 候选会因编译或运行失败被忽略。当前 ERROR 日志直接输出完整异常字符串;毕昇编译异常可能包含完整 MLIR、内存规划 IR 和大量 hivm.hir 指令,导致单个失败候选产生大量日志,掩盖真正的错误尾部和测试结果。

触发条件

以下任一路径获得包含完整编译诊断的异常时会触发:

  1. 并发 precompile future 返回异常。
  2. 当前进程 benchmark 抛出 NPUCompileError。
  3. 当前进程 benchmark 抛出可忽略的 RuntimeError。

原因

三个 ERROR 日志入口均直接记录 str(error) 或完整 msg,没有长度或行数限制。编译器附带的中间 IR 因此被全部提升到默认 ERROR 日志级别。

期望行为

  • ERROR 日志保留 choice 名称、配置、是否忽略以及诊断末尾 8 行,便于快速看到最终原因和 kernel cache 路径。
  • 当诊断被截断时明确输出 suppression 标记。
  • DEBUG 日志仍保留完整编译诊断,保证深度排障能力。
  • 不改变候选选择、失败忽略或 autotune 控制流。

验证结果

对 FlexAttention extended test 开启 TORCHINDUCTOR_MAX_AUTOTUNE=1 并清空 cache 后全量运行:

  • 36 passed, 15 warnings。
  • 命中 10 次截断摘要,其中 precompile 失败 5 次、runtime 失败 5 次。
  • ERROR 日志中 IR Dump After、module attributes、hivm.hir.anchor 和 func.func 均为 0 次。
  • 完整日志为 458 行、约 131 KiB;剩余主要内容是 max-autotune 正常候选性能表。
likedislike
ascend-robotascend-robotCollaborators
Sep 9 Added label: bug
TorchNPU-BotTorchNPU-BotCollaborators
Sep 9 Added label: triage-review; Removed label: bug
TorchNPU-Bot
TorchNPU-BotCollaborators
Sep 9 Comments:

issue待分派,添加triage-review标签

likedislike
ascend-robotascend-robotCollaborators
Sep 9 Added label: bug
stonexxxstonexxxCollaborators
Sep 9 Associated pull request
TorchNPU-BotTorchNPU-BotCollaborators
Sep 9 Added label: bot-triaged; Removed label: triage-review
TorchNPU-Bot
TorchNPU-BotCollaborators
Sep 9 Comments:

检测到当前 issue 已关联 PR,自动添加标签:bot-triaged

likedislike
chenrayray
chenrayrayCollaborators
Sep 29 Comments:

因为本单相关实施 PR 已全部结束(1 个已合入、0 个已关闭),按照本轮 issue 整理规则,先关闭此单。

核对的 PR:

如仍有问题或需要继续推进,请重新打开,并补充当前 PyTorch / TorchNPU / CANN 版本、硬件环境、复现步骤及相关日志;需求类请补充尚未完成的具体内容。

likedislike
chenrayraychenrayrayCollaborators
Sep 29 Close issue
chenrayraychenrayrayCollaborators
Sep 29 changed custom state from TODO to DONE
ascend-robotascend-robotCollaborators
Sep 29 Added label: resolved