torch反向计算图提取 #585
fangfangssj
started this conversation in
Ideas
Replies: 1 comment
-
传统标准流水线如下:
ai4c是训练一个agent来代替第三部分和第四部分嘛 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
流程
反向计算图的捕捉,先使用Dynamo将model.py中Python代码转换成一个前向的FX Graph,再将这个Graph传给AOT Autograd来自动生成反向图,使用Autograd来获取每个算子对应的反向操作,AOT Autograd引擎输出的是一个联合优化的计算图Joint Graph (Fwd + Bwd),最后保存为backward计算图。PR已经实现 #490
model.py (Python)
⬇
[TorchDynamo] <-- 1. 捕捉 Python 逻辑
⬇
FX Graph (Forward Only)
⬇
[AOT Autograd] <-- 2. 这里的 Autograd 引擎介入
┃
┣━━ 运行 Forward (FakeTensor) ━━┓
┃ ⬇
┃ [PyTorch C++ Autograd]
┃ ⬇
┗━━ 记录并生成 Joint Graph (Fwd + Bwd)
⬇
导出存为backward计算图
待讨论的地方:
Beta Was this translation helpful? Give feedback.
All reactions