[inductor] Add an AOT compilation mode for Inductor CPP backend#94822
[inductor] Add an AOT compilation mode for Inductor CPP backend#94822desertfire wants to merge 8 commits intogh/desertfire/69/basefrom
Conversation
Summary: The AOT mode currently works for the CPP backend. When turned on, Inductor compiles the model code into a .so file with __aot_inductor_entry as the entry function. If the AOT compilation fails, Inductor will explicitly fail. [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/94822
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 FailuresAs of commit aeb7045: NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Summary: The AOT mode currently works for the CPP backend. When turned on, Inductor compiles the model code into a .so file with __aot_inductor_entry as the entry function. If the AOT compilation fails, Inductor will explicitly fail. cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 [ghstack-poisoned]
|
Output from running |
Summary: The AOT mode currently works for the CPP backend. When turned on, Inductor compiles the model code into a .so file with __aot_inductor_entry as the entry function. If the AOT compilation fails, Inductor will explicitly fail. cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 [ghstack-poisoned]
jansel
left a comment
There was a problem hiding this comment.
How are model weights handled by this?
|
Discussed offline a bit - but you don't need to make it part of export. You can make AOTInductor a purely additive thing. One thing we could do that would be minimal changes is to not change how we produce a module or wrapper today under cpp_wrapper but instead make this aot thing purely additive - produce a side artifact of the .so (as we do), and a .h (As we do not yet do), if a flag is set. This would allow us to button up an impl in very flew lines, at the cost of a little bit of redundant work. Check out how we do You can do something like And provide your own AOTCodeGen alongside the other CodeGen (either composition, or add support to emit multiple codegen?). You can then use the flag to produce a pure compiled artifact as a side effect - no need to change any of the mainline flow of compilation. Once you have that - you can just call compile_fx after export, with the aot flag enabled. |
Summary: The AOT mode currently works for the CPP backend. When turned on, Inductor compiles the model code into a .so file with __aot_inductor_entry as the entry function. If the AOT compilation fails, Inductor will explicitly fail. cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 [ghstack-poisoned]
jansel
left a comment
There was a problem hiding this comment.
What is here looks good to me.
Still need to solve the issue of weight handling.
Should __aot_inductor_entry be just aot_inductor_entry, or perhaps a function name passed in by the user to avoid name conflicts? If the user is intended to call it we shouldn't name it __*.
|
I will update with refactoring after #95594 lands. Weight handling will come as the next PR. |
Summary: The AOT mode currently works for the CPP backend. When turned on, Inductor compiles the model code into a .so file with __aot_inductor_entry as the entry function. If the AOT compilation fails, Inductor will explicitly fail. cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 [ghstack-poisoned]
…ckend" Summary: The AOT mode currently works for the CPP backend. When turned on, Inductor compiles the model code into a .so file with aot_inductor_entry as the entry function. If the AOT compilation fails, Inductor will explicitly fail. cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 [ghstack-poisoned]
|
Also, this PR seems to almost quadruple the time it takes to run inductor/test_torchinductor_opinfo (prev ~1hr, after ~3.75 hr) |
Summary: The AOT mode currently works for the CPP backend. When turned on, Inductor compiles the model code into a .so file with aot_inductor_entry as the entry function. If the AOT compilation fails, Inductor will explicitly fail. Pull Request resolved: pytorch/pytorch#94822 Approved by: https://github.com/jansel
…nd (#94822)" This reverts commit 73b6609. Reverted pytorch/pytorch#94822 on behalf of https://github.com/clee2000 due to broke inductor_tmm_cpu_accuracy, https://hud.pytorch.org/pytorch/pytorch/commit/73b66098b2f43be508e1975fd6a425ed6308b993#11745396725
Summary: The AOT mode currently works for the CPP backend. When turned on, Inductor compiles the model code into a .so file with aot_inductor_entry as the entry function. If the AOT compilation fails, Inductor will explicitly fail. Pull Request resolved: pytorch/pytorch#94822 Approved by: https://github.com/jansel
…nd (#94822)" This reverts commit 73b6609. Reverted pytorch/pytorch#94822 on behalf of https://github.com/clee2000 due to broke inductor_tmm_cpu_accuracy, https://hud.pytorch.org/pytorch/pytorch/commit/73b66098b2f43be508e1975fd6a425ed6308b993#11745396725
…mode for Inductor CPP backend" Summary: This is a reland of #94822 cc soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 [ghstack-poisoned]
…r CPP backend" Summary: This is a reland of #94822 cc soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 [ghstack-poisoned]
…mode for Inductor CPP backend" Summary: This is a reland of #94822 cc soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 [ghstack-poisoned]
…r CPP backend" Summary: This is a reland of #94822 cc soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 [ghstack-poisoned]
…nd (#95985) Summary: This is a reland of #94822 Pull Request resolved: #95985 Approved by: https://github.com/jansel
Summary: This is a reland of #94822. Solved the long compilation issue for inductor cpp tests. [ghstack-poisoned]
…nd (#95985) Summary: This is a reland of pytorch/pytorch#94822 Pull Request resolved: pytorch/pytorch#95985 Approved by: https://github.com/jansel
…nd (#95985) Summary: This is a reland of pytorch/pytorch#94822 Pull Request resolved: pytorch/pytorch#95985 Approved by: https://github.com/jansel
… mode for Inductor CPP backend" Summary: This is a reland of #94822. Solved the long compilation issue for inductor cpp tests. cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 [ghstack-poisoned]
…or CPP backend" Summary: This is a reland of #94822. Solved the long compilation issue for inductor cpp tests. cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 [ghstack-poisoned]
…rch#94822) Summary: The AOT mode currently works for the CPP backend. When turned on, Inductor compiles the model code into a .so file with aot_inductor_entry as the entry function. If the AOT compilation fails, Inductor will explicitly fail. Pull Request resolved: pytorch#94822 Approved by: https://github.com/jansel
…nd (pytorch#94822)" This reverts commit 73b6609. Reverted pytorch#94822 on behalf of https://github.com/clee2000 due to broke inductor_tmm_cpu_accuracy, https://hud.pytorch.org/pytorch/pytorch/commit/73b66098b2f43be508e1975fd6a425ed6308b993#11745396725
…nd (pytorch#95985) Summary: This is a reland of pytorch#94822 Pull Request resolved: pytorch#95985 Approved by: https://github.com/jansel
…end (#96520) Summary: This is a reland of #94822. Solved the long compilation issue for inductor cpp tests. Pull Request resolved: #96520 Approved by: https://github.com/huydhn, https://github.com/malfet
…end (#96520) Summary: This is a reland of pytorch/pytorch#94822. Solved the long compilation issue for inductor cpp tests. Pull Request resolved: pytorch/pytorch#96520 Approved by: https://github.com/huydhn, https://github.com/malfet
…end (#96520) Summary: This is a reland of pytorch/pytorch#94822. Solved the long compilation issue for inductor cpp tests. Pull Request resolved: pytorch/pytorch#96520 Approved by: https://github.com/huydhn, https://github.com/malfet
Stack from ghstack (oldest at bottom):
Summary: The AOT mode currently works for the CPP backend. When turned on, Inductor compiles the model code into a .so file with aot_inductor_entry as the entry function. If the AOT compilation fails, Inductor will explicitly fail.
cc @mlazos @soumith @voznesenskym @yanboliang @penguinwu @anijain2305 @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @peterbell10