已关闭
[Bug]: triton_experimental 原生 TorchBench BERT 训练精度异常及编译失败 #3813
htchu创建于 8月7日关闭于 27 天前
8月7日 添加了label:bug
8月7日 添加了label:bot-triaged
TorchNPU-Bot
8月7日 评论:
8月7日 评论:
检测到当前 issue 已关联 PR,自动添加标签:bot-triaged


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


在提交新问题之前,请确保您已经在社区中搜索过相关问题,并使用了社区中提供的资源/工具后,仍未找到满意的解决方式。
⚠️ 安全信息提醒:请仔细检查提供的文本内容,确保其不包含敏感数据信息,包括但不限于:
在分享配置信息或代码示例时,请将敏感信息脱敏处理,或使用
<TOKEN>等占位符替代原有内容。环境信息
triton_experimental🐛 问题描述
按照
benchmarks/torchbench/README.md安装 TorchBench 源码包后,五个原生 BERT 系列模型均可完成 eager 训练,但 Inductor +triton_experimental初始测试只有BERT_pytorch通过:BERT_pytorchpass_accuracyhf_Bertfail_accuracyhf_DistilBertfail_to_runUnregistered range symbol: r0_1hf_Albertfail_to_runfastNLP_Bertfail_to_run其中
hf_Bert、hf_DistilBert和fastNLP_Bert分别对应三个确定性的后端缺陷。1.
hf_Bert:不受支持的 OUTER split-reduction 破坏融合输出失败 backward kernel 同时物化:
2048x768pointwise clone/permute 输出;1x768reduction 输出;[4, 512]reduction。现有
_npu_rsplit_outer_applicable()只检查 reduction 类型、输出 x 规模和 reduction 规模,没有限制 live output 数量和 reduction-tree 结构。partial+combine 重写随后按输出顺序选择output_buffers[0],将2048x768pointwise store 重定向到仅48x768的 partial workspace,造成越界写和错误 combine。同时,嵌套 reduction 循环没有应用r0_lo/r0_hi,每个 core 会重复处理完整 reduction 范围。表现为:前向输出仍正确,但首步已有大量梯度失配,连续训练第 3 步突变、第 4 步产生 NaN。
2.
hf_DistilBert:dual-view reduction fold 创建未注册的同名 Symbolbackward 的
buf352输出 shape 为[768],reduction ranges 为[4, 512]。codegen 在推断 load block shape 时失败:诊断显示
range_tree_nodes中实际存在打印名称为r0_1的 key。失败地址原本只包含 alias chain:_fold_dualview_reduction_index()将它折回 flat alias 时,在 flat symbol 不在原表达式中的 fallback 分支创建了:range-tree symbol 带
integer/nonnegativeassumptions。新建的普通 Symbol 虽然也打印为r0_1,但不等于注册表中的正式迭代 Symbol,导致字典查找失败。3.
fastNLP_Bert:in/out boundary downcast 丢失输入内容fastNLP 预处理在
.item()graph break 后报错:独立预处理最小复现结果:
生成 kernel 将运行时 int64
in_out_ptr0下转换为*i32,并通过mutated_arg_names标记其写入语义。launcher wrapper 将纯out_ptr和in_out_ptr一律替换为未初始化的 int32torch.empty_like()。该in_out_ptr0会先读取 advanced-index 结果,再执行 masked-fill 写回;使用空临时区会丢失输入内容,后续 reduction 因此错误。复现步骤
export ASCEND_RT_VISIBLE_DEVICES=7 source env.sh keep python -u benchmarks/torchbench/torchbench.py \ --accuracy --cold-start-latency --train --float32 \ --backend inductor --npu-backend triton \ --only hf_Bert --iterations 5 --accu-summary python -u benchmarks/torchbench/torchbench.py \ --accuracy --cold-start-latency --train --float32 \ --backend inductor --npu-backend triton \ --only hf_DistilBert --iterations 1 --accu-summary python -u benchmarks/torchbench/torchbench.py \ --accuracy --cold-start-latency --train --float32 \ --backend inductor --npu-backend triton \ --only fastNLP_Bert --iterations 1 --accu-summary期望行为
欢迎加入社区,感谢您对社区的贡献 🎉!