已关闭
【26.2.0众测】aot_eager 后端在小算子密集推理上比 Eager 慢约 3 倍(0.31x),名称易让人误以为是“加速 Eager”,建议文档明确其调试定位 #5109
程康博创建于 9月25日关闭于 17 天前
9月25日 添加了label:help-wantedbot-triaged
TorchNPU-Bot
9月25日 评论:
9月25日 评论:
检测到社区任务相关 issue,自动添加标签:help-wanted


程康博
9月25日 评论:
9月25日 评论:
aot_eager 0.31x 与 7 后端完整横评数据见众测 PR:
https://gitcode.com/Ascend/pytorch-ecosystem/merge_requests/39


17 天前 关闭了 issue
17 天前 issue状态由 TODO 改变为 DONE
17 天前 添加了label:resolved
环境
Atlas 800T A2 / 910B3 / CANN 9.1.0 / Python 3.12 aarch64;torch 2.7.1+torch_npu 2.7.1.post8(tf32 项在 2.7.1/2.9.0 均复现);模型 distilbert-base-uncased(DistilBertForMaskedLM),batch=4 seq=128 fp32
问题描述
aot_eager(AOT Autograd + eager,无图融合/算子编译)在小算子密集的 Transformer 推理上稳态延迟约 17.9ms vs Eager 5.57ms ≈ 0.31x(慢约 3.2 倍),正确性正常(allclose)。该后端名字里带 “eager”,初次接触 torch.compile 的用户很容易把它理解成“带编译加速的 eager”而用于性能场景,结果反而变慢。它实际定位应是功能调试/对比基线(验证图捕获与前后向拆分是否正确),并不以加速为目标。
期望
在 torch.compile 后端文档中明确:aot_eager 不做融合/编译优化,适合用于正确性调试而非性能加速;在小算子密集模型上可能慢于 Eager,加速应选 NPU Graph / GE 或 Inductor。附适用场景一句话即可显著降低误用。
实测数据(同一模型同一输入,warmup 后 20 次均值)
Eager 5.570ms;aot_eager 17.9ms(0.31x)。对照:GE 2.289ms、NPUGraph_EX 3.000ms、NPUGraphs 3.274ms。